Android Open Source - SDCardTrac Delete Data Preference






From Project

Back to project page SDCardTrac.

License

The source code is released under:

GNU General Public License

If you think the Android project SDCardTrac 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.nma.util.sdcardtrac;
/*from   ww w  . ja v  a2 s  .  c o m*/
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.RadioGroup;

/**
 * Created by naren on 10/14/14.
 */
// Custom preference for deleting data
public class DeleteDataPreference extends DialogPreference {
    RadioGroup grp;
    String lead;

    public DeleteDataPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        setDialogLayoutResource(R.layout.delete_select);
        setPositiveButtonText(android.R.string.ok);
        setNegativeButtonText(android.R.string.cancel);
        setDialogTitle(R.string.delete_title);
        setDialogIcon(null);
        lead = "";
    }

    @Override
    protected void onBindDialogView(View v) {
        grp = (RadioGroup)v.findViewById(R.id.delete_group);
        super.onBindDialogView(v);
    }

    @Override
    protected void onDialogClosed(boolean positiveResult) {
        int deleteBefore;
        String storeVal = getPersistedString("0");
        // Get selected value
        int id = grp.getCheckedRadioButtonId();
        deleteBefore = 60 * 60 * 24; // Day

        switch (id) {
            case R.id.delete_now:
                deleteBefore = 0;
                break;
            case R.id.delete_week:
                deleteBefore *= 7;
                break;
            case R.id.delete_month:
                deleteBefore *= 30;
                break;
            case R.id.delete_year:
                deleteBefore *= 365;
                break;
            default:
                deleteBefore = 0;
                break;
        }

        //Log.d(getClass().getName(), "Dialog = " + deleteBefore + " from " + id);
        if (positiveResult && (id != -1)) {
            String toStore = Integer.toString(deleteBefore);
            if (toStore.equals(storeVal)) {
                toStore = "0" + toStore; // Fake change
            }
            persistString(toStore);
        }
    }
}




Java Source Code List

com.jjoe64.graphview.BarGraphView.java
com.jjoe64.graphview.CustomLabelFormatter.java
com.jjoe64.graphview.GraphViewDataInterface.java
com.jjoe64.graphview.GraphViewSeries.java
com.jjoe64.graphview.GraphViewStyle.java
com.jjoe64.graphview.GraphView.java
com.jjoe64.graphview.LineGraphView.java
com.jjoe64.graphview.ValueDependentColor.java
com.jjoe64.graphview.compatible.RealScaleGestureDetector.java
com.jjoe64.graphview.compatible.ScaleGestureDetector.java
com.nma.util.sdcardtrac.AlarmHelper.java
com.nma.util.sdcardtrac.BitcoinIntegration.java
com.nma.util.sdcardtrac.ChangeLogFragment.java
com.nma.util.sdcardtrac.DatabaseLoader.java
com.nma.util.sdcardtrac.DatabaseManager.java
com.nma.util.sdcardtrac.DeleteDataPreference.java
com.nma.util.sdcardtrac.DeltaCompute.java
com.nma.util.sdcardtrac.FileObserverService.java
com.nma.util.sdcardtrac.GraphActivity.java
com.nma.util.sdcardtrac.GraphFragment.java
com.nma.util.sdcardtrac.GraphTabListener.java
com.nma.util.sdcardtrac.HelpFragment.java
com.nma.util.sdcardtrac.MyExpandableListAdapter.java
com.nma.util.sdcardtrac.SQLiteHelper.java
com.nma.util.sdcardtrac.SearchableActivity.java
com.nma.util.sdcardtrac.SettingsActivity.java
com.nma.util.sdcardtrac.StorageHelper.java
com.nma.util.sdcardtrac.UsageFileObserver.java