Fix loading screens for manage and running apps

Also add loading screen to manage permissions as this can take a
long time to load in some circumstances. Build loading screens into
Utils and SettingsPreferenceFragment so that it can be easily used
other places in the future.

Change-Id: I7febd06695487e02ced793a9fd418051b5f0eab8
This commit is contained in:
Jason Monk
2015-03-31 12:59:33 -04:00
parent 5f937152a5
commit b5aa73f46f
9 changed files with 123 additions and 77 deletions

View File

@@ -39,8 +39,8 @@ import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.Resources.NotFoundException;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -74,6 +74,9 @@ import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ListView;
import android.widget.TabWidget;
@@ -1158,4 +1161,39 @@ public final class Utils {
? R.string.launch_defaults_some
: R.string.launch_defaults_none);
}
public static void handleLoadingContainer(View loading, View doneLoading, boolean done,
boolean animate) {
setViewShown(loading, !done, animate);
setViewShown(doneLoading, done, animate);
}
private static void setViewShown(final View view, boolean shown, boolean animate) {
if (animate) {
Animation animation = AnimationUtils.loadAnimation(view.getContext(),
shown ? android.R.anim.fade_in : android.R.anim.fade_out);
if (shown) {
view.setVisibility(View.VISIBLE);
} else {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.setVisibility(View.INVISIBLE);
}
});
}
view.startAnimation(animation);
} else {
view.clearAnimation();
view.setVisibility(shown ? View.VISIBLE : View.INVISIBLE);
}
}
}