Skip to content

Commit

Permalink
changed launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Null-Ouwenjie committed Jul 15, 2016
1 parent 84232fa commit 8c8ff4c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/ouwenjie/zhizhihu/common/LLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
/**
* 调试工具类 (调试模式下:日志将被打印)
*
* @author ouwenjie
* @author ouwenjie
* @version 2016年3月16日 13:50:09
*/
public class LLog {

public static final String TAG = "Lightstao";
public static final String TAG = "Zhizhihu";

// verbose
public static final int LOG_LEVEL_V = 1;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/ouwenjie/zhizhihu/common/OttoBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
public class OttoBus {

private static final Bus BUS = new Bus();
private static final Bus sBUS = new Bus();

public static Bus getInstance() {
return BUS;
return sBUS;
}

private OttoBus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
*/
public class ApiServiceFactory {

private static volatile OkHttpClient client = null;
private static volatile OkHttpClient sHttpClient = null;

private static ApiService apiService = null;
private static ApiService sApiService = null;

// 为兼容 Realm 和 Gson
private static Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
Expand All @@ -51,34 +52,34 @@ public boolean shouldSkipClass(Class<?> clazz) {
.create();

public static synchronized ApiService getApiService() {
if (client == null) {
if (sHttpClient == null) {
initHttpClient();
}
if (apiService == null) {
if (sApiService == null) {
synchronized (ApiService.class) {
if (apiService == null) {
if (sApiService == null) {
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.client(sHttpClient)
.baseUrl(AppConfig.KZH_BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
apiService = retrofit.create(ApiService.class);
sApiService = retrofit.create(ApiService.class);
}
}
}
return apiService;
return sApiService;
}

public static synchronized OkHttpClient getHttpClient() {
if (client == null) {
if (sHttpClient == null) {
initHttpClient();
}
return client;
return sHttpClient;
}

/**
* 每个获取 APIService 的方法都在先检测 client 是否为空
* 每个获取 APIService 的方法都在先检测 sHttpClient 是否为空
*/
private static void initHttpClient() {
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
Expand All @@ -93,7 +94,7 @@ private static void initHttpClient() {
}
builder.addNetworkInterceptor(HttpInterceptor);
builder.addInterceptor(HttpInterceptor);
client = builder.build();
sHttpClient = builder.build();
}

private static final Interceptor LoggingInterceptor = new Interceptor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import rx.subscriptions.CompositeSubscription;

/**
* Interface that represents a MVPPresenter in the model view presenter Pattern
* defines methods to manage the Activity / Fragment lifecycle
* Presenter 抽象类,定义了基本的类型和流程
*/
public abstract class MVPPresenter<T extends MVPView> {

Expand Down Expand Up @@ -60,7 +59,7 @@ public T getAttachedView() {
protected void doRxError(Throwable e) {
Logger.t("doRxError=> ").e(e.getMessage());
if (e instanceof ModelErrorException) {
// 网络请求成功,但 code != 1,则显示后台的 message
// 网络请求成功,但出现错误,则显示后台的 message
mViewInterface.toast(e.getMessage());
} else {
// 网络错误
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void onCompleted() {

@Override
public void onError(Throwable e) {

doRxError(e);
}

@Override
Expand Down
Binary file modified app/src/main/res/mipmap-xhdpi/icon_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8c8ff4c

Please sign in to comment.