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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
package com.mapswithme.maps.news;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmDialogFragment;
import com.mapswithme.util.statistics.Statistics;
public class IntroductionDialogFragment extends BaseMwmDialogFragment
{
private static final String ARG_DEEPLINK = "arg_deeplink";
private static final String ARG_INTRODUCTION_FACTORY = "arg_introduction_factory";
public static void show(@NonNull FragmentManager fm, @NonNull String deepLink,
@NonNull IntroductionScreenFactory factory)
{
Bundle args = new Bundle();
args.putString(IntroductionDialogFragment.ARG_DEEPLINK, deepLink);
args.putInt(IntroductionDialogFragment.ARG_INTRODUCTION_FACTORY, factory.ordinal());
final IntroductionDialogFragment fragment = new IntroductionDialogFragment();
fragment.setArguments(args);
fragment.show(fm, IntroductionDialogFragment.class.getName());
Statistics.INSTANCE.trackEvent(Statistics.EventName.ONBOARDING_DEEPLINK_SCREEN_SHOW,
Statistics.params().add(Statistics.EventParam.TYPE,
factory.toStatisticValue()));
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
Dialog res = super.onCreateDialog(savedInstanceState);
View content = View.inflate(getActivity(), R.layout.fragment_welcome, null);
res.setContentView(content);
IntroductionScreenFactory factory = getScreenFactory();
TextView button = content.findViewById(R.id.btn__continue);
button.setText(factory.getAction());
button.setOnClickListener(v -> onAcceptClicked());
ImageView image = content.findViewById(R.id.iv__image);
image.setImageResource(factory.getImage());
TextView title = content.findViewById(R.id.tv__title);
title.setText(factory.getTitle());
TextView subtitle = content.findViewById(R.id.tv__subtitle1);
subtitle.setText(factory.getSubtitle());
return res;
}
@NonNull
private IntroductionScreenFactory getScreenFactory()
{
Bundle args = getArgumentsOrThrow();
int dataIndex = args.getInt(ARG_INTRODUCTION_FACTORY);
return IntroductionScreenFactory.values()[dataIndex];
}
private void onAcceptClicked()
{
String deepLink = getArgumentsOrThrow().getString(ARG_DEEPLINK);
if (TextUtils.isEmpty(deepLink))
throw new AssertionError("Deeplink must non-empty within introduction fragment!");
IntroductionScreenFactory factory = getScreenFactory();
factory.createButtonClickListener().onIntroductionButtonClick(requireActivity(), deepLink);
Statistics.INSTANCE.trackEvent(Statistics.EventName.ONBOARDING_DEEPLINK_SCREEN_ACCEPT,
Statistics.params().add(Statistics.EventParam.TYPE,
factory.toStatisticValue()));
dismissAllowingStateLoss();
}
@Override
public void onCancel(DialogInterface dialog)
{
super.onCancel(dialog);
Statistics.INSTANCE.trackEvent(Statistics.EventName.ONBOARDING_DEEPLINK_SCREEN_DECLINE,
Statistics.params().add(Statistics.EventParam.TYPE,
getScreenFactory().toStatisticValue()));
}
@Override
protected int getCustomTheme()
{
return getFullscreenTheme();
}
}
|