List of usage examples for android.widget ImageView getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:cn.com.wo.bitmap.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w w w.j a va 2 s .c o m * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable, boolean isBackground) { if (mFadeInBitmap && !isBackground) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap int index = 0; if (imageView.getTag() != null) index = (Integer) imageView.getTag(); imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap[index])); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); if (ImageFetcher.isDebug) Log.i(ImageFetcher.TAG, "setImageDrawable src"); } else { if (isBackground) { if (ImageFetcher.isDebug) Log.i(ImageFetcher.TAG, "setImageDrawable isBackground"); imageView.setBackgroundDrawable(null); imageView.setBackgroundDrawable(drawable); } else { if (ImageFetcher.isDebug) Log.i(ImageFetcher.TAG, "setImageDrawable src"); imageView.setImageDrawable(drawable); } } }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
private static BitmapLoaderTask getBitmapLoaderTask(ImageView imageView) { if (imageView != null) { final Object loaderTaskHolder = imageView.getTag(); if (loaderTaskHolder instanceof BitmapLoaderHolder) { final BitmapLoaderHolder asyncDrawable = (BitmapLoaderHolder) loaderTaskHolder; return asyncDrawable.getBitmapWorkerTask(); }/* w w w . j a v a 2s .co m*/ } return null; }
From source file:com.channelsoft.common.bitmapUtil.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView/*from ww w . j a v a 2 s. c om*/ * @param bitmap */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if ("0".equals(imageView.getTag())) { // ?? bitmap = toGrayscale(bitmap); } if (mFadeInBitmap) { // Transition drawable with a transparent drwabale and the final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); // Set background to loading bitmap //TODO: miaolikui delete 20121229 // imageView.setBackgroundDrawable( // new BitmapDrawable(mResources, mLoadingBitmap)); Log.d(TAG, tagStr + ":imageView.setImageDrawable:" + System.currentTimeMillis()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { Log.d(TAG, tagStr + ":imageView.setImageBitmap:" + System.currentTimeMillis()); imageView.setImageBitmap(bitmap); } }
From source file:org.openbmap.activities.MapViewActivity.java
/** * Draws arrow in direction of travel. If bearing is unavailable a generic position symbol is used. * If another refresh is taking place, update is skipped *//* w w w . j a v a 2 s . c om*/ private void refreshCompass(final Location location) { if (location == null) { return; } // ensure that previous refresh has been finished if (mRefreshDirectionPending) { return; } mRefreshDirectionPending = true; // determine which drawable we currently final ImageView iv = (ImageView) getView().findViewById(R.id.position_marker); final Integer id = (Integer) iv.getTag() == null ? 0 : (Integer) iv.getTag(); if (location.hasBearing()) { // determine which drawable we currently use drawCompass(iv, id, location.getBearing()); } else { // refresh only if needed if (id != R.drawable.cross) { iv.setImageResource(R.drawable.cross); } //Log.i(TAG, "Can't draw direction marker: no bearing provided"); } mRefreshDirectionPending = false; }
From source file:de.grobox.liberario.DirectionsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // remember view for UI changes when fragment is not active mView = inflater.inflate(R.layout.fragment_directions, container, false); locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); checkPreferences();//from www . j a v a 2 s . c o m setFromUI(); setToUI(); // timeView final Button timeView = (Button) mView.findViewById(R.id.timeView); timeView.setText(DateUtils.getcurrentTime(getActivity())); timeView.setTag(Calendar.getInstance()); timeView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showTimePickerDialog(); } }); // set current time on long click timeView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { timeView.setText(DateUtils.getcurrentTime(getActivity())); timeView.setTag(Calendar.getInstance()); return true; } }); Button plus10Button = (Button) mView.findViewById(R.id.plus15Button); plus10Button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { addToTime(15); } }); // dateView final Button dateView = (Button) mView.findViewById(R.id.dateView); dateView.setText(DateUtils.getcurrentDate(getActivity())); dateView.setTag(Calendar.getInstance()); dateView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDatePickerDialog(); } }); // set current date on long click dateView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { dateView.setText(DateUtils.getcurrentDate(getActivity())); dateView.setTag(Calendar.getInstance()); return true; } }); // Trip Date Type Spinner (departure or arrival) final TextView dateType = (TextView) mView.findViewById(R.id.dateType); dateType.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (dateType.getText().equals(getString(R.string.trip_dep))) { dateType.setText(getString(R.string.trip_arr)); } else { dateType.setText(getString(R.string.trip_dep)); } } }); // Products final ViewGroup productsLayout = (ViewGroup) mView.findViewById(R.id.productsLayout); for (int i = 0; i < productsLayout.getChildCount(); ++i) { final ImageView productView = (ImageView) productsLayout.getChildAt(i); final Product product = Product.fromCode(productView.getTag().toString().charAt(0)); // make inactive products gray if (mProducts.contains(product)) { productView.getDrawable().setColorFilter(null); } else { productView.getDrawable().setColorFilter(getResources().getColor(R.color.highlight), PorterDuff.Mode.SRC_ATOP); } // handle click on product icon productView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (mProducts.contains(product)) { productView.getDrawable().setColorFilter(getResources().getColor(R.color.highlight), PorterDuff.Mode.SRC_ATOP); mProducts.remove(product); Toast.makeText(v.getContext(), LiberarioUtils.productToString(v.getContext(), product), Toast.LENGTH_SHORT).show(); } else { productView.getDrawable().setColorFilter(null); mProducts.add(product); Toast.makeText(v.getContext(), LiberarioUtils.productToString(v.getContext(), product), Toast.LENGTH_SHORT).show(); } } }); // handle long click on product icon by showing product name productView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { Toast.makeText(view.getContext(), LiberarioUtils.productToString(view.getContext(), product), Toast.LENGTH_SHORT).show(); return true; } }); } if (!Preferences.getPref(getActivity(), Preferences.SHOW_ADV_DIRECTIONS)) { (mView.findViewById(R.id.productsScrollView)).setVisibility(View.GONE); } Button searchButton = (Button) mView.findViewById(R.id.searchButton); searchButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { NetworkProvider np = NetworkProviderFactory.provider(Preferences.getNetworkId(getActivity())); if (!np.hasCapabilities(NetworkProvider.Capability.TRIPS)) { Toast.makeText(v.getContext(), v.getContext().getString(R.string.error_no_trips_capability), Toast.LENGTH_SHORT).show(); return; } AsyncQueryTripsTask query_trips = new AsyncQueryTripsTask(v.getContext()); // check and set to location if (checkLocation(FavLocation.LOC_TYPE.TO)) { query_trips.setTo(getLocation(FavLocation.LOC_TYPE.TO)); } else { Toast.makeText(getActivity(), getResources().getString(R.string.error_invalid_to), Toast.LENGTH_SHORT).show(); return; } // check and set from location if (mGpsPressed) { if (getLocation(FavLocation.LOC_TYPE.FROM) != null) { query_trips.setFrom(getLocation(FavLocation.LOC_TYPE.FROM)); } else { mAfterGpsTask = query_trips; pd = new ProgressDialog(getActivity()); pd.setMessage(getResources().getString(R.string.stations_searching_position)); pd.setCancelable(false); pd.setIndeterminate(true); pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mAfterGpsTask = null; dialog.dismiss(); } }); pd.show(); } } else { if (checkLocation(FavLocation.LOC_TYPE.FROM)) { query_trips.setFrom(getLocation(FavLocation.LOC_TYPE.FROM)); } else { Toast.makeText(getActivity(), getString(R.string.error_invalid_from), Toast.LENGTH_SHORT) .show(); return; } } // remember trip if not from GPS if (!mGpsPressed) { FavDB.updateFavTrip(getActivity(), new FavTrip(getLocation(FavLocation.LOC_TYPE.FROM), getLocation(FavLocation.LOC_TYPE.TO))); } // set date query_trips.setDate(DateUtils.mergeDateTime(getActivity(), dateView.getText(), timeView.getText())); // set departure to true of first item is selected in spinner query_trips.setDeparture(dateType.getText().equals(getString(R.string.trip_dep))); // set products query_trips.setProducts(mProducts); // don't execute if we still have to wait for GPS position if (mAfterGpsTask != null) return; query_trips.execute(); } }); return mView; }
From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java
private View getColorImageView(int color) { final ImageView imageView = new ImageView(this); int width = EUExUtil.dipToPixels(32); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, width); int margin = EUExUtil.dipToPixels(4); lp.leftMargin = margin;//from ww w . j av a2s. c o m lp.rightMargin = margin; imageView.setLayoutParams(lp); imageView.setTag(color); GradientDrawable colorDrawable = new GradientDrawable(); colorDrawable.setColor(color); colorDrawable.setCornerRadius(8); if (Build.VERSION.SDK_INT < 16) { imageView.setBackgroundDrawable(colorDrawable); } else { imageView.setBackground(colorDrawable); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCurrnetColor = (int) imageView.getTag(); mScrawlImageView.setPaintColor(mCurrnetColor); mPreviewView.setColor(mCurrnetColor); } }); return imageView; }
From source file:com.eutectoid.dosomething.picker.GraphObjectAdapter.java
private void downloadProfilePicture(final String profileId, Uri pictureUri, final ImageView imageView) { if (pictureUri == null) { return;// w w w. j ava2s. c o m } // If we don't have an imageView, we are pre-fetching this image to store in-memory because we // think the user might scroll to its corresponding list row. If we do have an imageView, we // only want to queue a download if the view's tag isn't already set to the URL (which would mean // it's already got the correct picture). boolean prefetching = imageView == null; if (prefetching || !pictureUri.equals(imageView.getTag())) { if (!prefetching) { // Setting the tag to the profile ID indicates that we're currently downloading the // picture for this profile; we'll set it to the actual picture URL when complete. imageView.setTag(profileId); imageView.setImageResource(getDefaultPicture()); } ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureUri) .setCallerTag(this).setCallback(new ImageRequest.Callback() { @Override public void onCompleted(ImageResponse response) { processImageResponse(response, profileId, imageView); } }); ImageRequest newRequest = builder.build(); pendingRequests.put(profileId, newRequest); ImageDownloader.downloadAsync(newRequest); } }
From source file:com.trk.aboutme.facebook.widget.GraphObjectAdapter.java
private void downloadProfilePicture(final String profileId, URL pictureURL, final ImageView imageView) { if (pictureURL == null) { return;/*from w w w .j ava 2s. co m*/ } // If we don't have an imageView, we are pre-fetching this image to store in-memory because we // think the user might scroll to its corresponding list row. If we do have an imageView, we // only want to queue a download if the view's tag isn't already set to the URL (which would mean // it's already got the correct picture). boolean prefetching = imageView == null; if (prefetching || !pictureURL.equals(imageView.getTag())) { if (!prefetching) { // Setting the tag to the profile ID indicates that we're currently downloading the // picture for this profile; we'll set it to the actual picture URL when complete. imageView.setTag(profileId); imageView.setImageResource(getDefaultPicture()); } ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURL) .setCallerTag(this).setCallback(new ImageRequest.Callback() { @Override public void onCompleted(ImageResponse response) { processImageResponse(response, profileId, imageView); } }); ImageRequest newRequest = builder.build(); pendingRequests.put(profileId, newRequest); ImageDownloader.downloadAsync(newRequest); } }
From source file:com.facebook.widget.GraphObjectAdapter.java
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) { if (pictureURI == null) { return;/* ww w . ja v a2 s .c o m*/ } // If we don't have an imageView, we are pre-fetching this image to store in-memory because we // think the user might scroll to its corresponding list row. If we do have an imageView, we // only want to queue a download if the view's tag isn't already set to the URL (which would mean // it's already got the correct picture). boolean prefetching = imageView == null; if (prefetching || !pictureURI.equals(imageView.getTag())) { if (!prefetching) { // Setting the tag to the profile ID indicates that we're currently downloading the // picture for this profile; we'll set it to the actual picture URL when complete. imageView.setTag(profileId); imageView.setImageResource(getDefaultPicture()); } ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI) .setCallerTag(this).setCallback(new ImageRequest.Callback() { @Override public void onCompleted(ImageResponse response) { processImageResponse(response, profileId, imageView); } }); ImageRequest newRequest = builder.build(); pendingRequests.put(profileId, newRequest); ImageDownloader.downloadAsync(newRequest); } }
From source file:com.hybris.mobile.lib.http.manager.volley.VolleyPersistenceManager.java
@Override public void setImageFromUrl(final String url, final String requestId, final ImageView imageView, final OnRequestListener onRequestListener, final boolean forceImageTagToMatchRequestId) { if (onRequestListener != null) { onRequestListener.beforeRequest(); }/*from www . j a v a 2s.c o m*/ mImageLoader.get(url, new ImageListener() { @Override public void onErrorResponse(VolleyError error) { Log.e(TAG, "Error loading the image for url \"" + url + "\". " + error.getLocalizedMessage()); if (onRequestListener != null) { onRequestListener.afterRequest(false); } } @Override public void onResponse(ImageContainer response, boolean arg1) { if (response.getBitmap() != null && imageView != null) { boolean loadImage = true; if (forceImageTagToMatchRequestId && imageView.getTag() != null && !StringUtils.equals(requestId, imageView.getTag().toString())) { loadImage = false; } if (loadImage) { imageView.setImageBitmap(response.getBitmap()); } if (onRequestListener != null) { onRequestListener.afterRequest(true); } } } }); }