Show message if there are no updates

This commit is contained in:
Gabriele M
2017-08-09 17:18:15 +02:00
parent ca5b75ebd1
commit 7c25e7aef9
3 changed files with 33 additions and 9 deletions
+15
View File
@@ -76,6 +76,21 @@
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/no_new_updates_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="46dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/list_no_updates"
android:textColor="?android:textColorSecondary" />
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
+1
View File
@@ -81,6 +81,7 @@
<string name="list_download_progress_eta"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> - <xliff:g id="duration" example="3 minutes">%3$s</xliff:g> left</string>
<string name="list_installing_update">Installing update</string>
<string name="list_verifying_update">Verifying update</string>
<string name="list_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string>
<string name="action_description_download">Download</string>
<string name="action_description_pause">Pause download</string>
+17 -9
View File
@@ -40,6 +40,7 @@ import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import org.json.JSONException;
@@ -285,17 +286,24 @@ public class UpdatesActivity extends UpdatesListActivity {
List<String> updateIds = new ArrayList<>();
List<UpdateInfo> sortedUpdates = controller.getUpdates();
Collections.sort(sortedUpdates, new Comparator<UpdateInfo>() {
@Override
public int compare(UpdateInfo u1, UpdateInfo u2) {
return Long.compare(u2.getTimestamp(), u1.getTimestamp());
if (sortedUpdates.isEmpty()) {
findViewById(R.id.no_new_updates_view).setVisibility(View.VISIBLE);
findViewById(R.id.recycler_view).setVisibility(View.GONE);
} else {
findViewById(R.id.no_new_updates_view).setVisibility(View.GONE);
findViewById(R.id.recycler_view).setVisibility(View.VISIBLE);
Collections.sort(sortedUpdates, new Comparator<UpdateInfo>() {
@Override
public int compare(UpdateInfo u1, UpdateInfo u2) {
return Long.compare(u2.getTimestamp(), u1.getTimestamp());
}
});
for (UpdateInfo update : sortedUpdates) {
updateIds.add(update.getDownloadId());
}
});
for (UpdateInfo update : sortedUpdates) {
updateIds.add(update.getDownloadId());
mAdapter.setData(updateIds);
mAdapter.notifyDataSetChanged();
}
mAdapter.setData(updateIds);
mAdapter.notifyDataSetChanged();
}
private void getUpdatesList() {