Search in sources :

Example 41 with Snackbar

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();
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Example 42 with Snackbar

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();
    }
}
Also used : Context(android.content.Context) PopupMenu(io.github.hidroh.materialistic.widget.PopupMenu) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager) NavFloatingActionButton(io.github.hidroh.materialistic.widget.NavFloatingActionButton) AppBarLayout(com.google.android.material.appbar.AppBarLayout) MenuItem(android.view.MenuItem) Inject(javax.inject.Inject) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Menu(android.view.Menu) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic) ContextCompat(androidx.core.content.ContextCompat) TabLayout(com.google.android.material.tabs.TabLayout) ComponentName(android.content.ComponentName) IntentFilter(android.content.IntentFilter) WebItem(io.github.hidroh.materialistic.data.WebItem) TextUtils(android.text.TextUtils) SearchView(androidx.appcompat.widget.SearchView) FragmentTransaction(androidx.fragment.app.FragmentTransaction) BroadcastReceiver(android.content.BroadcastReceiver) Nullable(androidx.annotation.Nullable) ItemManager(io.github.hidroh.materialistic.data.ItemManager) Toolbar(androidx.appcompat.widget.Toolbar) ItemPagerAdapter(io.github.hidroh.materialistic.widget.ItemPagerAdapter) ViewPager(io.github.hidroh.materialistic.widget.ViewPager) SessionManager(io.github.hidroh.materialistic.data.SessionManager) SearchManager(android.app.SearchManager) Snackbar(com.google.android.material.snackbar.Snackbar) Intent(android.content.Intent) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 43 with Snackbar

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);
        }
    });
}
Also used : ItemManager(io.github.hidroh.materialistic.data.ItemManager) AlgoliaClient(io.github.hidroh.materialistic.data.AlgoliaClient) Snackbar(com.google.android.material.snackbar.Snackbar) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 44 with Snackbar

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();
}
Also used : Context(android.content.Context) MoodleWebService(ca.etsmtl.applets.etsmobile.http.MoodleWebService) Bundle(android.os.Bundle) Environment(android.os.Environment) NonNull(androidx.annotation.NonNull) MoodleCoreCourse(ca.etsmtl.applets.etsmobile.model.moodle.MoodleCoreCourse) Uri(android.net.Uri) Intent(android.content.Intent) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) Response(retrofit2.Response) MoodleCoreModule(ca.etsmtl.applets.etsmobile.model.moodle.MoodleCoreModule) ArrayList(java.util.ArrayList) Manifest(android.Manifest) OnPermissionDenied(permissions.dispatcher.OnPermissionDenied) Utility(ca.etsmtl.applets.etsmobile.util.Utility) Toast(android.widget.Toast) OnNeverAskAgain(permissions.dispatcher.OnNeverAskAgain) View(android.view.View) Build(android.os.Build) ExpandableListMoodleSectionAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListMoodleSectionAdapter) ContextCompat(androidx.core.content.ContextCompat) Cursor(android.database.Cursor) LayoutInflater(android.view.LayoutInflater) IntentFilter(android.content.IntentFilter) BroadcastReceiver(android.content.BroadcastReceiver) RuntimePermissions(permissions.dispatcher.RuntimePermissions) ViewGroup(android.view.ViewGroup) File(java.io.File) ApplicationManager(ca.etsmtl.applets.etsmobile.ApplicationManager) DownloadManager(android.app.DownloadManager) NeedsPermission(permissions.dispatcher.NeedsPermission) List(java.util.List) Callback(retrofit2.Callback) R(ca.etsmtl.applets.etsmobile2.R) ActivityNotFoundException(android.content.ActivityNotFoundException) FileProvider(androidx.core.content.FileProvider) MoodleModuleContent(ca.etsmtl.applets.etsmobile.model.moodle.MoodleModuleContent) ExpandableListView(android.widget.ExpandableListView) Snackbar(com.google.android.material.snackbar.Snackbar) Collections(java.util.Collections) Call(retrofit2.Call) MimeTypeMap(android.webkit.MimeTypeMap) FilenameUtils(org.apache.commons.io.FilenameUtils) Snackbar(com.google.android.material.snackbar.Snackbar) OnNeverAskAgain(permissions.dispatcher.OnNeverAskAgain) OnPermissionDenied(permissions.dispatcher.OnPermissionDenied)

Example 45 with Snackbar

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;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData) Snackbar(com.google.android.material.snackbar.Snackbar)

Aggregations

Snackbar (com.google.android.material.snackbar.Snackbar)110 View (android.view.View)61 Intent (android.content.Intent)46 TextView (android.widget.TextView)41 AlertDialog (androidx.appcompat.app.AlertDialog)29 Context (android.content.Context)28 ImageView (android.widget.ImageView)28 LayoutInflater (android.view.LayoutInflater)24 ArrayList (java.util.ArrayList)23 RecyclerView (androidx.recyclerview.widget.RecyclerView)22 Bundle (android.os.Bundle)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 DialogInterface (android.content.DialogInterface)19 List (java.util.List)19 CreateCardView (me.ccrama.redditslide.Views.CreateCardView)18 Submission (net.dean.jraw.models.Submission)18 SubredditView (me.ccrama.redditslide.Activities.SubredditView)17 ApiException (net.dean.jraw.ApiException)17 Activity (android.app.Activity)16 OnSingleClickListener (me.ccrama.redditslide.util.OnSingleClickListener)16