List of usage examples for android.widget ImageView invalidate
public void invalidate()
From source file:Main.java
/** * inject a image touch overley// w w w. j a v a 2 s . co m * @param v * @param event */ public static boolean imageOverlay(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // overlay is black with transparency of 0x77 (119) view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { // clear the overlay view.getDrawable().clearColorFilter(); view.invalidate(); break; } } return false; }
From source file:com.arlib.floatingsearchview.util.Util.java
public static void setIconColor(ImageView iconHolder, int color) { Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable()); DrawableCompat.setTint(wrappedDrawable, color); iconHolder.setImageDrawable(wrappedDrawable); iconHolder.invalidate(); }
From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java
@Override public void onClick(View v) { ImageView image = (ImageView) v; ((ImageView) v).getDrawable().clearColorFilter(); image.invalidate(); Integer index = (Integer) v.getTag(); Intent intent = SingleFragmentActivity.getIntent(getActivity(), SingleFragmentActivity.GALLERY); intent.putExtra(GalleryPagerFragment.CUR_INDEX, index); intent.putExtra(GalleryPagerFragment.URLS, mImageUrls); intent.putExtra(GalleryPagerFragment.TITLE, getString(R.string.view_photos)); startActivity(intent);//w w w .j a va 2 s.c om }
From source file:de.questmaster.fatremote.fragments.RemoteFragment.java
private void invokeSend() { // ring / vibrate if (!mSettings.isOverride() && mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM) != 0 || (mSettings.isOverride() && mSettings.isTone())) { mAudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK, 0.5f); }/* w w w. ja v a 2 s .c o m*/ if (mSettings.isVibrate()) { Vibrator vibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(25); } // Set sending image ImageView sending = (ImageView) c.findViewById(R.id.sendLED); sending.setImageResource(R.drawable.light_highlight); sending.invalidate(); // start sending NetworkProxy.getInstance(c).addRemoteEvent(new FATRemoteEvent(keyCode, keyModifier)); }
From source file:org.ciasaboark.tacere.activity.fragment.EventDetailsFragment.java
private void colorizeIcons() { HashMap<ImageView, RingerType> buttons = new HashMap<ImageView, RingerType>(); buttons.put((ImageView) view.findViewById(R.id.imageButtonNormal), RingerType.NORMAL); buttons.put((ImageView) view.findViewById(R.id.imageButtonVibrate), RingerType.VIBRATE); buttons.put((ImageView) view.findViewById(R.id.imageButtonSilent), RingerType.SILENT); buttons.put((ImageView) view.findViewById(R.id.imageButtonIgnore), RingerType.IGNORE); for (ImageView thisButton : buttons.keySet()) { thisButton.setImageDrawable(getColorizedIcon(buttons.get(thisButton))); thisButton.invalidate(); }/*from ww w . j a v a 2 s . c o m*/ }
From source file:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java
public void updateAutoUpdateView(boolean value) { ImageView icon = (ImageView) getView().findViewById(R.id.status_icon); icon.getDrawable().setAlpha((value ? 255 : 70)); icon.invalidate(); }
From source file:github.madmarty.madsonic.util.ImageLoader.java
public void loadAvatarImage(ImageView view, String username, boolean large, int size, boolean crossFade) { view.invalidate(); if (username == null) { // createUnknownAvatarImage(context); setUnknownAvatarImage(view);// w w w . j a v a 2s. c o m return; } if (size <= 0) { size = large ? imageSizeLarge : imageSizeDefault; } Bitmap bitmap = cache.get(getKey(username, size)); if (bitmap != null) { setAvatarImageBitmap(view, username, bitmap, crossFade); return; } setUnknownAvatarImage(view); queue.offer(new Task(view, username, size, imageSizeDefault, crossFade)); }
From source file:android.support.asy.image.ImageWorker.java
private void calculateImageViewHeight(String url, ImageView imageView) { String fileName = ((HotPotApplication) ((Activity) mContext).getApplication()) .getCacheImageAbsolutePath(url); final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;/* w ww. ja v a 2s . com*/ BitmapFactory.decodeFile(fileName, options); int width = options.outWidth; int height = options.outHeight; if (width != 0) { final int imageViewHeight = mScreenWidth * height / width; if (imageViewHeight != 0) { LayoutParams lp = imageView.getLayoutParams(); if (lp == null) { lp = new LayoutParams(mScreenWidth, imageViewHeight); imageView.setLayoutParams(lp); } else { lp.width = mScreenWidth; lp.height = imageViewHeight; } imageView.invalidate(); } } }
From source file:com.openerp.addons.messages.Message.java
private boolean markAsTodo(HashMap<Integer, Integer> msg_pos, final boolean flag) { boolean res = false; final int img[] = new int[] { R.drawable.ic_action_unstarred, R.drawable.ic_action_starred }; for (int key : msg_pos.keySet()) { final int pos = msg_pos.get(key); OEArgsHelper args = new OEArgsHelper(); args.addArg(key);/* w ww. j a v a 2s . c o m*/ if (markAsTodo(args, flag)) { listAdapter.updateRows(getRowForMessage(key), pos, "starred"); scope.context().runOnUiThread(new Runnable() { public void run() { ImageView imgStarred = (ImageView) lstview.getChildAt(pos) .findViewById(R.id.imgMessageStarred); imgStarred.setImageResource((flag) ? img[1] : img[0]); imgStarred.invalidate(); } }); } } return res; }
From source file:com.thingsee.tracker.MainActivity.java
@Override public void onMapReady(GoogleMap map) { mMap = map;//from w w w .j av a2 s . co m TileProvider wmsTileProvider = TileProviderFactory.getKapsiWmsTileProvider(); mMap.addTileOverlay(new TileOverlayOptions().tileProvider(wmsTileProvider).fadeIn(true)); initGoogleMap(); trackerList = (HorizontalScrollView) this.findViewById(R.id.tracker_scroll_area); mTrackerItemLayout = (LinearLayout) findViewById(R.id.trackers); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mainari, 16)); Marker mark = mMap.addMarker(new MarkerOptions().position(mainari)); ImageView locateButton = (ImageView) findViewById(R.id.app_icon); //set the ontouch listener locateButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: if (onChildOnMapView) { onUpPressed(); } else { userZoomAndPanOnMap = false; zoomToBoundingBox(); } case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); ImageView settingsButton = (ImageView) findViewById(R.id.header_settings_icon); //set the ontouch listener settingsButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; //overlay is black with transparency of 0x77 (119) view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: final Dialog verificationQuery = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar); verificationQuery.requestWindowFeature(Window.FEATURE_NO_TITLE); verificationQuery.setCancelable(false); verificationQuery.setContentView(R.layout.request_admin_code); ClearTextView ok = (ClearTextView) verificationQuery.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); EditText code = (EditText) verificationQuery.findViewById(R.id.verification_code); if (code.getText().toString().equalsIgnoreCase("password")) { Intent intent = new Intent(MainActivity.this, MenuActivity.class); startActivity(intent); } } }); ClearTextView cancel = (ClearTextView) verificationQuery.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); } }); verificationQuery.show(); verificationQuery.getWindow().setDimAmount(0.5f); verificationQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng position) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } }); mMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { if (trackersActive) { LatLng latlng = marker.getPosition(); userZoomAndPanOnMap = false; if ((latlng.latitude == mainari.latitude) && (latlng.longitude == mainari.longitude)) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } else { if (!onChildOnMapView) { trackerModelWithMarker = null; // Zoom to marker tapped zoomToMarker(latlng); //Remove other markers for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { focusOnChildOnMap(trackerModel.getSerialNumber()); trackerModelWithMarker = trackerModel; trackerModelWithMarker.getMarker().showInfoWindow(); } } } } else { trackerModelWithMarker.getMarker().showInfoWindow(); for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { onBackPressed(); } } } } } } return true; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { // Use default InfoWindow frame @Override public View getInfoWindow(Marker arg0) { return null; } // Defines the contents of the InfoWindow @Override public View getInfoContents(Marker arg0) { // Getting view from the layout file info_window_layout View v = null; for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == arg0.getPosition().latitude) && (trackerModel.getLatestLatLng().longitude == arg0.getPosition().longitude)) { v = getLayoutInflater().inflate(R.layout.info_window, null); trackerModelWithMarker = trackerModel; TextView trackerAccuracy = (TextView) v .findViewById(R.id.tracker_marker_popup_accuracy); if (trackerModelWithMarker.getAccuracy() != -1) { trackerAccuracy .setText(String.format(mResources.getString(R.string.tracker_accuracy), trackerModelWithMarker.getAccuracy())); } else { trackerAccuracy.setText( String.format(mResources.getString(R.string.tracker_accuracy), 0.0f)); } TextView trackerDistanceTs = (TextView) v .findViewById(R.id.tracker_marker_popup_update_timestamp); if (trackerModelWithMarker.getLastLocationUpdate() != 0) { String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, trackerModelWithMarker.getLastLocationUpdate()); trackerDistanceTs.setText( mResources.getString(R.string.tracker_timestamp) + " " + timeStampText); } else { trackerDistanceTs.setText(mResources.getString(R.string.tracker_timestamp) + " - "); } trackerInfoWindow = v; } } } // Returning the view containing InfoWindow contents return v; } }); IntentFilter statusIntentFilter = new IntentFilter(CommonConstants.BROADCAST_ACTION); statusIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); mFetchCloudDataStateReceiver = new FetchCloudDataStateReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(mFetchCloudDataStateReceiver, statusIntentFilter); mapLoaded = true; if (splashReady) { mSplashHandler.postDelayed(splashScreenOffFromDisplay, 0); } }