[android] Added checking promo category support in search

This commit is contained in:
Александр Зацепин 2018-10-18 13:32:19 +03:00 committed by Roman Kuznetsov
parent 33ada5561e
commit 52d94a68d2
3 changed files with 29 additions and 3 deletions

View file

@ -19,6 +19,7 @@ import com.mapswithme.util.statistics.Statistics;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolder>
{
@ -81,8 +82,8 @@ class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolde
private static String[] getAllCategories()
{
String[] searchCategories = DisplayedCategories.getKeys();
PromoCategory[] promos = PromoCategory.values();
int amountSize = searchCategories.length + promos.length;
List<PromoCategory> promos = PromoCategory.supportedValues();
int amountSize = searchCategories.length + promos.size();
String[] allCategories = new String[amountSize];
for (PromoCategory promo : promos)
{

View file

@ -5,8 +5,12 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import java.util.ArrayList;
import java.util.List;
public enum PromoCategory
{
RUTAXI
@ -43,6 +47,12 @@ public enum PromoCategory
{
return new RutaxiPromoProcessor(context);
}
@Override
boolean isSupported()
{
return Framework.nativeHasRuTaxiCategoryBanner();
}
};
@NonNull
@ -56,6 +66,8 @@ public enum PromoCategory
abstract int getPosition();
abstract boolean isSupported();
@NonNull
abstract PromoCategoryProcessor createProcessor(@NonNull Context context);
@ -69,4 +81,17 @@ public enum PromoCategory
}
return null;
}
@NonNull
static List<PromoCategory> supportedValues()
{
List<PromoCategory> result = new ArrayList<>();
for (PromoCategory category : values())
{
if (category.isSupported())
result.add(category);
}
return result;
}
}

View file

@ -18,7 +18,7 @@ public class RutaxiPromoProcessor implements PromoCategoryProcessor
@Override
public void process()
{
// TODO: added app launch when product desicion is ready.
// TODO: add app launch when product decision about input params for vezet app is ready.
Utils.openUrl(mContext, "https://go.onelink.me/757212956/a81b5d7c");
}
}