Skip to content

Commit 4776177

Browse files
committed
开始尝试组件化,分module开始
1 parent 6fc93a2 commit 4776177

34 files changed

+248
-13
lines changed

app/build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ android {
77
compileSdkVersion 25
88
buildToolsVersion "26.0.0"
99
defaultConfig {
10-
applicationId "com.xiasuhuei321.gank_kotlin"
11-
minSdkVersion 14
12-
targetSdkVersion 25
13-
versionCode 1
14-
versionName "1.0"
10+
applicationId rootProject.ext.android["applicationId"]
11+
minSdkVersion rootProject.ext.android["minSdkVersion"]
12+
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
13+
versionCode rootProject.ext.android["versionCode"]
14+
versionName rootProject.ext.android["versionName"]
1515
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1616
externalNativeBuild {
1717
cmake {

app/src/main/java/com/xiasuhuei321/gank_kotlin/customview/weather/WeatherView.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class WeatherView(context: Context, attributeSet: AttributeSet?, defaultStyle: I
4949
val canvas = holder.lockCanvas()
5050
if (canvas != null) {
5151
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
52-
draw(canvas, type, startTime)
52+
draw(canvas, type)
5353
}
5454
holder.unlockCanvasAndPost(canvas)
5555
val drawTime = System.currentTimeMillis() - startTime
@@ -98,9 +98,15 @@ class WeatherView(context: Context, attributeSet: AttributeSet?, defaultStyle: I
9898
thread.start()
9999
}
100100

101-
private fun draw(canvas: Canvas, type: Weather, startTime: Long) {
102-
// type什么的先放一边,先实现一个
103-
weatherShapePool.drawSnow(canvas)
101+
private fun draw(canvas: Canvas, type: Weather) {
102+
when (type) {
103+
Weather.RAIN -> {
104+
weatherShapePool.drawRain(canvas)
105+
}
106+
Weather.SNOW -> {
107+
weatherShapePool.drawSnow(canvas)
108+
}
109+
}
104110
}
105111

106112
enum class Weather {

conf.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
ext {
22
android = [
33
compileSdkVersion: 25,
4-
buildToolsVersion: "25.0.3",
5-
minSdkVersion : 17,
4+
buildToolsVersion: "26.0.0",
5+
minSdkVersion : 14,
66
targetSdkVersion : 25,
7-
applicationId : "com.csjbot.blackgaga",
7+
applicationId : "com.xiasuhuei321.gank_kotlin",
88
versionCode : 1,
99
versionName : 'V0.0.0.0001',
1010
]

gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ org.gradle.jvmargs=-Xmx1536m
1515
# This option should only be used with decoupled projects. More details, visit
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1717
# org.gradle.parallel=true
18+
isLibrary=false

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app'
1+
include ':app', ':weather'

weather/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

weather/build.gradle

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
if (!isLibrary.toBoolean()) {
2+
apply plugin: 'com.android.application'
3+
} else {
4+
apply plugin: 'com.android.library'
5+
}
6+
7+
8+
android {
9+
compileSdkVersion 26
10+
buildToolsVersion "26.0.1"
11+
12+
defaultConfig {
13+
applicationId "com.xiasuhuei321.weather"
14+
minSdkVersion 14
15+
targetSdkVersion 26
16+
versionCode 1
17+
versionName "1.0"
18+
19+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20+
21+
}
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
}
29+
30+
dependencies {
31+
compile fileTree(dir: 'libs', include: ['*.jar'])
32+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
33+
exclude group: 'com.android.support', module: 'support-annotations'
34+
})
35+
36+
compile 'com.android.support:appcompat-v7:26.+'
37+
testCompile 'junit:junit:4.12'
38+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
39+
}

weather/proguard-rules.pro

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/luojun/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xiasuhuei321.weather;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.xiasuhuei321.weather", appContext.getPackageName());
25+
}
26+
}

weather/src/main/AndroidManifest.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.xiasuhuei321.weather">
4+
5+
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
6+
android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round"
7+
android:supportsRtl="true" android:theme="@style/AppTheme">
8+
<activity android:name=".MainActivity">
9+
<intent-filter>
10+
<action android:name="android.intent.action.MAIN" />
11+
12+
<category android:name="android.intent.category.LAUNCHER" />
13+
</intent-filter>
14+
</activity>
15+
</application>
16+
17+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.xiasuhuei321.weather;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
public class MainActivity extends AppCompatActivity {
7+
8+
@Override
9+
protected void onCreate(Bundle savedInstanceState) {
10+
super.onCreate(savedInstanceState);
11+
setContentView(R.layout.activity_main);
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp"
3+
android:height="24dp" android:viewportHeight="108.0" android:viewportWidth="108.0">
4+
<path android:fillColor="#26A69A" android:pathData="M0,0h108v108h-108z"
5+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
6+
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
7+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8" />
8+
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
9+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
10+
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
11+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
12+
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
13+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
14+
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
15+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
16+
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
17+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
18+
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
19+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
20+
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
21+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
22+
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
23+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8" />
24+
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
25+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
26+
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
27+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8" />
28+
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
29+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
30+
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
31+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
32+
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
33+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
34+
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
35+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
36+
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
37+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
38+
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
39+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
40+
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
41+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
42+
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
43+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8" />
44+
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
45+
android:strokeColor="#66FFFFFF" android:strokeWidth="0.8" />
46+
</vector>
47+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.constraint.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
6+
android:layout_height="match_parent" tools:context="com.xiasuhuei321.weather.MainActivity">
7+
8+
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
9+
android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent"
10+
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"
11+
app:layout_constraintTop_toTopOf="parent" />
12+
13+
</android.support.constraint.ConstraintLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background" />
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
5+
</adaptive-icon>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background" />
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
5+
</adaptive-icon>
3.28 KB
Loading
Loading
Loading
2.33 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">Weather</string>
3+
</resources>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
</style>
10+
11+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.xiasuhuei321.weather;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11+
*/
12+
public class ExampleUnitTest {
13+
@Test
14+
public void addition_isCorrect() throws Exception {
15+
assertEquals(4, 2 + 2);
16+
}
17+
}

0 commit comments

Comments
 (0)