Android Open Source - AndroidTrainingCode Status Tracker






From Project

Back to project page AndroidTrainingCode.

License

The source code is released under:

Apache License

If you think the Android project AndroidTrainingCode 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

/*
 * Copyright (C) 2012 The Android Open Source Project
 *//from   w  w w.  j av  a2  s . c  o  m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.lifecycle.util;

import java.util.*;

public class StatusTracker {
  private Map<String, String> mStatusMap;
  private List<String> mMethodList;
  private static StatusTracker ourInstance = new StatusTracker();
  private static final String STATUS_SUFFIX = "ed";

  public static StatusTracker getInstance() {
    return ourInstance;
  }

  private StatusTracker() {
    mStatusMap = new LinkedHashMap<String, String>();
    mMethodList = new ArrayList<String>();
  }

  public List<String> getMethodList() {
    return mMethodList;
  }

  public void clear() {
    mMethodList.clear();
    mStatusMap.clear();
  }

  /**
   * Adds the status value for the given activityName into the Map.
   *
   * @param activityName
   * @param status
   */
  public void setStatus(String activityName, String status) {
    mMethodList.add(activityName + "." + status + "()");
    if (mStatusMap.containsKey(activityName)) mStatusMap.remove(activityName);
    mStatusMap.put(activityName, status);
  }

  /**
   * Gets the status value for the given activityName.
   *
   * @param activityName
   * @return
   */
  public String getStatus(String activityName) {
    String status = mStatusMap.get(activityName);
    status = status.substring(2, status.length());

    // String manipulation to ensure the status value is spelled correctly.
    if (status.endsWith("e")) {
      status = status.substring(0, status.length() - 1);
    }
    if (status.endsWith("p")) {
      status = status + "p";
    }
    status = status + STATUS_SUFFIX;
    return status;
  }

  public Set<String> keySet() {
    return mStatusMap.keySet();
  }
}




Java Source Code List

com.example.android.animationsdemo.ApplicationTest.java
com.example.android.animationsdemo.CardFlipActivity.java
com.example.android.animationsdemo.CrossfadeActivity.java
com.example.android.animationsdemo.LayoutChangesActivity.java
com.example.android.animationsdemo.MainActivity.java
com.example.android.animationsdemo.ScreenSlideActivity.java
com.example.android.animationsdemo.ScreenSlidePageFragment.java
com.example.android.animationsdemo.TouchHighlightImageButton.java
com.example.android.animationsdemo.ZoomActivity.java
com.example.android.lifecycle.ActivityA.java
com.example.android.lifecycle.ActivityB.java
com.example.android.lifecycle.ActivityC.java
com.example.android.lifecycle.ApplicationTest.java
com.example.android.lifecycle.DialogActivity.java
com.example.android.lifecycle.util.StatusTracker.java
com.example.android.lifecycle.util.Utils.java
com.example.android.threadsample.BroadcastNotifier.java
com.example.android.threadsample.Constants.java
com.example.android.threadsample.DataProviderContract.java
com.example.android.threadsample.DataProvider.java
com.example.android.threadsample.DisplayActivity.java
com.example.android.threadsample.PhotoDecodeRunnable.java
com.example.android.threadsample.PhotoDownloadRunnable.java
com.example.android.threadsample.PhotoFragment.java
com.example.android.threadsample.PhotoManager.java
com.example.android.threadsample.PhotoTask.java
com.example.android.threadsample.PhotoThumbnailFragment.java
com.example.android.threadsample.PhotoView.java
com.example.android.threadsample.ProgressNotifier.java
com.example.android.threadsample.RSSPullParser.java
com.example.android.threadsample.RSSPullService.java