blob: 0334ba64e35c9d6fcb612e15189cdae13cdf7e22 (
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
|
package it.niedermann.owncloud.notes.android.activity;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentContributingTab;
import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentCreditsTab;
import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentLicenseTab;
import it.niedermann.owncloud.notes.databinding.ActivityAboutBinding;
public class AboutActivity extends LockedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityAboutBinding binding = ActivityAboutBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
binding.pager.setAdapter(new TabsPagerAdapter(getSupportFragmentManager()));
binding.tabs.setupWithViewPager(binding.pager);
}
private class TabsPagerAdapter extends FragmentPagerAdapter {
TabsPagerAdapter(FragmentManager fragmentManager) {
super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@Override
public int getCount() {
return 3;
}
/**
* return the right fragment for the given position
*/
@NonNull
@Override
public Fragment getItem(int position) {
switch (position) {
case 1:
return new AboutFragmentContributingTab();
case 2:
return new AboutFragmentLicenseTab();
default:
return new AboutFragmentCreditsTab();
}
}
/**
* generate title based on given position
*/
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return getString(R.string.about_credits_tab_title);
case 1:
return getString(R.string.about_contribution_tab_title);
case 2:
return getString(R.string.about_license_tab_title);
default:
return null;
}
}
}
@Override
public boolean onSupportNavigateUp() {
finish(); // close this activity as oppose to navigating up
return true;
}
}
|