[android] Implemented quick filter click event

This commit is contained in:
alexzatsepin 2020-08-24 20:46:44 +03:00 committed by Maksim Andrianov
parent 744d0c2995
commit dd59773afc
3 changed files with 46 additions and 2 deletions

View file

@ -36,6 +36,8 @@ public class InteractiveCounterView extends RelativeLayout
private int mDefaultValue;
@DrawableRes
private int mIconRes;
@Nullable
private CounterChangeListener mChangeListener;
@NonNull
private final OnClickListener mPlusClickListener = new OnClickListener()
{
@ -45,6 +47,8 @@ public class InteractiveCounterView extends RelativeLayout
int value = getCurrentValue();
mCounterView.setText(String.valueOf(++value));
updateConstraints();
if (mChangeListener != null)
mChangeListener.onChange();
}
};
@ -57,6 +61,8 @@ public class InteractiveCounterView extends RelativeLayout
int value = getCurrentValue();
mCounterView.setText(String.valueOf(--value));
updateConstraints();
if (mChangeListener != null)
mChangeListener.onChange();
}
};
@ -142,4 +148,14 @@ public class InteractiveCounterView extends RelativeLayout
mMinusView.setEnabled(value != mMinValue);
mPlusView.setEnabled(value != mMaxValue);
}
public void setChangeListener(@Nullable CounterChangeListener listener)
{
mChangeListener = listener;
}
public interface CounterChangeListener
{
void onChange();
}
}

View file

@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
import com.mapswithme.maps.R;
import com.mapswithme.maps.search.FilterUtils;
import com.mapswithme.maps.widget.InteractiveCounterView;
import com.mapswithme.util.statistics.Statistics;
import java.util.Objects;
@ -65,14 +66,30 @@ public class GuestsRoomsMenuRenderer implements MenuRenderer
{
Objects.requireNonNull(view);
mRoomsView = view.findViewById(R.id.rooms);
mRoomsView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.ROOMS,
mRoomsView.getCurrentValue()));
mAdultsView = view.findViewById(R.id.adults);
mAdultsView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.ADULTS,
mAdultsView.getCurrentValue()));
mChildrenView = view.findViewById(R.id.children);
mChildrenView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.CHILDREN,
mChildrenView.getCurrentValue()));
mInfantsView = view.findViewById(R.id.infants);
mInfantsView.setChangeListener(() -> onChangeCounterValue(Statistics.EventParam.INFANTS,
mInfantsView.getCurrentValue()));
}
@Override
public void destroy()
{
// No op.
mRoomsView.setChangeListener(null);
mAdultsView.setChangeListener(null);
mChildrenView.setChangeListener(null);
mInfantsView.setChangeListener(null);
}
private void onChangeCounterValue(@NonNull String name, int count)
{
Statistics.INSTANCE.trackQuickFilterClick(Statistics.EventParam.HOTEL, name, count);
}
}

View file

@ -101,6 +101,7 @@ import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_PLAN_T
import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_ROUTE_FINISH;
import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_ROUTE_START;
import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_FILTER_CLICK;
import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_QUICKFILTER_CLICK;
import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_QUICKFILTER_OPEN;
import static com.mapswithme.util.statistics.Statistics.EventName.TIPS_TRICKS_CLOSE;
import static com.mapswithme.util.statistics.Statistics.EventName.TOOLBAR_CLICK;
@ -450,7 +451,8 @@ public enum Statistics
public static final String SEARCH_FILTER_CANCEL = "Search_Filter_Cancel";
public static final String SEARCH_FILTER_RESET = "Search_Filter_Reset";
public static final String SEARCH_FILTER_APPLY = "Search_Filter_Apply";
public static final String SEARCH_QUICKFILTER_OPEN = "Search_QuickFilter_Open";
static final String SEARCH_QUICKFILTER_OPEN = "Search_QuickFilter_Open";
static final String SEARCH_QUICKFILTER_CLICK = "Search_QuickFilter_Click";
static final String SEARCH_CAT_CLICKED = "Search. Category clicked";
static final String SEARCH_TAB_SELECTED = "Search_Tab_selected";
static final String SEARCH_FILTER_CLICK = "Search_Filter_Click";
@ -671,6 +673,10 @@ public enum Statistics
public static final String EXPORT_BOOKMARKS = "export_bookmarks";
public static final String BOOKMARKS_BACKUP = "bookmarks_backup";
public static final String AFTER_SAVE_REVIEW = "after_save_review";
public static final String ROOMS = "rooms";
public static final String ADULTS = "adults";
public static final String CHILDREN = "children";
public static final String INFANTS = "infants";
static final String BANNER = "banner";
static final String BATTERY = "battery";
static final String CALLER_ID = "Caller ID";
@ -1604,6 +1610,11 @@ public enum Statistics
.add(NETWORK, getConnectionState()).get());
}
public void trackQuickFilterClick(@NonNull String category, @NonNull String name, int count)
{
trackEvent(SEARCH_QUICKFILTER_CLICK, params().add(CATEGORY, category).add(name, count).get());
}
public void trackFilterEvent(@NonNull String event, @NonNull String category)
{
trackEvent(event, params()