blob: 064c7f18ac2321a5f2ffe10be5bdaf184349d607 (
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
|
package com.mapswithme.maps.base;
import android.os.Bundle;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
import androidx.appcompat.widget.Toolbar;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
public abstract class BaseToolbarActivity extends BaseMwmFragmentActivity
{
@CallSuper
@Override
protected void onSafeCreate(@Nullable Bundle savedInstanceState)
{
super.onSafeCreate(savedInstanceState);
Toolbar toolbar = getToolbar();
if (toolbar != null)
{
UiUtils.extendViewWithStatusBar(toolbar);
int title = getToolbarTitle();
if (title == 0)
toolbar.setTitle(getTitle());
else
toolbar.setTitle(title);
setupHomeButton(toolbar);
displayToolbarAsActionBar();
}
}
protected void setupHomeButton(@NonNull Toolbar toolbar)
{
UiUtils.showHomeUpButton(toolbar);
}
@StringRes
protected int getToolbarTitle()
{
return 0;
}
@Override
protected Class<? extends Fragment> getFragmentClass()
{
throw new RuntimeException("Must be implemented in child classes!");
}
@Override
protected int getContentLayoutResId()
{
return R.layout.activity_fragment_and_toolbar;
}
@Override
protected int getFragmentContentResId()
{
return R.id.fragment_container;
}
}
|