use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.
the class CommentPage method changeSubscription.
private void changeSubscription(Subreddit subreddit, boolean isChecked) {
UserSubscriptions.addSubreddit(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH), getContext());
Snackbar s = Snackbar.make(toolbar, isChecked ? getString(R.string.misc_subscribed) : getString(R.string.misc_unsubscribed), Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
}
use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.
the class CommentPage method onMenuItemClick.
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.search:
{
if (comments.comments != null && comments.submission != null) {
DataShare.sharedComments = comments.comments;
DataShare.subAuthor = comments.submission.getAuthor();
Intent i = new Intent(getActivity(), CommentSearch.class);
if (getActivity() instanceof MainActivity) {
getActivity().startActivityForResult(i, 423);
} else {
startActivityForResult(i, 423);
}
}
}
return true;
case R.id.sidebar:
doSidebarOpen();
return true;
case R.id.related:
if (adapter.submission.isSelfPost()) {
new AlertDialog.Builder(getActivity()).setTitle("Selftext posts have no related submissions").setPositiveButton(R.string.btn_ok, null).show();
} else {
Intent i = new Intent(getActivity(), Related.class);
i.putExtra(Related.EXTRA_URL, adapter.submission.getUrl());
startActivity(i);
}
return true;
case R.id.shadowbox:
if (SettingValues.isPro) {
if (comments.comments != null && comments.submission != null) {
ShadowboxComments.comments = new ArrayList<>();
for (CommentObject c : comments.comments) {
if (c instanceof CommentItem) {
if (c.comment.getComment().getDataNode().get("body_html").asText().contains("</a")) {
String body = c.comment.getComment().getDataNode().get("body_html").asText();
String url;
String[] split = body.split("<a href=\"");
if (split.length > 1) {
for (String chunk : split) {
url = chunk.substring(0, chunk.indexOf("\"", 1));
ContentType.Type t = ContentType.getContentType(url);
if (ContentType.mediaType(t)) {
ShadowboxComments.comments.add(new CommentUrlObject(c.comment, url, subreddit));
}
}
} else {
int start = body.indexOf("<a href=\"");
url = body.substring(start, body.indexOf("\"", start + 1));
ContentType.Type t = ContentType.getContentType(url);
if (ContentType.mediaType(t)) {
ShadowboxComments.comments.add(new CommentUrlObject(c.comment, url, subreddit));
}
}
}
}
}
if (!ShadowboxComments.comments.isEmpty()) {
Intent i = new Intent(getActivity(), ShadowboxComments.class);
startActivity(i);
} else {
Snackbar.make(mSwipeRefreshLayout, R.string.shadowbox_comments_nolinks, Snackbar.LENGTH_SHORT).show();
}
}
} else {
ProUtil.proUpgradeMsg(getContext(), R.string.general_shadowbox_comments_ispro).setNegativeButton(R.string.btn_no_thanks, (dialog, whichButton) -> dialog.dismiss()).show();
}
return true;
case R.id.sort:
{
openPopup(toolbar);
return true;
}
case R.id.content:
{
if (adapter != null && adapter.submission != null) {
if (!PostMatch.openExternal(adapter.submission.getUrl())) {
ContentType.Type type = ContentType.getContentType(adapter.submission);
switch(type) {
case STREAMABLE:
if (SettingValues.video) {
Intent myIntent = new Intent(getActivity(), MediaView.class);
myIntent.putExtra(MediaView.SUBREDDIT, subreddit);
myIntent.putExtra(MediaView.EXTRA_URL, adapter.submission.getUrl());
myIntent.putExtra(EXTRA_SUBMISSION_TITLE, adapter.submission.getTitle());
getActivity().startActivity(myIntent);
} else {
LinkUtil.openExternally(adapter.submission.getUrl());
}
break;
case IMGUR:
case XKCD:
Intent i2 = new Intent(getActivity(), MediaView.class);
i2.putExtra(MediaView.SUBREDDIT, subreddit);
i2.putExtra(EXTRA_SUBMISSION_TITLE, adapter.submission.getTitle());
if (adapter.submission.getDataNode().has("preview") && adapter.submission.getDataNode().get("preview").get("images").get(0).get("source").has("height") && type != ContentType.Type.XKCD) {
// Load the preview image which has probably already been cached in memory instead of the direct link
String previewUrl = adapter.submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
i2.putExtra(MediaView.EXTRA_DISPLAY_URL, previewUrl);
}
i2.putExtra(MediaView.EXTRA_URL, adapter.submission.getUrl());
getActivity().startActivity(i2);
break;
case EMBEDDED:
if (SettingValues.video) {
String data = adapter.submission.getDataNode().get("media_embed").get("content").asText();
{
Intent i = new Intent(getActivity(), FullscreenVideo.class);
i.putExtra(FullscreenVideo.EXTRA_HTML, data);
getActivity().startActivity(i);
}
} else {
LinkUtil.openExternally(adapter.submission.getUrl());
}
break;
case REDDIT:
PopulateSubmissionViewHolder.openRedditContent(adapter.submission.getUrl(), getActivity());
break;
case LINK:
LinkUtil.openUrl(adapter.submission.getUrl(), Palette.getColor(adapter.submission.getSubredditName()), getActivity());
break;
case NONE:
case SELF:
if (adapter.submission.getSelftext().isEmpty()) {
Snackbar s = Snackbar.make(rv, R.string.submission_nocontent, Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
} else {
LayoutInflater inflater = getActivity().getLayoutInflater();
final View dialoglayout = inflater.inflate(R.layout.parent_comment_dialog, null);
adapter.setViews(adapter.submission.getDataNode().get("selftext_html").asText(), adapter.submission.getSubredditName(), dialoglayout.findViewById(R.id.firstTextView), dialoglayout.findViewById(R.id.commentOverflow));
new AlertDialog.Builder(getActivity()).setView(dialoglayout).show();
}
break;
case ALBUM:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(getActivity(), AlbumPager.class);
i.putExtra(Album.EXTRA_URL, adapter.submission.getUrl());
i.putExtra(AlbumPager.SUBREDDIT, subreddit);
} else {
i = new Intent(getActivity(), Album.class);
i.putExtra(Album.EXTRA_URL, adapter.submission.getUrl());
i.putExtra(Album.SUBREDDIT, subreddit);
}
i.putExtra(EXTRA_SUBMISSION_TITLE, adapter.submission.getTitle());
getActivity().startActivity(i);
getActivity().overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(adapter.submission.getUrl());
}
break;
case TUMBLR:
if (SettingValues.image) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(getActivity(), TumblrPager.class);
i.putExtra(Album.EXTRA_URL, adapter.submission.getUrl());
i.putExtra(TumblrPager.SUBREDDIT, subreddit);
} else {
i = new Intent(getActivity(), Tumblr.class);
i.putExtra(Tumblr.SUBREDDIT, subreddit);
i.putExtra(Album.EXTRA_URL, adapter.submission.getUrl());
}
getActivity().startActivity(i);
getActivity().overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(adapter.submission.getUrl());
}
break;
case IMAGE:
PopulateSubmissionViewHolder.openImage(type, getActivity(), adapter.submission, null, -1);
break;
case VREDDIT_REDIRECT:
case VREDDIT_DIRECT:
case GIF:
PopulateSubmissionViewHolder.openGif(getActivity(), adapter.submission, -1);
break;
case VIDEO:
if (!LinkUtil.tryOpenWithVideoPlugin(adapter.submission.getUrl())) {
LinkUtil.openUrl(adapter.submission.getUrl(), Palette.getStatusBarColor(), getActivity());
}
}
} else {
LinkUtil.openExternally(adapter.submission.getUrl());
}
}
}
return true;
case R.id.reload:
if (comments != null) {
mSwipeRefreshLayout.setRefreshing(true);
comments.loadMore(adapter, subreddit);
}
return true;
case R.id.collapse:
{
if (adapter != null) {
adapter.collapseAll();
}
}
return true;
case android.R.id.home:
getActivity().onBackPressed();
return true;
}
return false;
}
use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.
the class NewsView method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id));
final View v = LayoutInflater.from(contextThemeWrapper).inflate(R.layout.fragment_verticalcontent, container, false);
if (getActivity() instanceof MainActivity) {
v.findViewById(R.id.back).setBackgroundResource(0);
}
rv = v.findViewById(R.id.vertical_content);
rv.setHasFixedSize(true);
final RecyclerView.LayoutManager mLayoutManager = createLayoutManager(LayoutUtils.getNumColumns(getResources().getConfiguration().orientation, getActivity()));
if (!(getActivity() instanceof SubredditView)) {
v.findViewById(R.id.back).setBackground(null);
}
rv.setLayoutManager(mLayoutManager);
rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator()));
rv.getLayoutManager().scrollToPosition(0);
mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getContext()));
/**
* If using List view mode, we need to remove the start margin from the SwipeRefreshLayout.
* The scrollbar style of "outsideInset" creates a 4dp padding around it. To counter this,
* change the scrollbar style to "insideOverlay" when list view is enabled.
* To recap: this removes the margins from the start/end so list view is full-width.
*/
if (SettingValues.defaultCardView == CreateCardView.CardEnum.LIST) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
MarginLayoutParamsCompat.setMarginStart(params, 0);
rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mSwipeRefreshLayout.setLayoutParams(params);
}
/**
* If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
* So, we estimate the height of the header in dp.
* If the view type is "single" (and therefore "commentPager"), we need a different offset
*/
final int HEADER_OFFSET = (SettingValues.single || getActivity() instanceof SubredditView) ? Constants.SINGLE_HEADER_VIEW_OFFSET : Constants.TAB_HEADER_VIEW_OFFSET;
mSwipeRefreshLayout.setProgressViewOffset(false, HEADER_OFFSET - Constants.PTR_OFFSET_TOP, HEADER_OFFSET + Constants.PTR_OFFSET_BOTTOM);
if (SettingValues.fab) {
fab = v.findViewById(R.id.post_floating_action_button);
if (SettingValues.fabType == Constants.FAB_POST) {
fab.setImageResource(R.drawable.ic_add);
fab.setContentDescription(getString(R.string.btn_fab_post));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent inte = new Intent(getActivity(), Submit.class);
inte.putExtra(Submit.EXTRA_SUBREDDIT, id);
getActivity().startActivity(inte);
}
});
} else {
fab.setImageResource(R.drawable.ic_visibility_off);
fab.setContentDescription(getString(R.string.btn_fab_hide));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!Reddit.fabClear) {
new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
Reddit.fabClear = true;
clearSeenPosts(false);
}).show();
} else {
clearSeenPosts(false);
}
}
});
final Handler handler = new Handler();
fab.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
detector.onTouchEvent(event);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
origY = event.getY();
handler.postDelayed(mLongPressRunnable, android.view.ViewConfiguration.getLongPressTimeout());
}
if (((event.getAction() == MotionEvent.ACTION_MOVE) && Math.abs(event.getY() - origY) > fab.getHeight() / 2.0f) || (event.getAction() == MotionEvent.ACTION_UP)) {
handler.removeCallbacks(mLongPressRunnable);
}
return false;
}
});
mLongPressRunnable = new Runnable() {
public void run() {
fab.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
if (!Reddit.fabClear) {
new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
Reddit.fabClear = true;
clearSeenPosts(true);
}).show();
} else {
clearSeenPosts(true);
}
Snackbar s = Snackbar.make(rv, getResources().getString(R.string.posts_hidden_forever), Snackbar.LENGTH_LONG);
/*Todo a way to unhide
s.setAction(R.string.btn_undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});*/
LayoutUtils.showSnackbar(s);
}
};
}
} else {
v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
}
if (fab != null)
fab.show();
header = getActivity().findViewById(R.id.header);
// TODO, have it so that if the user clicks anywhere in the rv to hide and cancel GoToSubreddit?
// final TextInputEditText GO_TO_SUB_FIELD = (TextInputEditText) getActivity().findViewById(R.id.toolbar_search);
// final Toolbar TOOLBAR = ((Toolbar) getActivity().findViewById(R.id.toolbar));
// final String PREV_TITLE = TOOLBAR.getTitle().toString();
// final ImageView CLOSE_BUTTON = (ImageView) getActivity().findViewById(R.id.close);
//
// rv.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// System.out.println("touched");
// KeyboardUtil.hideKeyboard(getActivity(), v.getWindowToken(), 0);
//
// GO_TO_SUB_FIELD.setText("");
// GO_TO_SUB_FIELD.setVisibility(View.GONE);
// CLOSE_BUTTON.setVisibility(View.GONE);
// TOOLBAR.setTitle(PREV_TITLE);
//
// return false;
// }
// });
resetScroll();
Reddit.isLoading = false;
if (MainActivity.shouldLoad == null || id == null || (MainActivity.shouldLoad != null && MainActivity.shouldLoad.equals(id)) || !(getActivity() instanceof MainActivity)) {
doAdapter();
}
return v;
}
use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.
the class SubmissionsView method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id));
final View v = LayoutInflater.from(contextThemeWrapper).inflate(R.layout.fragment_verticalcontent, container, false);
if (getActivity() instanceof MainActivity) {
v.findViewById(R.id.back).setBackgroundResource(0);
}
rv = v.findViewById(R.id.vertical_content);
rv.setHasFixedSize(true);
final RecyclerView.LayoutManager mLayoutManager = createLayoutManager(LayoutUtils.getNumColumns(getResources().getConfiguration().orientation, getActivity()));
if (!(getActivity() instanceof SubredditView)) {
v.findViewById(R.id.back).setBackground(null);
}
rv.setLayoutManager(mLayoutManager);
rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator()));
rv.getLayoutManager().scrollToPosition(0);
mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getContext()));
/**
* If using List view mode, we need to remove the start margin from the SwipeRefreshLayout.
* The scrollbar style of "outsideInset" creates a 4dp padding around it. To counter this,
* change the scrollbar style to "insideOverlay" when list view is enabled.
* To recap: this removes the margins from the start/end so list view is full-width.
*/
if (SettingValues.defaultCardView == CreateCardView.CardEnum.LIST) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
MarginLayoutParamsCompat.setMarginStart(params, 0);
rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mSwipeRefreshLayout.setLayoutParams(params);
}
/**
* If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
* So, we estimate the height of the header in dp.
* If the view type is "single" (and therefore "commentPager"), we need a different offset
*/
final int HEADER_OFFSET = (SettingValues.single || getActivity() instanceof SubredditView) ? Constants.SINGLE_HEADER_VIEW_OFFSET : Constants.TAB_HEADER_VIEW_OFFSET;
mSwipeRefreshLayout.setProgressViewOffset(false, HEADER_OFFSET - Constants.PTR_OFFSET_TOP, HEADER_OFFSET + Constants.PTR_OFFSET_BOTTOM);
if (SettingValues.fab) {
fab = v.findViewById(R.id.post_floating_action_button);
if (SettingValues.fabType == Constants.FAB_POST) {
fab.setImageResource(R.drawable.ic_add);
fab.setContentDescription(getString(R.string.btn_fab_post));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent inte = new Intent(getActivity(), Submit.class);
inte.putExtra(Submit.EXTRA_SUBREDDIT, id);
getActivity().startActivity(inte);
}
});
} else if (SettingValues.fabType == Constants.FAB_SEARCH) {
fab.setImageResource(R.drawable.ic_search);
fab.setContentDescription(getString(R.string.btn_fab_search));
fab.setOnClickListener(new View.OnClickListener() {
String term;
@Override
public void onClick(View v) {
MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(R.string.search_title).alwaysCallInputCallback().input(getString(R.string.search_msg), "", new MaterialDialog.InputCallback() {
@Override
public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
term = charSequence.toString();
}
});
// Add "search current sub" if it is not frontpage/all/random
if (!id.equalsIgnoreCase("frontpage") && !id.equalsIgnoreCase("all") && !id.contains(".") && !id.contains("/m/") && !id.equalsIgnoreCase("friends") && !id.equalsIgnoreCase("random") && !id.equalsIgnoreCase("popular") && !id.equalsIgnoreCase("myrandom") && !id.equalsIgnoreCase("randnsfw")) {
builder.positiveText(getString(R.string.search_subreddit, id)).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
Intent i = new Intent(getActivity(), Search.class);
i.putExtra(Search.EXTRA_TERM, term);
i.putExtra(Search.EXTRA_SUBREDDIT, id);
startActivity(i);
}
});
builder.neutralText(R.string.search_all).onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
Intent i = new Intent(getActivity(), Search.class);
i.putExtra(Search.EXTRA_TERM, term);
startActivity(i);
}
});
} else {
builder.positiveText(R.string.search_all).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
Intent i = new Intent(getActivity(), Search.class);
i.putExtra(Search.EXTRA_TERM, term);
startActivity(i);
}
});
}
builder.show();
}
});
} else {
fab.setImageResource(R.drawable.ic_visibility_off);
fab.setContentDescription(getString(R.string.btn_fab_hide));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!Reddit.fabClear) {
new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
Reddit.fabClear = true;
clearSeenPosts(false);
}).show();
} else {
clearSeenPosts(false);
}
}
});
final Handler handler = new Handler();
fab.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
detector.onTouchEvent(event);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
origY = event.getY();
handler.postDelayed(mLongPressRunnable, android.view.ViewConfiguration.getLongPressTimeout());
}
if (((event.getAction() == MotionEvent.ACTION_MOVE) && Math.abs(event.getY() - origY) > fab.getHeight() / 2.0f) || (event.getAction() == MotionEvent.ACTION_UP)) {
handler.removeCallbacks(mLongPressRunnable);
}
return false;
}
});
mLongPressRunnable = new Runnable() {
public void run() {
fab.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
if (!Reddit.fabClear) {
new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
Reddit.fabClear = true;
clearSeenPosts(true);
}).show();
} else {
clearSeenPosts(true);
}
Snackbar s = Snackbar.make(rv, getResources().getString(R.string.posts_hidden_forever), Snackbar.LENGTH_LONG);
/*Todo a way to unhide
s.setAction(R.string.btn_undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});*/
LayoutUtils.showSnackbar(s);
}
};
}
} else {
v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
}
if (fab != null)
fab.show();
header = getActivity().findViewById(R.id.header);
// TODO, have it so that if the user clicks anywhere in the rv to hide and cancel GoToSubreddit?
// final TextInputEditText GO_TO_SUB_FIELD = (TextInputEditText) getActivity().findViewById(R.id.toolbar_search);
// final Toolbar TOOLBAR = ((Toolbar) getActivity().findViewById(R.id.toolbar));
// final String PREV_TITLE = TOOLBAR.getTitle().toString();
// final ImageView CLOSE_BUTTON = (ImageView) getActivity().findViewById(R.id.close);
//
// rv.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// System.out.println("touched");
// KeyboardUtil.hideKeyboard(getActivity(), v.getWindowToken(), 0);
//
// GO_TO_SUB_FIELD.setText("");
// GO_TO_SUB_FIELD.setVisibility(View.GONE);
// CLOSE_BUTTON.setVisibility(View.GONE);
// TOOLBAR.setTitle(PREV_TITLE);
//
// return false;
// }
// });
resetScroll();
Reddit.isLoading = false;
if (MainActivity.shouldLoad == null || id == null || (MainActivity.shouldLoad != null && MainActivity.shouldLoad.equals(id)) || !(getActivity() instanceof MainActivity)) {
doAdapter();
}
return v;
}
use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.
the class MultiredditAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder2, final int pos) {
int i = (pos != 0) ? (pos - 1) : pos;
if (holder2 instanceof SubmissionViewHolder) {
final SubmissionViewHolder holder = (SubmissionViewHolder) holder2;
final Submission submission = dataSet.posts.get(i);
CreateCardView.colorCard(submission.getSubredditName().toLowerCase(Locale.ENGLISH), holder.itemView, "multi" + dataSet.multiReddit.getDisplayName(), true);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (Authentication.didOnline || submission.getComments() != null) {
holder.title.setAlpha(0.65f);
holder.leadImage.setAlpha(0.65f);
holder.thumbimage.setAlpha(0.65f);
Intent i2 = new Intent(context, CommentsScreen.class);
i2.putExtra(CommentsScreen.EXTRA_PAGE, holder2.getBindingAdapterPosition() - 1);
i2.putExtra(CommentsScreen.EXTRA_MULTIREDDIT, dataSet.multiReddit.getDisplayName());
context.startActivityForResult(i2, 940);
i2.putExtra("fullname", submission.getFullName());
clicked = holder2.getBindingAdapterPosition();
} else {
Snackbar s = Snackbar.make(holder.itemView, R.string.offline_comments_not_loaded, Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
}
}
});
new PopulateSubmissionViewHolder().populateSubmissionViewHolder(holder, submission, context, false, false, dataSet.posts, listView, true, false, "multi" + dataSet.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), null);
}
if (holder2 instanceof SubmissionFooterViewHolder) {
Handler handler = new Handler();
final Runnable r = new Runnable() {
public void run() {
// the loading spinner to replaced by nomoreposts.xml
notifyItemChanged(dataSet.posts.size() + 1);
}
};
handler.post(r);
if (holder2.itemView.findViewById(R.id.reload) != null) {
holder2.itemView.findViewById(R.id.reload).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dataSet.loadMore(context, baseView, true, MultiredditAdapter.this);
}
});
}
}
if (holder2 instanceof SpacerViewHolder) {
final int height = (context).findViewById(R.id.header).getHeight();
holder2.itemView.findViewById(R.id.height).setLayoutParams(new LinearLayout.LayoutParams(holder2.itemView.getWidth(), height));
if (listView.getLayoutManager() instanceof CatchStaggeredGridLayoutManager) {
CatchStaggeredGridLayoutManager.LayoutParams layoutParams = new CatchStaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
layoutParams.setFullSpan(true);
holder2.itemView.setLayoutParams(layoutParams);
}
}
}
Aggregations