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:cn.xiaocool.android_etong.net.constant.request.MainRequest.java

public void UpdateUserBank(final String realname, final String idcard, final String bank, final String bankno,
        final String phone, final String code) {
    new Thread() {
        Message msg = Message.obtain();

        @Override//ww w  . jav a  2s  .  com
        public void run() {
            String data = "&userid=" + user.getUserId() + "&realname=" + realname + "&idcard=" + idcard
                    + "&bank=" + bank + "&bankno=" + bankno + "&phone=" + phone + "&code=" + code;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(UpdateUserBank, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.UpdateUserBank;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

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

public void ApplyWithdraw(final String money, final String banktype) {
    new Thread() {
        Message msg = Message.obtain();

        @Override//from   w w  w .ja va 2  s.  c  o  m
        public void run() {
            String data = "&userid=" + user.getUserId() + "&money=" + money + "&banktype=" + banktype;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(ApplyWithdraw, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.ApplyWithdraw;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

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

public void GetMyApplyWithdraw() {
    new Thread() {
        Message msg = Message.obtain();

        @Override//from   www . ja v a2s . c  om
        public void run() {
            String data = "&userid=" + user.getUserId();
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(GetMyApplyWithdraw, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.GetMyApplyWithdraw;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

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

public void GetTimeGoodList(final String type) {
    new Thread() {
        Message msg = Message.obtain();

        @Override/*from   w ww  .j a  va  2  s.  c  om*/
        public void run() {
            String data = "&type=" + type;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(GetTimeGoodList, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.GetTimeGoodList;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

From source file:com.ichi2.anki.AbstractFlashcardViewer.java

@SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
// because of setDisplayZoomControls.
private WebView createWebView() {
    WebView webView = new MyWebView(this);
    webView.setWillNotCacheDrawing(true);
    webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    if (CompatHelper.isHoneycomb()) {
        // Disable the on-screen zoom buttons for API > 11
        webView.getSettings().setDisplayZoomControls(false);
    }//www.ja  v a2  s. c o m
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setSupportZoom(true);
    // Start at the most zoomed-out level
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(new AnkiDroidWebChromeClient());
    // Problems with focus and input tags is the reason we keep the old type answer mechanism for old Androids.
    webView.setFocusableInTouchMode(mUseInputTag);
    webView.setScrollbarFadingEnabled(true);
    Timber.d("Focusable = %s, Focusable in touch mode = %s", webView.isFocusable(),
            webView.isFocusableInTouchMode());

    webView.setWebViewClient(new WebViewClient() {
        // Filter any links using the custom "playsound" protocol defined in Sound.java.
        // We play sounds through these links when a user taps the sound icon.
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.startsWith("playsound:")) {
                // Send a message that will be handled on the UI thread.
                Message msg = Message.obtain();
                String soundPath = url.replaceFirst("playsound:", "");
                msg.obj = soundPath;
                mHandler.sendMessage(msg);
                return true;
            }
            if (url.startsWith("file") || url.startsWith("data:")) {
                return false; // Let the webview load files, i.e. local images.
            }
            if (url.startsWith("typeblurtext:")) {
                // Store the text the javascript has send us
                mTypeInput = URLDecoder.decode(url.replaceFirst("typeblurtext:", ""));
                //  and show the SHOW ANSWER? button again.
                mFlipCardLayout.setVisibility(View.VISIBLE);
                return true;
            }
            if (url.startsWith("typeentertext:")) {
                // Store the text the javascript has send us
                mTypeInput = URLDecoder.decode(url.replaceFirst("typeentertext:", ""));
                //  and show the answer.
                mFlipCardLayout.performClick();
                return true;
            }
            if (url.equals("signal:typefocus")) {
                // Hide the SHOW ANSWER? button when the input has focus. The soft keyboard takes up enough space
                // by itself.
                mFlipCardLayout.setVisibility(View.GONE);
                return true;
            }
            Timber.d("Opening external link \"%s\" with an Intent", url);
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            try {
                startActivityWithoutAnimation(intent);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace(); // Don't crash if the intent is not handled
            }
            return true;
        }

        // Run any post-load events in javascript that rely on the window being completely loaded.
        @Override
        public void onPageFinished(WebView view, String url) {
            Timber.d("onPageFinished triggered");
            view.loadUrl("javascript:onPageFinished();");
        }
    });
    // Set transparent color to prevent flashing white when night mode enabled
    webView.setBackgroundColor(Color.argb(1, 0, 0, 0));
    return webView;
}

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

public void GetUserInfoByQQ(final String qq) {
    new Thread() {
        Message msg = Message.obtain();

        @Override//from ww  w  .  jav a 2  s . co  m
        public void run() {
            String data = "&qq=" + qq;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(GetUserInfoByQQ, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.GetUserInfoByQQ;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

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

public void UpdateUserQQ(final String qq) {
    new Thread() {
        Message msg = Message.obtain();

        @Override/*from   w ww. ja v  a2 s  .  c  o m*/
        public void run() {
            String data = "&userid=" + user.getUserId() + "&qq=" + qq;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(UpdateUserQQ, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.UpdateUserQQ;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

From source file:com.taobao.weex.ui.component.WXComponent.java

private void updateStyleByPesudo(Map<String, Object> styles) {
    Message message = Message.obtain();
    WXDomTask task = new WXDomTask();
    task.instanceId = getInstanceId();//from w  w w .  j  av  a2  s .com
    task.args = new ArrayList<>();

    JSONObject styleJson = new JSONObject(styles);
    task.args.add(getRef());
    task.args.add(styleJson);
    task.args.add(true);//flag pesudo
    message.obj = task;
    message.what = WXDomHandler.MsgType.WX_DOM_UPDATE_STYLE;
    WXSDKManager.getInstance().getWXDomManager().sendMessage(message);
}

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

public void ShopGetTotalorder(final String shopid, final String begintime, final String endtime) {
    new Thread() {
        Message msg = Message.obtain();

        @Override//  w  w w .j  ava 2  s. c  om
        public void run() {
            String data = "&shopid=" + shopid + "&begintime=" + begintime + "&endtime=" + endtime;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(ShopGetTotalorder, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.ShopGetTotalorder;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}

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

public void ShopGetTotalOrderList(final String shopid, final String begintime, final String endtime) {
    new Thread() {
        Message msg = Message.obtain();

        @Override//ww w  .ja v a 2s .co  m
        public void run() {
            String data = "&shopid=" + shopid + "&begintime=" + begintime + "&endtime=" + endtime;
            Log.e("data=", data);
            String result_data = NetUtil.getResponse(ShopGetTotalOrderList, data);
            Log.e("result_data=", result_data);
            try {
                JSONObject jsonObject = new JSONObject(result_data);
                msg.what = CommunalInterfaces.ShopGetTotalOrderList;
                msg.obj = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            } finally {
                handler.sendMessage(msg);
            }
        }
    }.start();
}