blob: 9d563ad71bfafff0e33fd3d4cd5762e05e1991ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
package com.mapswithme.maps.search;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmRecyclerFragment;
import com.mapswithme.maps.purchase.AdsRemovalActivationCallback;
import com.mapswithme.maps.purchase.AdsRemovalPurchaseDialog;
public class SearchCategoriesFragment extends BaseMwmRecyclerFragment<CategoriesAdapter>
implements CategoriesAdapter.CategoriesUiListener, AdsRemovalActivationCallback
{
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
getAdapter().updateCategories(this);
}
@NonNull
@Override
protected CategoriesAdapter createAdapter()
{
return new CategoriesAdapter(this);
}
@Override
protected int getLayoutRes()
{
return R.layout.fragment_search_categories;
}
protected void safeOnActivityCreated(@Nullable Bundle savedInstanceState)
{
((SearchFragment) getParentFragment()).setRecyclerScrollListener(getRecyclerView());
}
@Override
public void onSearchCategorySelected(String category)
{
if (!passCategory(getParentFragment(), category))
passCategory(getActivity(), category);
}
@Override
public void onPromoCategorySelected(@NonNull PromoCategory promo)
{
PromoCategoryProcessor processor = promo.createProcessor(getActivity());
processor.process();
}
@Override
public void onAdsRemovalSelected()
{
AdsRemovalPurchaseDialog.show(this);
}
private static boolean passCategory(Object listener, String category)
{
if (!(listener instanceof CategoriesAdapter.CategoriesUiListener))
return false;
((CategoriesAdapter.CategoriesUiListener)listener).onSearchCategorySelected(category);
return true;
}
@Override
public void onAdsRemovalActivation()
{
getAdapter().updateCategories(this);
getAdapter().notifyDataSetChanged();
}
}
|