Example usage for android.os Message Message

List of usage examples for android.os Message Message

Introduction

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

Prototype

public Message() 

Source Link

Document

Constructor (but the preferred way to get a Message is to call #obtain() Message.obtain() ).

Usage

From source file:com.ty.highway.highwaysystem.ui.activity.basic.BaseActivity.java

public void sendMessage(int flag, int progress) {
    Message message = new Message();
    message.obj = progress;//  ww w  .j a v a2s .  c  om
    message.what = flag;
    handler.sendMessage(message);
}

From source file:com.xpg.gokit.activity.GokitControlActivity.java

public boolean onReceiveData(String data) {
    Log.i("info", data);
    // isInitFinish = false;
    Message msg = new Message();
    msg.obj = data;//from   ww  w . ja va  2  s  . c o  m
    msg.what = RESP;
    handler.sendMessage(msg);

    return true;
}

From source file:br.com.anteros.android.synchronism.view.AbstractSynchronismFragment.java

protected void showError(String errorMessage) {
    anSyncronism.stop();/*w  w  w.j  a  v a  2  s. com*/
    LOG.error(errorMessage);

    Message msg = new Message();
    msg.obj = errorMessage + "";

    showErrorHandler.sendMessage(msg);
}

From source file:de.ribeiro.android.gso.activities.PlanActivity.java

@Override
protected void onResume() {
    super.onResume();

    if (ctxt.appIsReady) {
        ctxt.mIsRunning = true;//from   w  w  w.  j  ava2 s .  c o  m
        ctxt.initViewPagerWaiting();
        LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
        lbm.registerReceiver(mMessageReceiver, new IntentFilter(Const.BROADCASTREFRESH));
        Message msg = new Message();
        msg.arg1 = Activity.RESULT_OK;
        ctxt.msgHandler.handleMessage(msg);
    }
}

From source file:net.evecom.android.log.DailyLogAddActivity.java

/**
 * //w ww .  ja v a 2 s  . co  m
 */
private void formSubmit() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Message msg_listData = new Message();
                String a = HttpUtil.BASE_URL + "teventAndroid/saveDailyLogAndroid";
                String b = "areaId=" + ShareUtil.getString(getApplicationContext(), "SESSION", "AREAID", "0")
                        + "&personid=" + ShareUtil.getString(getApplicationContext(), "SESSION", "EMPID", "1")
                        + "&personname="
                        + ShareUtil.getString(getApplicationContext(), "SESSION", "EMPNAME", "")
                        + "&personLoggin.ATTA1=" + btEditText.getText().toString().trim()
                        + "&personLoggin.LOGTYPE=" + sourceway + "&personLoggin.LOGDATE="
                        + gzsjButton.getText().toString().trim() + "&personLoggin.LOGWORK="
                        + rznrEditText.getText().toString().trim() + "&personLoggin.NOTES="
                        + bzEditText.getText().toString().trim();
                try {
                    sss = connServerForResultPost(a, b);

                } catch (Exception e) {
                    msg_listData.what = MESSAGETYPE_02;
                }
                if (sss == null || "".equals(sss) || sss.contains("failure")) {
                    msg_listData.what = MESSAGETYPE_02;
                } else {
                    msg_listData.what = MESSAGETYPE_01;
                }
                handler.sendMessage(msg_listData);
            } catch (Exception e) {
                if (null != e) {
                    e.printStackTrace();
                }
            }
        }
    }).start();
}

From source file:com.oneguy.recognize.engine.GoogleStreamingEngine.java

@Override
public void onStreamResponse(StreamResponse response) {
    if (mState == STATE_SHUTDOWN) {
        Log.d(TAG, "engine is SHUTDOWN,ignore response:" + response.toString());
    } else {//w  w  w . ja v  a2  s. co m
        Log.d(TAG, "response:" + response.toString());
        Message msg = new Message();
        msg.what = EVENT_RESPONSE;
        msg.obj = response;
        mHandler.sendMessage(msg);
    }
}

From source file:com.insthub.O2OMobile.Activity.MessageActivity.java

@Override
public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException {
    // TODO Auto-generated method stub
    mListViewPerson.stopRefresh();//w w w.  j  a  v a2  s  .c  o m
    mListViewPerson.stopLoadMore();
    mListViewSystem.stopRefresh();
    mListViewSystem.stopLoadMore();
    if (url.endsWith(ApiInterface.MESSAGE_LIST)) {
        setAdapterCont();
        if (mMessageListModel.publicMore == 0) {
            mListViewPerson.setPullLoadEnable(false);
        } else {
            mListViewPerson.setPullLoadEnable(true);
        }
    } else if (url.endsWith(ApiInterface.MESSAGE_READ)) {
        Message msg = new Message();
        msg.what = MessageConstant.MESSAGE_READ;
        EventBus.getDefault().post(msg);
        for (int i = 0; i < mMessageListModel.publicMessageList.size(); i++) {
            if (mMessageListModel.publicMessageList.get(i).id == mMessageId) {
                mMessageListModel.publicMessageList.get(i).is_readed = 1;
                break;
            }
        }
        mH0MessageAdapter.publicList = mMessageListModel.publicMessageList;
        mH0MessageAdapter.notifyDataSetChanged();
        setMessageUnreadCount();
    } else if (url.endsWith(ApiInterface.MESSAGE_SYSLIST)) {
        setSysAdapterCont();
        if (mMessageListModel.publicMoreSys == 0) {
            mListViewSystem.setPullLoadEnable(false);
        } else {
            mListViewSystem.setPullLoadEnable(true);
        }
    } else if (url.endsWith(ApiInterface.MESSAGE_UNREAD_COUNT)) {
        mUnreadMessageCount = mMessageUnreadCountModel.publicUnreadCount;
        setMessageUnreadCount();
    }
}

From source file:com.itime.team.itime.fragments.InboxFragment.java

/**
 * this method is called in the timer task thread, so do not modify data through adapter here
 * because the UI thread also access to it. Adapter may be not thread-safe.
 *//*w  w  w  .j a  va2s  .  c om*/
public void checkNewMessages() {
    InboxTask inboxTask = InboxTask.getInstance(getActivity().getApplicationContext());
    InboxTask.ResultCallBack<Integer> callback = new InboxTask.ResultCallBack<Integer>() {
        @Override
        public void callback(Integer result) {
            Log.i(LOG_TAG, "unread message count: " + result);

            // it is fine to just get value
            // if count is not consistent, load all the message
            if (mAdapter.getUnreadMessageCount() != result.intValue()) {
                // do not call setMessage to load messages directly
                Message message = new Message();
                message.what = HAS_NEW_MESSAGES;
                mHandler.sendMessage(message);
            }
        }
    };
    inboxTask.getUnreadMessageCount(User.ID, callback);
}

From source file:com.xpg.gokit.activity.GokitControlActivity.java

@Override
public void didDisconnected(XPGWifiDevice device) {
    if (!isUnbind) {
        Message msg = new Message();
        msg.what = DISCONNECT;/*w  w  w  .j av  a  2 s .c o  m*/
        handler.sendMessage(msg);
    }
    isUnbind = false;
}

From source file:net.evecom.androidecssp.base.BaseActivity.java

/**
 * /*  w  w w  .j  a  v  a2  s . c o  m*/
 *  dictValue dictKey TextViewDictName
 * 
 * @author Mars zhang
 * @created 2015-11-25 9:50:55
 * @param dictKey
 * @param value
 * @param view
 */
protected void setDictNameByValueToView(final String dictKey, final String dictValue, final TextView view) {
    final Handler mHandler = new Handler() {
        public void handleMessage(android.os.Message msg) {
            switch (msg.what) {
            case MESSAGETYPE_01:
                view.setText(msg.getData().getString("dictname"));
                break;
            default:
                break;
            }
        };
    };
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                HashMap<String, String> entityMap = new HashMap<String, String>();
                entityMap.put("dictkey", dictKey);
                String result = connServerForResultPost("jfs/ecssp/mobile/pubCtr/getDictByKey", entityMap);
                List<BaseModel> baseModels = getObjsInfo(result);
                HashMap<String, String> keyValehashmap = new HashMap<String, String>();
                for (int i = 0; i < baseModels.size(); i++) {
                    keyValehashmap.put(baseModels.get(i).get("dictvalue") + "",
                            baseModels.get(i).get("name") + "");
                }
                String dictname = ifnull(keyValehashmap.get(dictValue), "");
                Message message = new Message();
                Bundle mbundle = new Bundle();
                mbundle.putString("dictname", dictname);
                message.setData(mbundle);
                message.what = MESSAGETYPE_01;
                mHandler.sendMessage(message);
            } catch (ClientProtocolException e) {
                Log.v("mars", e.getMessage());
            } catch (IOException e) {
                Log.v("mars", e.getMessage());
            } catch (JSONException e) {
                Log.v("mars", e.getMessage());
            }
        }
    }).start();

}