Thread
多线程,举足轻重,记录整理部分相关的重要的知识点,后续应该还需要再学习一下Runnable,线程池.
后面有提到monitor,翻译为 监视器
线程的状态图/生命周期图:
app 未来可能有要往国外推的需求,需要做Facebook,Twitter登录,FB用umeng搞定了部分,剩下Twitter需要自己做.
前提是你有账号,去注册Twitter
Twitter开发者平台创建开发者账号
这里有个很难搞的坑,就是创建应用需要添加手机号,否则你会得到以下错误:
Error
You must add your mobile phone to your Twitter profile before creating an application. Please read https://support.twitter.com/articles/110250-adding-your-mobile-number-to-your-account-via-web for more information.
但是令人发指的是,Twitter又不支持中国大陆+86的手机,遇到这个问题后瞬间整个人就不好了…
但是还是得完成啊,于是百般搜索,寻找解决方案,无果.
最后给twitter support(support@twitter.com)发了邮件,最终,人家给我开通了时间有限的权限.1
2
3
4
5
6
7Thank you for reaching out. We’re aware that you are not able to register a mobile phone number to your account. We have enabled access for you to create an app without doing so. Please note that this access will expire 7 days from the date of this email, so you must create your app within this time frame.
While developing your application, please review our Developer Agreement and Policy to ensure that your application is compliant with our Rules.
Regards,
ElliotSamuelson
Twitter Platform Operations
finally,我可以创建应用了.
自定义View有几个非常重要的流程:
这里来学习一下onMeasure(重点讲),onLayout(大致了解),另外这里也侧重ViewGroup,因为vp比较难,如果把vp弄懂了,view应该也不在话下.
先讲几个知识点:
setMeasuredDimension(int measuredWidth, int measuredHeight)设置大小.setMeasuredDimension调用后,可以通过getMeasuredHeight(),getMeasuredWidth()获得测量的宽高getWidth,getHeight获取宽高,与之前的getMeasuredXXX不同,他们可能不相等. 为Hexo-Next 博客配置一个搜索引擎.
先去注册个账号,但是先别急着创建引擎.
在Sitemap.xml Support看Installing Your Sitemap小节.
按着步骤来,在博客根目录下新建一个robots.txt文件,填入内容1
2
3User-agent: *
Sitemap: http://www.yourdomain.com/sitemap1.xml
Sitemap: http://www.yourdomain.com/sitemap2.xml
拿我的为例:1
Sitemap: http://yifeiyuan.me/sitemap.xml
添加完后,push到github.
然后创建引擎,一步一步走,拿到 swiftype_key.
最后,编辑站点配置文件,新增字段 swiftype_key,配置好即可.
:1
2# Swiftype Search Key
swiftype_key: xxxxxxxxx
done.
这是我学习自定义View系列中的使用Canvas绘制几何图形.
The Canvas class holds the “draw” calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing).
Developer Guides: For more information about how to use Canvas, read the Canvas and Drawables developer guide.
可以看出要使用Canvas,我们还需要一个bitmap(画在什么上),一个原型(画什么),一个Paint(用什么笔画).
感觉Canvas更像是个媒介.
PS:Paint不是本文重点,就不提供Paint的相关代码了(其实就换换颜色什么的).
Canvas拥有各种draw方法,不过,这里我只学习记录如何绘制几何图形以及效果:
在学习这些知识之前,先来讲讲坐标系.
在Android中每个View都有着自己的坐标系,都是以自己的左上角的点为原点.
需要注意的是Y轴正方向是向下的

收集记录一些Hexo的奇淫技巧~
/Users/alanchen/Documents/hexoblog/scripts/openfile.js)1 | var exec = require('child_process').exec; |
PS:/Applications/Atom.app 为你要使用的编辑器的绝对路径!
保存退出后使用hexo n "filename"命令后会用指定的app打开文章,非常方便.
配置环境变量使用subl/Applications/Sublime Text.app/Contents/SharedSupport/bin
| Key | 作用 |
|---|---|
| command+shift+p | 打开命令模式 |
前面写过RxJava类似观察者模式,但是一直没提到RxJava如何取消订阅,今天就来学习一下.
RxJava中有个叫做Subscription的接口,可以用来取消订阅.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public interface Subscription {
/**
* Stops the receipt of notifications on the {@link Subscriber} that was registered when this Subscription
* was received.
* <p>
* This allows unregistering an {@link Subscriber} before it has finished receiving all events (i.e. before
* onCompleted is called).
*/
void unsubscribe();
/**
* Indicates whether this {@code Subscription} is currently unsubscribed.
*
* @return {@code true} if this {@code Subscription} is currently unsubscribed, {@code false} otherwise
*/
boolean isUnsubscribed();
}
从上面可以看到,我们只需要调用unsubscribe就可以取消订阅,那么如何得到一个Subscription对象呢?