commit
892375ce1c
3 changed files with 37 additions and 21 deletions
|
@ -100,7 +100,6 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
|
||||
tabHost.setCurrentTab(0);
|
||||
|
||||
|
||||
settings = ((OsmandApplication)getApplication()).getSettings();
|
||||
|
||||
indeterminateProgressBar = (ProgressBar) findViewById(R.id.IndeterminateProgressBar);
|
||||
|
@ -448,7 +447,11 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
public void downloadedIndexes(){
|
||||
for(WeakReference<Fragment> ref : fragList) {
|
||||
Fragment f = ref.get();
|
||||
if(f instanceof DownloadIndexFragment) {
|
||||
if(f instanceof LocalIndexesFragment){
|
||||
if(!f.isDetached()){
|
||||
((LocalIndexesFragment) f).reloadData();
|
||||
}
|
||||
} else if(f instanceof DownloadIndexFragment) {
|
||||
if(!f.isDetached()) {
|
||||
DownloadIndexAdapter adapter = ((DownloadIndexAdapter)((DownloadIndexFragment) f).getExpandableListAdapter());
|
||||
if (adapter != null) {
|
||||
|
|
|
@ -114,8 +114,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
if (asyncLoader == null || asyncLoader.getResult() == null) {
|
||||
asyncLoader = new LoadLocalIndexTask();
|
||||
asyncLoader.execute(getActivity());
|
||||
reloadData();
|
||||
}
|
||||
|
||||
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
|
||||
|
@ -132,6 +131,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
});
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
asyncLoader = new LoadLocalIndexTask();
|
||||
asyncLoader.execute(getActivity());
|
||||
}
|
||||
|
||||
|
||||
private void showContextMenu(final LocalIndexInfo info) {
|
||||
Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
@ -241,6 +245,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
protected void onPreExecute() {
|
||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true);
|
||||
listAdapter.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -383,9 +388,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
protected void onPostExecute(String result) {
|
||||
getDownloadActivity().setProgressBarIndeterminateVisibility(false);
|
||||
AccessibleToast.makeText(getDownloadActivity(), result, Toast.LENGTH_LONG).show();
|
||||
if (operation == RESTORE_OPERATION){
|
||||
listAdapter.clear();
|
||||
reloadIndexes();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +476,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
for(LocalIndexInfo info : getDownloadActivity().getLocalIndexInfos()){
|
||||
listAdapter.addLocalIndexInfo(info);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
listAdapter.sortData();
|
||||
}
|
||||
ActionBar actionBar = getDownloadActivity().getSupportActionBar();
|
||||
//hide action bar from downloadindexfragment
|
||||
|
@ -773,10 +779,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
final Collator cl = Collator.getInstance();
|
||||
for(List<LocalIndexInfo> i : data.values()) {
|
||||
Collections.sort(i, new Comparator<LocalIndexInfo>() {
|
||||
|
||||
@Override
|
||||
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
|
||||
return cl.compare(lhs.getName(), rhs.getName());
|
||||
return cl.compare(getNameToDisplay(lhs), getNameToDisplay(rhs));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -800,6 +805,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
LocalIndexInfo c = findCategory(i, i.isBackupedData());
|
||||
if(c != null){
|
||||
data.get(c).remove(i);
|
||||
if (data.get(c).size() == 0){
|
||||
data.remove(c);
|
||||
category.remove(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
@ -892,14 +901,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
||||
}
|
||||
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
||||
String mapDescr = getMapDescription(child.getFileName());
|
||||
String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(), child.getFileName());
|
||||
|
||||
if (mapDescr.length() > 0){
|
||||
viewName.setText(mapDescr + " - " + mapName);
|
||||
} else {
|
||||
viewName.setText(mapName);
|
||||
}
|
||||
viewName.setText(getNameToDisplay(child));
|
||||
if (child.isNotSupported()) {
|
||||
viewName.setTextColor(warningColor);
|
||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||
|
@ -957,6 +959,17 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
private String getNameToDisplay(LocalIndexInfo child) {
|
||||
String mapDescr = getMapDescription(child.getFileName());
|
||||
String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(), child.getFileName());
|
||||
|
||||
if (mapDescr.length() > 0){
|
||||
return mapDescr + " - " + mapName;
|
||||
} else {
|
||||
return mapName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
|
|
|
@ -84,7 +84,7 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
return;
|
||||
}
|
||||
|
||||
List<DownloadEntry> download = e.createDownloadEntry(getMyApplication(), getDownloadActivity().getDownloadType(), new ArrayList<DownloadEntry>());
|
||||
List<DownloadEntry> download = e.createDownloadEntry(getMyApplication(), e.getType(), new ArrayList<DownloadEntry>());
|
||||
if (download.size() > 0) {
|
||||
getDownloadActivity().getEntriesToDownload().put(e, download);
|
||||
getDownloadActivity().updateDownloadButton(true);
|
||||
|
|
Loading…
Reference in a new issue