今日小结 4.17

  • 开线程 thread,消息机制,消息队列,handler,runnable  OK
  • 获取室内温度
  • 组件通信  OK 

 

  • 优化 UI,优化 back 图标

  •     CardView   
    http://developer.android.com/training/material/lists-cards.html
    http://blog.csdn.net/xyz_lmn/article/details/35644799
    http://developer.android.com/design/material/index.html?q=imageloader#q=imageloader
    http://blog.csdn.net/xyz_lmn/article/details/35552103

  •   RecycleView
    http://blog.csdn.net/xyz_lmn/article/details/38735117
    http://blog.csdn.net/gao_chun/article/details/48550117


 1.添加Java doc , 描述class,method,field

Alt + Enter 打开 intentions,选择Add doc

 

2.组件通信

new一个Intent,用 Extra 以键值对形式 在活动间传递数据,比如:

            final int heartRate = characteristic.getIntValue(format, 1);
            Log.d(TAG, String.format("Received heart rate: %d", heartRate));
            intent.putExtra(EXTRA_DATA, String.valueOf(heartRate));

see:(1)ImageLoaderDemo1_Android UI-开源框架ImageLoader的完美例子.rar

(2)BLETemperature.rar

 

IntentFilter

广播 Broadcast

 

 

3.回调函数——在顶层覆写,在底层调用。比如 onCreate(),onDestroy(),onClick(),onCharacteristicRead()。一般都是on开头的,前面加了 @Override 的。

在顶层覆写底层的函数,顶层不需要调用,底层自动调用。

”回调“ 就是说覆写好了以后回过去调用(在顶层覆写好了以后,回到底层自动调用),比如:

        @Override
        public void onCharacteristicRead(BluetoothGatt gatt,
                                         BluetoothGattCharacteristic characteristic,
                                         int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
            }
        }

see:BluetoothLeGatt_BLE官方Demo.rar

 

回调函数在底层,就像单片机中的中断函数,靠顶层事件来触发它。

 

4.pending 未决定的,悬而未决的

挂起的,搁置的,即将发生的

 

5.进程>线程

一个进程可以包含多个线程

多线程是看似多个任务同时进行,实际上对于单CPU的系统,一个时间点只能有运行一个线程,所谓多线程是多个线程快速的交替运行就好像同时运行似的。

 

多个线程只有快速的交替运行,效率才是最高的,不能让一个线程占用CPU太长时间,因此必须要采取线程休眠的方式来保证多个线程交替运行。

休眠(sleep)是暂停一个(线程),去执行另一个。

posted @ 2016-04-18 07:45  虫葛尔Chongger  阅读(126)  评论(0编辑  收藏  举报