Android Open Source - com.elsewhat.android.slideshow Deletable Preference






From Project

Back to project page com.elsewhat.android.slideshow.

License

The source code is released under:

Copyright (C) 2012 Dagfinn Parnas <dagfinn.parnas@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Sof...

If you think the Android project com.elsewhat.android.slideshow 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 com.elsewhat.android.slideshow.api;
/*from ww  w  .j a va2s . co m*/
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.DialogPreference;
import android.util.AttributeSet;



public class DeletablePreference extends DialogPreference {
  OnPreferenceChangeListener mOnChangeListener;
  
  public DeletablePreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
  }
  
  public DeletablePreference(Context context) {
    super(context, null);
    // TODO Auto-generated constructor stub
  }

  /* (non-Javadoc)
   * @see android.preference.DialogPreference#onDialogClosed(boolean)
   */
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);
    if(positiveResult && mOnChangeListener!=null){
       mOnChangeListener.onPreferenceChange(this, "OK");
      
    }
    
    if(positiveResult &&isPersistent()){
      SharedPreferences preferences =getSharedPreferences();
      Editor editor =preferences.edit();
      //we want a unique value so that it triggers any SharedPreferenceListeners
      editor.putString(getKey(), System.currentTimeMillis()+"");
      editor.commit();
    }
  }

  /* (non-Javadoc)
   * @see android.preference.Preference#setOnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)
   */
  @Override
  public void setOnPreferenceChangeListener(
      OnPreferenceChangeListener onPreferenceChangeListener) {
    mOnChangeListener = onPreferenceChangeListener;
    //super.setOnPreferenceChangeListener(onPreferenceChangeListener);
  }
  
  

}




Java Source Code List

com.elsewhat.android.slideshow.activities.ChromecastAddin.java
com.elsewhat.android.slideshow.activities.ISlideshowInstance.java
com.elsewhat.android.slideshow.activities.SlideshowActivity.java
com.elsewhat.android.slideshow.activities.SlideshowDreamService.java
com.elsewhat.android.slideshow.activities.SlideshowPreferences.java
com.elsewhat.android.slideshow.api.Analytics.java
com.elsewhat.android.slideshow.api.AndroidUtils.java
com.elsewhat.android.slideshow.api.AsyncQueueableObject.java
com.elsewhat.android.slideshow.api.AsyncReadQueue.java
com.elsewhat.android.slideshow.api.CustomGallery.java
com.elsewhat.android.slideshow.api.DeletablePreference.java
com.elsewhat.android.slideshow.api.DownloadableObject.java
com.elsewhat.android.slideshow.api.FileDownloader.java
com.elsewhat.android.slideshow.api.FileUtils.java
com.elsewhat.android.slideshow.api.FlingKeyEvent.java
com.elsewhat.android.slideshow.api.ImageAdapter.java
com.elsewhat.android.slideshow.api.QueueablePhotoObject.java
com.elsewhat.android.slideshow.api.ReadOnlyPreference.java
com.elsewhat.android.slideshow.api.SlideshowBackend.java
com.elsewhat.android.slideshow.api.SlideshowPhotoCached.java
com.elsewhat.android.slideshow.api.SlideshowPhotoDrawable.java
com.elsewhat.android.slideshow.api.SlideshowPhoto.java
com.elsewhat.android.slideshow.backend.FlickrPublicSetBackend.java
com.elsewhat.android.slideshow.backend.OPMLBackend.java
com.elsewhat.android.slideshow.backend.SmugMugRecentBackend.java