Handler源码-注释翻译

Handler Class 头部注释

注:源码版本号 26

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* A Handler allows you to send and process {@link Message} and Runnable
* objects associated with a thread's {@link MessageQueue}.

译:Handler允许你通过关联的MessageQueue(消息队列)发送和处理消息、Runnable对象。

* Each Handler
* instance is associated with a single thread and that thread's message
* queue.

译:每一个Handler实力都关联着一个独立线程和此线程的一个消息队列。

* When you create a new Handler, it is bound to the thread /
* message queue of the thread that is creating it -- from that point on,
* it will deliver messages and runnables to that message queue and execute
* them as they come out of the message queue.

译:每当你创建一个新的Handler,它都会绑定到当前创建他的 线程/消息队列上 -- 从那一刻起,
它就会负责为消息队列提供新的消息和Runnables对象,还负责在消息和Runnables走出消息队列的
时候执行他们。

* <p>There are two main uses for a Handler: (1) to schedule messages and
* runnables to be executed as some point in the future; and (2) to enqueue
* an action to be performed on a different thread than your own.

译:一个Handler有两个主要用途(1)调度消息和Runnables以保证在未来的某个时间点执行他们。
2)把一个将被执行的Action插入到一个不同的Thread处理队列。

* <p>Scheduling messages is accomplished with the
* {@link #post}, {@link #postAtTime(Runnable, long)},
* {@link #postDelayed}, {@link #sendEmptyMessage},
* {@link #sendMessage}, {@link #sendMessageAtTime}, and
* {@link #sendMessageDelayed} methods. The <em>post</em> versions allow
* you to enqueue Runnable objects to be called by the message queue when
* they are received; the <em>sendMessage</em> versions allow you to enqueue
* a {@link Message} object containing a bundle of data that will be
* processed by the Handler's {@link #handleMessage} method (requiring that
* you implement a subclass of Handler).

译:调度消息是通过一系列方法完成的,包括(post,postAtTime(Runnable, long),postDelayed
,sendEmptyMessage,sendMessage,sendMessageAtTime,sendMessageDelayed)这几个版本。
其中
post: 允许你将Runnable对象插入队列,当他们被接收的时候就会被调用。
sendMessage:允许你将一个包含数据Bundle消息类型的对象插入队列,当它被接收的时候就会被Handler
的 handleMessage 方法处理(这里需要您自己实现一个Handler子类)。

* <p>When posting or sending to a Handler, you can either
* allow the item to be processed as soon as the message queue is ready
* to do so, or specify a delay before it gets processed or absolute time for
* it to be processed. The latter two allow you to implement timeouts,
* ticks, and other timing-based behavior.

译:当使用Post或者send发送消息至Handler时,你不能处理他们,直到消息队列准备好了。或者你在执行
之前指定一个延时或者绝对时间去执行。后者允许了你去实现超时、计时或者其他基于时间的行为。

* <p>When a
* process is created for your application, its main thread is dedicated to
* running a message queue that takes care of managing the top-level
* application objects (activities, broadcast receivers, etc) and any windows
* they create. You can create your own threads, and communicate back with
* the main application thread through a Handler. This is done by calling
* the same <em>post</em> or <em>sendMessage</em> methods as before, but from
* your new thread. The given Runnable or Message will then be scheduled
* in the Handler's message queue and processed when appropriate.
*/

译:当你的应用进程被创建的时候,他的主线程(UI线程)运行的消息队列,将被专用为保障管理最高级别
的应用对象(Activities,Broadcast,Receivers等),和任何窗口的创建,而且你可以创建你自己
的线程通过Handler与主应用线程进行交流。这些都是像之前一样通过调用 post 、sendMessage 来完
成的,只不过是在你自己的新线程里完成的。 给定的Runnable或者消息都会被调度到Handler的消息队列
里,等待适当的时候处理。

閱讀更多

Android高性能混音探索

为什么要做

一直有做音频合成的需求,但是在一些低端机器上总是出现问题。
其一是,长音频合成的时候经常OOM,导致在小内存机器上有限制。
其二是,CPU不给力的时候合成太慢。
所以想要一种优雅的方式解决音频合成,想了很久了,最近有点时间想要改进以上问题。

閱讀更多

FFmpeg开发学习笔记

閱讀更多

FFmpeg功能裁剪

使用./configure –help 选项可以看到如下信息
我们可以根据我们需要的功能对库文件大小进行裁剪

閱讀更多

FFmpeg移植Android平台

使用FFmpeg

FFmpeg的强大之处就不多讲了,大家可以自行百度或者去 ffmpeg.org 去查看文档,libav.org 是从FFmpeg分裂出来的分支,有兴趣的可以去查一下相关历史。今天我要做的事情是这样的:

閱讀更多

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

閱讀更多