Skip to content

Commit

Permalink
日常提交:2022-08-03.
Browse files Browse the repository at this point in the history
  • Loading branch information
walgr committed Aug 3, 2022
1 parent 9646089 commit 2f9f346
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.wpf.app.quick.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.annotation.LayoutRes
import androidx.lifecycle.ViewModelProvider
Expand All @@ -20,6 +22,11 @@ abstract class QuickViewModelActivity<VM : QuickViewModel<H>, H : QuickView> @Jv
BindViewModel<VM> {
private var mViewModel: VM? = null

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mViewModel?.onSaveInstanceState(outState)
}

override fun onResume() {
super.onResume()
mViewModel?.onResume()
Expand All @@ -35,6 +42,11 @@ abstract class QuickViewModelActivity<VM : QuickViewModel<H>, H : QuickView> @Jv
mViewModel?.onStop()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
mViewModel?.onActivityResult(requestCode, resultCode, data)
}

override fun onDestroy() {
super.onDestroy()
mViewModel?.onDestroy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.wpf.app.quick.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
Expand Down Expand Up @@ -52,6 +54,37 @@ abstract class QuickViewModelBindingActivity<VM : QuickBindingViewModel<VB>, VB
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mViewModel?.onSaveInstanceState(outState)
}

override fun onResume() {
super.onResume()
mViewModel?.onResume()
}

override fun onPause() {
super.onPause()
mViewModel?.onPause()
}

override fun onStop() {
super.onStop()
mViewModel?.onStop()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
mViewModel?.onActivityResult(requestCode, resultCode, data)
}

override fun onDestroy() {
super.onDestroy()
mViewModel?.onDestroy()
mViewModel = null
}

override fun initView() {
initView(viewBinding)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wpf.app.quick.activity

import android.app.Application
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.annotation.CallSuper
Expand Down Expand Up @@ -78,5 +79,36 @@ abstract class QuickViewModelBindingFragment<VM : QuickBindingViewModel<VB>, VB
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mViewModel?.onSaveInstanceState(outState)
}

override fun onResume() {
super.onResume()
mViewModel?.onResume()
}

override fun onPause() {
super.onPause()
mViewModel?.onPause()
}

override fun onStop() {
super.onStop()
mViewModel?.onStop()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
mViewModel?.onActivityResult(requestCode, resultCode, data)
}

override fun onDestroy() {
super.onDestroy()
mViewModel?.onDestroy()
mViewModel = null
}

abstract fun initView(viewDataBinding: VB?)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.wpf.app.quick.activity

import android.app.Application
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.annotation.CallSuper
import androidx.annotation.LayoutRes
Expand All @@ -20,6 +22,37 @@ open class QuickViewModelFragment<VM : QuickViewModel<H>, H : QuickView> @JvmOve
override val titleName: String = ""
) : QuickFragment(), BindViewModel<VM> {

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mViewModel?.onSaveInstanceState(outState)
}

override fun onResume() {
super.onResume()
mViewModel?.onResume()
}

override fun onPause() {
super.onPause()
mViewModel?.onPause()
}

override fun onStop() {
super.onStop()
mViewModel?.onStop()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
mViewModel?.onActivityResult(requestCode, resultCode, data)
}

override fun onDestroy() {
super.onDestroy()
mViewModel?.onDestroy()
mViewModel = null
}

private var mViewModel: VM? = null

@CallSuper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.wpf.app.quick.viewmodel

import android.content.Intent
import android.os.Bundle
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.ViewModel
Expand All @@ -11,6 +13,18 @@ import androidx.lifecycle.ViewModel
abstract class QuickBindingViewModel<T : ViewDataBinding> : ViewModel(), LifecycleObserver {
var mViewBinding: T? = null

open fun onResume() {}

open fun onPause() {}

open fun onStop() {}

open fun onDestroy() {}

open fun onSaveInstanceState(outState: Bundle) {}

open fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {}

abstract fun onBindingCreated(mViewBinding: T?)

fun getViewBinding(): T? {
Expand Down
14 changes: 10 additions & 4 deletions Quick/src/main/java/com/wpf/app/quick/viewmodel/QuickViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.wpf.app.quick.viewmodel

import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.ViewModel
import com.wpf.app.quick.activity.QuickView

Expand All @@ -10,13 +12,17 @@ import com.wpf.app.quick.activity.QuickView
abstract class QuickViewModel<T : QuickView> : ViewModel() {
var baseView: T? = null

fun onResume() {}
open fun onResume() {}

fun onPause() {}
open fun onPause() {}

fun onStop() {}
open fun onStop() {}

fun onDestroy() {}
open fun onDestroy() {}

open fun onSaveInstanceState(outState: Bundle) {}

open fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {}

abstract fun onViewCreated(baseView: T)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import com.wpf.app.quickbind.interfaces.Bind
*
*/
open class QuickBindData(
@Transient
@LayoutRes open val layoutId: Int,
) : QuickItemData(), Bind {

@Transient
private var mViewHolder: QuickViewHolder<QuickBindData>? = null
@Transient
private lateinit var mAdapter: QuickAdapter
private var dealBind = true
@Transient
private lateinit var mView: View

open fun onCreateViewHolder(itemView: View) {
Expand Down
2 changes: 1 addition & 1 deletion QuickBind/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
api project(":Quick-runtime")

//GSON
compileOnly 'com.google.code.gson:gson:2.9.0'
implementation 'com.google.code.gson:gson:2.9.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/com/wpf/app/quick/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import android.widget.TextView
import com.wpf.app.quick.activity.QuickViewModelBindingActivity
import com.wpf.app.quick.annotations.BindView
import com.wpf.app.quick.demo.databinding.ActivityMainBinding
import com.wpf.app.quick.demo.viewmodel.MainViewModel
import com.wpf.app.quick.demo.model.MyMessage
import com.wpf.app.quick.demo.model.TestModel
import com.wpf.app.quickbind.annotations.BindSp2View
import java.util.ArrayList
import java.util.HashMap
import com.wpf.app.quick.demo.viewmodel.MainViewModel
import com.wpf.app.quick.utils.startActivity
import com.wpf.app.quickbind.annotations.BindSp2View
import com.wpf.app.r2test.R2TestActivity

/**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android.nonTransitiveRClass=true
IS_REMOTE=true
IS_ONLY_PLUGIN=false
GROUP=com.wpf.app.quick
VERSION_NAME=0.2.11
VERSION_NAME=0.2.12

POM_DESCRIPTION=Quick Android.

Expand Down

0 comments on commit 2f9f346

Please sign in to comment.