summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2012-05-07 15:05:41 +0800
committerYuli Huang <yuli@google.com>2012-05-07 20:57:55 +0800
commit4b69c5f52e8ef3209bc0b6889c4a6355614607ca (patch)
treeac6d0c8c38f9eb63ac3b20405d4e9ec97b07580e /src/com/android/gallery3d
parent8f1c528dde90caf2d667634f769772cdac1d674d (diff)
downloadandroid_packages_apps_Gallery2-4b69c5f52e8ef3209bc0b6889c4a6355614607ca.tar.gz
android_packages_apps_Gallery2-4b69c5f52e8ef3209bc0b6889c4a6355614607ca.tar.bz2
android_packages_apps_Gallery2-4b69c5f52e8ef3209bc0b6889c4a6355614607ca.zip
Remove PhotoPage spinner shown in the action-bar.
Remove spinners shown for loading data out of view. bug:5406790 Change-Id: Iffaf97937b86b869559a27f190941c1de263e422
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/app/Gallery.java1
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java2
-rw-r--r--src/com/android/gallery3d/app/StateManager.java7
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java9
-rw-r--r--src/com/android/gallery3d/util/SpinnerVisibilitySetter.java112
5 files changed, 3 insertions, 128 deletions
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index 0fbe7ac0e..dd30d7e98 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -58,7 +58,6 @@ public final class Gallery extends AbstractGalleryActivity implements OnCancelLi
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_ACTION_BAR);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main);
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index acbaaeec6..2ecf5f309 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -231,7 +231,6 @@ public class PhotoPage extends ActivityState implements
@Override
public void onLoadingFinished() {
- GalleryUtils.setSpinnerVisibility((Activity) mActivity, false);
if (!mModel.isEmpty()) {
MediaItem photo = mModel.getCurrentMediaItem();
if (photo != null) updateCurrentPhoto(photo);
@@ -242,7 +241,6 @@ public class PhotoPage extends ActivityState implements
@Override
public void onLoadingStarted() {
- GalleryUtils.setSpinnerVisibility((Activity) mActivity, true);
}
});
} else {
diff --git a/src/com/android/gallery3d/app/StateManager.java b/src/com/android/gallery3d/app/StateManager.java
index 5866be948..77a24d8f3 100644
--- a/src/com/android/gallery3d/app/StateManager.java
+++ b/src/com/android/gallery3d/app/StateManager.java
@@ -93,11 +93,10 @@ public class StateManager {
}
public boolean createOptionsMenu(Menu menu) {
- if (!mStack.isEmpty()) {
- ((Activity) mContext).setProgressBarIndeterminateVisibility(false);
- return getTopState().onCreateActionBar(menu);
- } else {
+ if (mStack.isEmpty()) {
return false;
+ } else {
+ return getTopState().onCreateActionBar(menu);
}
}
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index b9535cbde..0406517d8 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -63,13 +63,9 @@ public class GalleryUtils {
private static final String KEY_CAMERA_UPDATE = "camera-update";
private static final String KEY_HAS_CAMERA = "has-camera";
- private static Context sContext;
-
-
static float sPixelDensity = -1f;
public static void initialize(Context context) {
- sContext = context;
if (sPixelDensity < 0) {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager wm = (WindowManager)
@@ -279,11 +275,6 @@ public class GalleryUtils {
return durationValue;
}
- public static void setSpinnerVisibility(final Activity activity,
- final boolean visible) {
- SpinnerVisibilitySetter.getInstance(activity).setSpinnerVisibility(visible);
- }
-
public static int determineTypeBits(Context context, Intent intent) {
int typeBits = 0;
String type = intent.resolveType(context);
diff --git a/src/com/android/gallery3d/util/SpinnerVisibilitySetter.java b/src/com/android/gallery3d/util/SpinnerVisibilitySetter.java
deleted file mode 100644
index 1e0534e90..000000000
--- a/src/com/android/gallery3d/util/SpinnerVisibilitySetter.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * 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.android.gallery3d.util;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Message;
-import android.os.SystemClock;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-/**
- * This class manages the visibility of the progress spinner in the action bar for an
- * Activity. It filters out short-lived appearances of the progress spinner by only
- * showing the spinner if it hasn't been hidden again before the end of a specified
- * delay period. It also enforces a minimum display time once the spinner is made visible.
- * This meant to cut down on the frequent "flashes" of the progress spinner.
- */
-public class SpinnerVisibilitySetter {
-
- private static final int MSG_SHOW_SPINNER = 1;
- private static final int MSG_HIDE_SPINNER = 2;
-
- // Amount of time after a show request that the progress spinner is actually made visible.
- // This means that any show/hide requests that happen subsequently within this period
- // of time will be ignored.
- private static final long SPINNER_DISPLAY_DELAY = 1000;
-
- // The minimum amount of time the progress spinner must be visible before it can be hidden.
- private static final long MIN_SPINNER_DISPLAY_TIME = 2000;
-
- static final WeakHashMap<Activity, SpinnerVisibilitySetter> sInstanceMap =
- new WeakHashMap<Activity, SpinnerVisibilitySetter>();
-
- private long mSpinnerVisibilityStartTime = -1;
- private WeakReference<Activity> mActivityRef;
-
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- Activity activity = mActivityRef.get();
-
- switch(msg.what) {
- case MSG_SHOW_SPINNER:
- removeMessages(MSG_SHOW_SPINNER);
- if (activity == null) break;
- if (mSpinnerVisibilityStartTime >= 0) break;
- mSpinnerVisibilityStartTime = SystemClock.elapsedRealtime();
- activity.setProgressBarIndeterminateVisibility(true);
- break;
- case MSG_HIDE_SPINNER:
- removeMessages(MSG_HIDE_SPINNER);
- if (activity == null) break;
- if (mSpinnerVisibilityStartTime < 0) break;
- long t = SystemClock.elapsedRealtime() - mSpinnerVisibilityStartTime;
- if (t >= MIN_SPINNER_DISPLAY_TIME) {
- mSpinnerVisibilityStartTime = -1;
- activity.setProgressBarIndeterminateVisibility(false);
- } else {
- sendEmptyMessageDelayed(MSG_HIDE_SPINNER, MIN_SPINNER_DISPLAY_TIME - t);
- }
- break;
- }
- }
- };
-
- /**
- * Gets the <code>SpinnerVisibilitySetter</code> for the given <code>activity</code>.
- *
- * This method must be called from the main thread.
- */
- public static SpinnerVisibilitySetter getInstance(Activity activity) {
- synchronized(sInstanceMap) {
- SpinnerVisibilitySetter setter = sInstanceMap.get(activity);
- if (setter == null) {
- setter = new SpinnerVisibilitySetter(activity);
- sInstanceMap.put(activity, setter);
- }
- return setter;
- }
- }
-
- private SpinnerVisibilitySetter(Activity activity) {
- // Activity are keys. Value objects should not strongly refer to keys.
- mActivityRef = new WeakReference<Activity>(activity);
- }
-
- public void setSpinnerVisibility(boolean visible) {
- if (visible) {
- mHandler.removeMessages(MSG_HIDE_SPINNER);
- mHandler.sendEmptyMessageDelayed(MSG_SHOW_SPINNER, SPINNER_DISPLAY_DELAY);
- } else {
- mHandler.removeMessages(MSG_SHOW_SPINNER);
- mHandler.sendEmptyMessage(MSG_HIDE_SPINNER);
- }
- }
-}