Android Open Source - SurgeTracker Surge Duration Dialog Fragment






From Project

Back to project page SurgeTracker.

License

The source code is released under:

MIT License

If you think the Android project SurgeTracker 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.bklimt.surgetracker.view;
/*from   w w w  .ja v  a  2  s . c  o m*/
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.NumberPicker;

import com.bklimt.surgetracker.R;
import com.bklimt.surgetracker.model.RootViewModel;
import com.bklimt.surgetracker.model.Surge;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Created by klimt on 7/3/14.
 */
public class SurgeDurationDialogFragment extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final Logger logger = Logger.getLogger(getClass().getName());

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage("Duration");

        View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_surge_duration, null);
        builder.setView(view);

        RootViewModel root = RootViewModel.get();
        final Surge surge = root.getSelectedSurge();

        final NumberPicker minutesPicker = (NumberPicker) view.findViewById(R.id.minutes);
        minutesPicker.setMinValue(0);
        minutesPicker.setMaxValue(600);
        minutesPicker.setValue(surge.getDurationSeconds() / 60);

        final NumberPicker secondsPicker = (NumberPicker) view.findViewById(R.id.seconds);
        secondsPicker.setMinValue(0);
        secondsPicker.setMaxValue(59);
        secondsPicker.setValue(surge.getDurationSeconds() % 60);

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                int minutes = minutesPicker.getValue();
                int seconds = secondsPicker.getValue();
                int duration = minutes * 60 + seconds;
                logger.log(Level.INFO, "Setting duration to " + duration);
                surge.setDurationSeconds(duration);
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
            }
        });

        return builder.create();
    }
}




Java Source Code List

com.bklimt.surgetracker.ApplicationTest.java
com.bklimt.surgetracker.SurgeTrackerApplication.java
com.bklimt.surgetracker.TimerThread.java
com.bklimt.surgetracker.backbone.CollectionListener.java
com.bklimt.surgetracker.backbone.Collection.java
com.bklimt.surgetracker.backbone.ModelListener.java
com.bklimt.surgetracker.backbone.Model.java
com.bklimt.surgetracker.backbone.Visitor.java
com.bklimt.surgetracker.model.AggregateCollection.java
com.bklimt.surgetracker.model.Aggregate.java
com.bklimt.surgetracker.model.RootViewModel.java
com.bklimt.surgetracker.model.SurgeCollection.java
com.bklimt.surgetracker.model.SurgeParseObject.java
com.bklimt.surgetracker.model.Surge.java
com.bklimt.surgetracker.view.AggregateListAdapter.java
com.bklimt.surgetracker.view.AggregateListFragment.java
com.bklimt.surgetracker.view.MainActivity.java
com.bklimt.surgetracker.view.SurgeDeletionDialogFragment.java
com.bklimt.surgetracker.view.SurgeDurationDialogFragment.java
com.bklimt.surgetracker.view.SurgeGraphFragment.java
com.bklimt.surgetracker.view.SurgeListAdapter.java
com.bklimt.surgetracker.view.SurgeListFragment.java
com.bklimt.surgetracker.view.SurgeStartDialogFragment.java