Search in sources :

Example 6 with ActionMode

use of android.support.v7.view.ActionMode in project Shuttle by timusus.

the class AlbumArtistFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (recyclerView == null) {
        int spanCount = SettingsManager.getInstance().getArtistColumnCount(getResources());
        layoutManager = new GridLayoutManager(getContext(), spanCount);
        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                if (albumArtistAdapter.items.get(position) instanceof EmptyView) {
                    return spanCount;
                }
                return 1;
            }
        });
        recyclerView = (FastScrollRecyclerView) inflater.inflate(R.layout.fragment_recycler, container, false);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.addItemDecoration(new GridDividerDecoration(getResources(), 4, true));
        recyclerView.setRecyclerListener(this);
        recyclerView.setAdapter(albumArtistAdapter);
        actionMode = null;
        themeUIComponents();
    }
    return recyclerView;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridDividerDecoration(com.simplecity.amp_library.ui.recyclerview.GridDividerDecoration) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) Nullable(android.support.annotation.Nullable)

Example 7 with ActionMode

use of android.support.v7.view.ActionMode in project Shuttle by timusus.

the class AlbumFragment method onCreateView.

@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (recyclerView == null) {
        int spanCount = SettingsManager.getInstance().getAlbumColumnCount(getResources());
        layoutManager = new GridLayoutManager(getContext(), spanCount);
        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                if (albumAdapter.items.get(position) instanceof EmptyView) {
                    return spanCount;
                }
                return 1;
            }
        });
        recyclerView = (FastScrollRecyclerView) inflater.inflate(R.layout.fragment_recycler, container, false);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.addItemDecoration(new GridDividerDecoration(getResources(), 4, true));
        recyclerView.setRecyclerListener(this);
        recyclerView.setAdapter(albumAdapter);
        actionMode = null;
        themeUIComponents();
    }
    return recyclerView;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridDividerDecoration(com.simplecity.amp_library.ui.recyclerview.GridDividerDecoration) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 8 with ActionMode

use of android.support.v7.view.ActionMode in project HoloEverywhere by Prototik.

the class ActionBarContextView method initForMode.

public void initForMode(final ActionMode mode) {
    if (mClose == null) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        mClose = inflater.inflate(R.layout.abc_action_mode_close_item, this, false);
        addView(mClose);
    } else if (mClose.getParent() == null) {
        addView(mClose);
    }
    View closeButton = mClose.findViewById(R.id.action_mode_close_button);
    closeButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            mode.finish();
        }
    });
    final MenuBuilder menu = (MenuBuilder) mode.getMenu();
    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.dismissPopupMenus();
    }
    mActionMenuPresenter = new ActionMenuPresenter(getContext());
    mActionMenuPresenter.setReserveOverflow(true);
    final ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT);
    if (!mSplitActionBar) {
        menu.addMenuPresenter(mActionMenuPresenter);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(null);
        addView(mMenuView, layoutParams);
    } else {
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = ViewGroup.LayoutParams.FILL_PARENT;
        layoutParams.height = mContentHeight;
        menu.addMenuPresenter(mActionMenuPresenter);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(mSplitBackground);
        mSplitView.addView(mMenuView, layoutParams);
    }
}
Also used : ViewGroup(android.view.ViewGroup) LayoutInflater(org.holoeverywhere.LayoutInflater) ActionMenuView(android.support.v7.internal.view.menu.ActionMenuView) TextView(org.holoeverywhere.widget.TextView) View(android.view.View) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) ActionMenuPresenter(android.support.v7.internal.view.menu.ActionMenuPresenter)

Example 9 with ActionMode

use of android.support.v7.view.ActionMode in project RoboBinding-gallery by RoboBinding.

the class ContextualActionModeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MemoryProductStore productStore = MemoryProductStore.getInstance();
    productStore.reset();
    presentationModel = new ContextualActionModePresentationModel(productStore);
    initializeContentView(R.layout.activity_contextual_action_mode, presentationModel);
    ListView productListView = (ListView) findViewById(R.id.productList);
    productListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            startSupportActionMode(new ActionMode.Callback() {

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {
                }

                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuBinder menuBinder = createMenuBinder(menu, getMenuInflater());
                    menuBinder.inflateAndBind(R.menu.contextual_action_mode, presentationModel);
                    return true;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    return false;
                }
            });
            return true;
        }
    });
}
Also used : MemoryProductStore(org.robobinding.gallery.model.MemoryProductStore) MenuBinder(org.robobinding.MenuBinder) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) ContextualActionModePresentationModel(org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel) ListView(android.widget.ListView) ActionMode(android.support.v7.view.ActionMode) Menu(android.view.Menu)

Example 10 with ActionMode

use of android.support.v7.view.ActionMode in project Signal-Android by WhisperSystems.

the class ConversationListFragment method handleDeleteAllSelected.

private void handleDeleteAllSelected() {
    int conversationsCount = getListAdapter().getBatchSelections().size();
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setIconAttribute(R.attr.dialog_alert_icon);
    alert.setTitle(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations, conversationsCount, conversationsCount));
    alert.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations, conversationsCount, conversationsCount));
    alert.setCancelable(true);
    alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            final Set<Long> selectedConversations = (getListAdapter()).getBatchSelections();
            if (!selectedConversations.isEmpty()) {
                new AsyncTask<Void, Void, Void>() {

                    private ProgressDialog dialog;

                    @Override
                    protected void onPreExecute() {
                        dialog = ProgressDialog.show(getActivity(), getActivity().getString(R.string.ConversationListFragment_deleting), getActivity().getString(R.string.ConversationListFragment_deleting_selected_conversations), true, false);
                    }

                    @Override
                    protected Void doInBackground(Void... params) {
                        DatabaseFactory.getThreadDatabase(getActivity()).deleteConversations(selectedConversations);
                        MessageNotifier.updateNotification(getActivity(), masterSecret);
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void result) {
                        dialog.dismiss();
                        if (actionMode != null) {
                            actionMode.finish();
                            actionMode = null;
                        }
                    }
                }.execute();
            }
        }
    });
    alert.setNegativeButton(android.R.string.cancel, null);
    alert.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Set(java.util.Set) HashSet(java.util.HashSet) DialogInterface(android.content.DialogInterface) AsyncTask(android.os.AsyncTask) SnackbarAsyncTask(org.thoughtcrime.securesms.util.task.SnackbarAsyncTask) ProgressDialog(android.app.ProgressDialog) Paint(android.graphics.Paint)

Aggregations

ActionMode (android.support.v7.view.ActionMode)7 View (android.view.View)6 RecyclerView (android.support.v7.widget.RecyclerView)5 Context (android.content.Context)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)3 Toolbar (android.support.v7.widget.Toolbar)3 Menu (android.view.Menu)3 MenuItem (android.view.MenuItem)3 FastAdapter (com.mikepenz.fastadapter.FastAdapter)3 ActionModeHelper (com.mikepenz.fastadapter_extensions.ActionModeHelper)3 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)3 AlertDialog (android.app.AlertDialog)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 ViewGroup (android.view.ViewGroup)2 Toast (android.widget.Toast)2 IAdapter (com.mikepenz.fastadapter.IAdapter)2 IItem (com.mikepenz.fastadapter.IItem)2