Skip to content

Commit

Permalink
网络请求 binding
Browse files Browse the repository at this point in the history
  • Loading branch information
br3ant committed Dec 24, 2020
1 parent a85c161 commit ec11518
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 19 deletions.
10 changes: 9 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
Expand All @@ -14,6 +13,15 @@ android {

}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

buildTypes {
release {
minifyEnabled false
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.10"
ext.kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath "com.android.tools.build:gradle:4.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
41 changes: 36 additions & 5 deletions utils/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
}

android {
compileSdkVersion 29
Expand Down Expand Up @@ -29,6 +31,10 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

viewBinding {
enabled = true
}
}

dependencies {
Expand All @@ -37,7 +43,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'

//fragmentation
api 'com.github.br3ant:Fragmentation:1.4.0'
api 'com.github.br3ant:Fragmentation:1.4.2'

//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
Expand All @@ -48,6 +54,28 @@ dependencies {
api "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.2.0"
api 'androidx.fragment:fragment-ktx:1.2.5'

//room
def room_version = '2.2.5'
api "androidx.room:room-runtime:$room_version"
api "androidx.room:room-rxjava2:$room_version"
api "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"

//rxhttp
api 'com.ljx.rxhttp:rxhttp:2.5.2'
kapt 'com.ljx.rxhttp:rxhttp-compiler:2.5.2' //生成RxHttp类,非kotlin项目,请使用annotationProcessor代替kapt
api 'com.ljx.rxlife:rxlife-coroutine:2.0.0' //管理协程生命周期,页面销毁,关闭请求
api 'com.ljx.rxlife2:rxlife-rxjava:2.0.0'

//rx
api 'io.reactivex.rxjava2:rxjava:2.2.14'
api 'io.reactivex.rxjava2:rxandroid:2.1.1'

//okhttp
api 'com.squareup.okhttp3:okhttp:4.9.0'

api 'com.github.liangjingkanji:BRV:1.3.13'

//gson
api 'com.google.code.gson:gson:2.8.6'

Expand All @@ -57,5 +85,8 @@ dependencies {
api 'com.gyf.immersionbar:immersionbar-ktx:3.0.0'

//阴影
api 'com.github.lihangleo2:ShadowLayout:3.0.4'
api 'com.github.lihangleo2:ShadowLayout:3.1.3'

//binding
api 'com.hi-dhl:binding:1.0.5'
}
15 changes: 4 additions & 11 deletions utils/src/main/java/com/br3ant/base/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ import me.yokeyword.fragmentation.SupportActivity
/**
* 基类Activity
*/
abstract class BaseActivity(
private val layout: Int = 0,
private val fullScreen: Boolean = false,
private val keepScreenOn: Boolean = false
) : SupportActivity() {
abstract class BaseActivity(private val layout: Int = 0, private val fullScreen: Boolean = false, private val keepScreenOn: Boolean = false) : SupportActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
if (getThemeId() != 0) {
setTheme(getThemeId())
}
super.onCreate(savedInstanceState)

window.clearFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
)
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
if (fullScreen) {
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
Expand All @@ -34,8 +28,7 @@ abstract class BaseActivity(
//全面屏
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val lp = window.attributes
lp.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
window.attributes = lp
}

Expand Down

0 comments on commit ec11518

Please sign in to comment.