[new downloader][android] fix: Clicks and context menus fixes in downloader.

fix: Layout fix for downloader items.
This commit is contained in:
Alexander Marchuk 2016-03-16 13:13:31 +03:00 committed by Sergey Yershov
parent 91fbb7d2f5
commit e80f141f06
3 changed files with 31 additions and 14 deletions

View file

@ -4,18 +4,17 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="@dimen/height_item_oneline"
android:orientation="horizontal"
android:minHeight="@dimen/downloader_status_size"
android:background="?clickableBackground"
android:paddingLeft="@dimen/margin_half"
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:gravity="center_vertical"
android:baselineAligned="false">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_half">
android:layout_marginRight="@dimen/margin_base">
<com.mapswithme.maps.widget.WheelProgressView
android:id="@+id/progress"
android:layout_width="@dimen/downloader_status_size"

View file

@ -39,7 +39,7 @@
<dimen name="place_page_width">360dp</dimen>
<dimen name="place_page_buttons_height">56dp</dimen>
<dimen name="downloader_status_size">48dp</dimen>
<dimen name="downloader_status_size">40dp</dimen>
<dimen name="search_progress_size">32dp</dimen>
<dimen name="panel_width">360dp</dimen>

View file

@ -63,6 +63,22 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
private enum MenuItem
{
DOWNLOAD(R.drawable.ic_downloader_download, R.string.downloader_download_map)
{
@Override
void invoke(CountryItem item, DownloaderAdapter adapter)
{
MapManager.nativeDownload(item.id);
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION,
Statistics.params().add(Statistics.EventParam.ACTION, "download")
.add(Statistics.EventParam.FROM, "downloader")
.add("is_auto", "false")
.add("scenario", (item.isExpandable() ? "download_group"
: "download")));
}
},
DELETE(R.drawable.ic_delete, R.string.delete)
{
private void deleteNode(CountryItem item)
@ -244,18 +260,13 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
switch (mItem.status)
{
case CountryItem.STATUS_DONE:
case CountryItem.STATUS_PROGRESS:
case CountryItem.STATUS_ENQUEUED:
processLongClick();
break;
case CountryItem.STATUS_DOWNLOADABLE:
MapManager.nativeDownload(mItem.id);
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION,
Statistics.params().add(Statistics.EventParam.ACTION, "download")
.add(Statistics.EventParam.FROM, "downloader")
.add("is_auto", "false")
.add("scenario", (mItem.isExpandable() ? "download_group"
: "download")));
MenuItem.DOWNLOAD.invoke(mItem, DownloaderAdapter.this);
break;
case CountryItem.STATUS_FAILED:
@ -285,12 +296,18 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
switch (mItem.status)
{
case CountryItem.STATUS_DOWNLOADABLE:
items.add(MenuItem.DOWNLOAD);
break;
case CountryItem.STATUS_UPDATABLE:
items.add(MenuItem.UPDATE);
// No break
case CountryItem.STATUS_DONE:
items.add(MenuItem.EXPLORE);
if (!mItem.isExpandable())
items.add(MenuItem.EXPLORE);
items.add(MenuItem.DELETE);
break;
@ -313,6 +330,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
break;
case CountryItem.STATUS_PARTLY:
items.add(MenuItem.DOWNLOAD);
items.add(MenuItem.DELETE);
break;
}