List of usage examples for android.os Handler obtainMessage
public final Message obtainMessage(int what, Object obj)
From source file:Main.java
public static Long startDownload(DownloadManager dm, Handler handler, String location) { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(location)); Long id = dm.enqueue(request); handler.sendMessageDelayed(handler.obtainMessage(MSG_DOWNLOAD_TIMEOUT, id), DOWNLOAD_TIMEOUT_MILLIS); if (DEBUG)/*from w w w .ja v a 2 s . co m*/ Log.d(TAG, "Starting download: DownloadId=" + id); return id; }
From source file:net.cs76.projects.student10792819.DrawableManager.java
/** * Fetch drawable on thread. Fetches drawable on a separate thread. * * @param urlString the url string//from www . j av a 2 s . c o m * @param listingAdapter the listing adapter * @param thumbnailCache the image view * @param position the position */ public static void fetchDrawableOnThread(final String urlString, final ListingAdapter listingAdapter, final Drawable[] thumbnailCache, final int position) { if (drawableMap.containsKey(urlString)) { Drawable o = drawableMap.get(urlString).get(); if (o != null) { thumbnailCache[position] = o; listingAdapter.notifyDataSetChanged(); return; } } final Handler handler = new Handler() { @Override public void handleMessage(Message message) { thumbnailCache[position] = (Drawable) message.obj; listingAdapter.notifyDataSetChanged(); } }; Thread thread = new Thread() { @Override public void run() { Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:it.cdpaf.helper.DrawableManager.java
public static void fetchDrawableOnThread(final Category cat, final ImageView imageView, final Context ctx) { final String urlString = Const.IMAGE_URL + cat.getNomeImmagine(); if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); //product.setImmagine(drawableMap.get(urlString)); }/*from ww w.ja v a2s. c om*/ final Handler handler = new Handler() { @Override public void handleMessage(Message message) { Drawable dr = (Drawable) message.obj; imageView.setImageDrawable(dr); cat.setImmagine(dr); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable d = ctx.getResources().getDrawable(R.drawable.ic_launcher); Message messagea = handler.obtainMessage(1, d); handler.sendMessage(messagea); Drawable drawable = fetchDrawable(urlString, ctx); Message messageb = handler.obtainMessage(1, drawable); handler.sendMessage(messageb); } }; thread.start(); }
From source file:it.cdpaf.helper.DrawableManager.java
public static void fetchDrawableOnThread(final Macrocategory mac, final ImageView imageView, final Context ctx) { final String urlString = Const.IMAGE_URL + mac.getNomeImmagine(); if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); //product.setImmagine(drawableMap.get(urlString)); }//from w ww .j a v a 2s. c om final Handler handler = new Handler() { @Override public void handleMessage(Message message) { Drawable dr = (Drawable) message.obj; imageView.setImageDrawable(dr); mac.setImmagine(dr); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable d = ctx.getResources().getDrawable(R.drawable.ic_launcher); Message messagea = handler.obtainMessage(1, d); handler.sendMessage(messagea); Drawable drawable = fetchDrawable(urlString, ctx); Message messageb = handler.obtainMessage(1, drawable); handler.sendMessage(messageb); } }; thread.start(); }
From source file:it.cdpaf.helper.DrawableManager.java
public static void fetchDrawableOnThread(final Product product, final ImageView imageView, final Context ctx) { final String urlString = Const.IMAGE_URL + product.getPercorsoImmagine(); if (drawableMap.containsKey(urlString)) { Log.d(ctx.getClass().getSimpleName(), "DRAWABLE MANAGER FDOT:" + "RIUSO, Size:" + drawableMap.size()); imageView.setImageDrawable(drawableMap.get(urlString)); return;/*from www.j av a2 s. c o m*/ //product.setImmagine(drawableMap.get(urlString)); } final Handler handler = new Handler() { @Override public void handleMessage(Message message) { Drawable dr = (Drawable) message.obj; imageView.setImageDrawable(dr); product.setImmagine(dr); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable d = ctx.getResources().getDrawable(R.drawable.blank); Message messagea = handler.obtainMessage(1, d); handler.sendMessage(messagea); Drawable drawable = fetchDrawable(urlString, ctx); Message messageb = handler.obtainMessage(1, drawable); handler.sendMessage(messageb); } }; Log.i("DRAWABLE MANAGER:", "LANCIO FDOT, Size:" + drawableMap.size()); thread.start(); }
From source file:it.cdpaf.helper.DrawableManager.java
public static ImageView fetchIvOnThread(String imagepath, int nthImage, final Context ctx) { final String urlString = Const.IMAGE_URL + imagepath; final Drawable resultDrawable; final ImageView imageView = new ImageView(ctx); String urlStringValid = ""; if (nthImage == 0) urlStringValid = urlString;/*from www.java 2 s . c o m*/ else { String url = urlString + "_" + nthImage; String[] result = urlString.split(".j"); String prima = result[0]; String seconda = result[1]; String jpg = ".j" + seconda; urlStringValid = prima + "_" + nthImage + jpg; } final String finalURl = urlStringValid; if (drawableMap.containsKey(urlStringValid)) { Log.d("ALL DRAWABLE", "INDIVIDUATO UN RIUSO : " + urlStringValid); resultDrawable = (drawableMap.get(urlStringValid)); imageView.setImageDrawable(resultDrawable); } else { final Handler handler = new Handler() { @Override public void handleMessage(Message message) { Drawable resDrawable = ((Drawable) message.obj); imageView.setImageDrawable(resDrawable); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable drawable = fetchDrawable(finalURl, ctx); Message messageb = handler.obtainMessage(1, drawable); handler.sendMessage(messageb); } }; Log.d("ALL DRAWABLE", "LANCIO UNA RICERCA : " + finalURl); thread.start(); } return imageView; }
From source file:com.example.hotspot.DrawableManager.java
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); }//from w ww. j a va2 s .c om final Handler handler = new Handler() { public void handleMessage(Message message) { imageView.setImageDrawable((Drawable) message.obj); } }; Thread thread = new Thread() { @Override public void run() { Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:com.novel.lightnovel.Utils.DrawableManager.java
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); }/* ww w . j av a 2s .c o m*/ final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageView.setImageDrawable((Drawable) message.obj); } }; Thread thread = new Thread() { @Override public void run() { Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:com.swavdev.tc.DrawableManager.java
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); }/*ww w . j a va 2s .c om*/ final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageView.setImageDrawable((Drawable) message.obj); } }; executorService.submit(new Thread() { @Override public void run() { Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }); }
From source file:org.videolan.vlc.media.MediaLibrary.java
private void notifyMediaUpdated(MediaWrapper mw) { // update the video and audio activities for (int i = 0; i < mUpdateHandler.size(); i++) { Handler h = mUpdateHandler.get(i); h.obtainMessage(0, mw).sendToTarget(); }//from w w w .j a v a2 s . c om }