diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
new file mode 100644
index 0000000..2a9c5e0
--- /dev/null
+++ b/.idea/assetWizardSettings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
new file mode 100644
index 0000000..c198fde
Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.travis.yml b/.travis.yml
index 0b7f966..35b743c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,12 +1,12 @@
language: android
jdk: oraclejdk8
before_install:
-- yes | sdkmanager "platforms;android-25"
+- yes | sdkmanager "platforms;android-27"
env:
global:
- - ANDROID_API_LEVEL=25
- - ANDROID_BUILD_TOOLS_VERSION=25.0.2
+ - ANDROID_API_LEVEL=27
+ - ANDROID_BUILD_TOOLS_VERSION=27.0.3
- TRAVIS_SECURE_ENV_VARS=true
android:
@@ -25,4 +25,4 @@ android:
script:
- ./gradlew clean
- - ./gradlew assembleDebug
+ - ./gradlew assembleDebug
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 16c1fae..00e765c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,25 +1,24 @@
+The MIT License (MIT)
+Copyright (c) 2017 Jenly Yu
+https://github.com/jenly1314
- The MIT License (MIT)
- Copyright (c) 2017 Jenly Yu
- https://github.com/jenly1314
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to permit
+persons to whom the Software is furnished to do so, subject to the
+following conditions:
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the
- following conditions:
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index 8cf7571..570bb12 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# MVPFrame
-[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/MVPFrame/master/app/app-release.apk)
+[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/MVPFrame/master/app/release/app-release.apk)
[![](https://jitpack.io/v/jenly1314/MVPFrame.svg)](https://jitpack.io/#jenly1314/MVPFrame)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/mit-license.php)
[![Blog](https://img.shields.io/badge/blog-Jenly-9933CC.svg)](http://blog.csdn.net/jenly121)
@@ -16,17 +16,17 @@ MVPFrame for Android 是一个集合了 Retrofit2 + RXJava2 + OkHttp3 + Mosby3
com.king.frame
mvpframe
- 1.0.6
+ 1.1.0
pom
```
### Gradle:
```gradle
-compile 'com.king.frame:mvpframe:1.0.6'
+compile 'com.king.frame:mvpframe:1.1.0'
```
### Lvy:
```lvy
-
+
```
@@ -42,24 +42,24 @@ allprojects {
## 引入的库:
```gradle
+ compileOnly 'com.android.support:support-v4:27.1.1'
+ compileOnly 'com.android.support:appcompat-v7:27.1.1'
+
// Model-View-Intent
- compile 'com.hannesdorfmann.mosby3:mvi:3.0.4'
+ api 'com.hannesdorfmann.mosby3:mvi:3.1.0'
// Plain MVP
- compile 'com.hannesdorfmann.mosby3:mvp:3.0.4'
+ api 'com.hannesdorfmann.mosby3:mvp:3.1.0'
// MVP + ViewState support
- compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4'
-
- compile 'com.squareup.retrofit2:retrofit:2.3.0'
- compile 'com.squareup.retrofit2:converter-gson:2.3.0'
- compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
+ api 'com.hannesdorfmann.mosby3:viewstate:3.1.0'
- compile 'com.squareup.okhttp3:okhttp:3.9.1'
- compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
+ api 'com.squareup.retrofit2:retrofit:2.4.0'
+ api 'com.squareup.retrofit2:converter-gson:2.4.0'
+ api 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
- compile 'io.reactivex.rxjava2:rxjava:2.1.1'
- compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
+ api 'io.reactivex.rxjava2:rxjava:2.1.16'
+ api 'io.reactivex.rxjava2:rxandroid:2.0.2'
- compile 'com.orhanobut:logger:1.15'
+ api 'com.jakewharton.timber:timber:4.7.1'
```
## 示例
diff --git a/app/build.gradle b/app/build.gradle
index 7a6fb53..40ca6c7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 25
- buildToolsVersion "25.0.2"
+ compileSdkVersion 27
+ buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.king.mvpframe"
minSdkVersion 15
- targetSdkVersion 25
+ targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -24,16 +24,15 @@ configurations.all {
}
dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- compile 'com.android.support:appcompat-v7:25.3.1'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- testCompile 'junit:junit:4.12'
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+ implementation 'com.android.support:support-v4:27.1.1'
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.2'
+ testImplementation 'junit:junit:4.12'
- compile project(':lib')
+ implementation project(':lib')
- compile 'com.jakewharton:butterknife:8.6.0'
+ implementation 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
}
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
new file mode 100644
index 0000000..19e5cea
Binary files /dev/null and b/app/release/app-release.apk differ
diff --git a/app/release/output.json b/app/release/output.json
new file mode 100644
index 0000000..9f0c959
--- /dev/null
+++ b/app/release/output.json
@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png
new file mode 100644
index 0000000..0de3dec
Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ
diff --git a/app/src/main/java/com/king/mvpframe/App.java b/app/src/main/java/com/king/mvpframe/App.java
index 9be09da..d45af23 100644
--- a/app/src/main/java/com/king/mvpframe/App.java
+++ b/app/src/main/java/com/king/mvpframe/App.java
@@ -3,8 +3,6 @@
import android.app.Application;
import com.king.frame.api.ApiManager;
-import com.orhanobut.logger.LogLevel;
-import com.orhanobut.logger.Logger;
/**
* @author Jenly Jenly
@@ -12,8 +10,6 @@
public class App extends Application {
- private static final String TAG = "Jenly";
-
@Override
public void onCreate() {
super.onCreate();
@@ -22,11 +18,5 @@ public void onCreate() {
private void init(){
ApiManager.init(Constants.BASE_URL);
-
- if(BuildConfig.DEBUG){
- Logger.init(TAG);
- }else{
- Logger.init(TAG).logLevel( LogLevel.NONE );
- }
}
}
diff --git a/app/src/main/java/com/king/mvpframe/MainActivity.java b/app/src/main/java/com/king/mvpframe/MainActivity.java
index 3f017bd..9dbabb9 100644
--- a/app/src/main/java/com/king/mvpframe/MainActivity.java
+++ b/app/src/main/java/com/king/mvpframe/MainActivity.java
@@ -5,16 +5,13 @@
import android.text.InputType;
import android.text.TextUtils;
import android.view.KeyEvent;
-import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
-import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
-import com.king.frame.mvp.base.BaseActivity;
import com.king.frame.mvp.base.QuickActivity;
import com.king.mvpframe.bean.IPAddress;
import com.king.mvpframe.mvp.presenter.IPAddrPresenter;
diff --git a/app/src/main/java/com/king/mvpframe/api/Api.java b/app/src/main/java/com/king/mvpframe/api/Api.java
index 78ad620..c931398 100644
--- a/app/src/main/java/com/king/mvpframe/api/Api.java
+++ b/app/src/main/java/com/king/mvpframe/api/Api.java
@@ -4,10 +4,6 @@
import com.king.frame.api.ApiObserver;
import com.king.frame.api.SimpleCallback;
import com.king.mvpframe.bean.IPAddress;
-import com.king.mvpframe.mvp.view.IIPAddrView;
-
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.schedulers.Schedulers;
/**
* @author Jenly Jenly
diff --git a/app/src/main/java/com/king/mvpframe/mvp/presenter/IPAddrPresenter.java b/app/src/main/java/com/king/mvpframe/mvp/presenter/IPAddrPresenter.java
index 4f9cb3b..c586e58 100644
--- a/app/src/main/java/com/king/mvpframe/mvp/presenter/IPAddrPresenter.java
+++ b/app/src/main/java/com/king/mvpframe/mvp/presenter/IPAddrPresenter.java
@@ -1,11 +1,14 @@
package com.king.mvpframe.mvp.presenter;
+import android.support.annotation.NonNull;
+
import com.king.frame.api.SimpleCallback;
import com.king.frame.mvp.base.BasePresenter;
import com.king.mvpframe.api.Api;
import com.king.mvpframe.bean.IPAddress;
import com.king.mvpframe.mvp.view.IIPAddrView;
-import com.orhanobut.logger.Logger;
+
+import timber.log.Timber;
/**
* @author Jenly Jenly
@@ -14,16 +17,20 @@
public class IPAddrPresenter extends BasePresenter{
+ public void getIp(final String ip){
-
- public void getIp(String ip){
- Logger.d("query:" + ip);
- getView().showProgress();
- Api.getApiAddr(ip, new SimpleCallback(getView()) {
+ ifViewAttached(new ViewAction() {
@Override
- public void onNext(IPAddress ipAddress) {
- getView().onGetIPAddr(ipAddress);
+ public void run(final @NonNull IIPAddrView view) {
+ view.showProgress();
+ Api.getApiAddr(ip, new SimpleCallback(view) {
+ @Override
+ public void onNext(IPAddress ipAddress) {
+ view.onGetIPAddr(ipAddress);
+ }
+ });
}
});
+
}
}
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..c7bd21d
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..01f0af0
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..bbd3e02
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..bbd3e02
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
index cde69bc..7df4e4c 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
index 9a078e3..ebae12c 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
index c133a0c..e29f86d 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
index efc028a..f1f8b4b 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index bfa42f0..40387b7 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
index 3af2608..9ace2ee 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index 324e72c..53613ff 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
index 9bec2e6..2ed8ddb 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index aee44e1..be04bb8 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
index 34947cd..57521ba 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/build.gradle b/build.gradle
index c56e44c..b620a4b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,19 +3,20 @@
buildscript {
repositories {
jcenter()
+ google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:3.1.3'
- classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
- classpath 'com.antfortune.freeline:gradle:0.8.7'
- classpath 'com.novoda:bintray-release:0.4.0'
+ classpath 'com.antfortune.freeline:gradle:0.8.8'
+ classpath 'com.novoda:bintray-release:0.8.1'
}
}
allprojects {
repositories {
jcenter()
+ google()
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0c5da03..80236a5 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Jul 04 14:19:22 CST 2017
+#Mon Jul 23 11:36:15 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/lib/bintray.gradle b/lib/bintray.gradle
index e69de29..ec139f7 100644
--- a/lib/bintray.gradle
+++ b/lib/bintray.gradle
@@ -0,0 +1,10 @@
+
+//添加
+publish {
+ userOrg = 'jenly'//bintray.com用户名
+ groupId = 'com.king.frame'//jcenter上的路径
+ artifactId = 'mvpframe'//项目名称
+ publishVersion = '1.1.0'//版本号
+ desc = 'MVPFrame for Android'//描述
+ website = 'https://github.com/jenly1314/MVPFrame'//网站
+}
\ No newline at end of file
diff --git a/lib/build.gradle b/lib/build.gradle
index 90c2a3e..f65bdc8 100644
--- a/lib/build.gradle
+++ b/lib/build.gradle
@@ -1,13 +1,14 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
+apply from: 'bintray.gradle'
android {
- compileSdkVersion 25
- buildToolsVersion "25.0.2"
+ compileSdkVersion 27
+ buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
- targetSdkVersion 25
+ targetSdkVersion 27
versionCode 1
versionName "1.0"
@@ -27,40 +28,25 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- provided 'com.android.support:appcompat-v7:25.3.1'
- testCompile 'junit:junit:4.12'
+ api fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+ testImplementation 'junit:junit:4.12'
+ compileOnly 'com.android.support:support-v4:27.1.1'
+ compileOnly 'com.android.support:appcompat-v7:27.1.1'
// Model-View-Intent
- compile 'com.hannesdorfmann.mosby3:mvi:3.0.4'
+ api 'com.hannesdorfmann.mosby3:mvi:3.1.0'
// Plain MVP
- compile 'com.hannesdorfmann.mosby3:mvp:3.0.4'
+ api 'com.hannesdorfmann.mosby3:mvp:3.1.0'
// MVP + ViewState support
- compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4'
+ api 'com.hannesdorfmann.mosby3:viewstate:3.1.0'
- compile 'com.squareup.retrofit2:retrofit:2.3.0'
- compile 'com.squareup.retrofit2:converter-gson:2.3.0'
- compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
+ api 'com.squareup.retrofit2:retrofit:2.4.0'
+ api 'com.squareup.retrofit2:converter-gson:2.4.0'
+ api 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
- compile 'com.squareup.okhttp3:okhttp:3.9.1'
- compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
+ api 'io.reactivex.rxjava2:rxjava:2.1.16'
+ api 'io.reactivex.rxjava2:rxandroid:2.0.2'
- compile 'io.reactivex.rxjava2:rxjava:2.1.1'
- compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
-
- compile 'com.orhanobut:logger:1.15'
+ api 'com.jakewharton.timber:timber:4.7.1'
}
-
-
-//添加
-publish {
- userOrg = 'jenly'//bintray.com用户名
- groupId = 'com.king.frame'//jcenter上的路径
- artifactId = 'mvpframe'//项目名称
- publishVersion = '1.0.6'//版本号
- desc = 'MVPFrame for Android'//描述
- website = 'https://github.com/jenly1314/MVPFrame'//网站
-}
\ No newline at end of file
diff --git a/lib/src/main/java/com/king/frame/api/ApiObserver.java b/lib/src/main/java/com/king/frame/api/ApiObserver.java
index 97b5870..66358b3 100644
--- a/lib/src/main/java/com/king/frame/api/ApiObserver.java
+++ b/lib/src/main/java/com/king/frame/api/ApiObserver.java
@@ -1,6 +1,5 @@
package com.king.frame.api;
-import com.orhanobut.logger.Logger;
import io.reactivex.Observable;
import io.reactivex.Observer;
@@ -8,6 +7,7 @@
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
+import timber.log.Timber;
/**
* @author Jenly Jenly
@@ -21,13 +21,20 @@ public class ApiObserver implements Observer {
private String mTag = TAG;
+ private boolean isLog = true;
+
public ApiObserver(ApiCallback callback){
this.mCallback = callback;
}
public ApiObserver(ApiCallback callback,String tag){
+ this(callback,tag,true);
+ }
+
+ public ApiObserver(ApiCallback callback,String tag,boolean isLog){
this.mCallback = callback;
this.mTag = tag;
+ this.isLog = isLog;
}
@Override
@@ -37,7 +44,9 @@ public void onSubscribe(@NonNull Disposable d) {
@Override
public void onError(Throwable e) {
- Logger.t(mTag).e(e,"onError");
+ if(isLog){
+ Timber.tag(mTag).e(e,"onError");
+ }
if(mCallback != null){
mCallback.onError( e );
}
@@ -45,7 +54,9 @@ public void onError(Throwable e) {
@Override
public void onNext(T t) {
- Logger.t(mTag).d("Response:" + t);
+ if(isLog) {
+ Timber.tag(mTag).d("Response:" + t);
+ }
if(mCallback != null){
mCallback.onNext( t );
}
diff --git a/lib/src/main/java/com/king/frame/api/LogInterceptor.java b/lib/src/main/java/com/king/frame/api/LogInterceptor.java
index 6d50a84..7c6a45d 100644
--- a/lib/src/main/java/com/king/frame/api/LogInterceptor.java
+++ b/lib/src/main/java/com/king/frame/api/LogInterceptor.java
@@ -1,7 +1,5 @@
package com.king.frame.api;
-import com.orhanobut.logger.Logger;
-
import java.io.IOException;
import okhttp3.Interceptor;
@@ -11,6 +9,7 @@
import okhttp3.Response;
import okhttp3.ResponseBody;
import okio.Buffer;
+import timber.log.Timber;
/**
* @author Jenly Jenly
@@ -20,18 +19,18 @@ public class LogInterceptor implements Interceptor{
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
- Logger.i(String.format("%1$s->%2$s",request.method(),request.url()));
+ Timber.i(String.format("%1$s->%2$s",request.method(),request.url()));
if(request.headers()!=null){
- Logger.i("Headers:" + request.headers());
+ Timber.i("Headers:" + request.headers());
}
if(request.body()!=null){
- Logger.i("RequestBody:" + bodyToString(request.body()));
+ Timber.i("RequestBody:" + bodyToString(request.body()));
}
Response response = chain.proceed(chain.request());
MediaType mediaType = response.body().contentType();
String responseBody = response.body().string();
- Logger.d("ResponseBody:" + responseBody);
+ Timber.d("ResponseBody:" + responseBody);
return response.newBuilder()
.body(ResponseBody.create(mediaType, responseBody))
@@ -46,7 +45,7 @@ private String bodyToString(final RequestBody request) {
copy.writeTo(buffer);
return buffer.readUtf8();
} catch (final IOException e) {
- Logger.e(e,"Did not work.");
+ Timber.e(e,"Did not work.");
}
}
return null;
diff --git a/lib/src/main/java/com/king/frame/mvp/base/BaseActivity.java b/lib/src/main/java/com/king/frame/mvp/base/BaseActivity.java
index 8c5b83c..f594401 100644
--- a/lib/src/main/java/com/king/frame/mvp/base/BaseActivity.java
+++ b/lib/src/main/java/com/king/frame/mvp/base/BaseActivity.java
@@ -21,7 +21,10 @@ public abstract class BaseActivity T findView(@IdRes int id){
return (T)mRootView.findViewById(id);
}
@@ -67,4 +75,6 @@ public void replaceChildFragment(@IdRes int id, Fragment fragment) {
public abstract void initUI();
public abstract void initData();
+
+ public abstract boolean isContentView(@LayoutRes int layoutId);
}
diff --git a/lib/src/main/java/com/king/frame/mvp/base/BaseFragment.java b/lib/src/main/java/com/king/frame/mvp/base/BaseFragment.java
index 97651ee..4b47961 100644
--- a/lib/src/main/java/com/king/frame/mvp/base/BaseFragment.java
+++ b/lib/src/main/java/com/king/frame/mvp/base/BaseFragment.java
@@ -2,12 +2,14 @@
import android.os.Bundle;
import android.support.annotation.IdRes;
+import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.hannesdorfmann.mosby3.mvp.MvpFragment;
+import com.king.frame.R;
/**
* @author Jenly Jenly
@@ -20,8 +22,10 @@ public abstract class BaseFragment T findView(@IdRes int id){
return (T)mRootView.findViewById(id);
}
@@ -53,4 +61,6 @@ public void replaceChildFragment(@IdRes int id, Fragment fragment) {
public abstract void initUI();
public abstract void initData();
+
+ public abstract boolean isContentView(@LayoutRes int layoutId);
}
diff --git a/lib/src/main/java/com/king/frame/mvp/base/QuickActivity.java b/lib/src/main/java/com/king/frame/mvp/base/QuickActivity.java
index acf304f..e1d60ca 100644
--- a/lib/src/main/java/com/king/frame/mvp/base/QuickActivity.java
+++ b/lib/src/main/java/com/king/frame/mvp/base/QuickActivity.java
@@ -2,6 +2,7 @@
import android.app.Dialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
@@ -9,6 +10,7 @@
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.util.DisplayMetrics;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -183,14 +185,24 @@ protected void showDialog(Context context,View contentView,float widthRatio){
}
protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio){
- showDialog(context,contentView,resId,widthRatio,false);
+ showDialog(context,contentView,resId,widthRatio,true);
}
- protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio,boolean isCancel){
+ protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio,final boolean isCancel){
dismissDialog();
mDialog = new Dialog(context,resId);
mDialog.setContentView(contentView);
- mDialog.setCanceledOnTouchOutside(isCancel);
+ mDialog.setCanceledOnTouchOutside(false);
+ mDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
+ @Override
+ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK && isCancel){
+ dismissDialog();
+ }
+ return true;
+
+ }
+ });
setDialogWindow(mDialog,widthRatio);
mDialog.show();
@@ -219,6 +231,11 @@ protected int getHeightPixels(){
//---------------------------------------
+ @Override
+ public boolean isContentView(int layoutId) {
+ return false;
+ }
+
@Override
public void showProgress(){
showProgressDialog();
diff --git a/lib/src/main/java/com/king/frame/mvp/base/QuickDialogFragment.java b/lib/src/main/java/com/king/frame/mvp/base/QuickDialogFragment.java
index 4a3a545..46dffab 100644
--- a/lib/src/main/java/com/king/frame/mvp/base/QuickDialogFragment.java
+++ b/lib/src/main/java/com/king/frame/mvp/base/QuickDialogFragment.java
@@ -2,6 +2,7 @@
import android.app.Dialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
@@ -9,6 +10,7 @@
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.util.DisplayMetrics;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -169,10 +171,24 @@ protected void showDialog(Context context,View contentView,float widthRatio){
}
protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio){
+ showDialog(context,contentView,resId,widthRatio,true);
+ }
+
+ protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio,final boolean isCancel){
dismissDialog();
mDialog = new Dialog(context,resId);
mDialog.setContentView(contentView);
mDialog.setCanceledOnTouchOutside(false);
+ mDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
+ @Override
+ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK && isCancel){
+ dismissDialog();
+ }
+ return true;
+
+ }
+ });
setDialogWindow(mDialog,widthRatio);
mDialog.show();
@@ -201,6 +217,11 @@ protected int getHeightPixels(){
//---------------------------------------
+ @Override
+ public boolean isContentView(int layoutId) {
+ return false;
+ }
+
@Override
public void showProgress(){
showProgressDialog();
diff --git a/lib/src/main/java/com/king/frame/mvp/base/QuickFragment.java b/lib/src/main/java/com/king/frame/mvp/base/QuickFragment.java
index 07d9b3a..0f5652e 100644
--- a/lib/src/main/java/com/king/frame/mvp/base/QuickFragment.java
+++ b/lib/src/main/java/com/king/frame/mvp/base/QuickFragment.java
@@ -2,6 +2,7 @@
import android.app.Dialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
@@ -9,6 +10,7 @@
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.util.DisplayMetrics;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -202,14 +204,24 @@ protected void showDialog(Context context,View contentView,float widthRatio){
}
protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio){
- showDialog(context,contentView,resId,widthRatio,false);
+ showDialog(context,contentView,resId,widthRatio,true);
}
- protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio,boolean isCancel){
+ protected void showDialog(Context context, View contentView, @StyleRes int resId, float widthRatio,final boolean isCancel){
dismissDialog();
mDialog = new Dialog(context,resId);
mDialog.setContentView(contentView);
- mDialog.setCanceledOnTouchOutside(isCancel);
+ mDialog.setCanceledOnTouchOutside(false);
+ mDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
+ @Override
+ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK && isCancel){
+ dismissDialog();
+ }
+ return true;
+
+ }
+ });
setDialogWindow(mDialog,widthRatio);
mDialog.show();
@@ -238,6 +250,11 @@ protected int getHeightPixels(){
//---------------------------------------
+ @Override
+ public boolean isContentView(int layoutId) {
+ return false;
+ }
+
@Override
public void showProgress(){
showProgressDialog();
diff --git a/lib/src/main/java/com/king/frame/util/SSLSocketFactoryUtils.java b/lib/src/main/java/com/king/frame/util/SSLSocketFactoryUtils.java
index d6d0dfa..a74652c 100644
--- a/lib/src/main/java/com/king/frame/util/SSLSocketFactoryUtils.java
+++ b/lib/src/main/java/com/king/frame/util/SSLSocketFactoryUtils.java
@@ -3,7 +3,6 @@
import android.content.Context;
import android.support.annotation.RawRes;
-import com.orhanobut.logger.Logger;
import java.io.InputStream;
import java.security.KeyManagementException;
@@ -21,6 +20,8 @@
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
+import timber.log.Timber;
+
/**
* @author Jenly Jenly
*/
@@ -57,7 +58,7 @@ public X509Certificate[] getAcceptedIssuers() {
}
};
} catch (Exception e) {
- Logger.e(e,"Exception");
+ Timber.e(e,"Exception");
}
return tm;
}
@@ -89,7 +90,7 @@ public static SSLSocketFactory createSSLSocketFactory(InputStream... certificate
try {
sslContext = SSLContext.getInstance("TLS");
} catch (NoSuchAlgorithmException e) {
- Logger.e(e,"NoSuchAlgorithmException");
+ Timber.e(e,"NoSuchAlgorithmException");
return null;
}
//获得服务器端证书
@@ -99,7 +100,7 @@ public static SSLSocketFactory createSSLSocketFactory(InputStream... certificate
try {
sslContext.init(null,turstManager,new SecureRandom());
} catch (KeyManagementException e) {
- Logger.e(e,"KeyManagementException");
+ Timber.e(e,"KeyManagementException");
}
//获得sslSocketFactory
@@ -143,7 +144,7 @@ public static TrustManager[] getTurstManager(InputStream... certificates) {
return trustManagerFactory.getTrustManagers();
} catch (Exception e) {
- Logger.e(e,"Exception");
+ Timber.e(e,"Exception");
}