am ab617db4: no blank album lists.
* commit 'ab617db46883ffbb9ee77dacd54613bdc026cc2d':
no blank album lists.
diff --git a/res/layout/settingslist.xml b/res/layout/settingslist.xml
index 0ea6661..c383856 100644
--- a/res/layout/settingslist.xml
+++ b/res/layout/settingslist.xml
@@ -22,11 +22,28 @@
android:paddingRight="16dp"
/>
- <ProgressBar android:id="@android:id/empty"
- style="?android:attr/progressBarStyleLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- />
+ <FrameLayout
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+ <ProgressBar
+ android:id="@+id/spinner"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+
+ <TextView
+ android:id="@+id/sorry"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:alpha="0.5"
+ android:gravity="center_vertical|center_horizontal"
+ android:text="@string/no_photos"
+ android:textColor="@android:color/white"
+ android:textSize="20sp"
+ android:visibility="gone" />
+
+ </FrameLayout>
</merge>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 087f8b1..1f64e10 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -47,4 +47,6 @@
<!-- Click to clear selection in the album selection activity. [CHAR LIMIT=15] -->
<string name="photodream_select_none">Deselect All</string>
+ <!-- Text shown instead of a list of albums when there are no albums with photos. [CHAR LIMIT=50] -->
+ <string name="no_photos">No photos on the device.</string>
</resources>
diff --git a/src/com/android/dreams/phototable/FlipperDreamSettings.java b/src/com/android/dreams/phototable/FlipperDreamSettings.java
index 87802c6..464029e 100644
--- a/src/com/android/dreams/phototable/FlipperDreamSettings.java
+++ b/src/com/android/dreams/phototable/FlipperDreamSettings.java
@@ -19,6 +19,7 @@
import android.content.SharedPreferences;
import android.database.DataSetObserver;
import android.os.AsyncTask;
+import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
@@ -40,6 +41,7 @@
private PhotoSourcePlexor mPhotoSource;
private SectionedAlbumDataAdapter mAdapter;
private MenuItem mSelectAll;
+ private AsyncTask<Void, Void, Void> mLoadingTask;
@Override
protected void onCreate(Bundle savedInstanceState){
@@ -48,11 +50,20 @@
init();
}
+ @Override
+ protected void onResume(){
+ super.onResume();
+ init();
+ }
+
protected void init() {
mPhotoSource = new PhotoSourcePlexor(this, mSettings);
setContentView(R.layout.settingslist);
-
- new AsyncTask<Void, Void, Void>() {
+ if (mLoadingTask != null && mLoadingTask.getStatus() != Status.FINISHED) {
+ mLoadingTask.cancel(true);
+ }
+ showApology(false);
+ mLoadingTask = new AsyncTask<Void, Void, Void>() {
@Override
public Void doInBackground(Void... unused) {
mAdapter = new SectionedAlbumDataAdapter(FlipperDreamSettings.this,
@@ -78,11 +89,10 @@
setListAdapter(mAdapter);
getListView().setItemsCanFocus(true);
updateActionItem();
- if (mAdapter.getCount() == 0) {
- findViewById(android.R.id.empty).setVisibility(View.GONE);
- }
+ showApology(mAdapter.getCount() == 0);
}
- }.execute();
+ };
+ mLoadingTask.execute();
}
@Override
@@ -105,6 +115,15 @@
}
}
+ private void showApology(boolean apologize) {
+ View empty = findViewById(R.id.spinner);
+ View sorry = findViewById(R.id.sorry);
+ if (empty != null && sorry != null) {
+ empty.setVisibility(apologize ? View.GONE : View.VISIBLE);
+ sorry.setVisibility(apologize ? View.VISIBLE : View.GONE);
+ }
+ }
+
private void updateActionItem() {
if (mAdapter != null && mSelectAll != null) {
if (mAdapter.areAllSelected()) {