use of android.support.v7.widget.PopupMenu in project MusicDNA by harjot-oberai.
the class AllPlaylistsFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
backBtn = (ImageView) view.findViewById(R.id.all_playlist_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
allPlaylistFragmentTitle = (TextView) view.findViewById(R.id.all_playlist_fragment_title);
if (SplashActivity.tf4 != null)
allPlaylistFragmentTitle.setTypeface(SplashActivity.tf4);
playlistFragIcon = (ImageView) view.findViewById(R.id.all_playlist_frag_icon);
playlistFragIcon.setImageTintList(ColorStateList.valueOf(HomeActivity.themeColor));
initializeHeaderImages(view);
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
noPlaylistContent = (LinearLayout) view.findViewById(R.id.noPlaylistContent);
allPlaylistRecycler = (RecyclerView) view.findViewById(R.id.all_playlists_recycler);
addPlaylistFAB = (FloatingActionButton) view.findViewById(R.id.new_playlist_fab);
addPlaylistFAB.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
addPlaylistFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.newPlaylistListener();
}
});
if (SplashActivity.tf4 != null)
((TextView) view.findViewById(R.id.noPlaylistContentText)).setTypeface(SplashActivity.tf4);
if (HomeActivity.allPlaylists.getPlaylists().size() == 0) {
allPlaylistRecycler.setVisibility(View.INVISIBLE);
noPlaylistContent.setVisibility(View.VISIBLE);
} else {
allPlaylistRecycler.setVisibility(View.VISIBLE);
noPlaylistContent.setVisibility(View.INVISIBLE);
}
vpAdapter = new ViewAllPlaylistsRecyclerAdapter(HomeActivity.allPlaylists.getPlaylists(), getContext());
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
allPlaylistRecycler.setLayoutManager(mLayoutManager2);
allPlaylistRecycler.setItemAnimator(new DefaultItemAnimator());
allPlaylistRecycler.setAdapter(vpAdapter);
allPlaylistRecycler.addOnItemTouchListener(new ClickItemTouchListener(allPlaylistRecycler) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
mCallback.onPlaylistSelected(position);
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
PopupMenu popup = new PopupMenu(getContext(), view);
popup.getMenuInflater().inflate(R.menu.playlist_popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getTitle().equals("Play")) {
HomeActivity.tempPlaylist = HomeActivity.allPlaylists.getPlaylists().get(position);
int size = HomeActivity.tempPlaylist.getSongList().size();
HomeActivity.queue.getQueue().clear();
for (int i = 0; i < size; i++) {
HomeActivity.queue.addToQueue(HomeActivity.tempPlaylist.getSongList().get(i));
}
HomeActivity.queueCurrentIndex = 0;
mCallback.onPlaylistMenuPLayAll();
} else if (item.getTitle().equals("Add to Queue")) {
Playlist pl = HomeActivity.allPlaylists.getPlaylists().get(position);
for (UnifiedTrack ut : pl.getSongList()) {
HomeActivity.queue.addToQueue(ut);
}
} else if (item.getTitle().equals("Delete")) {
HomeActivity.allPlaylists.getPlaylists().remove(position);
if (vpAdapter != null) {
vpAdapter.notifyItemRemoved(position);
}
if (HomeActivity.allPlaylists.getPlaylists().size() == 0) {
noPlaylistContent.setVisibility(View.VISIBLE);
}
new HomeActivity.SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
homeActivity.pAdapter.notifyItemRemoved(position);
} else if (item.getTitle().equals("Rename")) {
HomeActivity.renamePlaylistNumber = position;
mCallback.onPlaylistRename();
}
return true;
}
});
popup.show();
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
}
use of android.support.v7.widget.PopupMenu in project AgentWeb by Justson.
the class AgentWebFragment method showPoPup.
/**
* 显示更多菜单
*
* @param view 菜单依附在该View下面
*/
private void showPoPup(View view) {
if (mPopupMenu == null) {
mPopupMenu = new PopupMenu(this.getActivity(), view);
mPopupMenu.inflate(R.menu.toolbar_menu);
mPopupMenu.setOnMenuItemClickListener(mOnMenuItemClickListener);
}
mPopupMenu.show();
}
use of android.support.v7.widget.PopupMenu in project Fragmentation by YoKeyword.
the class HomeFragment method onMenuItemClick.
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_anim:
final PopupMenu popupMenu = new PopupMenu(_mActivity, mToolbar, GravityCompat.END);
popupMenu.inflate(R.menu.home_pop);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_anim_veritical:
((ISupportActivity) _mActivity).setFragmentAnimator(new DefaultVerticalAnimator());
Toast.makeText(_mActivity, R.string.anim_v, Toast.LENGTH_SHORT).show();
break;
case R.id.action_anim_horizontal:
((ISupportActivity) _mActivity).setFragmentAnimator(new DefaultHorizontalAnimator());
Toast.makeText(_mActivity, R.string.anim_h, Toast.LENGTH_SHORT).show();
break;
case R.id.action_anim_none:
((ISupportActivity) _mActivity).setFragmentAnimator(new DefaultNoAnimator());
Toast.makeText(_mActivity, R.string.anim_none, Toast.LENGTH_SHORT).show();
break;
}
popupMenu.dismiss();
return true;
}
});
popupMenu.show();
break;
}
return true;
}
use of android.support.v7.widget.PopupMenu in project PhotoNoter by yydcdut.
the class ImageDialogView method targetImageClick.
@OnClick(R.id.img_image)
public void targetImageClick(View v) {
PopupMenu popup = new PopupMenu(getContext(), mTargetImageView);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.menu_popup, popup.getMenu());
popup.setOnMenuItemClickListener(this);
popup.show();
}
use of android.support.v7.widget.PopupMenu in project Android-Developers-Samples by johnjohndoe.
the class PopupListFragment method showPopupMenu.
// BEGIN_INCLUDE(show_popup)
private void showPopupMenu(View view) {
final PopupAdapter adapter = (PopupAdapter) getListAdapter();
// Retrieve the clicked item from view's tag
final String item = (String) view.getTag();
// Create a PopupMenu, giving it the clicked view for an anchor
PopupMenu popup = new PopupMenu(getActivity(), view);
// Inflate our menu resource into the PopupMenu's Menu
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
// Set a listener so we are notified if a menu item is clicked
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch(menuItem.getItemId()) {
case R.id.menu_remove:
// Remove the item from the adapter
adapter.remove(item);
return true;
}
return false;
}
});
// Finally show the PopupMenu
popup.show();
}
Aggregations