blob: 5167669a8cc961db0f46cf8ae07b5b6ab67759bb (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package com.mapswithme.maps.base;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v4.app.DialogFragment;
import android.view.View;
import com.mapswithme.maps.R;
import com.mapswithme.util.ThemeUtils;
public class BaseMwmDialogFragment extends DialogFragment
{
@StyleRes
protected final int getFullscreenTheme()
{
return ThemeUtils.isNightTheme() ? getFullscreenDarkTheme() : getFullscreenLightTheme();
}
protected int getStyle()
{
return STYLE_NORMAL;
}
protected @StyleRes int getCustomTheme()
{
return 0;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
int style = getStyle();
int theme = getCustomTheme();
if (style != STYLE_NORMAL || theme != 0)
//noinspection WrongConstant
setStyle(style, theme);
}
@Override
public void onResume()
{
super.onResume();
org.alohalytics.Statistics.logEvent("$onResume", getClass().getSimpleName()
+ ":" + com.mapswithme.util.UiUtils.deviceOrientationAsString(getActivity()));
}
@Override
public void onPause()
{
super.onPause();
org.alohalytics.Statistics.logEvent("$onPause", getClass().getSimpleName());
}
@StyleRes
protected int getFullscreenLightTheme()
{
return R.style.MwmTheme_DialogFragment_Fullscreen;
}
@StyleRes
protected int getFullscreenDarkTheme()
{
return R.style.MwmTheme_DialogFragment_Fullscreen_Night;
}
@NonNull
protected Application getAppContextOrThrow()
{
Context context = getContext();
if (context == null)
throw new IllegalStateException("Before call this method make sure that the context exists");
return (Application) context.getApplicationContext();
}
@NonNull
protected View getViewOrThrow()
{
View view = getView();
if (view == null)
throw new IllegalStateException("Before call this method make sure that the view exists");
return view;
}
@NonNull
protected Bundle getArgumentsOrThrow()
{
Bundle args = getArguments();
if (args == null)
throw new AssertionError("Arguments must be non-null!");
return args;
}
}
|