Support App Links
Video: https://drive.google.com/file/d/11_MclDVE8Q_ojSYoCDxmK4Ah_FoABPhd/view?usp=sharing
Bug: 163019082
Change-Id: I2094c6078a1b3f7eae7307edbe74d9d764b4f501
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index 53617f5..5fd0e7a 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -44,6 +44,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.widget.ContentLoadingProgressBar;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -169,6 +170,21 @@
void onWallpaperSelected(int position);
}
+ /**
+ * Interface to be implemented by a Fragment hosting a {@link IndividualPickerFragment}
+ */
+ public interface IndividualPickerFragmentHost {
+ /**
+ * Sets the title in the toolbar.
+ */
+ void setToolbarTitle(CharSequence title);
+
+ /**
+ * Moves to the previous fragment.
+ */
+ void moveToPreviousFragment();
+ }
+
WallpaperPersister mWallpaperPersister;
WallpaperPreferences mWallpaperPreferences;
WallpaperChangedNotifier mWallpaperChangedNotifier;
@@ -185,6 +201,7 @@
Handler mHandler;
Random mRandom;
+ boolean mIsWallpapersReceived;
WallpaperChangedNotifier.Listener mWallpaperChangedListener =
new WallpaperChangedNotifier.Listener() {
@@ -218,6 +235,7 @@
private boolean mTestingMode;
private CurrentWallpaperBottomSheetPresenter mCurrentWallpaperBottomSheetPresenter;
private SetIndividualHolder mPendingSetIndividualHolder;
+ private ContentLoadingProgressBar mLoading;
/**
* Staged error dialog fragments that were unable to be shown when the activity didn't allow
@@ -357,7 +375,9 @@
// The absence of this category in the CategoryProvider indicates a broken
// state, see b/38030129. Hence, finish the activity and return.
- getActivity().finish();
+ getIndividualPickerFragmentHost().moveToPreviousFragment();
+ Toast.makeText(getContext(), R.string.collection_not_exist_msg,
+ Toast.LENGTH_SHORT).show();
return;
}
onCategoryLoaded();
@@ -365,7 +385,9 @@
}, false);
}
+
protected void onCategoryLoaded() {
+ getIndividualPickerFragmentHost().setToolbarTitle(mCategory.getTitle());
mWallpaperRotationInitializer = mCategory.getWallpaperRotationInitializer();
// Avoids the "rotation" action is not shown correctly
// in a rare case : onCategoryLoaded() is called after onBottomActionBarReady().
@@ -391,9 +413,13 @@
void fetchWallpapers(boolean forceReload) {
mWallpapers.clear();
+ mIsWallpapersReceived = false;
+ updateLoading();
mCategory.fetchWallpapers(getActivity().getApplicationContext(), new WallpaperReceiver() {
@Override
public void onWallpapersReceived(List<WallpaperInfo> wallpapers) {
+ mIsWallpapersReceived = true;
+ updateLoading();
for (WallpaperInfo wallpaper : wallpapers) {
mWallpapers.add(wallpaper);
}
@@ -421,6 +447,18 @@
}, forceReload);
}
+ void updateLoading() {
+ if (mLoading == null) {
+ return;
+ }
+
+ if (mIsWallpapersReceived) {
+ mLoading.hide();
+ } else {
+ mLoading.show();
+ }
+ }
+
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
@@ -446,6 +484,8 @@
mImageGrid.setAccessibilityDelegateCompat(
new WallpaperPickerRecyclerViewAccessibilityDelegate(
mImageGrid, (BottomSheetHost) getParentFragment(), getNumColumns()));
+ mLoading = view.findViewById(R.id.loading_indicator);
+ updateLoading();
maybeSetUpImageGrid();
setUpBottomSheet();
return view;
@@ -468,6 +508,10 @@
gridPaddingPx, gridPaddingPx, 0, paddingBottomPx);
}
+ private IndividualPickerFragmentHost getIndividualPickerFragmentHost() {
+ return (IndividualPickerFragmentHost) getParentFragment();
+ }
+
private void maybeSetUpImageGrid() {
// Skip if mImageGrid been initialized yet
if (mImageGrid == null) {