android.os.Message#setTarget ( )源码实例Demo

下面列出了android.os.Message#setTarget ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: browser   文件: BrowserActivity.java
@Override
/**
 * handles long presses for the browser, tries to get the
 * url of the item that was clicked and sends it (it can be null)
 * to the click handler that does cool stuff with it
 */
public void onLongPress() {
	if (mClickHandler == null) {
		mClickHandler = new ClickHandler(mActivity);
	}
	Message click = mClickHandler.obtainMessage();
	if (click != null) {
		click.setTarget(mClickHandler);
		getCurrentWebView().getWebView().requestFocusNodeHref(click);
	}
}
 
源代码2 项目: ucar-weex-core   文件: WXBridgeManager.java
/**
 * Initialize JavaScript framework
 * @param framework String representation of the framework to be init.
 */
public synchronized void initScriptsFramework(String framework) {
  Message msg = mJSHandler.obtainMessage();
  msg.obj = framework;
  msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK;
  msg.setTarget(mJSHandler);
  msg.sendToTarget();
}
 
源代码3 项目: ucar-weex-core   文件: WXBridgeManager.java
public void takeJSHeapSnapshot(String filename) {
  Message msg = mJSHandler.obtainMessage();
  msg.obj = filename;
  msg.what = WXJSBridgeMsgType.TAKE_HEAP_SNAPSHOT;
  msg.setTarget(mJSHandler);
  msg.sendToTarget();
}
 
源代码4 项目: Xndroid   文件: LightningView.java
@Override
public void onLongPress(MotionEvent e) {
    if (mCanTriggerLongPress) {
        Message msg = mWebViewHandler.obtainMessage();
        if (msg != null) {
            msg.setTarget(mWebViewHandler);
            if (mWebView == null) {
                return;
            }
            mWebView.requestFocusNodeHref(msg);
        }
    }
}
 
源代码5 项目: weex-uikit   文件: WXBridgeManager.java
/**
 * Initialize JavaScript framework
 * @param framework String representation of the framework to be init.
 */
public synchronized void initScriptsFramework(String framework) {
  Message msg = mJSHandler.obtainMessage();
  msg.obj = framework;
  msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK;
  msg.setTarget(mJSHandler);
  msg.sendToTarget();
}
 
源代码6 项目: AndroidProjects   文件: ComplexActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_complex);

    main_image_view = (ImageView) findViewById(R.id.main_image_view);

    bitmapObject = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    main_image_view.setImageBitmap(bitmapObject);


    boolean isUiThread = Looper.getMainLooper().getThread() == Thread.currentThread();

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        isUiThread = Looper.getMainLooper().isCurrentThread();
    }
    Log.e("Edwin", "isUiThread = " + isUiThread);

    Message message = mHandler2.obtainMessage();
    message.what = 1;
    message.obj = 100;
    message.setTarget(mHandler2);
    message.sendToTarget();

    Message message2 = mHandler2.obtainMessage();
    message2.what = 0;
    message2.obj = 200;
    message2.sendToTarget();


    new LooperThread1().start();
    new LooperThread2().start();

}
 
源代码7 项目: weex   文件: WXBridgeManager.java
/**
 * Initialize JavaScript framework
 * @param framework String representation of the framework to be init.
 */
public synchronized void initScriptsFramework(String framework) {
  Message msg = mJSHandler.obtainMessage();
  msg.obj = framework;
  msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK;
  msg.setTarget(mJSHandler);
  msg.sendToTarget();
}
 
源代码8 项目: JumpGo   文件: LightningView.java
@Override
public void onLongPress(MotionEvent e) {
    if (mCanTriggerLongPress) {
        Message msg = mWebViewHandler.obtainMessage();
        if (msg != null) {
            msg.setTarget(mWebViewHandler);
            if (mWebView == null) {
                return;
            }
            mWebView.requestFocusNodeHref(msg);
        }
    }
}
 
源代码9 项目: Ninja   文件: NinjaWebView.java
public void onLongPress() {
    Message click = clickHandler.obtainMessage();
    if (click != null) {
        click.setTarget(clickHandler);
    }
    requestFocusNodeHref(click);
}
 
源代码10 项目: firefox-echo-show   文件: LinkHandler.java
@Override
public boolean onLongClick(View v) {
    if (callback == null) {
        return false;
    }

    final WebView.HitTestResult hitTestResult = webView.getHitTestResult();

    switch (hitTestResult.getType()) {
        case WebView.HitTestResult.SRC_ANCHOR_TYPE:
            final String linkURL = hitTestResult.getExtra();
            callback.onLongPress(new IWebView.HitTarget(true, linkURL, false, null));
            return true;

        case WebView.HitTestResult.IMAGE_TYPE:
            final String imageURL = hitTestResult.getExtra();
            callback.onLongPress(new IWebView.HitTarget(false, null, true, imageURL));
            return true;

        case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
            // hitTestResult.getExtra() contains only the image URL, and not the link
            // URL. Internally, WebView's HitTestData contains both, but they only
            // make it available via requestFocusNodeHref...
            final Message message = new Message();
            message.setTarget(new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    final Bundle data = msg.getData();
                    final String url = data.getString("url");
                    final String src = data.getString("src");

                    if (url == null || src == null) {
                        throw new IllegalStateException("WebView did not supply url or src for image link");
                    }

                    if (callback != null) {
                        callback.onLongPress(new IWebView.HitTarget(true, url, true, src));
                    }
                }
            });

            webView.requestFocusNodeHref(message);
            return true;

        default:
            return false;
    }
}
 
源代码11 项目: focus-android   文件: LinkHandler.java
@Override
public boolean onLongClick(View v) {
    if (callback == null) {
        return false;
    }

    final WebView.HitTestResult hitTestResult = webView.getHitTestResult();

    switch (hitTestResult.getType()) {
        case WebView.HitTestResult.SRC_ANCHOR_TYPE:
            final String linkURL = hitTestResult.getExtra();
            callback.onLongPress(new IWebView.HitTarget(true, linkURL, false, null));
            return true;

        case WebView.HitTestResult.IMAGE_TYPE:
            final String imageURL = hitTestResult.getExtra();
            callback.onLongPress(new IWebView.HitTarget(false, null, true, imageURL));
            return true;

        case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
            // hitTestResult.getExtra() contains only the image URL, and not the link
            // URL. Internally, WebView's HitTestData contains both, but they only
            // make it available via requestFocusNodeHref...
            final Message message = new Message();
            message.setTarget(new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    final Bundle data = msg.getData();
                    final String url = data.getString("url");
                    final String src = data.getString("src");

                    if (url == null || src == null) {
                        throw new IllegalStateException("WebView did not supply url or src for image link");
                    }

                    if (callback != null) {
                        callback.onLongPress(new IWebView.HitTarget(true, url, true, src));
                    }
                }
            });

            webView.requestFocusNodeHref(message);
            return true;

        default:
            return false;
    }
}