use of com.mareksebera.simpledilbert.preferences.DilbertPreferences in project Simple-Dilbert by smarek.
the class DilbertFavoritedActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstance) {
DilbertPreferences preferences = new DilbertPreferences(this);
if (preferences.isForceLandscape())
setRequestedOrientation(preferences.getLandscapeOrientation());
setTheme(preferences.isDarkLayoutEnabled() ? R.style.AppThemeDark : R.style.AppThemeLight);
super.onCreate(savedInstance);
setContentView(R.layout.activity_dilbert_fragments);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
boolean isOfflineMode = getIntent().getBooleanExtra(INTENT_OFFLINE, false);
viewPager = findViewById(R.id.view_pager);
adapter = new DilbertFavoritedFragmentAdapter(getSupportFragmentManager(), isOfflineMode ? preferences.getCachedDates() : preferences.getFavoritedItems());
if (adapter.getCount() == 0) {
Toast.makeText(this, R.string.toast_no_favorites, Toast.LENGTH_LONG).show();
finish();
}
viewPager.addOnPageChangeListener(pageChangedListener);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(adapter.getCount());
if (preferences.isToolbarsHidden())
ActionBarUtility.toggleActionBar(this, viewPager);
}
Aggregations