Search in sources :

Example 6 with DilbertPreferences

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);
}
Also used : DilbertPreferences(com.mareksebera.simpledilbert.preferences.DilbertPreferences)

Aggregations

DilbertPreferences (com.mareksebera.simpledilbert.preferences.DilbertPreferences)6 LocalDate (org.joda.time.LocalDate)2 TargetApi (android.annotation.TargetApi)1 DownloadManager (android.app.DownloadManager)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 RemoteViews (android.widget.RemoteViews)1 DataSource (com.bumptech.glide.load.DataSource)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 RequestListener (com.bumptech.glide.request.RequestListener)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 AppWidgetTarget (com.bumptech.glide.request.target.AppWidgetTarget)1 Target (com.bumptech.glide.request.target.Target)1 GetStripUrl (com.mareksebera.simpledilbert.utilities.GetStripUrl)1 GetStripUrlInterface (com.mareksebera.simpledilbert.utilities.GetStripUrlInterface)1 File (java.io.File)1