Skip to content

Commit 0af1875

Browse files
committed
Improve comment
1 parent 4f483ee commit 0af1875

File tree

9 files changed

+141
-28
lines changed

9 files changed

+141
-28
lines changed

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,32 @@ compile 'me.jessyan:rxerrorhandler:2.0.2' //rxjava2
1414
compile 'me.jessyan:rxerrorhandler:1.0.1' //rxjava1
1515
```
1616

17-
## Usage
18-
### Step 1
17+
## Initialization
18+
1919
``` java
2020
RxErrorHandler rxErrorHandler = RxErrorHandler
2121
.builder()
2222
.with(this)
2323
.responseErrorListener(new ResponseErrorListener() {
2424
@Override
2525
                   public void handleResponseError(Context context, Throwable t) {
26-
Log.w(TAG, "error handle");
2726
if (t instanceof UnknownHostException) {
28-
//Do something
29-
}else if (t instanceof SocketTimeoutException) {
30-
//Do something
31-
}//Handle other Exception
32-
}
33-
}).build();
27+
//do something ...
28+
} else if (t instanceof SocketTimeoutException) {
29+
//do something ...
30+
} else {
31+
//handle other Exception ...
32+
}
33+
Log.w(TAG, "Error handle");
34+
}
35+
}).build(); //
3436
```
3537

36-
### Step 2
38+
## Usage
3739

3840
``` java
3941
Observable
40-
.error(new Exception("erro"))
42+
.error(new Exception("Error"))
4143
.retryWhen(new RetryWithDelay(3, 2))//retry(http connect timeout)
4244
.subscribe(new ErrorHandleSubscriber<Object>(rxErrorHandler) {
4345
@Override
@@ -48,11 +50,6 @@ compile 'me.jessyan:rxerrorhandler:1.0.1' //rxjava1
4850
});
4951
```
5052

51-
## ProGuard
52-
```
53-
-keep class me.jessyan.rxerrorhandler.** { *; }
54-
-keep interface me.jessyan.rxerrorhandler.** { *; }
55-
```
5653

5754
## About Me
5855
* **Email**: <jess.yan.effort@gmail.com>

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android {
2525

2626
dependencies {
2727
compile fileTree(include: ['*.jar'], dir: 'libs')
28-
compile 'com.android.support:appcompat-v7:25.3.1'
28+
compile 'com.android.support:appcompat-v7:26.0.2'
2929
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
3030
// compile 'me.jessyan:rxerrorhandler:2.0.2'
3131
compile project(':rxerrorhandler')

app/src/main/java/me/jessyan/rxerrorhandler/demo/MainActivity.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2017 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package me.jessyan.rxerrorhandler.demo;
217

318
import android.content.Context;
@@ -17,6 +32,13 @@
1732
import me.jessyan.rxerrorhandler.handler.RetryWithDelay;
1833
import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener;
1934

35+
/**
36+
* ================================================
37+
* Created by JessYan on 9/2/2016 13:27
38+
* Contact with <mailto:jess.yan.effort@gmail.com>
39+
* Follow me on <https://github.com/JessYanCoding>
40+
* ================================================
41+
*/
2042
public class MainActivity extends AppCompatActivity {
2143
private final String TAG = getClass().getSimpleName();
2244

@@ -37,6 +59,8 @@ public void handleResponseError(Context context, Throwable t) {
3759
//do something ...
3860
} else if (t instanceof ParseException || t instanceof JSONException) {
3961
//do something ...
62+
} else {
63+
//handle other Exception ...
4064
}
4165
Log.w(TAG, "Error handle");
4266
}

rxerrorhandler/proguard-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
19+
-keep class me.jessyan.rxerrorhandler.** { *; }
20+
-keep interface me.jessyan.rxerrorhandler.** { *; }

rxerrorhandler/src/main/java/me/jessyan/rxerrorhandler/core/RxErrorHandler.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2017 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package me.jessyan.rxerrorhandler.core;
217

318
import android.content.Context;
@@ -6,8 +21,11 @@
621
import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener;
722

823
/**
9-
* Created by jess on 9/2/16 13:27
10-
* Contact with jess.yan.effort@gmail.com
24+
* ================================================
25+
* Created by JessYan on 9/2/2016 13:27
26+
* Contact with <mailto:jess.yan.effort@gmail.com>
27+
* Follow me on <https://github.com/JessYanCoding>
28+
* ================================================
1129
*/
1230
public class RxErrorHandler {
1331
public final String TAG = this.getClass().getSimpleName();

rxerrorhandler/src/main/java/me/jessyan/rxerrorhandler/handler/ErrorHandleSubscriber.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2017 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package me.jessyan.rxerrorhandler.handler;
217

318
import io.reactivex.Observer;
@@ -6,10 +21,12 @@
621
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
722

823
/**
9-
* Created by jess on 9/2/16 14:41
10-
* Contact with jess.yan.effort@gmail.com
24+
* ================================================
25+
* Created by JessYan on 9/2/2016 14:41
26+
* Contact with <mailto:jess.yan.effort@gmail.com>
27+
* Follow me on <https://github.com/JessYanCoding>
28+
* ================================================
1129
*/
12-
1330
public abstract class ErrorHandleSubscriber<T> implements Observer<T> {
1431
private ErrorHandlerFactory mHandlerFactory;
1532

rxerrorhandler/src/main/java/me/jessyan/rxerrorhandler/handler/ErrorHandlerFactory.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1+
/**
2+
* Copyright 2017 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package me.jessyan.rxerrorhandler.handler;
217

318
import android.content.Context;
419

520
import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener;
621

722
/**
8-
* Created by jess on 9/2/16 13:47
9-
* Contact with jess.yan.effort@gmail.com
23+
* ================================================
24+
* Created by JessYan on 9/2/2016 13:47
25+
* Contact with <mailto:jess.yan.effort@gmail.com>
26+
* Follow me on <https://github.com/JessYanCoding>
27+
* ================================================
1028
*/
1129
public class ErrorHandlerFactory {
1230
public final String TAG = this.getClass().getSimpleName();

rxerrorhandler/src/main/java/me/jessyan/rxerrorhandler/handler/RetryWithDelay.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2017 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package me.jessyan.rxerrorhandler.handler;
217

318
import android.util.Log;
@@ -10,8 +25,11 @@
1025
import io.reactivex.functions.Function;
1126

1227
/**
13-
* Created by jess on 9/2/16 14:32
14-
* Contact with jess.yan.effort@gmail.com
28+
* ================================================
29+
* Created by JessYan on 9/2/16 14:32
30+
* Contact with <mailto:jess.yan.effort@gmail.com>
31+
* Follow me on <https://github.com/JessYanCoding>
32+
* ================================================
1533
*/
1634
public class RetryWithDelay implements
1735
Function<Observable<Throwable>, ObservableSource<?>> {

rxerrorhandler/src/main/java/me/jessyan/rxerrorhandler/handler/listener/ResponseErrorListener.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
/**
2+
* Copyright 2017 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package me.jessyan.rxerrorhandler.handler.listener;
217

318
import android.content.Context;
419

520
/**
6-
* Created by jess on 9/2/16 13:58
7-
* Contact with jess.yan.effort@gmail.com
21+
* ================================================
22+
* Created by JessYan on 9/2/2016 13:58
23+
* Contact with <mailto:jess.yan.effort@gmail.com>
24+
* Follow me on <https://github.com/JessYanCoding>
25+
* ================================================
826
*/
927
public interface ResponseErrorListener {
1028
void handleResponseError(Context context, Throwable t);

0 commit comments

Comments
 (0)