MFlisar / GDPRDialog

GDPR fragment dialog implementation
Apache License 2.0
211 stars 53 forks source link

Can I use the Extension without extending? #71

Closed mustii82 closed 5 years ago

mustii82 commented 6 years ago

Im Using a Framework called Libgdx which extends a class to my MainActivity to work properly.

But this library wants to extend too, that's why I can't use it.

Do you have any suggestions ?

MFlisar commented 6 years ago

Check out the simple demo please, no need to extend the activity from the library: https://github.com/MFlisar/GDPRDialog/blob/master/app/src/main/java/com/michaelflisar/gdprdialog/demo/MinimalDemoActivity.java

mustii82 commented 6 years ago

Even in the simple Demo you extend from: extends AppCompatActivity implements View.OnClickListener, GDPR.IGDPRCallback

MFlisar commented 6 years ago

Check the simple demo and just replace the AppCompatActivity with whatever activity you want! It shows what functions you need to call when and how. Read the demo and you will see that you don't need any activity, simply something implementing the GDPR.IGDPRCallback and some context.

mustii82 commented 6 years ago

The implementation fails here:

public void showDialog(AppCompatActivity activity, GDPRSetup setup, GDPRLocation location) {
        FragmentManager fm = activity.getSupportFragmentManager();
        if (fm.findFragmentByTag(GDPRDialog.class.getName()) == null) {
            try {
                if (fm.isStateSaved()) {
                    return;
                }...

I need an AppcompatActivity but can only give an Context

MFlisar commented 6 years ago

Which context do you have? FragmentActivity? Normal Activity? You need some sort of activity to show an android dialog...

mustii82 commented 6 years ago

i have an normal Activity but the arguments for most methods like showDialog() needs an AppCompatActivity

MFlisar commented 6 years ago

I can change this to FragmentActivity but not further... You have two choices:

MFlisar commented 5 years ago

Will close this. This library is made for app compat (and android x) in the future