Sorted updated in dashboard by date and updated description

This commit is contained in:
Bars107 2014-12-09 15:46:00 +02:00
parent 654d3889b9
commit 6a3469cce1
3 changed files with 15 additions and 10 deletions

View file

@ -12,6 +12,7 @@
android:layout_width="match_parent"
android:layout_height="40dp">
<TextView android:text="@string/map_update"
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingTop="2dp"
@ -19,11 +20,6 @@
android:layout_marginLeft="15dp"
android:textSize="14sp"
android:textColor="@color/dashboard_black"/>
<TextView android:id="@+id/update_count"
android:layout_marginLeft="2dp"
android:layout_width="wrap_content"
android:textColor="@color/dashboard_blue"
android:layout_height="wrap_content"/>
<ProgressBar android:id="@+id/main_progress"
android:visibility="visible"
android:layout_marginLeft="2dp"

View file

@ -32,7 +32,7 @@
<string name="osmo_use_https_descr">Use secure connection with server</string>
<string name="osmo_use_https">Use HTTPS</string>
<string name="advanced_settings">Advanced</string>
<string name="map_update">Maps</string>
<string name="map_update">You have %1$s maps to update</string>
<string name="search_for">Search for</string>
<string name="show_map">SHOW MAP</string>
<string name="show_all">SHOW ALL</string>

View file

@ -1,6 +1,8 @@
package net.osmand.plus.dashboard;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import android.widget.*;
@ -63,6 +65,13 @@ public class DashUpdatesFragment extends DashBaseFragment {
}
public void updatedDownloadsList(List<IndexItem> list) {
List<IndexItem> itemList = new ArrayList<IndexItem>(list);
Collections.sort(itemList, new Comparator<IndexItem>() {
@Override
public int compare(IndexItem indexItem, IndexItem t1) {
return (int)(t1.getTimestamp() - indexItem.getTimestamp());
}
});
View mainView = getView();
//it may be null because download index thread is async
if (mainView == null) {
@ -72,20 +81,20 @@ public class DashUpdatesFragment extends DashBaseFragment {
baseNames.clear();
downloadButtons.clear();
mainView.findViewById(R.id.main_progress).setVisibility(View.GONE);
((TextView) mainView.findViewById(R.id.update_count)).setText(String.valueOf(list.size()));
((TextView) mainView.findViewById(R.id.header)).setText(getString(R.string.map_update ,String.valueOf(list.size())));
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
updates.removeAllViews();
if (list.size() < 1) {
if (itemList.size() < 1) {
mainView.findViewById(R.id.maps).setVisibility(View.GONE);
return;
} else {
mainView.findViewById(R.id.maps).setVisibility(View.VISIBLE);
}
for (int i = 0; i < list.size(); i++) {
final IndexItem item = list.get(i);
for (int i = 0; i < itemList.size(); i++) {
final IndexItem item = itemList.get(i);
if (i > 2) {
break;
}