[android] Added fifa in search
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
@ -2,7 +2,9 @@ package com.mapswithme.maps.search;
|
|||
|
||||
import android.content.res.Resources;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
@ -12,23 +14,22 @@ import android.view.ViewGroup;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.widget.placepage.Sponsored;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolder>
|
||||
{
|
||||
@StringRes
|
||||
private final int mCategoryResIds[];
|
||||
@DrawableRes
|
||||
private final int mIconResIds[];
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
private final Resources mResources;
|
||||
|
||||
static final String LUGGAGE_CATEGORY = "luggagehero";
|
||||
|
||||
interface OnCategorySelectedListener
|
||||
{
|
||||
void onCategorySelected(String category);
|
||||
void onCategorySelected(@Nullable String category);
|
||||
}
|
||||
|
||||
private OnCategorySelectedListener mListener;
|
||||
|
@ -51,17 +52,17 @@ class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolde
|
|||
mCategoryResIds[i] = resources.getIdentifier(key, "string", packageName);
|
||||
if (mCategoryResIds[i] == 0)
|
||||
{
|
||||
if (key.equals(LUGGAGE_CATEGORY))
|
||||
PromoCategory category = PromoCategory.findByKey(key);
|
||||
if (category != null)
|
||||
{
|
||||
Statistics.INSTANCE.trackSponsoredEventForCustomProvider(
|
||||
Statistics.EventName.SEARCH_SPONSOR_CATEGORY_SHOWN,
|
||||
Statistics.ParamValue.LUGGAGE_HERO);
|
||||
mCategoryResIds[i] = R.string.luggage_storage;
|
||||
category.getStatisticValue());
|
||||
mCategoryResIds[i] = category.getStringId();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (mCategoryResIds[i] == 0)
|
||||
throw new IllegalStateException("Can't get string resource id for category:" + key);
|
||||
}
|
||||
}
|
||||
|
||||
String iconId = "ic_category_" + key;
|
||||
|
@ -112,10 +113,12 @@ class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolde
|
|||
return mCategoryResIds.length;
|
||||
}
|
||||
|
||||
private String getSuggestionFromCategory(int resId)
|
||||
@NonNull
|
||||
private String getSuggestionFromCategory(@StringRes int resId)
|
||||
{
|
||||
if (resId == R.string.luggage_storage)
|
||||
return LUGGAGE_CATEGORY + ' ';
|
||||
PromoCategory promoCategory = PromoCategory.findByStringId(resId);
|
||||
if (promoCategory != null)
|
||||
return promoCategory.getKey();
|
||||
return mResources.getString(resId) + ' ';
|
||||
}
|
||||
|
||||
|
|
91
android/src/com/mapswithme/maps/search/PromoCategory.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
package com.mapswithme.maps.search;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public enum PromoCategory
|
||||
{
|
||||
LUGGAGE_HERO
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
String getKey()
|
||||
{
|
||||
return "luggagehero";
|
||||
}
|
||||
|
||||
@Override
|
||||
int getStringId()
|
||||
{
|
||||
return R.string.luggage_storage;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
String getStatisticValue()
|
||||
{
|
||||
return Statistics.ParamValue.LUGGAGE_HERO;
|
||||
}
|
||||
},
|
||||
FIFA
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
String getKey()
|
||||
{
|
||||
return "fc2018";
|
||||
}
|
||||
|
||||
@Override
|
||||
int getStringId()
|
||||
{
|
||||
return R.string.football_world_cup;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
String getStatisticValue()
|
||||
{
|
||||
return Statistics.ParamValue.FIFA;
|
||||
}
|
||||
};
|
||||
|
||||
@NonNull
|
||||
abstract String getKey();
|
||||
|
||||
@StringRes
|
||||
abstract int getStringId();
|
||||
|
||||
@NonNull
|
||||
abstract String getStatisticValue();
|
||||
|
||||
@Nullable
|
||||
static PromoCategory findByStringId(@StringRes int nameId)
|
||||
{
|
||||
for (PromoCategory category : values())
|
||||
{
|
||||
if (category.getStringId() == nameId)
|
||||
return category;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PromoCategory findByKey(@Nullable String key)
|
||||
{
|
||||
if (TextUtils.isEmpty(key))
|
||||
return null;
|
||||
|
||||
for (PromoCategory cat : values())
|
||||
{
|
||||
if (cat.getKey().equals(key))
|
||||
return cat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -124,7 +124,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
return;
|
||||
}
|
||||
|
||||
if (mLuggageCategorySelected)
|
||||
if (mPromoCategorySelected)
|
||||
return;
|
||||
|
||||
if (mAdsLoader != null && !isTabletSearch() && query.length() >= MIN_QUERY_LENGTH_FOR_AD)
|
||||
|
@ -207,7 +207,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
|
||||
private final LastPosition mLastPosition = new LastPosition();
|
||||
private boolean mSearchRunning;
|
||||
private boolean mLuggageCategorySelected;
|
||||
private boolean mPromoCategorySelected;
|
||||
private String mInitialQuery;
|
||||
@Nullable
|
||||
private String mInitialLocale;
|
||||
|
@ -690,19 +690,19 @@ public class SearchFragment extends BaseMwmFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCategorySelected(String category)
|
||||
public void onCategorySelected(@Nullable String category)
|
||||
{
|
||||
if (!TextUtils.isEmpty(category) &&
|
||||
category.equals(CategoriesAdapter.LUGGAGE_CATEGORY + ' '))
|
||||
PromoCategory promoCategory = PromoCategory.findByKey(category);
|
||||
if (promoCategory != null)
|
||||
{
|
||||
mLuggageCategorySelected = true;
|
||||
mToolbarController.setQuery(category);
|
||||
mPromoCategorySelected = true;
|
||||
mToolbarController.setQuery(category + " ");
|
||||
|
||||
Statistics.INSTANCE.trackSponsoredEventForCustomProvider(
|
||||
Statistics.EventName.SEARCH_SPONSOR_CATEGORY_SELECTED,
|
||||
Statistics.ParamValue.LUGGAGE_HERO);
|
||||
promoCategory.getStatisticValue());
|
||||
showAllResultsOnMap();
|
||||
mLuggageCategorySelected = false;
|
||||
mPromoCategorySelected = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -391,6 +391,7 @@ public enum Statistics
|
|||
static final String PLACEPAGE = "placepage";
|
||||
public static final String FACEBOOK = "facebook";
|
||||
public static final String LUGGAGE_HERO = "LuggageHero";
|
||||
public static final String FIFA = "FIFA2018";
|
||||
public static final String CHECKIN = "check_in";
|
||||
public static final String CHECKOUT = "check_out";
|
||||
public static final String ANY = "any";
|
||||
|
|