Android Open Source - Keep-score Date Fragment






From Project

Back to project page Keep-score.

License

The source code is released under:

MIT License

If you think the Android project Keep-score 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 gr.sv1jsb.kratascore;
//from   w  ww. j a  va 2 s .c o m
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.widget.DatePicker;

import java.text.DateFormat;
import java.util.Calendar;


public class DateFragment extends DialogFragment implements
        DatePickerDialog.OnDateSetListener {



    private OnDateFragmentInteractionListener mListener;

    public static DateFragment newInstance() {
        DateFragment fragment = new DateFragment();

        return fragment;
    }
    public DateFragment() {
        // Required empty public constructor
    }


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

        // Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            mListener = (OnDateFragmentInteractionListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement OnDateFragmentInteractioListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    @Override
    public void onDateSet(DatePicker datePicker, int i, int i2, int i3) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(i, i2, i3,0,0);
        DateFormat sdf = DateFormat.getDateInstance(DateFormat.SHORT);
        mListener.onDateFragmentInteraction(sdf.format(calendar.getTime()), calendar.getTimeInMillis());
    }

    public interface OnDateFragmentInteractionListener {
        public void onDateFragmentInteraction(String date, long dateMillies);
    }

}




Java Source Code List

gr.sv1jsb.cropimage.ApplicationTest.java
gr.sv1jsb.cropimage.BitmapManager.java
gr.sv1jsb.cropimage.CropImageView.java
gr.sv1jsb.cropimage.CropImage.java
gr.sv1jsb.cropimage.HighlightView.java
gr.sv1jsb.cropimage.ImageViewTouchBase.java
gr.sv1jsb.cropimage.MonitoredActivity.java
gr.sv1jsb.cropimage.RotateBitmap.java
gr.sv1jsb.cropimage.Util.java
gr.sv1jsb.kratascore.AboutFragment.java
gr.sv1jsb.kratascore.AddScoreDialog.java
gr.sv1jsb.kratascore.ApplicationTest.java
gr.sv1jsb.kratascore.Constants.java
gr.sv1jsb.kratascore.DateFragment.java
gr.sv1jsb.kratascore.DeleteConfirmDialog.java
gr.sv1jsb.kratascore.EndConfirmDialog.java
gr.sv1jsb.kratascore.GameFragment.java
gr.sv1jsb.kratascore.GameListFragment.java
gr.sv1jsb.kratascore.GenericAlertDialog.java
gr.sv1jsb.kratascore.HelpFragment.java
gr.sv1jsb.kratascore.KrataScoreActivity.java
gr.sv1jsb.kratascore.NewGameActivity.java
gr.sv1jsb.kratascore.PhotoPickDialog.java
gr.sv1jsb.kratascore.PlayerActivity.java
gr.sv1jsb.kratascore.PlayerListActivity.java
gr.sv1jsb.kratascore.SearchActivity.java
gr.sv1jsb.kratascore.SortDialog.java
gr.sv1jsb.kratascore.adapters.BaseCursorAdapter.java
gr.sv1jsb.kratascore.adapters.GameAdapter.java
gr.sv1jsb.kratascore.adapters.GameListAdapter.java
gr.sv1jsb.kratascore.adapters.PlayerListAdapter.java
gr.sv1jsb.kratascore.persistance.KrataScoreContract.java
gr.sv1jsb.kratascore.persistance.KrataScoreDB.java
gr.sv1jsb.kratascore.persistance.Player.java
gr.sv1jsb.kratascore.provider.KrataScoreProvider.java
gr.sv1jsb.utils.ImageCache.java
gr.sv1jsb.utils.ImageUtils.java
gr.sv1jsb.utils.RandomStringUtils.java