forked from organicmaps/organicmaps
[android] Added statistic methods for categories and collections.
This commit is contained in:
parent
93bd00ff0b
commit
343d0d6f7e
4 changed files with 69 additions and 11 deletions
|
@ -13,6 +13,7 @@ import com.mapswithme.maps.R;
|
|||
import com.mapswithme.maps.adapter.OnItemClickListener;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
@ -29,6 +30,8 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
private final static int TYPE_HEADER_ITEM = 3;
|
||||
|
||||
private final long mParentCategoryId;
|
||||
@NonNull
|
||||
private final String mParentServerId;
|
||||
|
||||
@NonNull
|
||||
private List<BookmarkCategory> mItemsCollection;
|
||||
|
@ -62,13 +65,23 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
category.invertVisibility();
|
||||
notifyItemChanged(mHolder.getAdapterPosition());
|
||||
notifyItemChanged(SectionPosition.INVALID_POSITION);
|
||||
|
||||
String compilationTypeString = BookmarkManager.INSTANCE.getCompilationType(category.getId()) ==
|
||||
BookmarkManager.CATEGORY ?
|
||||
Statistics.ParamValue.CATEGORY :
|
||||
Statistics.ParamValue.COLLECTION;
|
||||
Statistics.INSTANCE.trackGuideVisibilityChange(
|
||||
category.isVisible() ? Statistics.ParamValue.SHOW : Statistics.ParamValue.HIDE,
|
||||
category.getServerId(), compilationTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
BookmarkCollectionAdapter(long parentCategoryId,
|
||||
BookmarkCollectionAdapter(@NonNull String parentServerId,
|
||||
long parentCategoryId,
|
||||
@NonNull List<BookmarkCategory> itemsCategories,
|
||||
@NonNull List<BookmarkCategory> itemsCollection)
|
||||
{
|
||||
mParentServerId = parentServerId;
|
||||
mParentCategoryId = parentCategoryId;
|
||||
//noinspection AssignmentOrReturnOfFieldWithMutableType
|
||||
mItemsCategory = itemsCategories;
|
||||
|
@ -220,7 +233,8 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
int compilationType = nextSectionPosition == mCategorySectionIndex ?
|
||||
BookmarkManager.CATEGORY : BookmarkManager.COLLECTION;
|
||||
headerViewHolder.setAction(mMassOperationAction,
|
||||
!isCategoryAllItemsAreVisible(nextSectionPosition), compilationType);
|
||||
!isCategoryAllItemsAreVisible(nextSectionPosition),
|
||||
compilationType, mParentServerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -141,17 +141,23 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
List<BookmarkCategory> mCategoryItems = BookmarkManager.INSTANCE.getChildrenCategories(categoryId);
|
||||
List<BookmarkCategory> mCollectionItems = BookmarkManager.INSTANCE.getChildrenCollections(categoryId);
|
||||
|
||||
mBookmarkCollectionAdapter = new BookmarkCollectionAdapter(categoryId ,mCategoryItems, mCollectionItems);
|
||||
mBookmarkCollectionAdapter = new BookmarkCollectionAdapter(
|
||||
getCategoryOrThrow().getServerId(), categoryId, mCategoryItems, mCollectionItems);
|
||||
mBookmarkCollectionAdapter.setOnClickListener((v, item) -> {
|
||||
Intent intent = new Intent(getActivity(), BookmarkListActivity.class)
|
||||
.putExtra(BookmarksListFragment.EXTRA_CATEGORY, item);
|
||||
// TODO(@velichkomarija): Statistics.INSTANCE.trackCollectionOrCategorySelect()
|
||||
|
||||
final boolean isCategory = BookmarkManager.INSTANCE.getCompilationType(item.getId()) ==
|
||||
BookmarkManager.CATEGORY;
|
||||
Statistics.INSTANCE.trackCollectionOrCategorySelect(item.getServerId(), item.getName(),
|
||||
isCategory);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_bookmark_list, container, false);
|
||||
}
|
||||
|
@ -615,9 +621,19 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
i.putExtra(MwmActivity.EXTRA_TASK,
|
||||
new Factory.ShowBookmarkTask(bookmark.getCategoryId(), bookmark.getBookmarkId()));
|
||||
|
||||
// TODO (@velichkomarija): Added from param category or collection instead MAIN if need.
|
||||
Statistics.INSTANCE.trackGuideBookmarkSelect(mCategoryDataSource.getData().getServerId(),
|
||||
Statistics.ParamValue.MAIN);
|
||||
getParamValueByType(bookmark.getCategoryId()));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getParamValueByType(long catId)
|
||||
{
|
||||
if (BookmarkManager.INSTANCE.isCompilation(catId))
|
||||
return Statistics.ParamValue.MAIN;
|
||||
else if (BookmarkManager.INSTANCE.getCompilationType(catId) == BookmarkManager.CATEGORY)
|
||||
return Statistics.ParamValue.CATEGORY;
|
||||
else
|
||||
return Statistics.ParamValue.COLLECTION;
|
||||
}
|
||||
|
||||
public void onItemMore(int position)
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.mapswithme.maps.widget.recycler.RecyclerClickListener;
|
|||
import com.mapswithme.maps.widget.recycler.RecyclerLongClickListener;
|
||||
import com.mapswithme.util.Graphics;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public class Holders
|
||||
{
|
||||
|
@ -92,13 +93,14 @@ public class Holders
|
|||
|
||||
void setAction(@NonNull HeaderActionChildCategories action,
|
||||
final boolean showAll,
|
||||
@BookmarkManager.CompilationType final int compilationType)
|
||||
@BookmarkManager.CompilationType final int compilationType,
|
||||
@NonNull String serverId)
|
||||
{
|
||||
mButton.setText(showAll
|
||||
? R.string.bookmarks_groups_show_all
|
||||
: R.string.bookmarks_groups_hide_all);
|
||||
mButton.setOnClickListener(new ToggleShowAllChildCategoryClickListener(
|
||||
action, showAll, compilationType));
|
||||
action, showAll, compilationType, serverId));
|
||||
}
|
||||
|
||||
public interface HeaderAction
|
||||
|
@ -121,22 +123,37 @@ public class Holders
|
|||
private final boolean mShowAll;
|
||||
@BookmarkManager.CompilationType
|
||||
private final int mCompilationType;
|
||||
private final String mServerId;
|
||||
private final String mCompilationTypeString;
|
||||
|
||||
ToggleShowAllChildCategoryClickListener(@NonNull HeaderActionChildCategories action, boolean showAll,
|
||||
@BookmarkManager.CompilationType int compilationType)
|
||||
ToggleShowAllChildCategoryClickListener(@NonNull HeaderActionChildCategories action,
|
||||
boolean showAll,
|
||||
@BookmarkManager.CompilationType int compilationType,
|
||||
@NonNull String serverId)
|
||||
{
|
||||
mAction = action;
|
||||
mShowAll = showAll;
|
||||
mCompilationType = compilationType;
|
||||
mServerId = serverId;
|
||||
mCompilationTypeString = compilationType == BookmarkManager.CATEGORY ?
|
||||
Statistics.ParamValue.CATEGORY : Statistics.ParamValue.COLLECTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if (mShowAll)
|
||||
{
|
||||
mAction.onShowAll(mCompilationType);
|
||||
Statistics.INSTANCE.trackGuideVisibilityChange(Statistics.ParamValue.SHOW_ALL, mServerId,
|
||||
mCompilationTypeString);
|
||||
}
|
||||
else
|
||||
{
|
||||
mAction.onHideAll(mCompilationType);
|
||||
Statistics.INSTANCE.trackGuideVisibilityChange(Statistics.ParamValue.HIDE_ALL, mServerId,
|
||||
mCompilationTypeString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -909,6 +909,16 @@ public enum BookmarkManager
|
|||
{
|
||||
return Arrays.asList(nativeGetChildrenCollections(catId));
|
||||
}
|
||||
|
||||
public boolean isCompilation(long catId)
|
||||
{
|
||||
return nativeIsCompilation(catId);
|
||||
}
|
||||
|
||||
public int getCompilationType(long catId)
|
||||
{
|
||||
return nativeGetCompilationType(catId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
native BookmarkCategory[] nativeGetBookmarkCategories();
|
||||
|
@ -918,6 +928,7 @@ public enum BookmarkManager
|
|||
native BookmarkCategory[] nativeGetChildrenCollections(long catId);
|
||||
|
||||
native boolean nativeIsCompilation(long catId);
|
||||
|
||||
native int nativeGetCompilationType(long catId);
|
||||
|
||||
@NonNull
|
||||
|
|
Loading…
Add table
Reference in a new issue