程序亦非猿

菩提本无树,程序亦非猿。


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 友链

  • 搜索

Thread相关知识点整理

发表于 2015-10-20 | 更新于: 2019-02-12 | 分类于 Android | 阅读次数:
字数统计: 1.2k | 阅读时长 ≈ 5 分钟

Thread

多线程,举足轻重,记录整理部分相关的重要的知识点,后续应该还需要再学习一下Runnable,线程池.

后面有提到monitor,翻译为 监视器

线程的状态图/生命周期图:
Thread-LifeCycle

阅读全文 »

RxJava操作符续

发表于 2015-10-16 | 更新于: 2019-02-12 | 分类于 Android | 阅读次数:
字数统计: 993 | 阅读时长 ≈ 3 分钟

前言

RxJava处理数据主要还是靠不同的操作符,在这里对RxJava比较常用的操作符做必要的介绍,附加一些自己的理解.

操作符有难有易,部分操作符非常简单容易理解,只记录些许文字
部分操作符复杂,可能会配有弹珠图,它十分有助于对操作符的理解,而理解弹珠图,前提是知道每个元素的意义,特给出下图:

一定要理解

OK,准备就绪,开启RxJava操作符之旅吧!

阅读全文 »

Twitter相关功能集成

发表于 2015-10-12 | 更新于: 2019-02-12 | 分类于 Android | 阅读次数:
字数统计: 2k | 阅读时长 ≈ 9 分钟

前言

app 未来可能有要往国外推的需求,需要做Facebook,Twitter登录,FB用umeng搞定了部分,剩下Twitter需要自己做.

Create-App

前提是你有账号,去注册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
7
Thank 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

发表于 2015-10-12 | 更新于: 2019-02-12 | 分类于 Android | 阅读次数:
字数统计: 2k | 阅读时长 ≈ 9 分钟

前言

自定义View有几个非常重要的流程:

  1. onFinishInflate()
  2. onAttachedToWindow()
  3. onMeasure(int widthMeasureSpec, int heightMeasureSpec)
  4. onLayout(boolean changed, int l, int t, int r, int b)
  5. onDraw(Canvas canvas)
  6. onDetachedFromWindow()

这里来学习一下onMeasure(重点讲),onLayout(大致了解),另外这里也侧重ViewGroup,因为vp比较难,如果把vp弄懂了,view应该也不在话下.

先讲几个知识点:

  1. onMeasure 负责测量大小,如果是View则测量自己,如果是ViewGroup则测量子View和自己.
  2. onMeasure 最终需要调用setMeasuredDimension(int measuredWidth, int measuredHeight)设置大小.
  3. onMeasure后,严格来说是setMeasuredDimension调用后,可以通过getMeasuredHeight(),getMeasuredWidth()获得测量的宽高
  4. onLayout 负责布局,即把子View放在哪里.
  5. onLayout 后可以调用getWidth,getHeight获取宽高,与之前的getMeasuredXXX不同,他们可能不相等.
  6. onMeasure onLayout 都可能执行很多次.
阅读全文 »

使用Swiftype做搜索引擎

发表于 2015-10-10 | 更新于: 2019-02-12 | 分类于 Android | 阅读次数:
字数统计: 143 | 阅读时长 ≈ 1 分钟

前言

为Hexo-Next 博客配置一个搜索引擎.

Swiftype

先去注册个账号,但是先别急着创建引擎.

在Sitemap.xml Support看Installing Your Sitemap小节.

按着步骤来,在博客根目录下新建一个robots.txt文件,填入内容

1
2
3
User-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.

NexT-配置
NexT-Github

使用Canvas绘制几何图形

发表于 2015-10-09 | 更新于: 2019-02-12 | 分类于 Android | 阅读次数:
字数统计: 1.2k | 阅读时长 ≈ 5 分钟

前言

这是我学习自定义View系列中的使用Canvas绘制几何图形.

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方法,不过,这里我只学习记录如何绘制几何图形以及效果:

  1. 点
  2. 直线
  3. 矩形(正方形)
  4. 弧形(扇形)
  5. 椭圆(圆)

坐标系

在学习这些知识之前,先来讲讲坐标系.
在Android中每个View都有着自己的坐标系,都是以自己的左上角的点为原点.
需要注意的是Y轴正方向是向下的

坐标系示意图

阅读全文 »

Hexo奇淫技巧

发表于 2015-09-29 | 更新于: 2021-02-08 | 分类于 Tools | 阅读次数:
字数统计: 305 | 阅读时长 ≈ 1 分钟

前言

收集记录一些Hexo的奇淫技巧~

自动打开刚添加的文章

  1. 在Hexo目录下新建scripts目录(有就无视)
  2. 在scripts下新建js脚本,名字随意(例子:/Users/alanchen/Documents/hexoblog/scripts/openfile.js)
  3. 在刚新建的脚本输入以下内容
    1
    2
    3
    4
    5
    var exec = require('child_process').exec;
    // Hexo 3 用户复制这段
    hexo.on('new', function(data){
    exec('open -a "/Applications/Atom.app" ' + data.path);
    });

PS:/Applications/Atom.app 为你要使用的编辑器的绝对路径!

保存退出后使用hexo n "filename"命令后会用指定的app打开文章,非常方便.

来源
Hexo添加文章时自动打开编辑器

添加网易云音乐

阅读全文 »

开发工具汇总

发表于 2015-09-28 | 更新于: 2019-02-12 | 分类于 Tools | 阅读次数:
字数统计: 385 | 阅读时长 ≈ 1 分钟

前言

开发Android不光用的只是AndroidStudio.
在这里记录好用的各种类型的工具/App.

Mac App

Go2Shell

一个小巧而强大的工具,快速在当前位置打开Shell

Dash

一个非常强大的文档工具.

Iterm2

神器..

Oh,my zsh

iterm2配ohmyzsh,爽到爆.

  1. 终极 Shell
阅读全文 »

SublimeText

发表于 2015-09-27 | 更新于: 2019-02-12 | 分类于 Tools | 阅读次数:
字数统计: 44 | 阅读时长 ≈ 1 分钟

SublimeText

Package Control

subl

配置环境变量使用subl
/Applications/Sublime Text.app/Contents/SharedSupport/bin

快捷键

Key 作用
command+shift+p 打开命令模式
阅读全文 »

RxJava之Subscription

发表于 2015-09-25 | 更新于: 2019-02-12 | 分类于 Java | 阅读次数:
字数统计: 659 | 阅读时长 ≈ 3 分钟

前言

前面写过RxJava类似观察者模式,但是一直没提到RxJava如何取消订阅,今天就来学习一下.

Subscription

RxJava中有个叫做Subscription的接口,可以用来取消订阅.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public 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对象呢?

阅读全文 »
1…101112…15
程序亦非猿

程序亦非猿

144 日志
11 分类
101 标签
GitHub
0%
© 2015 — 2021 程序亦非猿 | Site words total count: 122.7k
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.4
人次 次