List of usage examples for android.view View invalidate
public void invalidate()
From source file:net.xisberto.work_schedule.alarm.AlarmMessageActivity.java
@Override public boolean onTouch(View view, MotionEvent event) { if (event.getPointerCount() > 1) { return super.onTouchEvent(event); }/*from w w w . j a va 2 s .co m*/ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams(); int action = MotionEventCompat.getActionMasked(event); if (view.getId() == R.id.frame_bottom || view.getId() == R.id.frame_top) { switch (action) { case MotionEvent.ACTION_DOWN: initialPoint = event.getRawY(); moving = true; break; case MotionEvent.ACTION_MOVE: if (moving) { hinter.interrupt(); currentPoint = event.getRawY(); DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int screenHeight = displayMetrics.heightPixels; if (view.getId() == R.id.frame_top) { int new_margin = (int) (currentPoint - initialPoint); params.topMargin = (new_margin > 0) ? new_margin : 0; if ((new_margin > (screenHeight / 3)) && (!isFinishing())) { snoozeAlarm(); break; } } else { int new_margin = (int) (initialPoint - currentPoint); params.bottomMargin = (new_margin > 0) ? new_margin : 0; if ((new_margin > (screenHeight / 3)) && (!isFinishing())) { cancelAlarm(); break; } } view.setLayoutParams(params); view.invalidate(); } break; case MotionEvent.ACTION_UP: initialPoint = 0; TranslateAnimation ta; if (view.getId() == R.id.frame_top) { ta = new TranslateAnimation(0, 0, params.topMargin, 0); params.topMargin = 0; } else { ta = new TranslateAnimation(0, 0, -params.bottomMargin, 0); params.bottomMargin = 0; } ta.setDuration(100); view.setLayoutParams(params); view.startAnimation(ta); moving = false; startHinter(); break; default: return super.onTouchEvent(event); } } return true; }
From source file:org.thoughtland.xlocation.ActivityShare.java
private void blueStreakOfProgress(Integer current, Integer max) { // Set up the progress bar if (mProgressWidth == 0) { final View vShareProgressEmpty = (View) findViewById(R.id.vShareProgressEmpty); mProgressWidth = vShareProgressEmpty.getMeasuredWidth(); }/*from www . ja va 2 s . c om*/ // Display stuff if (max == 0) max = 1; int width = (int) ((float) mProgressWidth) * current / max; View vShareProgressFull = (View) findViewById(R.id.vShareProgressFull); vShareProgressFull.getLayoutParams().width = width; vShareProgressFull.invalidate(); vShareProgressFull.requestLayout(); }
From source file:com.google.appinventor.components.runtime.Form.java
private void setBackground(View bgview) { Drawable setDraw = backgroundDrawable; if (backgroundImagePath != "" && setDraw != null) { setDraw = backgroundDrawable.getConstantState().newDrawable(); setDraw.setColorFilter(/*from w ww .j a v a2 s . c om*/ (backgroundColor != Component.COLOR_DEFAULT) ? backgroundColor : Component.COLOR_WHITE, PorterDuff.Mode.DST_OVER); } else { setDraw = new ColorDrawable( (backgroundColor != Component.COLOR_DEFAULT) ? backgroundColor : Component.COLOR_WHITE); } ViewUtil.setBackgroundImage(bgview, setDraw); bgview.invalidate(); }
From source file:com.svpino.longhorn.fragments.StockListFragment.java
private void swapTiles(View tile1, View tile2) { StockTileViewHolder stockTileViewHolder1 = (StockTileViewHolder) tile1.getTag(); StockTileViewHolder stockTileViewHolder2 = (StockTileViewHolder) tile2.getTag(); this.callback.reorderStocks(stockTileViewHolder1.getStock(), stockTileViewHolder2.getStock()); this.selectedTiles.remove((Integer) stockTileViewHolder1.getPosition()); this.selectedTiles.remove((Integer) stockTileViewHolder2.getPosition()); updateContextualActionBar();//w ww . j av a2 s.c o m Stock tempStock = stockTileViewHolder1.getStock(); stockTileViewHolder1.setStock(stockTileViewHolder2.getStock()); stockTileViewHolder2.setStock(tempStock); tile1.setTag(stockTileViewHolder1); tile2.setTag(stockTileViewHolder2); this.tiles.remove(stockTileViewHolder1.getPosition()); this.tiles.remove(stockTileViewHolder2.getPosition()); this.tiles.put(stockTileViewHolder1.getPosition(), tile1); this.tiles.put(stockTileViewHolder2.getPosition(), tile2); stockTileViewHolder1.refresh(getResources()); stockTileViewHolder2.refresh(getResources()); tile1.setVisibility(View.VISIBLE); tile2.setVisibility(View.VISIBLE); tile1.invalidate(); tile2.invalidate(); }
From source file:org.path.episample.android.activities.MainMenuActivity.java
public void swapToFragmentView(ScreenList newFragment) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView: " + newFragment.toString()); String get = PropertiesSingleton.getProperty("survey", AdminPreferencesActivity.KEY_TURN_ON_OFF_WIFI_AUTOMATICALLY); if (!(get != null && get.equalsIgnoreCase("false"))) { if (mWifiManager.isWifiEnabled() && mWifiManager.getWifiState() != WifiManager.WIFI_STATE_DISABLED) { mWifiManager.setWifiEnabled(false); }/*from w w w. j a v a 2 s.c o m*/ } FragmentManager mgr = getFragmentManager(); Fragment f; if (newFragment == ScreenList.MAIN_SCREEN) { throw new IllegalStateException("unexpected reference to generic main screen"); } else if (newFragment == ScreenList.CUSTOM_VIEW) { WebLogger.getLogger(getAppName()).w(t, "swapToFragmentView: changing navigation to move to WebKit (was custom view)"); f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } newFragment = ScreenList.WEBKIT; } else if (newFragment == ScreenList.MAIN_MENU) { f = mgr.findFragmentById(MainMenuFragment.ID); if (f == null) { f = new MainMenuFragment(); } } else if (newFragment == ScreenList.COLLECT_MODULE) { f = mgr.findFragmentById(CollectFragment.ID); if (f == null) { f = new CollectFragment(); } } else if (newFragment == ScreenList.SEND_RECEIVE_WIFI_DIRECT_MODULE) { f = mgr.findFragmentById(SendReceiveFragment.ID); if (f == null) { f = new SendReceiveFragment(); } } /*else if (newFragment == ScreenList.SEND_RECEIVE_BLUETOOTH_MODULE) { f = mgr.findFragmentById(SendReceiveFragmentBT.ID); if (f == null) { f = new SendReceiveFragmentBT(); } }*/ else if (newFragment == ScreenList.SELECT_MODULE) { f = mgr.findFragmentById(SelectFragment.ID); if (f == null) { f = new SelectFragment(); } } else if (newFragment == ScreenList.NAVIGATE_MODULE) { f = mgr.findFragmentById(NavigateFragment.ID); if (f == null) { f = new NavigateFragment(); } } else if (newFragment == ScreenList.RESTORE_MODULE) { f = mgr.findFragmentById(RestoreFragment.ID); if (f == null) { f = new RestoreFragment(); } } else if (newFragment == ScreenList.EDIT_CENSUS_MODULE) { f = mgr.findFragmentById(EditCensusFragment.ID); if (f == null) { f = new EditCensusFragment(); } } else if (newFragment == ScreenList.REMOVE_CENSUS_MODULE) { f = mgr.findFragmentById(RemoveCensusFragment.ID); if (f == null) { f = new RemoveCensusFragment(); } } else if (newFragment == ScreenList.INVALIDATE_CENSUS_MODULE) { f = mgr.findFragmentById(InvalidateCensusFragment.ID); if (f == null) { f = new InvalidateCensusFragment(); } } else if (newFragment == ScreenList.FORM_CHOOSER) { f = mgr.findFragmentById(FormChooserListFragment.ID); if (f == null) { f = new FormChooserListFragment(); } } else if (newFragment == ScreenList.INITIALIZATION_DIALOG) { if (currentFragment == ScreenList.INITIALIZATION_DIALOG) { WebLogger.getLogger(getAppName()).e(t, "Unexpected: currentFragment == INITIALIZATION_DIALOG"); return; } else { f = mgr.findFragmentById(InitializationFragment.ID); if (f == null) { f = new InitializationFragment(); } ((InitializationFragment) f).setFragmentToShowNext( (currentFragment == null) ? ScreenList.FORM_CHOOSER.name() : currentFragment.name()); } } else if (newFragment == ScreenList.FORM_DELETER) { f = mgr.findFragmentById(FormDeleteListFragment.ID); if (f == null) { f = new FormDeleteListFragment(); } } else if (newFragment == ScreenList.FORM_DOWNLOADER) { f = mgr.findFragmentById(FormDownloadListFragment.ID); if (f == null) { f = new FormDownloadListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER) { f = mgr.findFragmentById(InstanceUploaderTableChooserListFragment.ID); if (f == null) { f = new InstanceUploaderTableChooserListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER) { f = mgr.findFragmentById(InstanceUploaderListFragment.ID); if (f == null) { f = new InstanceUploaderListFragment(); } ((InstanceUploaderListFragment) f).changeUploadTableId(); } else if (newFragment == ScreenList.WEBKIT) { f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } } else if (newFragment == ScreenList.ABOUT_MENU) { f = mgr.findFragmentById(AboutMenuFragment.ID); if (f == null) { f = new AboutMenuFragment(); } } else { throw new IllegalStateException("Unrecognized ScreenList type"); } FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); View wkt = findViewById(R.id.webkit_view); shadow.setVisibility(View.GONE); shadow.removeAllViews(); if (newFragment == ScreenList.WEBKIT) { frags.setVisibility(View.GONE); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); } else { wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } currentFragment = newFragment; BackStackEntry entry = null; for (int i = 0; i < mgr.getBackStackEntryCount(); ++i) { BackStackEntry e = mgr.getBackStackEntryAt(i); if (e.getName().equals(currentFragment.name())) { entry = e; break; } } if (entry != null) { // flush backward, including the screen want to go back to mgr.popBackStackImmediate(currentFragment.name(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } // add transaction to show the screen we want FragmentTransaction trans = mgr.beginTransaction(); trans.replace(R.id.main_content, f); trans.addToBackStack(currentFragment.name()); trans.commit(); // and see if we should re-initialize... if ((currentFragment != ScreenList.INITIALIZATION_DIALOG) && Survey.getInstance().shouldRunInitializationTask(getAppName())) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView -- calling clearRunInitializationTask"); // and immediately clear the should-run flag... Survey.getInstance().clearRunInitializationTask(getAppName()); // OK we should swap to the InitializationFragment view swapToFragmentView(ScreenList.INITIALIZATION_DIALOG); } else { levelSafeInvalidateOptionsMenu(); } }
From source file:at.alladin.rmbt.android.views.ResultQoSDetailView.java
@SuppressWarnings("unchecked") @Override//ww w. j a va 2 s .co m public void taskEnded(JSONArray result) { System.out.println("ResultQoSDetail taskEnded"); this.testResult = result; if (resultFetchEndTaskListener != null) { resultFetchEndTaskListener.taskEnded(result); } ProgressBar resultProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar); TextView resultTextView = (TextView) view.findViewById(R.id.info_text); try { results = new QoSServerResultCollection(result); View successList = view.findViewById(R.id.qos_success_list); List<HashMap<String, String>> itemList = new ArrayList<HashMap<String, String>>(); int index = 0; for (QoSTestResultEnum type : QoSTestResultEnum.values()) { if (results.getQoSStatistics().getTestCounter(type) > 0) { HashMap<String, String> listItem = new HashMap<String, String>(); listItem.put("name", ConfigHelper.getCachedQoSNameByTestType(type, activity)); listItem.put("type_name", type.toString()); listItem.put("index", String.valueOf(index++)); itemList.add(listItem); } } ListAdapter valueList = new SimpleAdapter(activity, itemList, R.layout.qos_category_list_item, new String[] { "name" }, new int[] { R.id.name }); resultProgressBar.setVisibility(View.GONE); if (valueList.getCount() > 0) { //in case the view will change again: if (ListView.class.isAssignableFrom(successList.getClass())) { ((ListView) successList).setAdapter(valueList); ((ListView) successList).setOnItemClickListener(this); } else { ViewGroup vgList = (ViewGroup) successList; for (int i = 0; i < valueList.getCount(); i++) { View v = valueList.getView(i, null, null); QoSTestResultEnum key = QoSTestResultEnum .valueOf(((HashMap<String, String>) valueList.getItem(i)).get("type_name")); if (results.getQoSStatistics().getFailureCounter(key) > 0) { ImageView img = (ImageView) v.findViewById(R.id.status); img.setImageResource(R.drawable.traffic_lights_red); } TextView status = (TextView) v.findViewById(R.id.qos_type_status); status.setText((results.getQoSStatistics().getTestCounter(key) - results.getQoSStatistics().getFailedTestsCounter(key)) + "/" + results.getQoSStatistics().getTestCounter(key)); v.setOnClickListener(this); v.setTag(valueList.getItem(i)); vgList.addView(v); } } successList.invalidate(); resultTextView.setVisibility(View.GONE); successList.setVisibility(View.VISIBLE); } else { resultTextView.setText(R.string.result_qos_error_no_data_available); } } catch (Throwable t) { resultTextView.setText(R.string.result_qos_error_no_data_available); resultProgressBar.setVisibility(View.GONE); t.printStackTrace(); } }
From source file:com.android.leanlauncher.Workspace.java
void updateShortcuts(ArrayList<ShortcutInfo> shortcuts) { final HashSet<ShortcutInfo> updates = new HashSet<ShortcutInfo>(shortcuts); mapOverItems(MAP_RECURSE, new ItemOperator() { @Override//from ww w . j ava2 s .c o m public boolean evaluate(ItemInfo info, View v, View parent) { if (info instanceof ShortcutInfo && v instanceof BubbleTextView && updates.contains(info)) { ShortcutInfo si = (ShortcutInfo) info; BubbleTextView shortcut = (BubbleTextView) v; shortcut.applyFromShortcutInfo(si, mIconCache, true, true); if (parent != null) { parent.invalidate(); } } // process all the shortcuts return false; } }); }
From source file:com.android.leanlauncher.Workspace.java
public void disableShortcutsByPackageName(final ArrayList<String> packages, final UserHandleCompat user, final int reason) { final HashSet<String> packageNames = new HashSet<String>(); packageNames.addAll(packages);/* w ww. ja va2 s. c o m*/ mapOverItems(MAP_RECURSE, new ItemOperator() { @Override public boolean evaluate(ItemInfo info, View v, View parent) { if (info instanceof ShortcutInfo && v instanceof BubbleTextView) { ShortcutInfo shortcutInfo = (ShortcutInfo) info; ComponentName cn = shortcutInfo.getTargetComponent(); if (user.equals(shortcutInfo.user) && cn != null && packageNames.contains(cn.getPackageName())) { shortcutInfo.isDisabled |= reason; BubbleTextView shortcut = (BubbleTextView) v; shortcut.applyFromShortcutInfo(shortcutInfo, mIconCache, true, true); if (parent != null) { parent.invalidate(); } } } // process all the shortcuts return false; } }); }