use of com.google.android.material.snackbar.Snackbar in project android by owncloud.
the class RenameFileDialogFragment method showSnackMessage.
/**
* Show a temporary message in a Snackbar bound to the content view of the parent Activity
*
* @param messageResource Message to show.
*/
private void showSnackMessage(int messageResource) {
Snackbar snackbar = Snackbar.make(getActivity().findViewById(android.R.id.content), messageResource, Snackbar.LENGTH_LONG);
snackbar.show();
}
use of com.google.android.material.snackbar.Snackbar in project materialistic by hidroh.
the class BaseListActivity method onPostCreate.
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (!Preferences.isReleaseNotesSeen(this)) {
Snackbar snackbar = Snackbar.make(findViewById(R.id.content_frame), R.string.hint_update, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.title_activity_release, v -> {
snackbar.dismiss();
startActivity(new Intent(BaseListActivity.this, ReleaseNotesActivity.class));
}).setActionTextColor(ContextCompat.getColor(this, R.color.orange500)).addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
Preferences.setReleaseNotesSeen(BaseListActivity.this);
}
}).show();
}
}
use of com.google.android.material.snackbar.Snackbar in project materialistic by hidroh.
the class ListFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
MaterialisticDatabase.getInstance(getContext()).getLiveData().observe(getViewLifecycleOwner(), mObserver);
String managerClassName = getArguments().getString(EXTRA_ITEM_MANAGER);
ItemManager itemManager;
if (TextUtils.equals(managerClassName, AlgoliaClient.class.getName())) {
itemManager = mAlgoliaItemManager;
} else if (TextUtils.equals(managerClassName, AlgoliaPopularClient.class.getName())) {
itemManager = mPopularItemManager;
} else {
itemManager = mHnItemManager;
}
getAdapter().setHotThresHold(AppUtils.HOT_THRESHOLD_NORMAL);
if (itemManager == mHnItemManager && mFilter != null) {
switch(mFilter) {
case ItemManager.BEST_FETCH_MODE:
getAdapter().setHotThresHold(AppUtils.HOT_THRESHOLD_HIGH);
break;
case ItemManager.NEW_FETCH_MODE:
getAdapter().setHotThresHold(AppUtils.HOT_THRESHOLD_LOW);
break;
}
} else if (itemManager == mPopularItemManager) {
getAdapter().setHotThresHold(AppUtils.HOT_THRESHOLD_HIGH);
}
getAdapter().initDisplayOptions(mRecyclerView);
getAdapter().setCacheMode(mCacheMode);
getAdapter().setUpdateListener((showAll, itemCount, actionClickListener) -> {
if (showAll) {
Snackbar.make(mRecyclerView, getResources().getQuantityString(R.plurals.new_stories_count, itemCount, itemCount), Snackbar.LENGTH_LONG).setAction(R.string.show_me, actionClickListener).show();
} else {
final Snackbar snackbar = Snackbar.make(mRecyclerView, getResources().getQuantityString(R.plurals.showing_new_stories, itemCount, itemCount), Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.show_all, actionClickListener).show();
}
});
mStoryListViewModel = new ViewModelProvider(this).get(StoryListViewModel.class);
mStoryListViewModel.inject(itemManager, mIoThreadScheduler);
mStoryListViewModel.getStories(mFilter, mCacheMode).observe(getViewLifecycleOwner(), itemLists -> {
if (itemLists == null) {
return;
}
if (itemLists.first != null) {
onItemsLoaded(itemLists.first);
}
if (itemLists.second != null) {
onItemsLoaded(itemLists.second);
}
});
}
use of com.google.android.material.snackbar.Snackbar in project ETSMobile-Android2 by ApplETS.
the class MoodleCourseDetailsFragment method showPermissionsSnackbar.
/**
* Shows a snackbar in case he/she needs to allow the app to write to external storage
* in order to download a file coming from Moodle.
*/
@OnPermissionDenied(Manifest.permission.WRITE_EXTERNAL_STORAGE)
@OnNeverAskAgain(Manifest.permission.WRITE_EXTERNAL_STORAGE)
void showPermissionsSnackbar() {
Snackbar snackbar = Snackbar.make(getView(), R.string.moodle_allow_storage_permissions, Snackbar.LENGTH_SHORT).setAction(R.string.action_settings, (listener) -> Utility.goToAppSettings(listener.getContext())).setActionTextColor(ContextCompat.getColor(getActivity(), R.color.ets_red));
snackbar.show();
}
use of com.google.android.material.snackbar.Snackbar in project AntennaPod by AntennaPod.
the class ShownotesWebView method onContextItemSelected.
public boolean onContextItemSelected(MenuItem item) {
if (selectedUrl == null) {
return false;
}
final int itemId = item.getItemId();
if (itemId == R.id.open_in_browser_item) {
IntentUtils.openInBrowser(getContext(), selectedUrl);
} else if (itemId == R.id.share_url_item) {
ShareUtils.shareLink(getContext(), selectedUrl);
} else if (itemId == R.id.copy_url_item) {
ClipData clipData = ClipData.newPlainText(selectedUrl, selectedUrl);
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(clipData);
Snackbar s = Snackbar.make(this, R.string.copied_url_msg, Snackbar.LENGTH_LONG);
ViewCompat.setElevation(s.getView(), 100);
s.show();
} else if (itemId == R.id.go_to_position_item) {
if (Timeline.isTimecodeLink(selectedUrl) && timecodeSelectedListener != null) {
timecodeSelectedListener.accept(Timeline.getTimecodeLinkTime(selectedUrl));
} else {
Log.e(TAG, "Selected go_to_position_item, but URL was no timecode link: " + selectedUrl);
}
} else {
selectedUrl = null;
return false;
}
selectedUrl = null;
return true;
}
Aggregations