Android Open Source - Simple-Dilbert Dilbert Favorited Activity






From Project

Back to project page Simple-Dilbert.

License

The source code is released under:

Apache License

If you think the Android project Simple-Dilbert listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mareksebera.simpledilbert.favorites;
/*from   w ww  .j  a v a  2s  .  com*/
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.widget.Toast;

import com.mareksebera.simpledilbert.R;
import com.mareksebera.simpledilbert.core.DilbertFragmentInterface;
import com.mareksebera.simpledilbert.preferences.DilbertPreferences;
import com.mareksebera.simpledilbert.utilities.ActionBarUtility;

public final class DilbertFavoritedActivity extends ActionBarActivity implements DilbertFragmentInterface {

    private ViewPager viewPager;
    private DilbertFavoritedFragmentAdapter adapter;

    private final ViewPager.OnPageChangeListener pageChangedListener = new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            setTitle(adapter.getPageTitle(position));
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    };

    @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);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        viewPager = (ViewPager) findViewById(R.id.view_pager);
        adapter = new DilbertFavoritedFragmentAdapter(
                getSupportFragmentManager(), preferences.getFavoritedItems());
        if (adapter.getCount() == 0) {
            Toast.makeText(this, R.string.toast_no_favorites, Toast.LENGTH_LONG)
                    .show();
            finish();
        }
        viewPager.setOnPageChangeListener(pageChangedListener);
        viewPager.setAdapter(adapter);
        viewPager.setCurrentItem(adapter.getCount());
        if (preferences.isToolbarsHidden())
            ActionBarUtility.toggleActionBar(this, viewPager);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    // Compat helper method
    public void toggleActionBar() {
        ActionBarUtility.toggleActionBar(this, viewPager);
    }
}




Java Source Code List

com.mareksebera.simpledilbert.AppController.java
com.mareksebera.simpledilbert.core.DilbertFragmentActivity.java
com.mareksebera.simpledilbert.core.DilbertFragmentAdapter.java
com.mareksebera.simpledilbert.core.DilbertFragmentInterface.java
com.mareksebera.simpledilbert.core.DilbertFragment.java
com.mareksebera.simpledilbert.favorites.DilbertFavoritedActivity.java
com.mareksebera.simpledilbert.favorites.DilbertFavoritedFragmentAdapter.java
com.mareksebera.simpledilbert.favorites.FavoritedItem.java
com.mareksebera.simpledilbert.picker.FolderPickerActivity.java
com.mareksebera.simpledilbert.picker.FolderPickerAdapter.java
com.mareksebera.simpledilbert.picker.FolderPickerFragment.java
com.mareksebera.simpledilbert.preferences.DilbertPreferencesActivity.java
com.mareksebera.simpledilbert.preferences.DilbertPreferences.java
com.mareksebera.simpledilbert.utilities.ActionBarUtility.java
com.mareksebera.simpledilbert.utilities.DownloadManagerBroadcastReceiver.java
com.mareksebera.simpledilbert.utilities.FailSafeBitmapDisplayer.java
com.mareksebera.simpledilbert.utilities.FindUrls.java
com.mareksebera.simpledilbert.utilities.FixedViewPager.java
com.mareksebera.simpledilbert.utilities.GetStripUrlInterface.java
com.mareksebera.simpledilbert.utilities.GetStripUrl.java
com.mareksebera.simpledilbert.widget.WidgetProvider.java