List of usage examples for android.widget LinearLayout getDividerPadding
public int getDividerPadding()
From source file:com.pressurelabs.flowopensource.TheHubActivity.java
/** * Generates a Popup Menu with Two Actions Edit and Delete. * * Deleting the Flow removes the single card from the UI and also notifiers the AppDataManager to * delete from file/*from w w w . j av a 2 s .c o m*/ * * Editing launches a renaming process * * @param longClickedFlow Flow represented by cardview longclicked * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked * @return */ private boolean showLongClickPopUpMenu(final Flow longClickedFlow, final int cardPosition, final View cardViewClicked) { LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_longclick, null); LinearLayout viewGroup = (LinearLayout) layout.findViewById(R.id.popup_longclick); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(layout, RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT); int dividerMargin = viewGroup.getDividerPadding(); // Top bottom int popupPadding = layout.getPaddingBottom(); int popupDisplayHeight = -(cardViewClicked.getHeight() - dividerMargin - popupPadding); // Prevents border popup.setBackgroundDrawable(new ColorDrawable()); popup.setFocusable(true); // Getting a reference to Close button, and close the popup when clicked. ImageView delete = (ImageView) layout.findViewById(R.id.popup_delete_item); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* Deletes current Flow from file and UI */ rvContent.remove(cardPosition); manager.delete(longClickedFlow.getUuid()); adapter.notifyItemRemoved(cardPosition); adapter.notifyItemRangeChanged(cardPosition, adapter.getItemCount()); popup.dismiss(); Snackbar bar = Snackbar.make(cardViewClicked, R.string.snackbar_hub_msg, Snackbar.LENGTH_LONG) .setAction("NO!!!", new View.OnClickListener() { @Override public void onClick(View v) { rvContent.add(cardPosition, longClickedFlow); manager.save(longClickedFlow.getUuid(), longClickedFlow); adapter.notifyItemInserted(cardPosition); } }); bar.show(); } }); ImageView edit = (ImageView) layout.findViewById(R.id.popup_edit_item); edit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popup.dismiss(); renameFlow(cardPosition, cardViewClicked); } }); // Displaying the popup at the specified location, + offsets. popup.showAsDropDown(cardViewClicked, cardViewClicked.getMeasuredWidth(), popupDisplayHeight, Gravity.TOP); longClickPopup = popup; return true; }
From source file:com.pressurelabs.flowopensource.TheHubActivity.java
/** * Displays a popup window prompting the user to * * Confirm the changes to the name, saving the new name to file and updating the UI. * * Cancel the changes, returning the user back to the original state before editing * * @param newName new name to be used/*from w ww . j a va2 s . c om*/ * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked * @param switcher the viewSwitcher object used to rename */ private void showEditPopupWindow(final EditText newName, View cardViewClicked, final ViewSwitcher switcher, final int cardPosition) { LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_editing, null); LinearLayout viewGroup = (LinearLayout) layout.findViewById(R.id.popup_editing); // Creating the PopupWindow final PopupWindow popupEditing = new PopupWindow(layout, RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT); int dividerMargin = viewGroup.getDividerPadding(); // Top bottom int popupPadding = layout.getPaddingBottom(); int popupDisplayHeight = -(cardViewClicked.getHeight() - dividerMargin - popupPadding); // Prevents border from appearing outside popupwindow popupEditing.setBackgroundDrawable(new ColorDrawable()); popupEditing.setFocusable(false); // Getting a reference to Close button, and close the popup when clicked. ImageView confirmEdit = (ImageView) layout.findViewById(R.id.popup_confirm_item_changes); confirmEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Flow toChange = rvContent.get(cardPosition); if (newName.getText().toString().equals("")) { // Need to optimize this so that the dialog does NOT disappear and just display toast Toast.makeText(TheHubActivity.this, "This Flow needs a name!", Toast.LENGTH_LONG).show(); } else { toChange.setName(newName.getText().toString()); manager.overwrite(toChange.getUuid(), toChange); adapter.notifyDataSetChanged(); switcher.showNext(); menuState = AppConstants.MENU_ITEMS_NATIVE; invalidateOptionsMenu(); popupEditing.dismiss(); newName.clearFocus(); } } }); ImageView cancelEdit = (ImageView) layout.findViewById(R.id.popup_cancel_item_changes); cancelEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switcher.showNext(); menuState = AppConstants.MENU_ITEMS_NATIVE; invalidateOptionsMenu(); popupEditing.dismiss(); } }); // Displaying the popup at the specified location, + offsets. popupEditing.showAsDropDown(cardViewClicked, cardViewClicked.getMeasuredWidth(), popupDisplayHeight, Gravity.TOP); editingPopup = popupEditing; }
From source file:mn.today.TheHubActivity.java
/** * Generates a Popup Menu with Two Actions Edit and Delete. * * Deleting the Flow removes the single card from the UI and also notifiers the AppDataManager to * delete from file/*ww w .j a va 2 s . co m*/ * * Editing launches a renaming process * * @param longClickedFlow Flow represented by cardview longclicked * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked * @return */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) private boolean showLongClickPopUpMenu(final ToDay longClickedFlow, final int cardPosition, final View cardViewClicked) { LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_longclick, null); LinearLayout viewGroup = (LinearLayout) layout.findViewById(R.id.popup_longclick); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(layout, RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT); int dividerMargin = viewGroup.getDividerPadding(); // Top bottom int popupPadding = layout.getPaddingBottom(); int popupDisplayHeight = -(cardViewClicked.getHeight() - dividerMargin - popupPadding); // Prevents border popup.setBackgroundDrawable(new ColorDrawable()); popup.setFocusable(true); // Getting a reference to Close button, and close the popup when clicked. ImageView delete = (ImageView) layout.findViewById(R.id.popup_delete_item); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* Deletes current Flow from file and UI */ rvContent.remove(cardPosition); manager.delete(longClickedFlow.getUuid()); adapter.notifyItemRemoved(cardPosition); adapter.notifyItemRangeChanged(cardPosition, adapter.getItemCount()); popup.dismiss(); Snackbar bar = Snackbar.make(cardViewClicked, R.string.snackbar_hub_msg, Snackbar.LENGTH_LONG) .setAction("!!!", new View.OnClickListener() { @Override public void onClick(View v) { rvContent.add(cardPosition, longClickedFlow); manager.save(longClickedFlow.getUuid(), longClickedFlow); adapter.notifyItemInserted(cardPosition); } }); bar.show(); } }); ImageView edit = (ImageView) layout.findViewById(R.id.popup_edit_item); edit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popup.dismiss(); renameFlow(cardPosition, cardViewClicked); } }); // Displaying the popup at the specified location, + offsets. popup.showAsDropDown(cardViewClicked, cardViewClicked.getMeasuredWidth(), popupDisplayHeight, Gravity.TOP); longClickPopup = popup; return true; }
From source file:mn.today.TheHubActivity.java
/** * Displays a popup window prompting the user to * * Confirm the changes to the name, saving the new name to file and updating the UI. * * Cancel the changes, returning the user back to the original state before editing * * @param newName new name to be used//from w ww. j a v a 2 s . c om * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked * @param switcher the viewSwitcher object used to rename */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) private void showEditPopupWindow(final EditText newName, View cardViewClicked, final ViewSwitcher switcher, final int cardPosition) { LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_editing, null); LinearLayout viewGroup = (LinearLayout) layout.findViewById(R.id.popup_editing); // Creating the PopupWindow final PopupWindow popupEditing = new PopupWindow(layout, RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT); int dividerMargin = viewGroup.getDividerPadding(); // Top bottom int popupPadding = layout.getPaddingBottom(); int popupDisplayHeight = -(cardViewClicked.getHeight() - dividerMargin - popupPadding); // Prevents border from appearing outside popupwindow popupEditing.setBackgroundDrawable(new ColorDrawable()); popupEditing.setFocusable(false); // Getting a reference to Close button, and close the popup when clicked. ImageView confirmEdit = (ImageView) layout.findViewById(R.id.popup_confirm_item_changes); confirmEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToDay toChange = rvContent.get(cardPosition); if (newName.getText().toString().equals("")) { // Need to optimize this so that the dialog does NOT disappear and just display toast Toast.makeText(TheHubActivity.this, "?? !", Toast.LENGTH_LONG).show(); } else { toChange.setName(newName.getText().toString()); manager.overwrite(toChange.getUuid(), toChange); adapter.notifyDataSetChanged(); switcher.showNext(); menuState = AppConstants.MENU_ITEMS_NATIVE; invalidateOptionsMenu(); popupEditing.dismiss(); newName.clearFocus(); } } }); ImageView cancelEdit = (ImageView) layout.findViewById(R.id.popup_cancel_item_changes); cancelEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switcher.showNext(); menuState = AppConstants.MENU_ITEMS_NATIVE; invalidateOptionsMenu(); popupEditing.dismiss(); } }); // Displaying the popup at the specified location, + offsets. popupEditing.showAsDropDown(cardViewClicked, cardViewClicked.getMeasuredWidth(), popupDisplayHeight, Gravity.TOP); editingPopup = popupEditing; }