本文整理了Java中android.os.Message.getTarget()
方法的一些代码示例,展示了Message.getTarget()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getTarget()
方法的具体详情如下:
包路径:android.os.Message
类名称:Message
方法名:getTarget
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithHandler() throws Exception {
Handler h = new Handler();
Message m = Message.obtain(h);
assertThat(m.getTarget()).isEqualTo(h);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithHandlerAndWhat() throws Exception {
Handler h = new Handler();
int what = 10;
Message m = Message.obtain(h, what);
assertThat(m.getTarget()).isEqualTo(h);
assertThat(m.what).isEqualTo(what);
assertThat(m.getTarget()).isEqualTo(h);
}
代码示例来源:origin: robolectric/robolectric
private void unschedule() {
Handler target = realMessage.getTarget();
if (target != null && scheduledRunnable != null) {
shadowOf(target.getLooper()).getScheduler().remove(scheduledRunnable);
scheduledRunnable = null;
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithHandlerWhatAndObject() throws Exception {
Handler h = new Handler();
int what = 10;
Object obj = "test";
Message m = Message.obtain(h, what, obj);
assertThat(m.getTarget()).isEqualTo(h);
assertThat(m.what).isEqualTo(what);
assertThat(m.getTarget()).isEqualTo(h);
assertThat(m.obj).isEqualTo(obj);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testGetTarget() throws Exception {
Message m = new Message();
Handler h = new Handler();
m.setTarget(h);
assertThat(m.getTarget()).isEqualTo(h);
}
代码示例来源:origin: google/ExoPlayer
Handler target = pendingMessage.message.getTarget();
if (target != null) {
boolean isRemoved = false;
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithHandlerWhatAndTwoArgs() throws Exception {
Handler h = new Handler();
int what = 2;
int arg1 = 3;
int arg2 = 5;
Message m = Message.obtain(h, what, arg1, arg2);
assertThat(m.getTarget()).isEqualTo(h);
assertThat(m.what).isEqualTo(what);
assertThat(m.arg1).isEqualTo(arg1);
assertThat(m.arg2).isEqualTo(arg2);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSendToTarget() {
ShadowLooper.pauseMainLooper();
Object testObject = new Object();
Handler handler = new Handler();
Message message = handler.obtainMessage(123, testObject);
assertThat(handler).isEqualTo(message.getTarget());
message.sendToTarget();
assertTrue(handler.hasMessages(123, testObject));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithHandlerWhatTwoArgsAndObj() throws Exception {
Handler h = new Handler();
int what = 2;
int arg1 = 3;
int arg2 = 5;
Object obj = "test";
Message m = Message.obtain(h, what, arg1, arg2, obj);
assertThat(m.getTarget()).isEqualTo(h);
assertThat(m.what).isEqualTo(what);
assertThat(m.arg1).isEqualTo(arg1);
assertThat(m.arg2).isEqualTo(arg2);
assertThat(m.obj).isEqualTo(obj);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithMessage() throws Exception {
Bundle b = new Bundle();
Message m = new Message();
m.arg1 = 10;
m.arg2 = 42;
m.obj = "obj";
m.what = 24;
m.setData(b);
m.setTarget(new Handler());
Message m2 = Message.obtain(m);
assertThat(m2.arg1).isEqualTo(m.arg1);
assertThat(m2.arg2).isEqualTo(m.arg2);
assertThat(m2.obj).isEqualTo(m.obj);
assertThat(m2.what).isEqualTo(m.what);
assertThat(m2.getTarget()).isEqualTo(m.getTarget());
assertThat(m2.getData()).isNotNull();
assertThat(m2.getData().isEmpty()).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testCopyFrom() throws Exception {
Bundle b = new Bundle();
Message m = new Message();
m.arg1 = 10;
m.arg2 = 42;
m.obj = "obj";
m.what = 24;
m.setData(b);
m.setTarget(new Handler());
Message m2 = new Message();
m2.copyFrom(m);
assertThat(m2.arg1).isEqualTo(m.arg1);
assertThat(m2.arg2).isEqualTo(m.arg2);
assertThat(m2.obj).isEqualTo(m.obj);
assertThat(m2.what).isEqualTo(m.what);
assertThat(m2.getTarget()).isNull();
assertThat(m2.getData()).isNotNull();
assertThat(m2.getData().isEmpty()).isTrue();
}
代码示例来源:origin: robolectric/robolectric
private static void dispatchMessage(Message msg) {
final Handler target = msg.getTarget();
shadowOf(msg).setNext(null);
// If target is null it means the message has been removed
// from the queue prior to being dispatched by the scheduler.
if (target != null) {
_Message_ msgProxy = reflector(_Message_.class, msg);
msgProxy.markInUse();
target.dispatchMessage(msg);
if (getApiLevel() >= LOLLIPOP) {
msgProxy.recycleUnchecked();
} else {
msgProxy.recycle();
}
}
}
代码示例来源:origin: google/ExoPlayer
Handler target = pendingMessage.message.getTarget();
if (target != null) {
boolean isRemoved = false;
代码示例来源:origin: com.github.japgolly.android.test/robolectric
@Implementation
public static Message obtain(Message msg) {
Message m = new Message();
m.copyFrom(msg);
m.setTarget(msg.getTarget());
return m;
}
代码示例来源:origin: org.robolectric/shadows-core
private void unschedule() {
Handler target = realMessage.getTarget();
if (target != null && scheduledRunnable != null) {
shadowOf(target.getLooper()).getScheduler().remove(scheduledRunnable);
scheduledRunnable = null;
}
}
代码示例来源:origin: org.robolectric/framework
private void unschedule() {
Handler target = realMessage.getTarget();
if (target != null && scheduledRunnable != null) {
shadowOf(target.getLooper()).getScheduler().remove(scheduledRunnable);
scheduledRunnable = null;
}
}
代码示例来源:origin: org.robolectric/shadows-core-v23
private void unschedule() {
Handler target = realMessage.getTarget();
if (target != null && scheduledRunnable != null) {
shadowOf(target.getLooper()).getScheduler().remove(scheduledRunnable);
scheduledRunnable = null;
}
}
代码示例来源:origin: org.robolectric/shadows-framework
private void unschedule() {
Handler target = realMessage.getTarget();
if (target != null && scheduledRunnable != null) {
shadowOf(target.getLooper()).getScheduler().remove(scheduledRunnable);
scheduledRunnable = null;
}
}
代码示例来源:origin: org.robolectric/shadows-core-v23
private static void dispatchMessage(Message msg) {
final Handler target = msg.getTarget();
shadowOf(msg).setNext(null);
// If target is null it means the message has been removed
// from the queue prior to being dispatched by the scheduler.
if (target != null) {
callInstanceMethod(msg, "markInUse");
target.dispatchMessage(msg);
callInstanceMethod(msg, "recycleUnchecked");
}
}
}
代码示例来源:origin: org.robolectric/shadows-core
private static void dispatchMessage(Message msg) {
final Handler target = msg.getTarget();
shadowOf(msg).setNext(null);
// If target is null it means the message has been removed
// from the queue prior to being dispatched by the scheduler.
if (target != null) {
callInstanceMethod(msg, "markInUse");
target.dispatchMessage(msg);
if (getApiLevel() >= LOLLIPOP) {
callInstanceMethod(msg, "recycleUnchecked");
} else {
callInstanceMethod(msg, "recycle");
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!