List of usage examples for android.widget ViewSwitcher showPrevious
@android.view.RemotableViewMethod public void showPrevious()
From source file:com.friedran.appengine.dashboard.gui.DashboardLoadFragment.java
private void switchChartToProgress(View chartView) { ViewSwitcher switcher = (ViewSwitcher) chartView.findViewById(R.id.load_chart_switcher); if (switcher.getDisplayedChild() != 0) { switcher.showPrevious(); }//from www. ja v a 2s . c o m }
From source file:de.azapps.mirakel.helper.TaskDialogHelpers.java
@SuppressLint("NewApi") public static void handleSubtask(final Context ctx, final Task task, final OnTaskChangedListner taskChanged, final boolean asSubtask) { final List<Pair<Long, String>> names = Task.getTaskNames(); final CharSequence[] values = new String[names.size()]; for (int i = 0; i < names.size(); i++) { values[i] = names.get(i).second; }//from w ww .ja v a2s.co m final View v = ((Activity) ctx).getLayoutInflater().inflate(R.layout.select_subtask, null, false); final ListView lv = (ListView) v.findViewById(R.id.subtask_listview); final List<Task> tasks = Task.cursorToTaskList( ctx.getContentResolver().query(MirakelInternalContentProvider.TASK_URI, Task.allColumns, ModelBase.ID + "=" + task.getId() + " AND " + Task.BASIC_FILTER_DISPLAY_TASKS, null, null)); subtaskAdapter = new SubtaskAdapter(ctx, 0, tasks, task, asSubtask); lv.post(new Runnable() { @Override public void run() { lv.setAdapter(subtaskAdapter); } }); searchString = ""; done = false; content = false; reminder = false; optionEnabled = false; newTask = true; listId = SpecialList.firstSpecialSafe().getId(); final EditText search = (EditText) v.findViewById(R.id.subtask_searchbox); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { Drawable left = ctx.getResources().getDrawable(android.R.drawable.ic_menu_search); Drawable right = null; left.setBounds(0, 0, 42, 42); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && ctx.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { right = ctx.getResources().getDrawable(android.R.drawable.ic_menu_search); right.setBounds(0, 0, 42, 42); left = null; } search.setCompoundDrawables(left, null, right, null); } search.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(final Editable s) { // Nothing } @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { // Nothing } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { searchString = s.toString(); updateListView(subtaskAdapter, task, lv, ctx); } }); final Button options = (Button) v.findViewById(R.id.subtasks_options); final LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.subtask_option_wrapper); wrapper.setVisibility(View.GONE); options.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (optionEnabled) { wrapper.setVisibility(View.GONE); } else { wrapper.setVisibility(View.VISIBLE); final InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(search.getWindowToken(), 0); } optionEnabled = !optionEnabled; } }); final ViewSwitcher switcher = (ViewSwitcher) v.findViewById(R.id.subtask_switcher); final Button subtaskNewtask = (Button) v.findViewById(R.id.subtask_newtask); final Button subtaskSelectOld = (Button) v.findViewById(R.id.subtask_select_old); final boolean darkTheme = MirakelCommonPreferences.isDark(); if (asSubtask) { v.findViewById(R.id.subtask_header).setVisibility(View.GONE); switcher.showNext(); newTask = false; } else { subtaskNewtask.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (newTask) { return; } switcher.showPrevious(); subtaskNewtask .setTextColor(ctx.getResources().getColor(darkTheme ? R.color.White : R.color.Black)); subtaskSelectOld.setTextColor(ctx.getResources().getColor(R.color.Grey)); newTask = true; } }); subtaskSelectOld.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (!newTask) { return; } switcher.showNext(); subtaskNewtask.setTextColor(ctx.getResources().getColor(R.color.Grey)); subtaskSelectOld .setTextColor(ctx.getResources().getColor(darkTheme ? R.color.White : R.color.Black)); if (subtaskAdapter != null) { subtaskAdapter.notifyDataSetChanged(); } newTask = false; lv.invalidateViews(); updateListView(subtaskAdapter, task, lv, ctx); } }); } final CheckBox doneBox = (CheckBox) v.findViewById(R.id.subtask_done); doneBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { done = isChecked; updateListView(subtaskAdapter, task, lv, ctx); } }); final CheckBox reminderBox = (CheckBox) v.findViewById(R.id.subtask_reminder); reminderBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { reminder = isChecked; updateListView(subtaskAdapter, task, lv, ctx); } }); final Button list = (Button) v.findViewById(R.id.subtask_list); list.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final List<ListMirakel> lists = ListMirakel.all(true); final CharSequence[] names = new String[lists.size()]; for (int i = 0; i < names.length; i++) { names[i] = lists.get(i).getName(); } new AlertDialog.Builder(ctx).setSingleChoiceItems(names, -1, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { listId = lists.get(which).getId(); updateListView(subtaskAdapter, task, lv, ctx); list.setText(lists.get(which).getName()); dialog.dismiss(); } }).show(); } }); final CheckBox contentBox = (CheckBox) v.findViewById(R.id.subtask_content); contentBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { content = isChecked; updateListView(subtaskAdapter, task, lv, ctx); } }); final EditText newTaskEdit = (EditText) v.findViewById(R.id.subtask_add_task_edit); final AlertDialog dialog = new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.add_subtask)) .setView(v).setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { if (newTask && newTaskEdit.getText().length() > 0) { newSubtask(newTaskEdit.getText().toString(), task, ctx); } else if (!newTask) { final List<Task> checked = subtaskAdapter.getSelected(); for (final Task t : checked) { if (!asSubtask) { if (!t.hasSubtasksLoop(task)) { task.addSubtask(t); } else { ErrorReporter.report(ErrorType.TASKS_CANNOT_FORM_LOOP); } } else { if (!task.hasSubtasksLoop(t)) { t.addSubtask(task); } else { ErrorReporter.report(ErrorType.TASKS_CANNOT_FORM_LOOP); } } } } if (taskChanged != null) { taskChanged.onTaskChanged(task); } ((Activity) ctx).getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.dismiss(); } }).setNegativeButton(android.R.string.cancel, dialogDoNothing).show(); newTaskEdit.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { newSubtask(v.getText().toString(), task, ctx); v.setText(null); if (taskChanged != null) { taskChanged.onTaskChanged(task); } dialog.dismiss(); } return false; } }); }
From source file:com.quaap.audiometer.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pref = getApplicationContext().getSharedPreferences("main", MODE_PRIVATE); mMeterView = (MeterView) findViewById(R.id.meterLayout); mMicLevelReader = new MicLevelReader(this, LevelMethod.dBFS); ImageButton show_ctrls = (ImageButton) findViewById(R.id.show_ctrls); show_ctrls.setOnClickListener(new View.OnClickListener() { @Override//from w ww. j a v a 2 s . co m public void onClick(View view) { ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls); ctrls.showNext(); } }); ImageButton hide_ctrls = (ImageButton) findViewById(R.id.hide_ctrls); hide_ctrls.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls); ctrls.showPrevious(); } }); final SeekBar scaleCtrl = (SeekBar) findViewById(R.id.scaleCtrl); scaleCtrl.setProgress(pref.getInt("scaleCtrl", scaleCtrl.getProgress())); setScale(); scaleCtrl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { setScale(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); final ToggleButton onoff = (ToggleButton) findViewById(R.id.toggleButton); onoff.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (onoff.isChecked()) { if (!startit()) { onoff.setChecked(false); } } else { stopit(); } } }); LevelMethod levM = LevelMethod.valueOf(pref.getString("levelMethod", LevelMethod.dBFS.toString())); final Spinner levelType = (Spinner) findViewById(R.id.levelType); ArrayAdapter<LevelMethod> levelTypeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, LevelMethod.values()); levelType.setAdapter(levelTypeAdapter); levelType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { LevelMethod lmeth = (LevelMethod) adapterView.getSelectedItem(); levelMethodChanged(lmeth); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); levelType.setSelection(levelTypeAdapter.getPosition(levM)); levelMethodChanged((LevelMethod) levelType.getSelectedItem()); checkMicrophoneAccess(); }
From source file:de.measite.contactmerger.MergeActivity.java
public void updateList() { progressContainer = findViewById(R.id.progress_bar_container); progressBar = (ProgressBar) findViewById(R.id.analyze_progress); progressContainer.setVisibility(View.GONE); loadText = (TextView) findViewById(R.id.load_text); TextView stopScan = (TextView) findViewById(R.id.stop_scan); Typeface font = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf"); stopScan.setTypeface(font);// w ww . j a v a2 s .co m stopScan.setClickable(true); stopScan.setOnClickListener(this); startScan = (Button) findViewById(R.id.start_scan); startScan.setOnClickListener(this); ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.switcher); ViewSwitcher switcher_list = (ViewSwitcher) findViewById(R.id.switcher_list); Context context = getApplicationContext(); File path = context.getDatabasePath("contactsgraph"); File modelFile = new File(path, "model.kryo.gz"); if (path.exists() && modelFile.exists()) { this.adapter.update(); while (switcher.getCurrentView().getId() != R.id.switcher_list) { switcher.showNext(); } if (adapter.getCount() == 0) { while (switcher_list.getCurrentView().getId() != R.id.all_done) { switcher_list.showNext(); } } else { while (switcher_list.getCurrentView().getId() != R.id.contact_merge_list) { switcher_list.showPrevious(); } } switcher_list.postInvalidate(); } else { if (switcher.getCurrentView().getId() == R.id.contact_merge_list) { switcher.showPrevious(); } Intent intent = new Intent(getApplicationContext(), AnalyzerService.class); intent.putExtra("forceRunning", true); startService(intent); } switcher.postInvalidate(); }
From source file:de.baumann.thema.RequestActivity.java
@SuppressWarnings("unchecked") private void populateView(ArrayList arrayListFinal) { ArrayList<AppInfo> local_arrayList; local_arrayList = arrayListFinal;//from w w w. j a va2 s. c om 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(); } } } }); }