Android Open Source - mac-hopper Donate Preference






From Project

Back to project page mac-hopper.

License

The source code is released under:

MIT License

If you think the Android project mac-hopper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package uk.co.danhawkes.machopper.ui.preferences;
/*  ww  w  .  ja v a  2s. c  o m*/
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.preference.ListPreference;
import android.util.AttributeSet;

public class DonatePreference extends ListPreference {

  private String value;

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

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

  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);
    if (positiveResult) {
      Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(value));
      getContext().startActivity(i);
    }
  }

  @Override
  protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);

    if ((getEntries() == null) || (getEntryValues() == null)) {
      throw new IllegalStateException(
          "ListPreference requires an entries array and an entryValues array.");
    }
    builder.setItems(getEntries(), new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        DonatePreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
        dialog.dismiss();

        // Set the value outside of the usual preference mechanism so
        // it's not saved
        value = getEntryValues()[which].toString();
      }
    });

    builder.setPositiveButton(null, null);
  }

  @Override
  protected boolean callChangeListener(Object newValue) {
    return false;
  }
}




Java Source Code List

uk.co.danhawkes.machopper.AlarmUtils.java
uk.co.danhawkes.machopper.AppSingleton.java
uk.co.danhawkes.machopper.Application.java
uk.co.danhawkes.machopper.Logger.java
uk.co.danhawkes.machopper.Store.java
uk.co.danhawkes.machopper.mac.MacChangeBroadcastReceiver.java
uk.co.danhawkes.machopper.mac.MacUtils.java
uk.co.danhawkes.machopper.mac.Mac.java
uk.co.danhawkes.machopper.ui.CountdownFragment.java
uk.co.danhawkes.machopper.ui.HelpDialogFragment.java
uk.co.danhawkes.machopper.ui.LogFragment.java
uk.co.danhawkes.machopper.ui.MainActivity.java
uk.co.danhawkes.machopper.ui.preferences.ContactPreference.java
uk.co.danhawkes.machopper.ui.preferences.DonatePreference.java
uk.co.danhawkes.machopper.ui.preferences.PreferenceActivity.java
uk.co.danhawkes.machopper.ui.preferences.PreferenceFragment.java
uk.co.danhawkes.machopper.ui.preferences.TimePreference.java
uk.co.danhawkes.machopper.ui.preferences.UiUtils.java