Example usage for android.os Message obtain

List of usage examples for android.os Message obtain

Introduction

In this page you can find the example usage for android.os Message obtain.

Prototype

public static Message obtain() 

Source Link

Document

Return a new Message instance from the global pool.

Usage

From source file:Main.java

private static void postAnimationMessage(final AnimationDrawable ani, final int what) {
    aniHandler.postDelayed(new Runnable() {

        public void run() {
            Message msg = Message.obtain();
            msg.what = what;//from  w  w w . j  a va2  s  .c o  m
            msg.obj = ani;
            aniHandler.sendMessage(msg);
        }
    }, 5);
}

From source file:Main.java

/**
 *
 * @param view//from ww  w .ja v a2 s  .c o m
 * @param duration
 */
public static void fadeOut(final View view, long duration) {
    Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(duration);

    animation.setFillAfter(true);
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            Message message = Message.obtain();
            message.obj = view;
            handler.sendMessage(message);
        }
    });

    view.startAnimation(animation);
}

From source file:ServiceConsumerActivity.java

public void queryService() {
    if (isBound) {
        Bundle bundle = new Bundle();
        bundle.putString("location", editText.getText().toString().trim());

        Message message = Message.obtain();
        message.replyTo = messengerFromService;
        message.setData(bundle);//from  w w  w  .  java  2s . c om
        try {
            messengerToService.send(message);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        textView.setText(R.string.report_appears_here);
        doToast(R.string.service_not_bound);
    }
}

From source file:org.lol.reddit.common.General.java

public static Message handlerMessage(int what, Object obj) {
    final Message msg = Message.obtain();
    msg.what = what;/* w  w  w.  j a v  a  2  s. c  o  m*/
    msg.obj = obj;
    return msg;
}

From source file:com.pansapiens.occyd.UrlFetch.java

public void fetch() {
    String response = "";
    Message msg = Message.obtain();
    msg.what = 0;/*ww  w .  j  a  v a  2  s . c  o  m*/
    msg.obj = "empty";
    try {

        // create an http client with a get request
        // for our url
        HttpClient httpClient = new DefaultHttpClient();
        HttpContext localContext = new BasicHttpContext();
        HttpGet httpGet = new HttpGet(url.toString());

        // set the User-Agent
        List<Header> headers = new ArrayList<Header>();
        headers.add(new BasicHeader("User-Agent", USER_AGENT));
        httpClient.getParams().setParameter(ClientPNames.DEFAULT_HEADERS, headers);

        // execute the request
        HttpResponse resp = httpClient.execute(httpGet, localContext);

        BufferedReader in = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
        String inputLine;

        response = "";
        while ((inputLine = in.readLine()) != null)
            response += inputLine;
        in.close();

        msg.what = 1;
        msg.obj = response;

    } catch (IOException e) {
        msg.what = 0;
        msg.obj = "io exception : " + url.toString();
    } finally {
        handler.sendMessage(msg);
    }
}

From source file:com.adeven.adjustio.RequestHandler.java

protected RequestHandler(PackageHandler packageHandler) {
    super(Constants.LOGTAG, MIN_PRIORITY);
    setDaemon(true);//from   w ww . j a  v a2  s  .  co m
    start();

    this.internalHandler = new InternalHandler(getLooper(), this);
    this.packageHandler = packageHandler;

    Message message = Message.obtain();
    message.arg1 = InternalHandler.INIT;
    internalHandler.sendMessage(message);
}

From source file:com.adjust.sdk.PackageHandler.java

public PackageHandler(ActivityHandler activityHandler, Context context, boolean dropOfflineActivities) {
    super(Constants.LOGTAG, MIN_PRIORITY);
    setDaemon(true);//from  www.j  av  a  2  s  . com
    start();
    this.internalHandler = new InternalHandler(getLooper(), this);
    this.logger = AdjustFactory.getLogger();

    this.activityHandler = activityHandler;
    this.context = context;
    this.dropOfflineActivities = dropOfflineActivities;

    Message message = Message.obtain();
    message.arg1 = InternalHandler.INIT;
    internalHandler.sendMessage(message);
}

From source file:com.adjust.sdk.RequestHandler.java

public RequestHandler(IPackageHandler packageHandler) {
    super(Constants.LOGTAG, MIN_PRIORITY);
    setDaemon(true);/*  www . jav a2s  .  co m*/
    start();

    this.logger = AdjustFactory.getLogger();
    this.internalHandler = new InternalHandler(getLooper(), this);
    this.packageHandler = packageHandler;

    Message message = Message.obtain();
    message.arg1 = InternalHandler.INIT;
    internalHandler.sendMessage(message);
}

From source file:com.adeven.adjustio.RequestHandler.java

protected void sendPackage(ActivityPackage pack) {
    Message message = Message.obtain();
    message.arg1 = InternalHandler.SEND;
    message.obj = pack;
    internalHandler.sendMessage(message);
}

From source file:com.adjust.sdk.RequestHandler.java

@Override
public void sendPackage(ActivityPackage pack) {
    Message message = Message.obtain();
    message.arg1 = InternalHandler.SEND;
    message.obj = pack;
    internalHandler.sendMessage(message);
}