[android] Fixes after review.

This commit is contained in:
velichkomarija 2020-10-02 17:20:09 +03:00 committed by Aleksandr Zatsepin
parent 857c06cb60
commit ab3f65b985
4 changed files with 29 additions and 42 deletions

View file

@ -270,12 +270,9 @@
<dimen name="toggle_map_layer_frame_height">98dp</dimen>
<dimen name="focal_radius">44dp</dimen>
<dimen name="guide_image_height">180dp</dimen>
<dimen name="guide_description_block_height">108dp</dimen>
<dimen name="guide_description_content_by_height">60dp</dimen>
<dimen name="content_by_logo_width">68dp</dimen>
<dimen name="bookmark_checkbox_size">32dp</dimen>
<dimen name="bookmark_collection_item_end_margin">56dp</dimen>
<dimen name="bookmark_category_title_height">60dp</dimen>
<!-- Purchases-->
<dimen name="ads_removal_dialog_min_height">508dp</dimen>

View file

@ -1,6 +1,5 @@
package com.mapswithme.maps.bookmarks;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.ViewGroup;
@ -20,9 +19,6 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
private final static int TYPE_COLLECTION_ITEM = 1;
private final static int TYPE_CATEGORY_ITEM = 2;
// TODO (@velichkomarija): Delete this if do not need.
@NonNull
private final Context mContext;
@NonNull
private List<BookmarkCategory> mItemsCollection;
@NonNull
@ -30,9 +26,9 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
@NonNull
private int mSectionCount;
@NonNull
private int mCollectionSectionIndex;
private int mCollectionSectionIndex = SectionPosition.INVALID_POSITION;
@NonNull
private int mCategorySectionIndex;
private int mCategorySectionIndex = SectionPosition.INVALID_POSITION;
@Nullable
private OnItemClickListener<BookmarkCategory> mClickListener;
@ -70,10 +66,11 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
}
}
private void calculateSections()
BookmarkCollectionAdapter(@NonNull List<BookmarkCategory> itemsCategories,
@NonNull List<BookmarkCategory> itemsCollection)
{
mCollectionSectionIndex = SectionPosition.INVALID_POSITION;
mCategorySectionIndex = SectionPosition.INVALID_POSITION;
mItemsCategory = itemsCategories;
mItemsCollection = itemsCollection;
mSectionCount = 0;
if (mItemsCollection.size() > 0)
@ -118,7 +115,7 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
}
@NonNull
public BookmarkCategory getCategoryByPosition(SectionPosition sp, int type)
public BookmarkCategory getGroupByPosition(SectionPosition sp, int type)
{
List<BookmarkCategory> categories = getItemsListByType(type);
@ -128,16 +125,6 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
return categories.get(itemIndex);
}
BookmarkCollectionAdapter(@NonNull Context context,
@NonNull List<BookmarkCategory> itemsCategories,
@NonNull List<BookmarkCategory> itemsCollection)
{
mContext = context;
mItemsCategory = itemsCategories;
mItemsCollection = itemsCollection;
calculateSections();
}
public void setOnClickListener(@Nullable OnItemClickListener<BookmarkCategory> listener)
{
mClickListener = listener;
@ -207,9 +194,9 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
private void bindCollectionHolder(RecyclerView.ViewHolder holder, SectionPosition position, int type)
{
final BookmarkCategory category = getCategoryByPosition(position, type);
final BookmarkCategory category = getGroupByPosition(position, type);
Holders.CollectionViewHolder collectionViewHolder = (Holders.CollectionViewHolder) holder;
collectionViewHolder.setCategory(category);
collectionViewHolder.setEntity(category);
collectionViewHolder.setName(category.getName());
bindSize(collectionViewHolder, category);
collectionViewHolder.setVisibilityState(category.isVisible());
@ -244,7 +231,6 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
for (int i = 0; i < mSectionCount; ++i)
{
int sectionItemsCount = getItemsCount(i);
if (sectionItemsCount == 0)
continue;

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@ -142,7 +143,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
List<BookmarkCategory> mCategoryItems = BookmarkManager.INSTANCE.getChildrenCategories(categoryId);
List<BookmarkCategory> mCollectionItems = BookmarkManager.INSTANCE.getChildrenCollections(categoryId);
mBookmarkCollectionAdapter = new BookmarkCollectionAdapter(requireContext(), mCategoryItems, mCollectionItems);
mBookmarkCollectionAdapter = new BookmarkCollectionAdapter(mCategoryItems, mCollectionItems);
}
@Override
@ -224,30 +225,31 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
private void configureGuidesInfoLayout(View view)
{
if (!mCategoryDataSource.getData().isMyCategory())
BookmarkCategory category = mCategoryDataSource.getData();
if (!category.isMyCategory())
{
ImageView imageView = view.findViewById(R.id.guide_image);
String imageUrl = mCategoryDataSource.getData().getImageUrl();
if (imageUrl.isEmpty())
String imageUrl = category.getImageUrl();
if (TextUtils.isEmpty(imageUrl))
{
UiUtils.hide(imageView);
}
else
{
Glide.with(view.getContext())
.load(imageUrl)
.centerCrop()
.into(imageView);
.load(imageUrl)
.centerCrop()
.into(imageView);
}
TextView title = view.findViewById(R.id.guide_title);
title.setText(mCategoryDataSource.getData().getName());
title.setText(category.getName());
TextView descriptionBtn = view.findViewById(R.id.btn_description);
boolean isHideDescriptionBtn = mCategoryDataSource.getData()
.getDescription()
.isEmpty() || mCategoryDataSource.getData()
.getAnnotation()
.isEmpty();
boolean isHideDescriptionBtn = TextUtils.isEmpty(category.getDescription())
|| TextUtils.isEmpty(category.getAnnotation());
UiUtils.hideIf(isHideDescriptionBtn, descriptionBtn);
BookmarkCategory.Author author = mCategoryDataSource.getData().getAuthor();
BookmarkCategory.Author author = category.getAuthor();
ImageView imageViewLogo = view.findViewById(R.id.logo);
TextView authorTextView = view.findViewById(R.id.content_by);
@ -264,7 +266,9 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
}
}
else
{
UiUtils.hide(view.findViewById(R.id.guide_info));
}
}
private void configureAdapter()

View file

@ -161,7 +161,7 @@ public class Holders
mSize.setText(mSize.getResources().getQuantityString(phrase, size, size));
}
void setCategory(@NonNull BookmarkCategory entity)
void setEntity(@NonNull BookmarkCategory entity)
{
mEntity = entity;
}