use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class SubredditListView method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(where));
View v = ((LayoutInflater) contextThemeWrapper.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_verticalcontent, container, false);
rv = ((RecyclerView) v.findViewById(R.id.vertical_content));
final RecyclerView.LayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity());
rv.setLayoutManager(mLayoutManager);
rv.setItemAnimator(new SlideUpAlphaAnimator());
mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("no sub", getContext()));
// If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
// So, we estimate the height of the header in dp
mSwipeRefreshLayout.setProgressViewOffset(false, Constants.TAB_HEADER_VIEW_OFFSET - Constants.PTR_OFFSET_TOP, Constants.TAB_HEADER_VIEW_OFFSET + Constants.PTR_OFFSET_BOTTOM);
v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
doAdapter();
return v;
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class Inbox method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();
if (Authentication.reddit == null || !Authentication.reddit.isAuthenticated() || Authentication.me == null) {
LogUtil.v("Reauthenticating");
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
if (Authentication.reddit == null) {
new Authentication(getApplicationContext());
}
try {
Authentication.me = Authentication.reddit.me();
Authentication.mod = Authentication.me.isMod();
Authentication.authentication.edit().putBoolean(Reddit.SHARED_PREF_IS_MOD, Authentication.mod).apply();
if (Reddit.notificationTime != -1) {
Reddit.notifications = new NotificationJobScheduler(Inbox.this);
Reddit.notifications.start(getApplicationContext());
}
if (Reddit.cachedData.contains("toCache")) {
Reddit.autoCache = new AutoCacheScheduler(Inbox.this);
Reddit.autoCache.start(getApplicationContext());
}
final String name = Authentication.me.getFullName();
Authentication.name = name;
LogUtil.v("AUTHENTICATED");
UserSubscriptions.doCachedModSubs();
if (Authentication.reddit.isAuthenticated()) {
final Set<String> accounts = Authentication.authentication.getStringSet("accounts", new HashSet<String>());
if (accounts.contains(name)) {
// convert to new system
accounts.remove(name);
accounts.add(name + ":" + Authentication.refresh);
Authentication.authentication.edit().putStringSet("accounts", accounts).apply();
}
Authentication.isLoggedIn = true;
Reddit.notFirst = true;
}
} catch (Exception ignored) {
}
return null;
}
}.execute();
}
super.onCreate(savedInstance);
last = SettingValues.prefs.getLong("lastInbox", System.currentTimeMillis() - (60 * 1000 * 60));
SettingValues.prefs.edit().putLong("lastInbox", System.currentTimeMillis()).apply();
applyColorTheme("");
setContentView(R.layout.activity_inbox);
setupAppBar(R.id.toolbar, R.string.title_inbox, true, true);
mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
tabs = (TabLayout) findViewById(R.id.sliding_tabs);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
tabs.setSelectedTabIndicatorColor(new ColorPreferences(Inbox.this).getColor("no sub"));
pager = (ViewPager) findViewById(R.id.content_view);
findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
adapter = new OverviewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
if (getIntent() != null && getIntent().hasExtra(EXTRA_UNREAD)) {
pager.setCurrentItem(1);
}
tabs.setupWithViewPager(pager);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
findViewById(R.id.header).animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
if (position == 3 && findViewById(R.id.read) != null) {
findViewById(R.id.read).setVisibility(View.GONE);
} else if (findViewById(R.id.read) != null) {
findViewById(R.id.read).setVisibility(View.VISIBLE);
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class BaseActivity method applyColorTheme.
/**
* Applies the activity's base color theme. Should be called before inflating any layouts.
*/
protected void applyColorTheme() {
getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
getTheme().applyStyle(new ColorPreferences(this).getFontStyle().getBaseId(), true);
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class Discover method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstance);
applyColorTheme("");
setContentView(R.layout.activity_multireddits);
((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
setupAppBar(R.id.toolbar, R.string.discover_title, true, false);
mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
tabs.setTabMode(TabLayout.MODE_FIXED);
tabs.setSelectedTabIndicatorColor(new ColorPreferences(Discover.this).getColor("no sub"));
ViewPager pager = (ViewPager) findViewById(R.id.content_view);
pager.setAdapter(new OverviewPagerAdapter(getSupportFragmentManager()));
tabs.setupWithViewPager(pager);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
findViewById(R.id.header).animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
use of me.ccrama.redditslide.ColorPreferences in project Slide by ccrama.
the class Announcement method setViews.
private void setViews(String rawHTML, String subredditName, SpoilerRobotoTextView firstTextView, CommentOverflow commentOverflow) {
if (rawHTML.isEmpty()) {
return;
}
List<String> blocks = SubmissionParser.getBlocks(rawHTML);
int startIndex = 0;
// the <div class="md"> case is when the body contains a table or code block first
if (!blocks.get(0).equals("<div class=\"md\">")) {
firstTextView.setVisibility(View.VISIBLE);
firstTextView.setTextHtml(blocks.get(0), subredditName);
firstTextView.setLinkTextColor(new ColorPreferences(this).getColor(subredditName));
startIndex = 1;
} else {
firstTextView.setText("");
firstTextView.setVisibility(View.GONE);
}
if (blocks.size() > 1) {
if (startIndex == 0) {
commentOverflow.setViews(blocks, subredditName);
} else {
commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subredditName);
}
SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout);
for (int i = 0; i < commentOverflow.getChildCount(); i++) {
View maybeScrollable = commentOverflow.getChildAt(i);
if (maybeScrollable instanceof HorizontalScrollView) {
sidebar.addScrollable(maybeScrollable);
}
}
} else {
commentOverflow.removeAllViews();
}
}
Aggregations