Android Open Source - Books Date Picker Fragment






From Project

Back to project page Books.

License

The source code is released under:

Apache License

If you think the Android project Books 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.contender.books;
//  ww  w  .  j  a v  a 2  s.  c om
import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;

/**
 * Implements the DatePickerFragment dialog used by {@link BookActivity}
 * <p>
 * Provides a UI for the user to set a date.
 * 
 * @author Paul Klinkenberg
 */
public class DatePickerFragment extends DialogFragment
 {

  DatePickerDialog.OnDateSetListener mListener;
  
  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    // Verify that the host activity implements the callback interface
    try {
      mListener = (DatePickerDialog.OnDateSetListener) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(activity.toString() + " must implement OnDateSetListener");
    }
  }
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    Calendar c = BookActivity.dueDate;
    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(), mListener, year, month, day);
  }
  
}




Java Source Code List

com.contender.books.BookActivity.java
com.contender.books.BooksStorage.java
com.contender.books.DatePickerFragment.java
com.contender.books.EditOrDeleteDialogFragment.java
com.contender.books.HistoryActivity.java
com.contender.books.MainView.java
com.contender.books.ScanOrManualDialogFragment.java
com.contender.books.SettingsActivity.java
com.contender.books.SpecialCursorAdapter.java
com.google.zxing.integration.android.IntentIntegrator.java
com.google.zxing.integration.android.IntentResult.java