-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e50c2b
commit 8c0946c
Showing
15 changed files
with
256 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon Dec 07 18:23:08 CST 2020 | ||
#Wed Dec 09 17:04:49 CST 2020 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#####https://www.cnblogs.com/zhangzhonghui/p/11463250.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
include ':vector_common' | ||
include ':app' | ||
rootProject.name = "Vector_CommonLibrary" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
plugins { | ||
id 'com.android.library' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "29.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.2.1' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
|
||
//字体图标库 | ||
implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2' | ||
implementation 'com.joanzapata.iconify:android-iconify-ionicons:2.2.2' | ||
//网络请求依赖 | ||
implementation 'com.squareup.okio:okio:1.13.0' | ||
implementation 'com.squareup.okhttp3:okhttp:3.11.0' | ||
implementation 'com.squareup.retrofit2:retrofit:2.3.0' | ||
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
vector_common/src/androidTest/java/com/vector/common/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.vector.common; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.vector.common.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.vector.common"> | ||
|
||
</manifest> |
14 changes: 14 additions & 0 deletions
14
vector_common/src/main/java/com/vector/common/app/ConfigType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.vector.common.app; | ||
|
||
/** | ||
* Created by 瓮少波 on 2018/4/23. | ||
*/ | ||
|
||
public enum ConfigType { | ||
API_HOST, | ||
APPLICATION_CONTEXT, | ||
CONFIG_READY, | ||
ICON, | ||
LOADER_DELAYED, | ||
INTERCEPTOR | ||
} |
93 changes: 93 additions & 0 deletions
93
vector_common/src/main/java/com/vector/common/app/Configurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.vector.common.app; | ||
|
||
import android.content.Context; | ||
|
||
import com.joanzapata.iconify.IconFontDescriptor; | ||
import com.joanzapata.iconify.Iconify; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
import okhttp3.Interceptor; | ||
|
||
/** | ||
* @author Vector Weng | ||
* @description: App initialization general configuration class | ||
* @date :2020/12/9 17:16 | ||
*/ | ||
public class Configurator { | ||
|
||
private static final HashMap<String, Object> VECTOR_CONFIGS = new HashMap<>(); | ||
private static final ArrayList<IconFontDescriptor> ICONS = new ArrayList<>(); | ||
private static final ArrayList<Interceptor> INTERCEPTORS = new ArrayList<>(); | ||
|
||
private Configurator() { | ||
VECTOR_CONFIGS.put(ConfigType.CONFIG_READY.name(), false); | ||
} | ||
|
||
private static final class Holder { | ||
private static final Configurator INSTANCE = new Configurator(); | ||
} | ||
|
||
public static Configurator getInstance() { | ||
return Holder.INSTANCE; | ||
} | ||
|
||
public final void configure() { | ||
initIcons(); | ||
VECTOR_CONFIGS.put(ConfigType.CONFIG_READY.name(), true); | ||
} | ||
|
||
final HashMap<String, Object> getConfigs() { | ||
return VECTOR_CONFIGS; | ||
} | ||
|
||
public final Configurator withContext(Context context) { | ||
VECTOR_CONFIGS.put(ConfigType.APPLICATION_CONTEXT.name(), context); | ||
return this; | ||
} | ||
|
||
public final Configurator withApiHost(String host) { | ||
VECTOR_CONFIGS.put(ConfigType.API_HOST.name(), host); | ||
return this; | ||
} | ||
|
||
public final Configurator withIcon(IconFontDescriptor descriptor) { | ||
ICONS.add(descriptor); | ||
return this; | ||
} | ||
|
||
public final Configurator withInterceptor(Interceptor interceptor) { | ||
INTERCEPTORS.add(interceptor); | ||
VECTOR_CONFIGS.put(ConfigType.INTERCEPTOR.name(), INTERCEPTORS); | ||
return this; | ||
} | ||
|
||
public final Configurator withInterceptor(ArrayList<Interceptor> interceptors) { | ||
INTERCEPTORS.addAll(interceptors); | ||
VECTOR_CONFIGS.put(ConfigType.INTERCEPTOR.name(), INTERCEPTORS); | ||
return this; | ||
} | ||
|
||
private void initIcons() { | ||
if (ICONS.size() > 0) { | ||
final Iconify.IconifyInitializer initializer = Iconify.with(ICONS.get(0)); | ||
for (int i = 1; i < ICONS.size(); i++) { | ||
initializer.with(ICONS.get(i)); | ||
} | ||
} | ||
} | ||
|
||
private void checkConfiguration() { | ||
final boolean isReady = (boolean) VECTOR_CONFIGS.get(ConfigType.CONFIG_READY.name()); | ||
if (!isReady) | ||
throw new RuntimeException("Configuration is not ready,call configure"); | ||
} | ||
|
||
final <T> T getConfiguration(Enum<ConfigType> key) { | ||
checkConfiguration(); | ||
return (T) VECTOR_CONFIGS.get(key.name()); | ||
} | ||
|
||
|
||
} |
27 changes: 27 additions & 0 deletions
27
vector_common/src/main/java/com/vector/common/app/Vector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.vector.common.app; | ||
|
||
import android.content.Context; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* @author Vector Weng | ||
* @description: | ||
* @date :2020/12/9 17:16 | ||
*/ | ||
public class Vector { | ||
|
||
public static final Configurator init(Context context) { | ||
return Configurator.getInstance(); | ||
} | ||
|
||
public static HashMap<String, Object> getConfigs() { | ||
return Configurator.getInstance().getConfigs(); | ||
} | ||
|
||
public static Context getApplicationContext() { | ||
return (Context) getConfigs().get(ConfigType.APPLICATION_CONTEXT); | ||
|
||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
vector_common/src/test/java/com/vector/common/ExampleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.vector.common; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
public class ExampleUnitTest { | ||
@Test | ||
public void addition_isCorrect() { | ||
assertEquals(4, 2 + 2); | ||
} | ||
} |