dev
This commit is contained in:
4
foudations/mogo-commons/apipackage.txt
Normal file
4
foudations/mogo-commons/apipackage.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
com.mogo.commons.mvp
|
||||
com.mogo.commons.debug
|
||||
com.mogo.commons.voice
|
||||
com.mogo.commons.data
|
||||
@@ -1,15 +1,13 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
@@ -36,7 +34,13 @@ dependencies {
|
||||
api rootProject.ext.dependencies.aiassist
|
||||
api rootProject.ext.dependencies.androidxappcompat
|
||||
api rootProject.ext.dependencies.analytics
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
} else {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
3
foudations/mogo-commons/gradle.properties
Normal file
3
foudations/mogo-commons/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.commons
|
||||
POM_ARTIFACT_ID=mogo-commons
|
||||
VERSION_CODE=1
|
||||
@@ -4,16 +4,26 @@ package com.mogo.commons.debug;
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 各个莫快递调试信息控制接口
|
||||
* 各个模块递调试信息控制接口
|
||||
*/
|
||||
public class DebugConfig {
|
||||
|
||||
private static boolean sDebug = true;
|
||||
|
||||
/**
|
||||
* 是否为调试模式
|
||||
*
|
||||
* @return true - 调试模式 false - 非调试模式
|
||||
*/
|
||||
public static boolean isDebug() {
|
||||
return sDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置调试模式
|
||||
*
|
||||
* @param sDebug true - 调试模式 false - 非调试模式
|
||||
*/
|
||||
public static void setDebug( boolean sDebug ) {
|
||||
DebugConfig.sDebug = sDebug;
|
||||
}
|
||||
|
||||
@@ -10,5 +10,10 @@ import android.content.Context;
|
||||
*/
|
||||
public interface IView {
|
||||
|
||||
/**
|
||||
* 获取上下文
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Context getContext();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
/**
|
||||
* 布局资源
|
||||
*
|
||||
* @return
|
||||
* @return 布局资源 id
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
package com.mogo.commons.mvp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
@@ -14,7 +22,8 @@ import androidx.lifecycle.OnLifecycleEvent;
|
||||
*/
|
||||
public abstract class Presenter< V extends IView > implements LifecycleObserver {
|
||||
|
||||
private V mView;
|
||||
protected V mView;
|
||||
private Context mContext;
|
||||
|
||||
public Presenter( V view ) {
|
||||
this.mView = view;
|
||||
@@ -49,4 +58,35 @@ public abstract class Presenter< V extends IView > implements LifecycleObserver
|
||||
@NonNull LifecycleOwner owner,
|
||||
@NonNull Lifecycle.Event event ) {
|
||||
}
|
||||
|
||||
protected Context getContext() {
|
||||
if ( mContext != null ) {
|
||||
return mContext;
|
||||
}
|
||||
if ( mView instanceof Activity ) {
|
||||
mContext = ( ( Activity ) mView );
|
||||
}
|
||||
if ( mView instanceof Fragment ) {
|
||||
mContext = ( ( Fragment ) mView ).getContext();
|
||||
}
|
||||
if ( mView instanceof android.app.Fragment ) {
|
||||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) {
|
||||
mContext = ( ( android.app.Fragment ) mView ).getContext();
|
||||
} else {
|
||||
mContext = ( ( android.app.Fragment ) mView ).getActivity();
|
||||
}
|
||||
}
|
||||
if ( mView instanceof Dialog ) {
|
||||
mContext = ( ( Dialog ) mView ).getContext();
|
||||
}
|
||||
if ( mView instanceof PopupWindow ) {
|
||||
if ( ( ( PopupWindow ) mView ).getContentView() != null ) {
|
||||
mContext = ( ( PopupWindow ) mView ).getContentView().getContext();
|
||||
}
|
||||
}
|
||||
if ( mView instanceof View ) {
|
||||
mContext = ( ( View ) mView ).getContext();
|
||||
}
|
||||
return mContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
@@ -37,4 +35,11 @@ dependencies {
|
||||
api rootProject.ext.dependencies.retrofitconvertergson
|
||||
api rootProject.ext.dependencies.retrofitconverterscalars
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
3
foudations/mogo-utils/gradle.properties
Normal file
3
foudations/mogo-utils/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.commons
|
||||
POM_ARTIFACT_ID=mogo-utils
|
||||
VERSION_CODE=1
|
||||
Reference in New Issue
Block a user