Skip to content

Commit

Permalink
Merge pull request #1 from bboyfeiyu/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
MiJack committed Jan 4, 2016
2 parents 5e5b530 + d819883 commit 00049d3
Show file tree
Hide file tree
Showing 230 changed files with 5,576 additions and 423 deletions.
Empty file modified .gitattributes
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified android-blog/Android性能优化系列/readme.md
100644 → 100755
Empty file.
Empty file modified android-blog/Google+ 团队的 Android UI 测试/readme.md
100644 → 100755
Empty file.
Empty file modified android-blog/readme.md
100644 → 100755
Empty file.
Binary file removed androidweekly/.DS_Store
Binary file not shown.
301 changes: 301 additions & 0 deletions androidweekly/Android中的人脸检测入门.md

Large diffs are not rendered by default.

Empty file modified androidweekly/Android性能案例研究续集/readme.md
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file modified androidweekly/Square 开源库Flow和Mortar的介绍/readme.md
100644 → 100755
Empty file.
Empty file modified androidweekly/kotlin-for-android简介/readme.md
100644 → 100755
Empty file.
4 changes: 1 addition & 3 deletions androidweekly/readme.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
AndroidWeekly.net
---

# 不要将文章放到这个文件夹下啦!请放到最新的issue文件夹中,谢谢大家。
Empty file.
Empty file.
Empty file modified androidweekly/一种更清晰的Android架构/readme.md
100644 → 100755
Empty file.
399 changes: 0 additions & 399 deletions androidweekly/为你的应用加速 - 安卓优化指南/readme.md

This file was deleted.

Empty file modified androidweekly/使用Robolectric的参数化测试/readme.md
100644 → 100755
Empty file.
Empty file.
Empty file modified androidweekly/功能测试框架 espresso/readme.md
100644 → 100755
Empty file.
Empty file modified androidweekly/在Android 5.0中使用JobScheduler/readme.md
100644 → 100755
Empty file.
Empty file modified androidweekly/在Android调试模式中使用Stetho/README.md
100644 → 100755
Empty file.
Empty file modified androidweekly/安卓字体渲染器/readme.md
100644 → 100755
Empty file.
Empty file modified androidweekly/安卓的模糊视图/readme.md
100644 → 100755
Empty file.
Empty file modified androidweekly/欢迎来到Android多进程时代/readme.md
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified androidweekly/深入了解Bundle和Map/readme.md
100644 → 100755
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file modified authorization.md
100644 → 100755
Empty file.
Empty file modified git简单使用教程.md
100644 → 100755
Empty file.
Empty file modified issue-10/Android如何直播RTMP流.md
100644 → 100755
Empty file.
Empty file modified issue-10/Android进行单元测试难在哪-part2.md
100644 → 100755
Empty file.
Empty file modified issue-10/readme.md
100644 → 100755
Empty file.
Empty file modified issue-10/使用Facebook-SDK为安卓应用添加Like按钮.md
100644 → 100755
Empty file.
Empty file.
Empty file modified issue-11/Android-Espresso测试框架介绍.md
100644 → 100755
Empty file.
Empty file modified issue-11/Android进行单元测试难在哪-part3.md
100644 → 100755
Empty file.
Empty file modified issue-11/Code Review最佳实践.md
100644 → 100755
Empty file.
Empty file modified issue-11/readme.md
100644 → 100755
Empty file.
Empty file modified issue-11/听FaceBook工程师讲Custom-ViewGroups.md
100644 → 100755
Empty file.
Empty file modified issue-11/详解Dagger2.md
100644 → 100755
Empty file.
16 changes: 8 additions & 8 deletions issue-12/Android上MVP的介绍.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ god object是十分复杂的,他的每一个部分都不能重复利用,无
###总结


现在你可以发现,一个调用了setRetainInstance(true)的Fragment也不奏效,我们还是需要保存/恢复fragment的状态,所以为简化问题,我们暂不考虑上述情况的Fragment。[Occam's razor](http://en.wikipedia.org/wiki/Occam's_razor)
现在你可以发现,一个setRetainInstance(true)的Fragment也不奏效,我们还是希望这样的Fragment在所有的情景下为保存/恢复的状态模式,所以为简化问题,我们暂不考虑上述情况的Fragment。[Occam's razor](http://en.wikipedia.org/wiki/Occam's_razor)



Expand All @@ -126,7 +126,7 @@ god object是十分复杂的,他的每一个部分都不能重复利用,无
* 重启后台请求由于进程重启


第一个部分,用Android的API可以实现。第二个部分,就是Presenter的作用了。Presenter将会记住有哪些请求需要执行,当进程在执行过程中重启时,Presenter将会出现执行它们
第一个部分,用Android的API可以实现。第二个部分,就是Presenter的作用了。Presenter只会记住有哪些请求需要执行,当进程在执行过程中重启时,Presenter将会再次执行它们


#####一个简单的例子(no MVP)
Expand Down Expand Up @@ -257,7 +257,7 @@ public class MainPresenter {

```

从严格意义上来说,MainPresenter有三个事件处理线程: *onNext*, *onError*, *onTakeView*他们调用了`publish()`方法*onNext**onError*的值将会在MainActivity中发布,而不是由onTakeView提供
从严格意义上来说,MainPresenter有三个事件处理线程: *onNext*, *onError*, *onTakeView*他们在`publish()`方法中被回调*onNext**onError*的值将会在由onTakeView方法传入的View实例,也就是MainActivity中来发布


```java
Expand Down Expand Up @@ -315,19 +315,19 @@ Nucleus是我从[Mortar](https://github.com/square/mortar)和 Keep It Stupid Sim

它有以下特征:

* 它支持在View/Fragment/Activity的Bundle中保存/恢复Presenter的状态,一个Presenter可以保存请求参数,以便之后重启它们
* 它支持在View/Fragment/Activity的Bundle中保存/恢复Presenter的状态,一个Presenter可以保存它的请求参数到bundles中,以便之后重启它们

* 只需要一行代码,它就可以直接将请求结果或者错误反馈给View,所以你不需要写`!= null`之类的核对代码
* 只需要一行代码,它就可以直接将请求结果和错误反馈给View,所以你不需要写`!= null`之类的非空判断语句

* 它允许你可以有多个持有Presenter的实例。 不过你不能在用[Dagger](http://square.github.io/dagger/)实例化的presenter中这样使用(传统方法).
* 它允许一个view实例可以持有多个Presenter。不过你不能在用[Dagger](http://square.github.io/dagger/)实例化的presenter中这样使用(传统方法).

* 它可以用一行代码快速的将View和Presenter绑定。

* 它提供一些现成的基类,例如: `NucleusView`, `NucleusFragment`, `NucleusSupportFragment`, `NucleusActivity`. 你可以将他们的代码拷贝出来改造出一个自己的类以利用Nucleus的presenter。

* 支持在进程重启后,自动重新发起请求,在`onDestroy`方法中,自动的退订RxJava的订阅。

* 最后,它简洁明了,每一个开发者都会理解,Presenter的驱动只用了180行代码,RxJava用了230行代码
* 最后,它简洁明了,每一个开发者都会理解,以上这些只用了180行代码来驱动Presenter这个类,加上230行RxJava的依赖


使用了[Nucleus](https://github.com/konmik/nucleus)[例 02](https://github.com/konmik/MVPExamples/tree/master/example02)
Expand Down Expand Up @@ -385,7 +385,7 @@ public class MainActivity extends NucleusActivity<MainPresenter> {
}
```

正如你看到的,跟上一个代码相比,这个例子十分简洁。Nucleus 可以构造/销毁/变成 Presenter, 向Presenter中添加/分离 View ,并且自动向附加的view发送请求。
正如你看到的,跟上一个代码相比,这个例子十分简洁。Nucleus 可以构造/销毁/保存 Presenter, 绑定/解绑 View ,并且自动向已经绑定的view发送请求的结果

`MainPresenter`的代码比较短,因为它使用`deliverLatestCache()`的操作,延迟了由一个数据源发出所有的数据和错误,直到View可用。它还把数据缓存在内存中,以便它可以在Configuration change时可以被重用。

Expand Down
Empty file modified issue-12/Android自动截屏工具.md
100644 → 100755
Empty file.
Empty file modified issue-12/Android进行单元测试难在哪-part4.md
100644 → 100755
Empty file.
Empty file modified issue-12/MVP框架Mosby架构详解.md
100644 → 100755
Empty file.
Empty file modified issue-12/readme.md
100644 → 100755
Empty file.
Empty file.
Empty file modified issue-12/自动化Android开发.md
100644 → 100755
Empty file.
Empty file modified issue-13/Android进行单元测试难在哪-终.md
100644 → 100755
Empty file.
Empty file modified issue-13/Square:从今天开始抛弃Fragment吧!.md
100644 → 100755
Empty file.
Empty file modified issue-13/readme.md
100644 → 100755
Empty file.
Empty file modified issue-13/优化android-studio编译效率的方法.md
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions issue-13/创建-RecyclerView-LayoutManager-Part-2.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State

---

[part1]:https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-9/%E5%88%9B%E5%BB%BA-RecyclerView-LayoutManager-Part-1.md
[part1]:../issue-9/创建-RecyclerView-LayoutManager-Part-1.md
[author]:http://wiresareobsolete.com/
[part2]:https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-13/https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-13/%E5%88%9B%E5%BB%BA-RecyclerView-LayoutManager-Part-2.md
[part3]:https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-13/https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-13/%E5%88%9B%E5%BB%BA-RecyclerView-LayoutManager-Part-3.md
[part2]:http://wiresareobsolete.com/2014/09/recyclerview-layoutmanager-2/
[part3]:./创建-RecyclerView-LayoutManager-Part-3.md
[sample-github]:https://github.com/devunwired/recyclerview-playground
6 changes: 3 additions & 3 deletions issue-13/创建-RecyclerView-LayoutManager-Part-3.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State
---


[part1]:https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-9/%E5%88%9B%E5%BB%BA-RecyclerView-LayoutManager-Part-1.md
[part1]:../issue-9/创建-RecyclerView-LayoutManager-Part-1.md
[author]:http://wiresareobsolete.com/
[part2]:https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-13/%E5%88%9B%E5%BB%BA-RecyclerView-LayoutManager-Part-2.md
[part3]:https://github.com/bboyfeiyu/android-tech-frontier/blob/master/issue-13/%E5%88%9B%E5%BB%BA-RecyclerView-LayoutManager-Part-3.md
[part2]:./创建-RecyclerView-LayoutManager-Part-2.md
[part3]:http://wiresareobsolete.com/2015/02/recyclerview-layoutmanager-3/
[sample-github]:https://github.com/devunwired/recyclerview-playground
[animate-01]:http://i.embed.ly/1/display/resize?url=http%3A%2F%2Fwiresareobsolete.com%2Fwordpress%2Fwp-content%2Fuploads%2F2015%2F02%2FDefaultRecyclerAnimationsSmall.gif&grow=true&key=92b31102528511e1a2ec4040d3dc5c07
[animate-02]:http://i.embed.ly/1/display/resize?url=http%3A%2F%2Fwiresareobsolete.com%2Fwordpress%2Fwp-content%2Fuploads%2F2015%2F02%2FRecycleConceptSmall.gif&grow=true&key=92b31102528511e1a2ec4040d3dc5c07&height=400
Expand Down
Empty file modified issue-13/创建-RecyclerView-LayoutManager-Redux.md
100644 → 100755
Empty file.
Empty file modified issue-14/Android-Design-Support-Library.md
100644 → 100755
Empty file.
Empty file modified issue-14/Android之WebRTC介绍.md
100644 → 100755
Empty file.
Empty file modified issue-14/Design-Support-Library(I)-Navigation-View.md
100644 → 100755
Empty file.
Empty file modified issue-14/MVVM 模式简介.md
100644 → 100755
Empty file.
Empty file modified issue-14/新的测试注解.md
100644 → 100755
Empty file.
Empty file modified issue-15/2015-Google-IO带来的新Android开发工具 .md
100644 → 100755
Empty file.
Empty file modified issue-15/Android-C++引用计数介绍.md
100644 → 100755
Empty file.
Empty file modified issue-15/Android-M的App-Links实现详解.md
100644 → 100755
Empty file.
Empty file modified issue-15/facebook代码分析工具-infer.md
100644 → 100755
Empty file.
Empty file modified issue-15/readme.md
100644 → 100755
Empty file.
Empty file modified issue-15/你可能漏掉的知识点-onResumeFragments.md
100644 → 100755
Empty file.
Empty file modified issue-15/如何修复编译时的MultiDex崩溃.md
100644 → 100755
Empty file.
Empty file modified issue-16/Android一体机模式:规则限制.md
100644 → 100755
Empty file.
Empty file modified issue-16/readme.md
100644 → 100755
Empty file.
Empty file modified issue-16/为什么你应该停止使用EventBus.md
100644 → 100755
Empty file.
Empty file modified issue-16/手动实现布局Transitions动画-第一部分.md
100644 → 100755
Empty file.
Empty file modified issue-16/手动实现布局Transitions动画-第三部分.md
100644 → 100755
Empty file.
Empty file modified issue-16/手动实现布局Transitions动画-第二部分.md
100644 → 100755
Empty file.
Empty file modified issue-16/结合RxJava更简单地使用SQLite.md
100644 → 100755
Empty file.
Empty file modified issue-17/Android UI 自动化测试.md
100644 → 100755
Empty file.
Empty file modified issue-17/Android中的帧动画.md
100644 → 100755
Empty file.
Empty file modified issue-17/Android开发III-规范与性能.md
100644 → 100755
Empty file.
Empty file modified issue-17/readme.md
100644 → 100755
Empty file.
Empty file modified issue-17/为什么需要在你的Crash报告中使用git-SHA.md
100644 → 100755
Empty file.
Empty file modified issue-17/使用RxJava从几个数据源中加载数据.md
100644 → 100755
Empty file.
Empty file.
Empty file modified issue-17/当钢铁侠变得反应更快-RxJava.md
100644 → 100755
Empty file.
Empty file modified issue-18/Service测试.md
100644 → 100755
Empty file.
Empty file modified issue-18/readme.md
100644 → 100755
Empty file.
Empty file modified issue-18/如何提高你的代码质量.md
100644 → 100755
Empty file.
Empty file modified issue-18/拖拽RecyclerView.md
100644 → 100755
Empty file.
Empty file modified issue-18/用组合代替继承能为Activity带来什么.md
100644 → 100755
Empty file.
Empty file modified issue-18/还在用Toast?你Out啦,试试Snackbar吧!.md
100644 → 100755
Empty file.
Empty file modified issue-19/Android-UI自动化测试.md
100644 → 100755
Empty file.
Empty file modified issue-19/RxJava-Observables单元测试.md
100644 → 100755
Empty file.
Empty file modified issue-19/gradle技巧之语法浅谈.md
100644 → 100755
Empty file.
Empty file modified issue-19/readme.md
100644 → 100755
Empty file.
Empty file modified issue-20/readme.md
100644 → 100755
Empty file.
Empty file modified issue-20/在你开发应用前应知道的六件事情.md
100644 → 100755
Empty file.
Empty file modified issue-20/检测和解决Android应用的性能问题.md
100644 → 100755
Empty file.
Empty file modified issue-21/Android数据绑定-再见Presenter,你好ViewModel.md
100644 → 100755
Empty file.
Empty file modified issue-21/TextView预渲染研究.md
100644 → 100755
Empty file.
Empty file modified issue-21/Yelp是如何通过Glide优化图片加载的.md
100644 → 100755
Empty file.
Empty file modified issue-21/使用Mockito对异步方法进行单元测试.md
100644 → 100755
Empty file.
Empty file modified issue-22/Android中的AOP编程.md
100644 → 100755
Empty file.
Empty file modified issue-22/Binder框架解析.md
100644 → 100755
Empty file.
Empty file modified issue-22/深入剖析Android网络开发库-part1.md
100644 → 100755
Empty file.
Empty file modified issue-23/Android-MVPR-架构模式-Part1.md
100644 → 100755
Empty file.
Empty file modified issue-23/Android-MVVM模式.md
100644 → 100755
Empty file.
Empty file modified issue-23/使用Espresso进行UI测试.md
100644 → 100755
Empty file.
Empty file modified issue-23/使用TDD的方式开发一个Hackernews客户端.md
100644 → 100755
Empty file.
Empty file modified issue-24/Android双向数据绑定.md
100644 → 100755
Empty file.
Empty file modified issue-24/适用于Android的Flux架构.md
100644 → 100755
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#为什么不仅继承Observale而且使用Observale.create()?
---

> * 原文链接 : [Why use Observable.create() and not just inherit from Observable?](http://www.grokkingandroid.com/why-use-observable-create-and-not-just-inherit-from-observable/?utm_source=Android+Weekly&utm_campaign=553bcbfc02-Android_Weekly_174&utm_medium=email&utm_term=0_4eb677ad19-553bcbfc02-337955857)
* 原文作者 :[Wolfram Rittmeyer](http://www.grokkingandroid.com/author/writtmeyer/)
* [译文出自 : 开发技术前线 www.devtf.cn](http://www.devtf.cn)
* 译者 : [dengshiwei](https://github.com/dengshiwei)
* 校对者: [desmond1121](https://github.com/desmond1121)
* 状态 : 已完成

在你开始使用[RxJava](https://github.com/ReactiveX/RxJava/wiki)的时候,你需要创建Observables。它们是RxJava的核心,但是应该怎么做呢?

看下[Observable](http://reactivex.io/RxJava/javadoc/rx/Observable.html)类可能会让你头晕,看到Observable类的源码更是如此。这个类不仅包含了近10000行代码(虽然其中7600行是注释)而且包含了大量的final methods。实际上仅final methods就有330个。但是你可以继承Observable,奇怪,很奇怪。

接下来你可能会想:没关系,让我继承Observable来看看我能继承多少。

但是你应该不介意看看这个类的构造函数说明文档,你可以看到:

```
注意: 除了你明确的需要继承的情况下,使用create(OnSubscribe)方法替代这个构造函数来创建一个 Observable对象。
```

好吧!既然你这么想知道这到底是怎么回事,你需要看一看onCreate()方法的说明文档:

```
返回一个Observable对象,当一个Subscriber订阅它时执行特定的功能。
...
编写你传递给create()方法的函数以便它的行为作为一个Observable:它应该适当地唤醒Subscriber的onNext、onError、和onCompleted方法。
...
一个标准的Observable必须恰好唤醒一次Subscriber的onCompleted方法或它的onError方法。
```

额,看下这个方法的代码可能有些帮助?

public final static Observable create(OnSubscribe f) {
return new Observable(hook.onCreate(f));
}

什么?它将参数传递给构造函数?这警告又是什么呢?

好吧,第一:为什么你把继承Observable放在第一位?它的所有方法都是final类型的,因此你通过继承基本不可能给Observable增加更多的功能函数。坚持RxJava的方式做事情是不错的:通过chaining API调用它的fluent API。

另一方面:它是不明确的,使用create()方法你可以直观看到创造的Observable对象。

此外:如果你仔细看看源代码,你回注意到一个小小的引用hook.onCreate()。这是非常重要的,因为RxJava允许你提供包含特定方法的hook对象和允许你替换具体的RxJava的工作。

有次我在调试模式下使用hook来记录哪个线程创建observables对象以及在什么线程上进行工作。在服务器环境下,你可能希望为你的hooks对象添加监视逻辑,通过使用构造方法,你可以解决这一问题同时提高自己做的可能性以及简单化、

说了这么多关于:继承Observable是不被禁止的,在所有规则条件下,总有一些情况下它是不适用的和一些情况下它是有意义的。例如,[Subject](http://reactivex.io/RxJava/javadoc/rx/subjects/Subject.html)类是继承于Observable。只要仔细点同时使用时多想想。
File renamed without changes.
Loading

0 comments on commit 00049d3

Please sign in to comment.