blob: 04ee232e37d88dc1bda215ddd75cdc30354595bb (
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
|
package it.niedermann.nextcloud.deck.ui;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import it.niedermann.nextcloud.deck.Application;
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.ActivityAboutBinding;
import it.niedermann.nextcloud.deck.ui.about.AboutFragmentContributingTab;
import it.niedermann.nextcloud.deck.ui.about.AboutFragmentCreditsTab;
import it.niedermann.nextcloud.deck.ui.about.AboutFragmentLicenseTab;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme);
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
ActivityAboutBinding binding = ActivityAboutBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
binding.viewPager.setAdapter(new TabsPagerAdapter(getSupportFragmentManager()));
binding.tabLayout.setupWithViewPager(binding.viewPager);
}
private class TabsPagerAdapter extends FragmentPagerAdapter {
@SuppressWarnings("WeakerAccess")
public 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 0:
return new AboutFragmentCreditsTab();
case 1:
return new AboutFragmentContributingTab();
case 2:
return new AboutFragmentLicenseTab();
default:
throw new IllegalArgumentException("position must be between 0 and 2");
}
}
/**
* 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:
throw new IllegalArgumentException("position must be between 0 and 2");
}
}
}
@Override
public boolean onSupportNavigateUp() {
finish(); // close this activity as oppose to navigating up
return true;
}
}
|