-
Notifications
You must be signed in to change notification settings - Fork 50
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
Showing
85 changed files
with
4,012 additions
and
63 deletions.
There are no files selected for viewing
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,65 +1,10 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
.idea/caches | ||
|
||
# Keystore files | ||
# Uncomment the following line if you do not want to check your keystore files in. | ||
#*.jks | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.gradle | ||
/local.properties | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md |
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,63 @@ | ||
|
||
|
||
## Widget ## | ||
|
||
#### 在 Android 中渲染 #### | ||
|
||
外部通过调用 render 方法,获得一个 View,进行渲染 | ||
|
||
## StatelessWidget ## | ||
承 Widget,无状态控件 | ||
需要实现一个 Widget<T> build() 方法,来完成 Widget 的构建 | ||
|
||
## StatefulWidget ## | ||
|
||
继承 Widget,内部带有一个 State | ||
需要实现一个 State<T> createState(Context context) 方法 来构建一个 State 对象 | ||
|
||
## AndroidWidget ## | ||
|
||
承 Widget,带有 Android 常用的构建方法 和 生命周期 | ||
|
||
#### 构建过程 #### | ||
|
||
构造方法 -> createView | ||
|
||
render(first call) -> bind lifecycle | ||
|
||
onStart -> initView -> bindEvent -> initData -> updateView | ||
|
||
#### 生命周期 #### | ||
通过 Activity 或 Fragment 中绑定 Lifecycle 来让 Widget 获得完整的生命周期 | ||
|
||
onStart | ||
onResume | ||
onPause | ||
onStop | ||
onDestroy | ||
|
||
#### BaseAndroidWidget #### | ||
|
||
initView -> initProps -> updateProps | ||
|
||
#### ViewGroupWidget #### | ||
|
||
构造方法 -> addChildren -> updateChildrenProps && updateProps | ||
|
||
updaetView 中,调用 children 的 updateView 或 setState 或 update 方法 | ||
|
||
|
||
|
||
## LifecycleStatelessWidget ## | ||
|
||
带有生命周期的 StatelessWidget | ||
|
||
## LifecycleStatefulWidget ## | ||
|
||
带有生命周期的 StatelfulWidget | ||
|
||
## 容器 ## | ||
|
||
Widget 类似于 View,是一个原子性的控件,并不能包容其他Widget,比如 BaseAndroidWidget。 | ||
而我们一般使用的都是 LifecycleStatefulWidget 或 LifecycleStatelessWidget,他里面可以组合一个或多个 Widget | ||
|
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,56 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.ittianyu.relight" | ||
minSdkVersion 17 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
|
||
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation "com.android.support:appcompat-v7:$support_version" | ||
implementation "com.android.support:support-media-compat:$support_version" | ||
implementation "com.android.support:support-v4:$support_version" | ||
implementation "com.android.support:design:$support_version" | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
|
||
|
||
// anko | ||
implementation ("org.jetbrains.anko:anko:$anko_version") { | ||
exclude group: 'com.android.support', module:'support-media-compat' | ||
exclude group: 'com.android.support', module:'support-v4' | ||
} | ||
|
||
// Support library depends on this lightweight import | ||
implementation "android.arch.lifecycle:runtime:$lifecycle_version" | ||
// alternately - if using Java8, use the following instead of compiler | ||
implementation "android.arch.lifecycle:common-java8:$lifecycle_version" | ||
|
||
implementation project(':lib') | ||
} |
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 |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/ittianyu/relight/ExampleInstrumentedTest.kt
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,24 @@ | ||
package com.ittianyu.relight | ||
|
||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.runner.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getTargetContext() | ||
assertEquals("com.ittianyu.relight", appContext.packageName) | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.ittianyu.relight"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".a_hello.UserActivity" /> | ||
<activity android:name=".b_list.ListActivity" /> | ||
<activity android:name=".c_lcee.LceeActivity" /> | ||
</application> | ||
|
||
</manifest> |
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,31 @@ | ||
package com.ittianyu.relight | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
import android.view.View | ||
import com.ittianyu.relight.a_hello.UserActivity | ||
import com.ittianyu.relight.b_list.ListActivity | ||
import com.ittianyu.relight.c_lcee.LceeActivity | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
} | ||
|
||
fun onClick(view: View) { | ||
when (view.id) { | ||
R.id.a_hello -> { | ||
startActivity(Intent(this, UserActivity::class.java)) | ||
} | ||
R.id.b_list -> { | ||
startActivity(Intent(this, ListActivity::class.java)) | ||
} | ||
R.id.c_lcee -> { | ||
startActivity(Intent(this, LceeActivity::class.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,44 @@ | ||
package com.ittianyu.relight.a_hello; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Created by 86839 on 2017/10/4. | ||
*/ | ||
|
||
public class User implements Serializable { | ||
private int id; | ||
private String name; | ||
|
||
public User() { | ||
} | ||
|
||
public User(int id, String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/ittianyu/relight/a_hello/UserActivity.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,22 @@ | ||
package com.ittianyu.relight.a_hello; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.ittianyu.relight.utils.WidgetUtils; | ||
|
||
|
||
/** | ||
* Created by 86839 on 2017/10/4. | ||
*/ | ||
public class UserActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// setContentView(WidgetUtils.create(this, UserLayoutStateless.class, UserModel.getInstance().getUser())); | ||
setContentView(WidgetUtils.create(this, UserLayoutStateful.class)); | ||
} | ||
|
||
} |
Oops, something went wrong.