[android] Fixed review notes

This commit is contained in:
Dmitry Donskoy 2018-06-22 18:49:53 +03:00 committed by Aleksandr Zatsepin
parent 1a3ecbf65d
commit 21ca23e584
3 changed files with 19 additions and 19 deletions

View file

@ -159,7 +159,9 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag
.setIcon(item.isVisible() ? R.drawable.ic_hide : R.drawable.ic_show)
.setTitle(item.isVisible() ? R.string.hide : R.string.show);
final boolean deleteIsPossible = getAdapter().getBookmarkCategories().size() > 1 || mSelectedCategory.isFromCatalog();
boolean isMultipleItems = getAdapter().getBookmarkCategories().size() > 1;
boolean fromCatalog = mSelectedCategory.isFromCatalog();
final boolean deleteIsPossible = isMultipleItems || fromCatalog;
bs.getItemById(getDeleteMenuItemResId())
.setVisible(deleteIsPossible)
.setEnabled(deleteIsPossible);
@ -267,6 +269,7 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag
SharingHelper.INSTANCE.prepareBookmarkCategoryForSharing(getActivity(), category.getId());
}
@CallSuper
protected void onDeleteActionSelected(@NonNull BookmarkCategory category)
{
BookmarkManager.INSTANCE.deleteCategory(category.getId());
@ -274,7 +277,7 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag
}
@Override
public void onItemLongClick(View v, BookmarkCategory category)
public void onItemLongClick(@NonNull View v, @NonNull BookmarkCategory category)
{
showBottomMenu(category);
}

View file

@ -1,7 +1,6 @@
package com.mapswithme.maps.bookmarks;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -64,6 +63,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
public void onStart()
{
super.onStart();
mImportCategoryListener.attach(this);
BookmarkManager.INSTANCE.addCatalogListener(mImportCategoryListener);
}
@ -71,7 +71,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
public void onStop()
{
super.onStop();
mImportCategoryListener.clear();
mImportCategoryListener.detach();
BookmarkManager.INSTANCE.removeCatalogListener(mImportCategoryListener);
}
@ -229,25 +229,21 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
{
Toast.makeText(mFragment.getContext(), R.string.bookmarks_webview_success_toast,
Toast.LENGTH_SHORT).show();
return;
}
else
{
DialogUtils.showAlertDialog(mFragment.getActivity(),
R.string.title_error_downloading_bookmarks,
R.string.subtitle_error_downloading_bookmarks,
android.R.string.ok,
(dialog, which) -> onOkClicked(dialog));
}
DialogUtils.showAlertDialog(mFragment.getActivity(),
R.string.title_error_downloading_bookmarks,
R.string.subtitle_error_downloading_bookmarks);
}
private void onOkClicked(DialogInterface dialog)
{
dialog.dismiss();
}
public void clear()
public void detach()
{
mFragment = null;
}
public void attach(@NonNull BookmarksCatalogFragment fragment)
{
mFragment = fragment;
}
}
}

View file

@ -1,8 +1,9 @@
package com.mapswithme.maps.bookmarks;
import android.support.annotation.NonNull;
import android.view.View;
public interface OnItemLongClickListener<T>
{
void onItemLongClick(View v, T item);
void onItemLongClick(@NonNull View v, @NonNull T item);
}