Exemple #1
0
  @Override
  public void onResume() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    prefs.registerOnSharedPreferenceChangeListener(this);
    readFromSharedPref(prefs);
    mTime.readFromSharedPref(prefs, "sw");
    mTime.postInvalidate();

    setButtons(mState);
    mTimeText.setTime(mAccumulatedTime, true, true);
    if (mState == Stopwatches.STOPWATCH_RUNNING) {
      acquireWakeLock();
      startUpdateThread();
    } else if (mState == Stopwatches.STOPWATCH_STOPPED && mAccumulatedTime != 0) {
      mTimeText.blinkTimeStr(true);
    }
    showLaps();
    ((DeskClock) getActivity()).registerPageChangedListener(this);
    // View was hidden in onPause, make sure it is visible now.
    View v = getView();
    if (v != null) {
      v.setVisibility(View.VISIBLE);
    }
    super.onResume();
  }
Exemple #2
0
  @Override
  public void onPause() {
    // This is called because the lock screen was activated, the window stay
    // active under it and when we unlock the screen, we see the old time for
    // a fraction of a second.
    View v = getView();
    if (v != null) {
      v.setVisibility(View.INVISIBLE);
    }

    if (mState == Stopwatches.STOPWATCH_RUNNING) {
      stopUpdateThread();
    }
    // The stopwatch must keep running even if the user closes the app so save stopwatch state
    // in shared prefs
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    prefs.unregisterOnSharedPreferenceChangeListener(this);
    writeToSharedPref(prefs);
    mTime.writeToSharedPref(prefs, "sw");
    mTimeText.blinkTimeStr(false);
    if (mSharePopup != null) {
      mSharePopup.dismiss();
      mSharePopup = null;
    }
    ((DeskClock) getActivity()).unregisterPageChangedListener(this);
    releaseWakeLock();
    super.onPause();
  }
Exemple #3
0
  /**
   * Make the final display setup.
   *
   * <p>If the fragment is starting with an existing list of laps, shows the laps list and if the
   * spacers around the clock exist, hide them. If there are not laps at the start, hide the laps
   * list and show the clock spacers if they exist.
   */
  @Override
  public void onStart() {
    super.onStart();

    boolean lapsVisible = mLapsAdapter.getCount() > 0;

    mLapsList.setVisibility(lapsVisible ? View.VISIBLE : View.GONE);
    if (mSpacersUsed) {
      int spacersVisibility = lapsVisible ? View.GONE : View.VISIBLE;
      if (mStartSpace != null) {
        mStartSpace.setVisibility(spacersVisibility);
      }
      if (mEndSpace != null) {
        mEndSpace.setVisibility(spacersVisibility);
      }
    }
    ((ViewGroup) getView()).setLayoutTransition(mLayoutTransition);
    mCircleLayout.setLayoutTransition(mCircleLayoutTransition);
  }