Search in sources :

Example 96 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity method setupAddMenuPopup.

/** Setup the popup that allows you to add new media from camera, video camera or local files **/
private void setupAddMenuPopup() {
    String capturePhoto = getString(R.string.media_add_popup_capture_photo);
    String captureVideo = getString(R.string.media_add_popup_capture_video);
    String pickPhotoFromGallery = getString(R.string.select_photo);
    String pickVideoFromGallery = getString(R.string.select_video);
    String[] items = new String[] { capturePhoto, captureVideo, pickPhotoFromGallery, pickVideoFromGallery };
    @SuppressLint("InflateParams") View menuView = getLayoutInflater().inflate(R.layout.actionbar_add_media, null, false);
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.actionbar_add_media_cell, items);
    ListView listView = (ListView) menuView.findViewById(R.id.actionbar_add_media_listview);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            adapter.notifyDataSetChanged();
            if (position == 0) {
                MediaBrowserActivity enclosingActivity = MediaBrowserActivity.this;
                WordPressMediaUtils.launchCamera(enclosingActivity, BuildConfig.APPLICATION_ID, enclosingActivity);
            } else if (position == 1) {
                WordPressMediaUtils.launchVideoCamera(MediaBrowserActivity.this);
            } else if (position == 2) {
                WordPressMediaUtils.launchPictureLibrary(MediaBrowserActivity.this);
            } else if (position == 3) {
                WordPressMediaUtils.launchVideoLibrary(MediaBrowserActivity.this);
            }
            mAddMediaPopup.dismiss();
        }
    });
    int width = getResources().getDimensionPixelSize(R.dimen.action_bar_spinner_width);
    mAddMediaPopup = new PopupWindow(menuView, width, ViewGroup.LayoutParams.WRAP_CONTENT, true);
    mAddMediaPopup.setBackgroundDrawable(new ColorDrawable());
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) PopupWindow(android.widget.PopupWindow) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) ListView(android.widget.ListView) ColorDrawable(android.graphics.drawable.ColorDrawable) SuppressLint(android.annotation.SuppressLint) ArrayAdapter(android.widget.ArrayAdapter)

Example 97 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project WordPress-Android by wordpress-mobile.

the class PhotoChooserFragment method reload.

/*
     * populates the adapter with media stored on the device
     */
public void reload() {
    if (!isAdded()) {
        AppLog.w(AppLog.T.POSTS, "Photo chooser > can't reload when not added");
        return;
    }
    // save the current state so we can restore it after loading
    if (mGridManager != null) {
        mRestoreState = mGridManager.onSaveInstanceState();
    }
    mGridManager = new GridLayoutManager(getActivity(), NUM_COLUMNS);
    mRecycler.setLayoutManager(mGridManager);
    mRecycler.setAdapter(getAdapter());
    getAdapter().refresh(true);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 98 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project WordPress-Android by wordpress-mobile.

the class ReaderPostListFragment method blockBlogForPost.

/*
     * blocks the blog associated with the passed post and removes all posts in that blog
     * from the adapter
     */
private void blockBlogForPost(final ReaderPost post) {
    if (post == null || !isAdded() || !hasPostAdapter() || !NetworkUtils.checkConnection(getActivity())) {
        return;
    }
    ReaderActions.ActionListener actionListener = new ReaderActions.ActionListener() {

        @Override
        public void onActionResult(boolean succeeded) {
            if (!succeeded && isAdded()) {
                ToastUtils.showToast(getActivity(), R.string.reader_toast_err_block_blog, ToastUtils.Duration.LONG);
            }
        }
    };
    // perform call to block this blog - returns list of posts deleted by blocking so
    // they can be restored if the user undoes the block
    final BlockedBlogResult blockResult = ReaderBlogActions.blockBlogFromReader(post.blogId, actionListener);
    // Only pass the blogID if available. Do not track feedID
    AnalyticsUtils.trackWithSiteId(AnalyticsTracker.Stat.READER_BLOG_BLOCKED, mCurrentBlogId);
    // remove posts in this blog from the adapter
    getPostAdapter().removePostsInBlog(post.blogId);
    // show the undo snackbar enabling the user to undo the block
    View.OnClickListener undoListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ReaderBlogActions.undoBlockBlogFromReader(blockResult);
            refreshPosts();
        }
    };
    Snackbar.make(getView(), getString(R.string.reader_toast_blog_blocked), Snackbar.LENGTH_LONG).setAction(R.string.undo, undoListener).show();
}
Also used : BlockedBlogResult(org.wordpress.android.ui.reader.actions.ReaderBlogActions.BlockedBlogResult) SearchView(android.support.v7.widget.SearchView) ReaderSiteHeaderView(org.wordpress.android.ui.reader.views.ReaderSiteHeaderView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) FilteredRecyclerView(org.wordpress.android.ui.FilteredRecyclerView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) ReaderActions(org.wordpress.android.ui.reader.actions.ReaderActions)

Example 99 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Lightning-Browser by anthonycr.

the class BookmarkSettingsFragment method showChooserDialog.

private void showChooserDialog(final Activity activity, List<String> list) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1);
    for (String title : list) {
        adapter.add(title);
    }
    builder.setTitle(R.string.supported_browsers_title);
    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String title = adapter.getItem(which);
            Preconditions.checkNonNull(title);
            Source source = null;
            if (title.equals(getString(R.string.stock_browser))) {
                source = Source.STOCK;
            } else if (title.equals(getTitle(activity, "com.android.chrome"))) {
                source = Source.CHROME_STABLE;
            } else if (title.equals(getTitle(activity, "com.android.beta"))) {
                source = Source.CHROME_BETA;
            } else if (title.equals(getTitle(activity, "com.android.dev"))) {
                source = Source.CHROME_DEV;
            }
            if (source != null) {
                new ImportBookmarksTask(activity, source).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
        }
    });
    Dialog dialog = builder.show();
    BrowserDialog.setDialogSize(activity, dialog);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Source(acr.browser.lightning.database.bookmark.BookmarkLocalSync.Source) Dialog(android.app.Dialog) BrowserDialog(acr.browser.lightning.dialog.BrowserDialog) AlertDialog(android.support.v7.app.AlertDialog) ArrayAdapter(android.widget.ArrayAdapter)

Example 100 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project StylishMusicPlayer by ryanhoo.

the class PlayListFragment method onAction.

// Adapter Callbacks
@Override
public void onAction(View actionView, final int position) {
    final PlayList playList = mAdapter.getItem(position);
    PopupMenu actionMenu = new PopupMenu(getActivity(), actionView, Gravity.END | Gravity.BOTTOM);
    actionMenu.inflate(R.menu.play_list_action);
    if (playList.isFavorite()) {
        actionMenu.getMenu().findItem(R.id.menu_item_rename).setVisible(false);
        actionMenu.getMenu().findItem(R.id.menu_item_delete).setVisible(false);
    }
    actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.menu_item_play_now) {
                PlayListNowEvent playListNowEvent = new PlayListNowEvent(playList, 0);
                RxBus.getInstance().post(playListNowEvent);
            } else if (item.getItemId() == R.id.menu_item_rename) {
                mEditIndex = position;
                EditPlayListDialogFragment.editPlayList(playList).setCallback(PlayListFragment.this).show(getFragmentManager().beginTransaction(), "EditPlayList");
            } else if (item.getItemId() == R.id.menu_item_delete) {
                mDeleteIndex = position;
                mPresenter.deletePlayList(playList);
            }
            return true;
        }
    });
    actionMenu.show();
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListNowEvent(io.github.ryanhoo.music.event.PlayListNowEvent) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)688 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)612 View (android.view.View)593 TextView (android.widget.TextView)245 ArrayList (java.util.ArrayList)179 Intent (android.content.Intent)148 ImageView (android.widget.ImageView)132 Toolbar (android.support.v7.widget.Toolbar)118 GridLayoutManager (android.support.v7.widget.GridLayoutManager)111 AdapterView (android.widget.AdapterView)109 ViewGroup (android.view.ViewGroup)97 AlertDialog (android.support.v7.app.AlertDialog)91 Bundle (android.os.Bundle)85 ListView (android.widget.ListView)85 BindView (butterknife.BindView)85 Nullable (android.support.annotation.Nullable)78 DialogInterface (android.content.DialogInterface)71 Context (android.content.Context)65 ArrayAdapter (android.widget.ArrayAdapter)65 LayoutInflater (android.view.LayoutInflater)64