Open downloaded maps on dialog confirm.

This commit is contained in:
Dmitry Yunitsky 2014-10-14 15:59:11 +03:00 committed by Alex Zolotarev
parent 87b2959ebb
commit f7465d067b
3 changed files with 41 additions and 17 deletions

View file

@ -360,7 +360,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter
sizes = getDownloadableItemSizes(position);
setHolderSizeString(holder, 0, sizes[1]);
setHolderPercentString(holder, mActivity.getString(R.string.downloader_queued), R.color.downloader_gray);
setHolderPercentString(holder, "0%", R.color.downloader_gray);
break;
case MapStorage.ON_DISK_OUT_OF_DATE:
@ -627,6 +627,9 @@ abstract class BaseDownloadAdapter extends BaseAdapter
*/
protected void onCountryProgress(int position, long current, long total)
{
if (mListView == null)
return;
// do update only one item's view; don't call notifyDataSetChanged
final View v = mListView.getChildAt(position - mListView.getFirstVisiblePosition());
if (v != null)

View file

@ -31,6 +31,7 @@ public class DownloadActivity extends MapsWithMeBaseListActivity implements View
private static final int MODE_UPDATE_ALL = 1;
private static final int MODE_CANCEL_ALL = 2;
public static final String EXTRA_OPEN_DOWNLOADED_LIST = "open_downloaded";
@Override
protected void onCreate(Bundle savedInstanceState)
@ -39,10 +40,15 @@ public class DownloadActivity extends MapsWithMeBaseListActivity implements View
setContentView(R.layout.downloader_list_view);
mExtendedAdapter = new ExtendedDownloadAdapterWrapper(this, new DownloadAdapter(this));
setListAdapter(mExtendedAdapter);
mMode = MODE_DISABLED;
mListenerSlotId = ActiveCountryTree.addListener(this);
if (getIntent().getBooleanExtra(EXTRA_OPEN_DOWNLOADED_LIST, false))
openDownloadedList();
else
{
mExtendedAdapter = getExtendedAdater();
setListAdapter(mExtendedAdapter);
mMode = MODE_DISABLED;
mListenerSlotId = ActiveCountryTree.addListener(this);
}
}
@Override
@ -99,6 +105,7 @@ public class DownloadActivity extends MapsWithMeBaseListActivity implements View
{
mMode = MODE_DISABLED;
mDownloadedAdapter.onPause();
mExtendedAdapter = getExtendedAdater();
mExtendedAdapter.onResume(getListView());
setListAdapter(mExtendedAdapter);
updateActionBar();
@ -141,13 +148,17 @@ public class DownloadActivity extends MapsWithMeBaseListActivity implements View
protected void onListItemClick(ListView l, View v, int position, long id)
{
if (getListAdapter().getItemViewType(position) == ExtendedDownloadAdapterWrapper.TYPE_EXTENDED)
{
setListAdapter(getDownloadedAdapter());
mMode = MODE_NONE;
updateActionBar();
openDownloadedList();
}
private void openDownloadedList()
{
setListAdapter(getDownloadedAdapter());
mMode = MODE_NONE;
updateActionBar();
if (mExtendedAdapter != null)
mExtendedAdapter.onPause();
mDownloadedAdapter.onResume(getListView());
}
mDownloadedAdapter.onResume(getListView());
}
private ListAdapter getDownloadedAdapter()
@ -158,6 +169,14 @@ public class DownloadActivity extends MapsWithMeBaseListActivity implements View
return mDownloadedAdapter;
}
private ExtendedDownloadAdapterWrapper getExtendedAdater()
{
if (mExtendedAdapter == null)
mExtendedAdapter = new ExtendedDownloadAdapterWrapper(this, new DownloadAdapter(this));
return mExtendedAdapter;
}
@Override
public void onClick(View v)
{

View file

@ -429,7 +429,7 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void doUpdate()
{
runDownloadActivity();
runDownloadActivity(false);
}
@Override
@ -582,7 +582,7 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void doUpdate()
{
runDownloadActivity();
runDownloadActivity(false);
}
@Override
@ -703,9 +703,10 @@ public class MWMActivity extends NvEventQueueActivity
}
}
private void runDownloadActivity()
private void runDownloadActivity(boolean openDownloadedList)
{
startActivity(new Intent(this, DownloadActivity.class));
final Intent intent = new Intent(this, DownloadActivity.class).putExtra(DownloadActivity.EXTRA_OPEN_DOWNLOADED_LIST, openDownloadedList);
startActivity(intent);
}
@Override
@ -1427,7 +1428,7 @@ public class MWMActivity extends NvEventQueueActivity
break;
case R.id.btn_download_maps:
setVerticalToolbarVisible(false);
runDownloadActivity();
runDownloadActivity(false);
break;
case R.id.btn_more_apps:
setVerticalToolbarVisible(false);
@ -1594,7 +1595,8 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void onClick(DialogInterface dialog, int which)
{
runDownloadActivity();
// TODO start country download automatically?
runDownloadActivity(true);
closeRouting();
dialog.dismiss();
}