Ejemplo n.º 1
0
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mDateLayout = view.findViewById(R.id.date);
    mTimeLayout = view.findViewById(R.id.time);

    mDateTextView = (TextView) view.findViewById(R.id.date_text);
    mTimeTextView = (TextView) view.findViewById(R.id.time_text);

    mDateLayout.setOnClickListener(this);
    mTimeLayout.setOnClickListener(this);

    if (savedInstanceState != null) {
      time = (Calendar) savedInstanceState.getSerializable("time");
      date = (Calendar) savedInstanceState.getSerializable("date");

      if (time != null) {
        setDate(DateFormat.getTimeInstance(), time.getTime(), mTimeTextView);
      }
      if (date != null) {
        setDate(DateFormat.getDateInstance(), date.getTime(), mDateTextView);
      }
    }
  }
Ejemplo n.º 2
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   if (time != null) outState.putSerializable("time", time);
   if (date != null) outState.putSerializable("date", date);
 }