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:net.evecom.androidecssp.activity.event.ContinueAddActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    // /*from  w  w  w.j  a  va 2 s.  c  o m*/
    case R.layout.tree_list_at:

        String id = data.getStringExtra("nodeid");
        String name = data.getStringExtra("nodeName");
        String title = data.getStringExtra("title");
        if (null != id) {
            if (title.equals("")) {
                hashMap.put("infoContinue.reporterdept", id);
                hashMap.put("infoContinue.reporterdeptname", name);
                continueDept.setText(name);
            } else {
                hashMap.put("infoContinue.coutinuearea", id);
                continueArea.setText(name);
            }
        }
        break;
    // 
    case R.layout.picture_select_at:
        new Thread(new Runnable() {
            @Override
            public void run() {
                filebeans.removeAll(filebeans);
                filebeans = getDb().findAll(FileManageBean.class);
                Message message = new Message();
                message.what = R.layout.picture_select_at;
                pubHandler.sendMessage(message);
            }
        }).start();
        break;
    default:
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

private void selectChromecastDevice() {

    Message m = new Message();
    m.what = 1102;/*  w  w w. ja  va  2 s.  c om*/
    mHandler.sendMessage(m);

    synchronized (mLock) {
        try {
            DebugLog.d(TAG, "wait start");
            mLock.wait();

            if (haveCastDevice == true && chromecast.getJsActivityPauseStatus() == false) {
                CloudGamePlayer.playToCast();
            } else {
                chromecast.setChromecastWebMode(false);
            }
            DebugLog.d(TAG, "wait end");
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            DebugLog.d(TAG, "exception = " + e.getMessage());
        }
    }
}

From source file:org.jared.synodroid.ds.server.SynoServer.java

/**
 * Send a message//from   ww w .j a  va 2  s.  c  o m
 */
public void fireMessage(ResponseHandler handlerP, int msgP, Object objP) {
    // Send the connecting message
    Message msg = new Message();
    msg.what = msgP;
    msg.obj = objP;
    handlerP.handleReponse(msg);

}

From source file:com.app.jdy.ui.CashAdvanceActivity.java

public void getData() {
    new Thread(new Runnable() {

        @Override/*w ww . java2 s  .c  om*/
        public void run() {
            SharedPreferences userPreferences = getSharedPreferences("umeng_general_config",
                    Context.MODE_PRIVATE);
            memberId = userPreferences.getString("ID", "").trim();

            canWithdCash = HttpUtils.request(null, URLs.CanWithdCash_URL + "/" + memberId);

            String bankCard = HttpUtils.request(null, URLs.BANKCARD_URL + "/" + memberId);

            Message msg = new Message();
            msg.what = 1;
            Bundle bundle = new Bundle();

            try {
                JSONObject jsonObject = new JSONObject(bankCard);
                String tmpJson = jsonObject.getString("data");
                JSONArray jsonArray = new JSONArray(tmpJson);
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject tmpObj = (JSONObject) jsonArray.get(i);
                    String bankName = tmpObj.getString("bankName");
                    String bankCode = tmpObj.getString("bankCode");
                    String bankCode1 = tmpObj.getString("bankCode1");

                    bundle.putString("bankName", bankName);
                    bundle.putString("bankCode", bankCode);
                    bundle.putString("bankCode1", bankCode1);
                }

            } catch (JSONException e) {

                e.printStackTrace();
            }

            bundle.putString("canWithdCash", canWithdCash);

            msg.setData(bundle);
            handler.sendMessage(msg);

        }
    }).start();
}

From source file:com.zzisoo.toylibrary.fragment.ToyListViewFragment.java

private void getData() {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();

    asyncHttpClient.get(getActivity(), Config.URL_BOOKS_LIST, new AsyncHttpResponseHandler() {
        private IntroProgressPopupDialog mIntroProgressPopup;

        @Override//from   w w  w  . ja  v a2  s.  c  o  m
        public void onStart() {
            super.onStart();
            mIntroProgressPopup = new IntroProgressPopupDialog(getActivity());
            mIntroProgressPopup.setProgressBarVisible(false);
            mIntroProgressPopup.show();
        }

        @Override
        public void onPreProcessResponse(ResponseHandlerInterface instance, HttpResponse response) {
            super.onPreProcessResponse(instance, response);
        }

        @Override
        public void onProgress(int bytesWritten, int totalSize) {
            mIntroProgressPopup.setProgressBarVisible(true);

            super.onProgress(bytesWritten, totalSize);
            Log.v(TAG, bytesWritten + "/" + totalSize);
            mIntroProgressPopup.setProgress((int) (100 * bytesWritten / totalSize));
        }

        @Override
        public void onSuccess(int i, Header[] headers, byte[] bytes) {
            Log.d(TAG, "Http Get Success");
            String responseStr = new String(bytes);
            Log.d(TAG, "[" + i + "] Received Msg:" + responseStr);
            mIntroProgressPopup.dismiss();

            mPref.setUpdateMode();
            mPref.setStringPref(SharedPref.PREF_TOYS_LIST, responseStr);
            mPref.updateFinish();
            dataLoad(responseStr);
        }

        @Override
        public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
            Log.d(TAG, "Http Get Failure");
            Log.d(TAG, "Code [" + i + "] ");
            mIntroProgressPopup.setProgressBarVisible(false);
            mIntroProgressPopup.setText("ERROR Code: " + i);

            String oldData = mPref.getStringPref(SharedPref.PREF_TOYS_LIST);
            if (oldData.equals(SharedPref.NODATA_STRING)) {
                delayedFinish();
            } else {
                delayLoadOldData(oldData);
            }
        }

        private void delayedFinish() {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mIntroProgressPopup.setText("Retry. Check Network.");
                }
            }, 1000);
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mIntroProgressPopup.setText("Will Finish.");
                }
            }, 2000);
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Message msg = new Message();
                    msg.arg1 = MSG_FINISH;
                    mActivityHandler.dispatchMessage(msg);
                }
            }, 5000);
        }

        private void delayLoadOldData(final String oldData) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mIntroProgressPopup.setText("ERROR But Found OldData.");
                }
            }, 1000);
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mIntroProgressPopup.dismiss();
                    dataLoad(oldData);
                }
            }, 2000);

        }

    });

}

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

/**
 * // w  w w . ja v a  2 s . co m
 *  dictValue dictKey TextViewDictName 
 * 
 * @author Mars zhang
 * @created 2015-11-25 9:50:55
 * @param dictKey
 * @param value
 * @param view
 */
protected void setLikeDictNameByValueToView(final String url, 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(url, 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();

}

From source file:org.ueu.uninet.it.IragarkiOholaKontaktua.java

/**
 * Deskribapen luzea lortzen da unibertsitatea.net webgunetik
 * Horretarako hari berri bat erabiltzen da
 * Prozesua bukatzen denean irudi kargatzaileari ematen zaio abisua layouta prestatzeko
 *//* www  .j  a  v a  2 s  .  co  m*/
private void getTestua() {
    // TODO iragarkia saretik lortzean arazorik balego handler-era bidali
    // mezua erabiltzaileari oharra erakusteko
    // TODO bigeiratu iragarki zerrendan zelan egin den
    try {
        final IragarkiEskuratzailea ie = new IragarkiEskuratzailea();
        new Thread() {
            @Override
            public void run() {
                Iragarkia iragarkia = ie.getIragarkia(url);

                Message msg = new Message();
                Bundle bundle = new Bundle();

                bundle.putString("edukia", iragarkia.edukia);
                msg.setData(bundle);

                msg.what = 1;
                msg.setData(bundle);
                handler_iragarkia.sendMessage(msg);
                // Abisua eman irudi kargatzaile hariari testua lortu dela
                latch.countDown();
                // Bide batez progress dialogoa gelditu soilik irudirik ez
                // dagoenean
                // bestela irudia eta layout-a prestatu arte itxoingo da
                if (!irudirik && progressDialog != null && progressDialog.isShowing())
                    progressDialog.dismiss();
            }
        }.start();
        // return iragarkia.edukia;
    } catch (IllegalThreadStateException e) {
        handler_iragarkia.sendEmptyMessage(0);
    } catch (Exception e) {
        // return "";
        handler_iragarkia.sendEmptyMessage(0);
    }

}

From source file:com.sabdroidex.controllers.couchpotato.CouchPotatoController.java

/**
 * This function refreshes the elements from movies.
 * //  w w  w .  ja  v a 2s .  co  m
 * @param messageHandler The message handler that will receive the result
 * @param status The status we want to fetch
 */
public static void refreshMovies(final Handler messageHandler, final String status) {
    if (executingRefreshMovies || !Preferences.isSet(Preferences.COUCHPOTATO_URL)) {
        return;
    }
    if (status == null) {
        getStatusList();
    }
    if (profiles == null) {
        getProfiles();
    }

    Thread thread = new Thread() {

        @Override
        public void run() {
            try {

                String result = makeApiCall(MESSAGE.MOVIE_LIST.toString().toLowerCase(), "status=" + status);
                JSONObject jsonObject = new JSONObject(result);
                MovieList movieList;

                if (!jsonObject.isNull("message") && !"".equals(jsonObject.getString("message"))) {
                    sendUpdateMessageStatus(messageHandler, "SickBeard : " + jsonObject.getString("message"));
                } else {
                    SimpleJSONMarshaller jsonMarshaller = new SimpleJSONMarshaller(MovieList.class);
                    movieList = (MovieList) jsonMarshaller.unMarshal(jsonObject);

                    Message message = new Message();
                    message.setTarget(messageHandler);
                    message.what = MESSAGE.MOVIE_LIST.hashCode();
                    message.obj = movieList;
                    message.sendToTarget();
                }
            } catch (IOException e) {
                Log.w(TAG, " " + e.getMessage());
            } catch (Throwable e) {
                Log.w(TAG, " " + e.getMessage());
            } finally {
                executingRefreshMovies = false;
                executingCommand = false;
            }
        }
    };
    executingCommand = true;
    thread.start();
}

From source file:com.tvs.signaltracker.MainScreen.java

private void InitUp() {
    if (CommonHandler.ServiceMode < 3) {
        SignalCallBack = new STCallBack() {

            @Override/*from  w  w w . j av  a2s  .c  o m*/
            public void Call(Object argument) {
                SignalObject sig = (SignalObject) argument;
                Bundle data = new Bundle();
                data.putDouble("lat", sig.latitude);
                data.putDouble("lon", sig.longitude);
                data.putShort("signal", sig.signal);
                Message msg = new Message();
                msg.setData(data);
                msg.what = 0;
                if (!MainScreenHandler.sendMessage(msg)) {
                    Log.i("SignalTracker::MainScreen", "Failed to put signal on map. Delaying 2s");
                    MainScreenHandler.sendMessageDelayed(msg, 2000);
                }
            }

        };
        SignalCallBack.from = "MainScreen";

        CommonHandler.AddSignalCallback(SignalCallBack);
        if (CommonHandler.Signals != null) {
            for (int i = 0; i < CommonHandler.Signals.size(); i++)
                SignalCallBack.Call(CommonHandler.Signals.get(i));
        }
    }
    MainScreenHandler.postDelayed(UpdateUI, 100);
}

From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java

public void getMyShopText() {
    new Thread() {
        Message msg = new Message();

        public void run() {
            String data = "&userid=" + user.getUserId();
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(WebAddress.GETMYSHOP, data);
            Log.e("successful", result_data);
            try {
                JSONObject obj = new JSONObject(result_data);
                msg.what = CommunalInterfaces.GET_MY_SHOP_TEXT;
                msg.obj = obj;/*from   w ww .ja v  a 2s .  co  m*/
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}