01 February 2016

小米2月工作记录


2016.02.16

adb shell dumpsys activity com.mi.vtalk 好用,可以看出UI层级

adb shell dumpsys dbinfo com.mi.vtalk 查看最近的数据库操作命令


2016.02.17

GreenDAO ORM框架

RxAndroid

ExecutorService pool = Executors.newSingleThreadExecutor(); newFixedThreadPool() newCachedThreadPool() newScheduledThreadPool()

4个线程池都是通过下面的 ThreadPoolExecutor 创建,只是参数不同。

 public ThreadPoolExecutor(int corePoolSize,
                              int maximumPoolSize,
                              long keepAliveTime,
                              TimeUnit unit,
                              BlockingQueue<Runnable> workQueue,
                              ThreadFactory threadFactory,
                              RejectedExecutionHandler handler)

corePoolSize - 池中所保存的线程数,包括空闲线程。

maximumPoolSize-池中允许的最大线程数。

keepAliveTime -当线程数大于核心时,此为终止前多余的空闲线程等待新任务的最长时间。

unit - keepAliveTime 参数的时间单位。

workQueue - 执行前用于保持任务的队列。此队列仅保持由execute方法提交的Runnable任务。

无界队列 LinkedBlockingQueue 有界队列 ArrayBlockingQueue

threadFactory - 执行程序创建新线程时使用的工厂。

handler - 由于超出线程范围和队列容量而使执行被阻塞时所使用的处理程序。


ThreadPoolExecutor是Executors类的底层实现。

// 线程池示例
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1, 2, 0, TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(3),Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());

2016.2.18

onBackpressureBuffer()方法将告诉Observable发射的数据如果比观察者消费的数据要更快的话,它必须把它们存储在缓存中并提供一个合适的时间给它们。


2016.2.19

Fragment

在 fragment.setArguments(…)

然后在 onCreate() 获得参数

ViewPager

android.support.v4.app.FragmentPagerAdapter 不可见时Frament不会销毁

android.support.v4.app.FragmentStatePagerAdapter 会销毁

少用 android:gravity 有坑!!!!

下面这个布局死也弄不出,中心对齐的效果。去掉gravity就行了。

	 <RelativeLayout
	            android:layout_width="0dp"
	            android:layout_height="match_parent"
	            android:layout_weight="1"
	            android:gravity="center_horizontal">

	            <ImageView
	                android:id="@+id/weixin_iv"
	                android:layout_width="wrap_content"
	                android:layout_height="wrap_content"
	                android:layout_centerVertical="true"
	                android:src="@drawable/pay_icon_weixin_normal" />

	            <TextView
	                android:id="@+id/weixin_tv"
	                android:layout_width="wrap_content"
	                android:layout_height="wrap_content"
	                android:layout_below="@id/weixin_iv"
	                android:layout_marginTop="13dp"
	                android:gravity="center"
	                android:text="@string/weixin"
	                android:textColor="@color/color_black_trans_40"
	                android:textSize="11sp" />

	            <ImageView
	                android:id="@+id/weixin_selected_iv"
	                android:layout_width="wrap_content"
	                android:layout_height="wrap_content"
	                android:layout_alignParentBottom="true"
	                android:layout_alignParentRight="true"
	                android:src="@drawable/pay_icon_jiao"
	                android:visibility="gone" />
    </RelativeLayout>

2016.02.29



blog comments powered by Disqus