use of org.ethack.orwall.adapter.TabsPagerAdapter in project orWall by EthACKdotOrg.
the class TabbedMain method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabbed_main);
// Import old settings to SQLite, and remove them from SharedPreferences
NatRules natRules = new NatRules(this);
Set oldRules = getSharedPreferences(Preferences.PREFERENCES, MODE_PRIVATE).getStringSet("nat_rules", null);
if (natRules.getRuleCount() == 0 && oldRules != null) {
natRules.importFromSharedPrefs(oldRules);
getSharedPreferences(Preferences.PREFERENCES, MODE_PRIVATE).edit().remove("nat_rules").apply();
}
// Is it the first application run?
if (Preferences.isFirstRun(this)) {
// Initialize orWall iptables rules - #72 should be better after that
Iptables iptables = new Iptables(this);
iptables.boot();
// Start Wizard
Intent wizard = new Intent(this, WizardActivity.class);
startActivity(wizard);
}
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// create the tab header
for (String tab : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab).setTabListener(this));
}
// changer in order to take care of tab switching
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}