Example usage for android.os Handler obtainMessage

List of usage examples for android.os Handler obtainMessage

Introduction

In this page you can find the example usage for android.os Handler obtainMessage.

Prototype

public final Message obtainMessage(int what, Object obj) 

Source Link

Document

Same as #obtainMessage() , except that it also sets the what and obj members of the returned Message.

Usage

From source file:io.github.mkjung.ivi.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(UPDATE_ITEM, mw).sendToTarget();
    }/*from  w  w  w  .  jav a  2  s  .  c om*/
}

From source file:co.uk.rehope.androidapp.DrawableManager.java

public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable((Drawable) drawableMap.get(urlString));
    }/*from www.  j a  va 2s  .  c  o  m*/

    final Handler handler = new Handler() {
        public void handleMessage(Message message) {
            imageView.setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            // TODO : set imageView to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:ac.robinson.mediaphone.activity.TemplateBrowserActivity.java

private void postUpdateTemplateIcons() {
    mPendingIconsUpdate = true;/*  ww w.  j ava  2  s .c  o  m*/
    Handler handler = mScrollHandler;
    handler.removeMessages(R.id.msg_update_template_icons);
    Message message = handler.obtainMessage(R.id.msg_update_template_icons, TemplateBrowserActivity.this);
    handler.sendMessage(message);
}

From source file:br.com.agendatech.cadastro.DrawableManager.java

public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable(drawableMap.get(urlString));
    }/*from www  .  ja  v a 2  s .  c om*/

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            imageView.setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.scott.crash.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  v  a 2s .c om*/

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            imageView.setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image 
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.example.hotelapp.DrawableManager.java

@SuppressLint("HandlerLeak")
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable(drawableMap.get(urlString));
    }//  w w w. j  av a2  s.c  om

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            imageView.setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.ferg.awful.async.DrawableManager.java

public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (urlString == null) {
        imageView.setImageDrawable(null);
        return;/*from  www  . ja  v a2s .co  m*/
    }

    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable(drawableMap.get(urlString));
    }

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            imageView.setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.github.bcfurtado.copaapp.util.DrawableManager.java

/**
 * Carrega a imagem a partir de uma url em uma thread separada da thread da interface.
 * @param urlString indica a url da imagem
 * @param imageView indica a imagemView a qual  imagem vai ser associada ao ser carregada.
 */// w  w w.j a v a2 s.  c om
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable(drawableMap.get(urlString));
    }

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            imageView.setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.example.prox.model.DrawableLoader.java

public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {

    imageViewReference = new WeakReference<ImageView>(imageView);

    if (drawableMap.containsKey(urlString)) {
        imageViewReference.get().setImageDrawable(drawableMap.get(urlString));
    }/*from  www  .j  av  a2s. c o m*/

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            imageViewReference.get().setImageDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}

From source file:com.wilson.android.library.DrawableManager.java

public void fetchDrawableOnThreadForListener(final String urlString, final DrawableManagerListener artItem) {
    if (drawableMap.containsKey(urlString)) {
        artItem.setFetchedDrawable(drawableMap.get(urlString));
    }// w  ww . ja  v a  2  s  .  co m

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            artItem.setFetchedDrawable((Drawable) message.obj);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set artItem to a "pending" image
            Drawable drawable = fetchDrawable(urlString);
            Message message = handler.obtainMessage(1, drawable);
            handler.sendMessage(message);
        }
    };
    thread.start();
}