List of usage examples for android.widget ViewSwitcher showNext
@android.view.RemotableViewMethod public void showNext()
From source file:de.baumann.thema.RequestActivity.java
@SuppressWarnings("unchecked") private void populateView(ArrayList arrayListFinal) { ArrayList<AppInfo> local_arrayList; local_arrayList = arrayListFinal;/*from w ww . j ava 2s . c o m*/ GridView grid = (GridView) findViewById(R.id.appgrid); assert grid != null; grid.setVerticalSpacing(GridView.AUTO_FIT); grid.setHorizontalSpacing(GridView.AUTO_FIT); grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); grid.setFastScrollEnabled(true); grid.setFastScrollAlwaysVisible(true); if (DEBUG) Log.v(TAG, "height: " + getDisplaySize("height") + "; width: " + getDisplaySize("width")); AppAdapter appInfoAdapter; if (isPortrait()) { grid.setNumColumns(numCol_Portrait); if (isTablet(context)) { grid.setNumColumns(numCol_Portrait); //Here you can change the number of columns for Tablets if (DEBUG) Log.v(TAG, "isTablet"); } if (isXLargeTablet(context)) { grid.setNumColumns(numCol_Portrait); //Here you can change the number of columns for Large Tablets if (DEBUG) Log.v(TAG, "isXLargeTablet"); } appInfoAdapter = new AppAdapter(this, R.layout.request_item_list, local_arrayList); } else { grid.setNumColumns(numCol_Landscape); if (isTablet(context)) { grid.setNumColumns(numCol_Landscape); //Here you can change the number of columns for Tablets if (DEBUG) Log.v(TAG, "isTablet"); } if (isXLargeTablet(context)) { grid.setNumColumns(numCol_Landscape); //Here you can change the number of columns for Large Tablets if (DEBUG) Log.v(TAG, "isXLargeTablet"); } appInfoAdapter = new AppAdapter(this, R.layout.request_item_grid, local_arrayList); } grid.setAdapter(appInfoAdapter); grid.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> AdapterView, View view, int position, long row) { AppInfo appInfo = (AppInfo) AdapterView.getItemAtPosition(position); CheckBox checker = (CheckBox) view.findViewById(R.id.CBappSelect); ViewSwitcher icon = (ViewSwitcher) view.findViewById(R.id.viewSwitcherChecked); LinearLayout localBackground = (LinearLayout) view.findViewById(R.id.card_bg); Animation aniIn = AnimationUtils.loadAnimation(context, R.anim.request_flip_in_half_1); Animation aniOut = AnimationUtils.loadAnimation(context, R.anim.request_flip_in_half_2); checker.toggle(); appInfo.setSelected(checker.isChecked()); icon.setInAnimation(aniIn); icon.setOutAnimation(aniOut); if (appInfo.isSelected()) { if (DEBUG) Log.v(TAG, "Selected App: " + appInfo.getName()); localBackground .setBackgroundColor(ContextCompat.getColor(context, R.color.request_card_pressed)); if (icon.getDisplayedChild() == 0) { icon.showNext(); } } else { if (DEBUG) Log.v(TAG, "Deselected App: " + appInfo.getName()); localBackground .setBackgroundColor(ContextCompat.getColor(context, R.color.request_card_unpressed)); if (icon.getDisplayedChild() == 1) { icon.showPrevious(); } } } }); }
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 w w . jav a 2s . co m*/ * @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
/** * 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 w w . j av a2 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; }