// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/DialogHelper.java
// public class DialogHelper {
//     public static final String TAG_FRAGMENT_DONATION = "dialog_donate";
// 
//     public static void showDonateDialog(@NonNull AppCompatActivity activity) {
//         showDialog(activity, DonateDialogFragment.class, TAG_FRAGMENT_DONATION);
//     }
// 
//     private static void showDialog(@NonNull AppCompatActivity activity,
//                                    @NonNull Class clazz,
//                                    @NonNull String tag) {
//         try {
//             showDialog(activity, (DialogFragment) clazz.newInstance(), tag);
//         } catch (InstantiationException e) {
//             throw new RuntimeException(e);
//         } catch (IllegalAccessException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     private static void showDialog(@NonNull AppCompatActivity activity,
//                                    @NonNull DialogFragment fragment,
//                                    @NonNull String tag) {
//         if (Looper.myLooper() != Looper.getMainLooper()) {
//             throw new RuntimeException("Should be called on the main thread");
//         }
// 
//         FragmentManager fm = activity.getSupportFragmentManager();
//         FragmentTransaction ft = fm.beginTransaction();
//         Fragment prev = fm.findFragmentByTag(tag);
//         if (prev != null) {
//             ft.remove(prev);
//         }
//         ft.addToBackStack(null);
//         fragment.show(ft, tag);
//     }
// }


import android.content.Context;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.DialogHelper;
import io.github.mobodev.heartbeatfixerforgcm.R;
package io.github.mobodev.heartbeatfixerforgcm.preference;



/**
 * Created by shaobin on 3/9/15.
 */
public class DonatePreference extends Preference {
    public DonatePreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public DonatePreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public DonatePreference(Context context) {
        super(context);
        init();
    }

    private void init() {
        setTitle(R.string.pref_donate_title);
        setSummary(R.string.pref_donate_summary);
    }


    @Override
    protected void onClick() {
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/DialogHelper.java
// public class DialogHelper {
//     public static final String TAG_FRAGMENT_DONATION = "dialog_donate";
// 
//     public static void showDonateDialog(@NonNull AppCompatActivity activity) {
//         showDialog(activity, DonateDialogFragment.class, TAG_FRAGMENT_DONATION);
//     }
// 
//     private static void showDialog(@NonNull AppCompatActivity activity,
//                                    @NonNull Class clazz,
//                                    @NonNull String tag) {
//         try {
//             showDialog(activity, (DialogFragment) clazz.newInstance(), tag);
//         } catch (InstantiationException e) {
//             throw new RuntimeException(e);
//         } catch (IllegalAccessException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     private static void showDialog(@NonNull AppCompatActivity activity,
//                                    @NonNull DialogFragment fragment,
//                                    @NonNull String tag) {
//         if (Looper.myLooper() != Looper.getMainLooper()) {
//             throw new RuntimeException("Should be called on the main thread");
//         }
// 
//         FragmentManager fm = activity.getSupportFragmentManager();
//         FragmentTransaction ft = fm.beginTransaction();
//         Fragment prev = fm.findFragmentByTag(tag);
//         if (prev != null) {
//             ft.remove(prev);
//         }
//         ft.addToBackStack(null);
//         fragment.show(ft, tag);
//     }
// }


// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/DonatePreference.java
import android.content.Context;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.DialogHelper;
import io.github.mobodev.heartbeatfixerforgcm.R;

package io.github.mobodev.heartbeatfixerforgcm.preference;



/**
 * Created by shaobin on 3/9/15.
 */
public class DonatePreference extends Preference {
    public DonatePreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public DonatePreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public DonatePreference(Context context) {
        super(context);
        init();
    }

    private void init() {
        setTitle(R.string.pref_donate_title);
        setSummary(R.string.pref_donate_summary);
    }


    @Override
    protected void onClick() {
        DialogHelper.showDonateDialog((AppCompatActivity)getContext());