Giter Club home page Giter Club logo

Comments (8)

MFlisar avatar MFlisar commented on July 19, 2024

Handler is problematic, but I could define a callback interface that the parent activity needs to implement which will be called if the button is clicked - the standard thing for fragment <-> activity communication...

from changelog.

gonemad avatar gonemad commented on July 19, 2024

What do you mean by "Handler is problematic". If it took an callback interface as an input (instead of forcing the parent activity to implement something which does not work very well if your using MVP with a single activity) that would work fine. I was thinking the AlertDialog's neutral or negative button could be leveraged

from changelog.

MFlisar avatar MFlisar commented on July 19, 2024

This is a DialogFragment, no AlertDialog. It survices rotation e.g.... All the data passed to it must be parcelable. That's why the builder is parcelable...

It should be possible to check if the parent activity or the parent fragment implements the callback interface, but that's the only solution I can think of (other than buses or similar, which is not part of the library, and it should work without them as well)

from changelog.

gonemad avatar gonemad commented on July 19, 2024

ah yea.. that makes sense

okay so i propose you do the callback interface that the activity would have to support and also add the ability to pass in a fragment that implements the interface as well. Under the hood the activity is only used to get the support manager. As mentioned before my app is a single activity with tons of fragments so i would like to keep all the of the logic for the fragment that is going to show the changelog inside that fragment (or.. well the presenter of the fragment). I believe you can leverage

https://developer.android.com/reference/android/app/Fragment#settargetfragment

to access the fragment that created the dialogfragment

Example:
https://gist.github.com/Joev-/5695813

from changelog.

MFlisar avatar MFlisar commented on July 19, 2024

Would you mind adding this with the callback and create a pull request? Feel free to make it the way you like it, I may make adjustments afterwards... (like support for parent activity, maybe layout adjustments, whatever).

from changelog.

gonemad avatar gonemad commented on July 19, 2024

Yeah I can take a stab at it

from changelog.

MFlisar avatar MFlisar commented on July 19, 2024

I added withRateButton(true) and the IChangelogRateHandler, check out this to see the implementation:

builder.setNeutralButton(getContext().getString(R.string.changelog_dialog_rate), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean handled = false;
Object target = getTargetFragment();
if (target != null) {
handled = onUserWantsToRate(target);
}
if (handled)
return;
target = getActivity();
if (target != null) {
handled = onUserWantsToRate(target);
}
}
});

And

private boolean onUserWantsToRate(Object target) {
if (target instanceof IChangelogRateHandler)
return ((IChangelogRateHandler)target).onRateButtonClicked();
return false;
}

New feature is added in this release: https://github.com/MFlisar/changelog/releases/tag/1.0.3

from changelog.

MFlisar avatar MFlisar commented on July 19, 2024

PS: v1.0.4 will open the play store link by default, no need to implement the callback if you want this default behaviour

from changelog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.