use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class BaseActivity method applyColorTheme.
/**
* Applies the activity's base color theme based on the theme of a specific subreddit. Should be
* called before inflating any layouts.
*
* @param subreddit The subreddit to base the theme on
*/
protected void applyColorTheme(String subreddit) {
getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
getTheme().applyStyle(new ColorPreferences(this).getThemeSubreddit(subreddit), true);
getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class Album 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);
if (getIntent().hasExtra(SUBREDDIT)) {
this.subreddit = getIntent().getExtras().getString(SUBREDDIT);
}
final ViewPager pager = (ViewPager) findViewById(R.id.images);
album = new OverviewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(album);
pager.setCurrentItem(1);
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);
}
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class AlbumPager 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);
if (getIntent().hasExtra(SUBREDDIT)) {
this.subreddit = getIntent().getStringExtra(SUBREDDIT);
}
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle(R.string.type_album);
ToolbarColorizeHelper.colorizeToolbar(mToolbar, Color.WHITE, this);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mToolbar.setPopupTheme(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE));
adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1);
String url = getIntent().getExtras().getString("url", "");
setShareUrl(url);
pagerLoad = new LoadIntoPager(url, this);
pagerLoad.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (!Reddit.appRestart.contains("tutorialSwipe")) {
startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
}
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class ModQueue method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstance);
applyColorTheme("");
setContentView(R.layout.activity_inbox);
setupAppBar(R.id.toolbar, R.string.drawer_moderation, true, true);
TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
tabs.setSelectedTabIndicatorColor(new ColorPreferences(ModQueue.this).getColor("no sub"));
final View header = findViewById(R.id.header);
ViewPager pager = (ViewPager) findViewById(R.id.content_view);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
header.animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
pager.setAdapter(new OverviewPagerAdapter(getSupportFragmentManager()));
tabs.setupWithViewPager(pager);
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class MultiredditOverview method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstance);
applyColorTheme("");
setContentView(R.layout.activity_multireddits);
setupAppBar(R.id.toolbar, R.string.title_multireddits, true, false);
findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
tabs = (TabLayout) findViewById(R.id.sliding_tabs);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
pager = (ViewPager) findViewById(R.id.content_view);
mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
profile = "";
if (getIntent().getExtras() != null) {
profile = getIntent().getExtras().getString(EXTRA_PROFILE, "");
}
if (profile.equalsIgnoreCase(Authentication.name)) {
profile = "";
}
UserSubscriptions.MultiCallback callback = new UserSubscriptions.MultiCallback() {
@Override
public void onComplete(List<MultiReddit> multiReddits) {
if (multiReddits != null && !multiReddits.isEmpty()) {
setDataSet(multiReddits);
} else {
buildDialog();
}
}
};
if (profile.isEmpty()) {
UserSubscriptions.getMultireddits(callback);
} else {
UserSubscriptions.getPublicMultireddits(callback, profile);
}
}
Aggregations