use of android.support.v7.widget.PopupMenu in project MTweaks-KernelAdiutorMOD by morogoku.
the class CardView method refresh.
@Override
protected void refresh() {
super.refresh();
if (mTitle != null) {
if (mTitleText != null) {
mTitle.setText(mTitleText);
mTitleParent.setVisibility(View.VISIBLE);
if (mLayoutParent != null) {
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mLayout.getLayoutParams();
layoutParams.topMargin = -mLayout.getPaddingLeft();
mLayout.requestLayout();
mLayout.setPadding(mLayout.getPaddingLeft(), 0, mLayout.getPaddingRight(), mLayout.getPaddingBottom());
}
} else {
mTitleParent.setVisibility(View.GONE);
}
}
if (mMenuButton != null && mOnMenuListener != null) {
mMenuButton.setVisibility(View.VISIBLE);
mPopupMenu = new PopupMenu(mMenuButton.getContext(), mMenuButton);
mOnMenuListener.onMenuReady(this, mPopupMenu);
}
if (mRootView != null && getOnItemClickListener() != null) {
mRootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getOnItemClickListener().onClick(CardView.this);
}
});
}
}
use of android.support.v7.widget.PopupMenu in project TamTime by flyingrub.
the class FavoriteStopsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.view_recycler_load, container, false);
setHasOptionsMenu(true);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.progress);
linearLayout.setVisibility(View.GONE);
TextView textView = (TextView) view.findViewById(R.id.empty_view);
textView.setText(getString(R.string.no_favorite_stop));
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
recyclerView.setHasFixedSize(false);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setBackgroundColor(getResources().getColor(R.color.windowBackgroundCard));
favoriteStops = new FavoriteStops(getActivity());
getActivity().setTitle(getString(R.string.all_stops_favs));
if (favoriteStops.getFavoriteStop().size() == 0) {
textView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
return view;
}
adapter = new FavoriteAdapter(favoriteStops.getFavoriteStop());
recyclerView.setAdapter(adapter);
adapter.SetOnItemClickListener(new FavoriteAdapter.OnItemClickListener() {
@Override
public void onItemClick(View v, int position) {
selectitem(position);
}
});
adapter.SetOnMenuClickListener(new FavoriteAdapter.OnMenuClickListener() {
@Override
public void onItemClick(View v, final int position) {
// Creating the instance of PopupMenu
PopupMenu popup = new PopupMenu(getActivity(), v);
// Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.delete_menu, popup.getMenu());
// registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
favoriteStops.remove(position);
recyclerView.swapAdapter(new FavoriteAdapter(favoriteStops.getFavoriteStop()), false);
return true;
}
});
// showing popup menu
popup.show();
}
});
return view;
}
use of android.support.v7.widget.PopupMenu in project TamTime by flyingrub.
the class HomeFragment method setupFavStopLine.
public void setupFavStopLine() {
homeAdapter = new HomeAdapter(favoriteStopLine.getFavStopLines(), getActivity(), favHomeView, searchView);
homeAdapter.SetOnItemClickListener(new HomeAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, final int position) {
PopupMenu popup = new PopupMenu(getActivity(), view);
// Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.remove_from_home, popup.getMenu());
// registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
favoriteStopLine.removeLineStop(position - 1);
setupFavStopLine();
return true;
}
});
popup.show();
}
});
favStopLinesRecycler.swapAdapter(homeAdapter, false);
}
use of android.support.v7.widget.PopupMenu in project Rocket by mozilla-tw.
the class DownloadListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
if (viewHolder instanceof DownloadViewHolder) {
DownloadViewHolder holder = (DownloadViewHolder) viewHolder;
DownloadInfo downloadInfo = mDownloadInfo.get(position);
if (!TextUtils.isEmpty(downloadInfo.getFileName())) {
holder.title.setText(downloadInfo.getFileName());
} else {
holder.title.setText(R.string.unknown);
}
holder.icon.setImageResource(mappingIcon(downloadInfo));
String subtitle = "";
if (DownloadManager.STATUS_SUCCESSFUL == downloadInfo.getStatus()) {
subtitle = downloadInfo.getSize() + ", " + downloadInfo.getDate();
} else {
subtitle = statusConvertStr(downloadInfo.getStatus());
}
holder.subtitle.setText(subtitle);
holder.action.setTag(R.id.status, downloadInfo.getStatus());
holder.action.setTag(R.id.row_id, downloadInfo.getRowId());
holder.action.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
final long rowid = (long) view.getTag(R.id.row_id);
int status = (int) view.getTag(R.id.status);
final PopupMenu popupMenu = new PopupMenu(view.getContext(), view);
popupMenu.getMenuInflater().inflate(R.menu.menu_delete, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch(menuItem.getItemId()) {
case R.id.remove:
removeItem(rowid);
TelemetryWrapper.downloadRemoveFile();
popupMenu.dismiss();
return true;
case R.id.delete:
delete(view, rowid);
TelemetryWrapper.downloadDeleteFile();
popupMenu.dismiss();
return true;
case R.id.cancel:
cancel(rowid);
popupMenu.dismiss();
return true;
default:
break;
}
return false;
}
});
if (DownloadManager.STATUS_RUNNING == status) {
popupMenu.getMenu().findItem(R.id.remove).setVisible(false);
popupMenu.getMenu().findItem(R.id.delete).setVisible(false);
popupMenu.getMenu().findItem(R.id.cancel).setVisible(true);
} else {
popupMenu.getMenu().findItem(R.id.remove).setVisible(true);
popupMenu.getMenu().findItem(R.id.delete).setVisible(true);
popupMenu.getMenu().findItem(R.id.cancel).setVisible(false);
}
popupMenu.show();
TelemetryWrapper.showFileContextMenu();
}
});
holder.itemView.setTag(downloadInfo);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DownloadInfo download = (DownloadInfo) view.getTag();
TelemetryWrapper.downloadOpenFile(false);
if (new File(URI.create(download.getFileUri()).getPath()).exists()) {
IntentUtils.intentOpenFile(view.getContext(), download.getFileUri(), download.getMimeType());
} else {
Toast.makeText(mContext, R.string.cannot_find_the_file, Toast.LENGTH_LONG).show();
}
}
});
} else if (viewHolder instanceof OnOpeningViewHolder) {
viewHolder.itemView.setVisibility(View.GONE);
}
}
use of android.support.v7.widget.PopupMenu in project samourai-wallet-android by Samourai-Wallet.
the class LandingActivity method showPopup.
/**
* Shows overflow menu manually
*
* @param v
*/
public void showPopup(View v) {
Context wrapper = new ContextThemeWrapper(this, R.style.popMenuStyle);
PopupMenu popup = new PopupMenu(wrapper, v, Gravity.LEFT);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.landing_activity_menu, popup.getMenu());
popup.setOnMenuItemClickListener(this);
popup.show();
}
Aggregations