Skip to content

Commit 11dd436

Browse files
committed
finish main activity
1 parent c27b8a4 commit 11dd436

35 files changed

+4224
-763
lines changed

app/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ dependencies {
2525
testCompile 'junit:junit:4.12'
2626
compile 'com.android.support:appcompat-v7:23.2.1'
2727
compile 'com.android.support:design:23.2.1'
28-
compile 'com.facebook.fresco:fresco:0.9.0+'
28+
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
2929
compile 'com.android.support:recyclerview-v7:23.2.1'
30-
compile 'com.jakewharton:butterknife:7.0.1'
3130
compile 'com.commit451:PhotoView:1.2.4'
3231
compile 'de.greenrobot:greendao:2.1.0'
3332
compile 'de.greenrobot:greendao-generator:2.1.0'
34-
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
35-
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
3633
compile 'com.android.support:support-v4:23.2.1'
3734
compile files('libs/commons-codec-1.6.jar')
3835
compile 'io.reactivex:rxjava:1.1.1'
3936
compile 'io.reactivex:rxandroid:1.1.0'
37+
38+
4039
}

app/libs/commons-codec-1.6.jar

-227 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,25 @@
1010
<application
1111
android:name=".App"
1212
android:allowBackup="true"
13+
android:configChanges="orientation|keyboardHidden|screenSize"
1314
android:icon="@mipmap/ic_launcher"
1415
android:label="@string/app_name"
16+
android:screenOrientation="portrait"
1517
android:supportsRtl="true"
1618
android:theme="@style/AppTheme">
1719
<activity
18-
android:name=".actiity.MainActivity"
19-
android:label="@string/app_name"
20-
android:theme="@style/AppTheme.NoActionBar"></activity>
20+
android:name=".actiity.MainActivity"></activity>
2121
<activity
2222
android:name=".actiity.splashActivity"
23-
android:configChanges="orientation|keyboardHidden|screenSize"
24-
android:label="@string/title_activity_splash"
2523
android:theme="@style/FullscreenTheme">
2624
<intent-filter>
2725
<action android:name="android.intent.action.MAIN" />
28-
2926
<category android:name="android.intent.category.LAUNCHER" />
3027
</intent-filter>
3128
</activity>
3229

33-
<activity
34-
android:name=".base.BaseWebActivity"
35-
android:screenOrientation="portrait"
36-
android:theme="@style/AppTheme.NoActionBar" />
37-
30+
<activity android:name=".base.BaseWebActivity" />
31+
<activity android:name=".actiity.PhotoPagerActivity" />
3832
<service android:name=".InitDataService" />
3933
</application>
4034

app/src/main/java/com/jiang/android/rxjavaapp/App.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@
2929
package com.jiang.android.rxjavaapp;
3030

3131
import android.app.Application;
32+
import android.content.Context;
33+
import android.graphics.Bitmap;
3234

33-
import com.facebook.drawee.backends.pipeline.Fresco;
3435
import com.jiang.android.rxjavaapp.database.helper.DbCore;
36+
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
37+
import com.nostra13.universalimageloader.core.DisplayImageOptions;
38+
import com.nostra13.universalimageloader.core.ImageLoader;
39+
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
40+
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
41+
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
42+
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
3543

3644
/**
3745
* Created by jiang on 16/3/13.
@@ -40,7 +48,38 @@ public class App extends Application {
4048
@Override
4149
public void onCreate() {
4250
super.onCreate();
43-
Fresco.initialize(this);
4451
DbCore.init(this);
52+
initImageLoader(getApplicationContext());
53+
}
54+
55+
private void initImageLoader(Context context) {
56+
57+
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
58+
//.showImageForEmptyUri(R.drawable.ic_empty)
59+
//.showImageOnFail(R.drawable.ic_error)
60+
.resetViewBeforeLoading(true)
61+
.cacheInMemory(true)
62+
.cacheOnDisk(true)
63+
.imageScaleType(ImageScaleType.EXACTLY)
64+
.bitmapConfig(Bitmap.Config.RGB_565)
65+
.considerExifParams(true)
66+
.displayer(new FadeInBitmapDisplayer(300))
67+
.build();
68+
69+
// This configuration tuning is custom. You can tune every option, you may tune some of them,
70+
// or you can create default configuration by
71+
// ImageLoaderConfiguration.createDefault(this);
72+
// method.
73+
ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
74+
config.threadPriority(Thread.NORM_PRIORITY - 2);
75+
config.denyCacheImageMultipleSizesInMemory();
76+
config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
77+
config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
78+
config.tasksProcessingOrder(QueueProcessingType.LIFO);
79+
config.defaultDisplayImageOptions(defaultOptions);
80+
81+
// Initialize ImageLoader with configuration.
82+
ImageLoader.getInstance().init(config.build());
83+
4584
}
4685
}

app/src/main/java/com/jiang/android/rxjavaapp/InitDataService.java

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
import android.widget.Toast;
3434

3535
import com.jiang.android.rxjavaapp.actiity.MainActivity;
36+
import com.jiang.android.rxjavaapp.common.CommonString;
37+
import com.jiang.android.rxjavaapp.common.OperatorsUrl;
3638
import com.jiang.android.rxjavaapp.common.SPKey;
39+
import com.jiang.android.rxjavaapp.database.alloperators;
3740
import com.jiang.android.rxjavaapp.database.helper.DbUtil;
3841
import com.jiang.android.rxjavaapp.database.operators;
3942
import com.jiang.android.rxjavaapp.utils.L;
@@ -65,14 +68,16 @@ public void call(Subscriber<? super Boolean> subscriber) {
6568

6669
try {
6770
List<operators> lists = getOperatorsData();
71+
List<alloperators> alloperatorses = getAllOperators();
6872
DbUtil.getOperatorsService().save(lists);
73+
DbUtil.getAllOperatorsService().save(alloperatorses);
6974
subscriber.onNext(true);
7075
subscriber.onCompleted();
7176
} catch (Exception e) {
7277
subscriber.onError(e);
7378
}
7479
}
75-
}).subscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<Boolean>() {
80+
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<Boolean>() {
7681
@Override
7782
public void onCompleted() {
7883
Toast.makeText(InitDataService.this, "数据库初始化成功", Toast.LENGTH_SHORT).show();
@@ -98,38 +103,63 @@ public void onNext(Boolean operatorss) {
98103

99104
public List<operators> getOperatorsData() {
100105
List<operators> lists = new ArrayList<>();
101-
lists.add(new operators(0l, "Creating", 1l));
102-
lists.add(new operators(1l, "Transforming", 2l));
103-
lists.add(new operators(2l, "Filtering", 3l));
104-
lists.add(new operators(3l, "Combining", 4l));
105-
lists.add(new operators(4l, "Error Handling", 5l));
106-
lists.add(new operators(5l, "Utility", 6l));
107-
lists.add(new operators(6l, "Conditional", 7l));
108-
lists.add(new operators(7l, "Mathematical", 8l));
109-
lists.add(new operators(8l, "Async", 9l));
110-
lists.add(new operators(9l, "Connect", 10l));
111-
lists.add(new operators(10l, "Convert", 11l));
112-
lists.add(new operators(11l, "Blocking", 12l));
113-
lists.add(new operators(12l, "String", 13l));
106+
lists.add(new operators(1l, "RxJava介绍", 1l));
107+
lists.add(new operators(2l, "Creating", 2l));
108+
lists.add(new operators(3l, "Transforming", 3l));
109+
lists.add(new operators(4l, "Filtering", 4l));
110+
lists.add(new operators(5l, "Combining", 5l));
111+
lists.add(new operators(6l, "Error Handling", 6l));
112+
lists.add(new operators(7l, "Utility", 7l));
113+
lists.add(new operators(8l, "Conditional", 8l));
114+
lists.add(new operators(9l, "Mathematical", 9l));
115+
lists.add(new operators(10l, "Async", 10l));
116+
lists.add(new operators(11l, "Connect", 11l));
117+
lists.add(new operators(12l, "Convert", 12l));
118+
lists.add(new operators(13l, "Blocking", 13l));
119+
lists.add(new operators(14l, "String", 14l));
114120
return lists;
115121
}
122+
116123
/**
117-
*
118-
*
119124
* Creating 创建操作 - Create/Defer/From/Just/Start/Repeat/Range
120-
Transforming 变换操作 - Buffer/Window/Map/FlatMap/GroupBy/Scan
121-
Filtering 过滤操作 - Debounce/Distinct/Filter/Sample/Skip/Take
122-
Combining 结合操作 - And/StartWith/Join/Merge/Switch/Zip
123-
Error Handling 错误处理 - Catch/Retry
124-
Utility 辅助操作 - Delay/Do/ObserveOn/SubscribeOn/Subscribe
125-
Conditional 条件和布尔操作 - All/Amb/Contains/SkipUntil/TakeUntil
126-
Mathematical 算术和聚合操作 - Average/Concat/Count/Max/Min/Sum/Reduce
127-
Async 异步操作 - Start/ToAsync/StartFuture/FromAction/FromCallable/RunAsync
128-
Connect 连接操作 - Connect/Publish/RefCount/Replay
129-
Convert 转换操作 - ToFuture/ToList/ToIterable/ToMap/toMultiMap
130-
Blocking 阻塞操作 - ForEach/First/Last/MostRecent/Next/Single/Latest
131-
String 字符串操作 - ByLine/Decode/Encode/From/Join/Split/StringConcat
125+
* Transforming 变换操作 - Buffer/Window/Map/FlatMap/GroupBy/Scan
126+
* Filtering 过滤操作 - Debounce/Distinct/Filter/Sample/Skip/Take
127+
* Combining 结合操作 - And/StartWith/Join/Merge/Switch/Zip
128+
* Error Handling 错误处理 - Catch/Retry
129+
* Utility 辅助操作 - Delay/Do/ObserveOn/SubscribeOn/Subscribe
130+
* Conditional 条件和布尔操作 - All/Amb/Contains/SkipUntil/TakeUntil
131+
* Mathematical 算术和聚合操作 - Average/Concat/Count/Max/Min/Sum/Reduce
132+
* Async 异步操作 - Start/ToAsync/StartFuture/FromAction/FromCallable/RunAsync
133+
* Connect 连接操作 - Connect/Publish/RefCount/Replay
134+
* Convert 转换操作 - ToFuture/ToList/ToIterable/ToMap/toMultiMap
135+
* Blocking 阻塞操作 - ForEach/First/Last/MostRecent/Next/Single/Latest
136+
* String 字符串操作 - ByLine/Decode/Encode/From/Join/Split/StringConcat
137+
*/
138+
139+
public List<alloperators> getAllOperators() {
140+
141+
List<alloperators> alloperatorses = new ArrayList<>();
142+
getIntroduceList(alloperatorses);
143+
return alloperatorses;
144+
}
145+
146+
private void getIntroduceList(List<alloperators> alloperatorses) {
147+
alloperatorses.add(new alloperators(1l, "ReactiveX", "什么是Rx,Rx的理念和优势", CommonString.SPLASH_INDEX_URL, OperatorsUrl.INTRODUCE, 1l));
148+
alloperatorses.add(new alloperators(2l, "Observables", "简要介绍Observable的观察者模型", CommonString.OBSERVABLES, OperatorsUrl.OBSERVABLES, 1l));
149+
alloperatorses.add(new alloperators(3l, "Single", "一种特殊的只发射单个值的Observable", CommonString.SPLASH_INDEX_URL, OperatorsUrl.SINGLE, 1l));
150+
alloperatorses.add(new alloperators(4l, "Subject", "Observable和Observer的复合体,也是二者的桥梁", CommonString.SUBJECT, OperatorsUrl.SUBJECT, 1l));
151+
alloperatorses.add(new alloperators(5l, "Scheduler", "介绍了各种异步任务调度和默认调度器", CommonString.SPLASH_INDEX_URL, OperatorsUrl.SCHEDULE, 1l));
152+
153+
}
154+
155+
156+
/**
132157
*
133158
*
159+
* ReactiveX - 什么是Rx,Rx的理念和优势
160+
Observables - 简要介绍Observable的观察者模型
161+
Single - 一种特殊的只发射单个值的Observable
162+
Subject - Observable和Observer的复合体,也是二者的桥梁
134163
*/
164+
135165
}

0 commit comments

Comments
 (0)