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());
}
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);
}
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();
}
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);
}
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();
}
Aggregations