Search in sources :

Example 31 with ColorPreferences

use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.

the class SubredditView method doSubSidebarNoLoad.

public void doSubSidebarNoLoad(final String subOverride) {
    findViewById(R.id.loader).setVisibility(View.GONE);
    invalidateOptionsMenu();
    if (!subOverride.equalsIgnoreCase("all") && !subOverride.equalsIgnoreCase("frontpage") && !subOverride.equalsIgnoreCase("friends") && !subOverride.equalsIgnoreCase("mod") && !subOverride.contains("+") && !subOverride.contains(".") && !subOverride.contains("/m/")) {
        if (drawerLayout != null) {
            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END);
        }
        findViewById(R.id.sidebar_text).setVisibility(View.GONE);
        findViewById(R.id.sub_title).setVisibility(View.GONE);
        findViewById(R.id.subscribers).setVisibility(View.GONE);
        findViewById(R.id.active_users).setVisibility(View.GONE);
        findViewById(R.id.header_sub).setBackgroundColor(Palette.getColor(subOverride));
        ((TextView) findViewById(R.id.sub_infotitle)).setText(subOverride);
        // Sidebar buttons should use subOverride's accent color
        int subColor = new ColorPreferences(this).getColor(subOverride);
        ((TextView) findViewById(R.id.theme_text)).setTextColor(subColor);
        ((TextView) findViewById(R.id.wiki_text)).setTextColor(subColor);
        ((TextView) findViewById(R.id.post_text)).setTextColor(subColor);
        ((TextView) findViewById(R.id.mods_text)).setTextColor(subColor);
        ((TextView) findViewById(R.id.flair_text)).setTextColor(subColor);
        ((TextView) findViewById(R.id.sorting).findViewById(R.id.sort)).setTextColor(subColor);
        ((TextView) findViewById(R.id.sync)).setTextColor(subColor);
    } else {
        if (drawerLayout != null) {
            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);
        }
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) TextView(android.widget.TextView)

Example 32 with ColorPreferences

use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.

the class Tumblr method onCreate.

public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), true);
    setContentView(R.layout.album);
    // Keep the screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    final ViewPager pager = (ViewPager) findViewById(R.id.images);
    album = new OverviewPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(album);
    pager.setCurrentItem(1);
    if (getIntent().hasExtra(SUBREDDIT)) {
        subreddit = getIntent().getStringExtra(SUBREDDIT);
    }
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == 0 && positionOffsetPixels == 0) {
                finish();
            }
            if (position == 0 && ((OverviewPagerAdapter) pager.getAdapter()).blankPage != null) {
                if (((OverviewPagerAdapter) pager.getAdapter()).blankPage != null) {
                    ((OverviewPagerAdapter) pager.getAdapter()).blankPage.doOffset(positionOffset);
                }
                ((OverviewPagerAdapter) pager.getAdapter()).blankPage.realBack.setBackgroundColor(adjustAlpha(positionOffset * 0.7f));
            }
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager)

Example 33 with ColorPreferences

use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.

the class TumblrPager method onCreate.

public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), true);
    setContentView(R.layout.album_pager);
    // Keep the screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle(R.string.type_album);
    ToolbarColorizeHelper.colorizeToolbar(mToolbar, Color.WHITE, this);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (getIntent().hasExtra(SUBREDDIT)) {
        this.subreddit = getIntent().getStringExtra(SUBREDDIT);
    }
    mToolbar.setPopupTheme(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE));
    adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1);
    String url = getIntent().getExtras().getString("url", "");
    setShareUrl(url);
    new LoadIntoPager(url, this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) Intent(android.content.Intent)

Example 34 with ColorPreferences

use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.

the class Tutorial method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
    getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
    getTheme().applyStyle(new ColorPreferences(this).getFontStyle().getBaseId(), true);
    setContentView(R.layout.activity_tutorial);
    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.vp);
    /*
      The pager adapter, which provides the pages to the view pager widget.
     */
    PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    if (getIntent().hasExtra("page")) {
        mPager.setCurrentItem(1);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Palette.getDarkerColor(Color.parseColor("#FF5252")));
    }
}
Also used : FontPreferences(me.ccrama.redditslide.Visuals.FontPreferences) Window(android.view.Window) ColorPreferences(me.ccrama.redditslide.ColorPreferences) PagerAdapter(android.support.v4.view.PagerAdapter) FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter)

Example 35 with ColorPreferences

use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.

the class MultiredditOverview method setDataSet.

private void setDataSet(List<MultiReddit> data) {
    try {
        usedArray = data;
        if (usedArray.isEmpty()) {
            buildDialog();
        } else {
            if (adapter == null) {
                adapter = new OverviewPagerAdapter(getSupportFragmentManager());
            } else {
                adapter.notifyDataSetChanged();
            }
            pager.setAdapter(adapter);
            pager.setOffscreenPageLimit(1);
            tabs.setupWithViewPager(pager);
            tabs.setSelectedTabIndicatorColor(new ColorPreferences(MultiredditOverview.this).getColor(usedArray.get(0).getDisplayName()));
            doDrawerSubs(0);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Window window = this.getWindow();
                window.setStatusBarColor(Palette.getDarkerColor(usedArray.get(0).getDisplayName()));
            }
            final View header = findViewById(R.id.header);
            tabs.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {

                @Override
                public void onTabReselected(TabLayout.Tab tab) {
                    super.onTabReselected(tab);
                    int[] firstVisibleItems;
                    int pastVisiblesItems = 0;
                    firstVisibleItems = ((CatchStaggeredGridLayoutManager) (((MultiredditView) adapter.getCurrentFragment()).rv.getLayoutManager())).findFirstVisibleItemPositions(null);
                    if (firstVisibleItems != null && firstVisibleItems.length > 0) {
                        for (int firstVisibleItem : firstVisibleItems) {
                            pastVisiblesItems = firstVisibleItem;
                        }
                    }
                    if (pastVisiblesItems > 8) {
                        ((MultiredditView) adapter.getCurrentFragment()).rv.scrollToPosition(0);
                        if (header != null) {
                            header.animate().translationY(header.getHeight()).setInterpolator(new LinearInterpolator()).setDuration(0);
                        }
                    } else {
                        ((MultiredditView) adapter.getCurrentFragment()).rv.smoothScrollToPosition(0);
                    }
                }
            });
            findViewById(R.id.header).setBackgroundColor(Palette.getColor(usedArray.get(0).getDisplayName()));
        }
    } catch (NullPointerException e) {
        buildDialog(true);
        Log.e(LogUtil.getTag(), "Cannot load multis:\n" + e);
    }
}
Also used : Window(android.view.Window) CatchStaggeredGridLayoutManager(me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager) ColorPreferences(me.ccrama.redditslide.ColorPreferences) LinearInterpolator(android.view.animation.LinearInterpolator) TabLayout(android.support.design.widget.TabLayout) MultiredditView(me.ccrama.redditslide.Fragments.MultiredditView) View(android.view.View) TextView(android.widget.TextView) MultiredditView(me.ccrama.redditslide.Fragments.MultiredditView)

Aggregations

ColorPreferences (me.ccrama.redditslide.ColorPreferences)50 View (android.view.View)23 TextView (android.widget.TextView)22 Intent (android.content.Intent)16 DialogInterface (android.content.DialogInterface)14 AlertDialogWrapper (com.afollestad.materialdialogs.AlertDialogWrapper)14 ArrayList (java.util.ArrayList)14 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)13 LayoutInflater (android.view.LayoutInflater)12 RecyclerView (android.support.v7.widget.RecyclerView)10 ImageView (android.widget.ImageView)10 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)10 Context (android.content.Context)9 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)9 HorizontalScrollView (android.widget.HorizontalScrollView)9 Snackbar (android.support.design.widget.Snackbar)8 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)8 CaseInsensitiveArrayList (me.ccrama.redditslide.CaseInsensitiveArrayList)8 LinearInterpolator (android.view.animation.LinearInterpolator)7 Dialog (android.app.Dialog)6