Skip to content

Commit

Permalink
日常提交:2022-10-19。
Browse files Browse the repository at this point in the history
Signed-off-by: 王朋飞 <walgr1010>
  • Loading branch information
王朋飞 committed Oct 19, 2022
1 parent d956792 commit 25fc1c7
Show file tree
Hide file tree
Showing 46 changed files with 118 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class QuickViewModelBindingFragment<VM : QuickBindingViewModel<VB>, VB

open fun setViewBinding() {
if (view != null) {
viewBinding = DataBindingUtil.getBinding(view!!)
viewBinding = DataBindingUtil.getBinding(requireView())
if (viewBinding != null) {
viewBinding!!.lifecycleOwner = this
viewBinding!!.setVariable(
Expand All @@ -67,8 +67,8 @@ abstract class QuickViewModelBindingFragment<VM : QuickBindingViewModel<VB>, VB
setViewModel(
ViewModelProvider(
this,
ViewModelProvider.AndroidViewModelFactory(context!!.applicationContext as Application)
).get(viewModelCls)
ViewModelProvider.AndroidViewModelFactory(requireContext().applicationContext as Application)
)[viewModelCls]
)
bind(this, mViewModel)
if (mViewModel != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ open class QuickViewModelFragment<VM : QuickViewModel<H>, H : QuickView> @JvmOve
if (vmClass != null && context != null) {
mViewModel = ViewModelProvider(
this,
ViewModelProvider.AndroidViewModelFactory(context!!.applicationContext as Application)
).get(vmClass)
ViewModelProvider.AndroidViewModelFactory(requireContext().applicationContext as Application)
)[vmClass]
QuickBind.bind(this, mViewModel)
mViewModel?.baseView = this as H
mViewModel?.onViewCreated(this as H)
Expand Down
6 changes: 5 additions & 1 deletion Quick/src/main/java/com/wpf/app/quick/activity/RFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open class RFragment(
override val titleName: String = ""
) : QuickFragment(R.layout.fragment_recyclerview, titleName = titleName) {

var mRecyclerView: com.wpf.app.quickrecyclerview.QuickRecyclerView? = null
private var mRecyclerView: QuickRecyclerView? = null

@CallSuper
override fun initView(view: View?) {
Expand All @@ -23,4 +23,8 @@ open class RFragment(
override fun getTitle(): String? {
return titleName
}

open fun getRecyclerView(): QuickRecyclerView? {
return mRecyclerView
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open class RModelFragment<VM : QuickViewModel<H>, H : QuickView> @JvmOverloads c
@IdRes open val listId: Int = 0,
override val titleName: String = ""
) : QuickViewModelFragment<VM, H>(layoutId = layoutId) {
private var mRecyclerView: com.wpf.app.quickrecyclerview.QuickRecyclerView? = null
private var mRecyclerView: QuickRecyclerView? = null

@CallSuper
override fun initView(view: View?) {
Expand All @@ -27,7 +27,7 @@ open class RModelFragment<VM : QuickViewModel<H>, H : QuickView> @JvmOverloads c
super.initView(view)
}

open fun getRecyclerView(): com.wpf.app.quickrecyclerview.QuickRecyclerView? {
open fun getRecyclerView(): QuickRecyclerView? {
return mRecyclerView
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class RViewModelBindingFragment<VM : QuickBindingViewModel<VB>, VB : Vi
) : QuickViewModelBindingFragment<VM, VB>(
layoutId, null, titleName
) {
private var mRecyclerView: com.wpf.app.quickrecyclerview.QuickRecyclerView? = null
private var mRecyclerView: QuickRecyclerView? = null

@CallSuper
override fun initView(view: View?) {
Expand All @@ -32,7 +32,7 @@ abstract class RViewModelBindingFragment<VM : QuickBindingViewModel<VB>, VB : Vi
return titleName
}

open fun getRecyclerView(): com.wpf.app.quickrecyclerview.QuickRecyclerView? {
open fun getRecyclerView(): QuickRecyclerView? {
return mRecyclerView
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.wpf.app.quick.helper
package com.wpf.app.quick.helper.attribute

import android.content.Context
import android.util.AttributeSet
import com.wpf.app.quick.helper.attribute.SpViewAttributeHelper

/**
* Created by 王朋飞 on 2022/6/10.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wpf.app.quick.viewmodel

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import androidx.databinding.ViewDataBinding
Expand All @@ -13,6 +14,7 @@ import com.wpf.app.quick.activity.QuickViewModelBindingActivity
*/
abstract class QuickBindingViewModel<T : ViewDataBinding> : ViewModel(), LifecycleObserver {
var mViewBinding: T? = null
@SuppressLint("StaticFieldLeak")
var activity: QuickViewModelBindingActivity<out QuickBindingViewModel<T>, T>? = null

open fun onResume() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ open class QuickBottomSheetView(

protected var mBehavior: BottomSheetBehavior<View>? = null
open fun initBottomSheet() {
if (canScroll()) {
mBehavior = BottomSheetBehavior()
mBehavior = if (canScroll()) {
BottomSheetBehavior()
} else {
mBehavior = NoScrollBottomSheetBehavior()
NoScrollBottomSheetBehavior()
}
setBottomSheet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class QuickBindGroup<T : ViewGroup> @JvmOverloads constructor(
private var dealBind: Boolean = true
) : QuickItemGroup<T>(mContext, attributeSet, defStyleAttr, layoutId), Bind {

@Deprecated("有的手机有复用bug")
private var isLoadFirst = true
override fun onCreateViewHolder() {
if (dealBind) {
QuickBind.bind(this)
Expand All @@ -32,6 +32,10 @@ open class QuickBindGroup<T : ViewGroup> @JvmOverloads constructor(

@CallSuper
override fun onBindViewHolder(position: Int) {
if (isLoadFirst) {
onCreateViewHolder()
isLoadFirst = false
}
if (dealBind) {
dealInPlugins(this, null, QuickBind.bindPlugin)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class QuickViewGroup<T : ViewGroup> @JvmOverloads constructor(

private fun initViewGroupByT() {
if (this.shadowView != null) return
val tCls: Class<T>? = com.wpf.app.quickutil.GenericEx.get0Clazz(this)
val tCls: Class<T>? = GenericEx.get0Clazz(this)
tCls?.let {
val t =
tCls.getConstructor(Context::class.java, AttributeSet::class.java, Int::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.wpf.app.quick.util
package com.wpf.app.quick.widgets.quickview.helper

import android.app.Activity
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.wpf.app.quick.widgets.quickview.helper

import android.content.Context
import android.util.AttributeSet
import com.wpf.app.quick.widgets.quickview.QuickBindView

class StateImageView(
mContext: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0,
) : QuickBindView(
mContext,
attributeSet,
defStyleAttr,
) {


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ open class QuickChildSelectData(
onChildClick: RunItemClickWithSelf<QuickChildSelectData>? = null,
override var id: String? = null,
override var name: String? = null,
override var isSelect: Boolean = false,
override var defaultSelect: Boolean = false,
override var isSelect: Boolean = defaultSelect,
override var canCancel: Boolean = true, //是否可以取消选择
override var singleSelect: Boolean = false, //true 单选 false 多选
override val isGlobal: Boolean = true, //true 全局范围 false 同父范围
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wpf.app.quick.widgets.selectview.data

import android.view.View
import com.wpf.app.quick.annotations.BindData2View
import com.wpf.app.quickbind.helper.binddatahelper.ItemClick
import com.wpf.app.quickbind.interfaces.itemClick
import com.wpf.app.quickrecyclerview.data.QuickBindData

abstract class QuickClickData(
override val layoutId: Int = 0,
override val layoutView: View? = null,
override val isSuspension: Boolean = false,
): QuickBindData() {

@BindData2View(helper = ItemClick::class)
private val itemClick = itemClick {
onClick()
}

abstract fun onClick()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ open class QuickParentSelectData(
onParentClick: RunItemClickWithSelf<QuickParentSelectData>? = null,
override var id: String? = null,
override var name: String? = null,
override var isSelect: Boolean = false,
override var defaultSelect: Boolean = false,
override var isSelect: Boolean = defaultSelect,
override var canCancel: Boolean = true, //是否可以取消选择
override var singleSelect: Boolean = true, //true 单选 false 多选
override val isGlobal: Boolean = true, //true 全局范围 false 同父范围
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import com.wpf.app.quickrecyclerview.holder.QuickViewHolder
open class QuickSelectData(
open var id: String? = null,
open var name: String? = null,
open var isSelect: Boolean = false,
open var defaultSelect: Boolean = false, //是否默认选中,true清空后会再次选中
open var defaultSelect: Boolean = false, //是否默认选中,true 清空后会再次选中
open var isSelect: Boolean = defaultSelect,
@LayoutRes override val layoutId: Int = 0,
override val layoutView: View? = null,
override val isSuspension: Boolean = false, //View是否悬浮置顶
Expand All @@ -32,7 +32,6 @@ open class QuickSelectData(
onBindViewHolder(adapter, viewHolder, position)
}

@CallSuper
open fun onBindViewHolder(
adapter: QuickSelectAdapter,
viewHolder: QuickViewHolder<QuickBindData>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wpf.app.quick.widgets.selectview.listeners

import com.wpf.app.quick.widgets.selectview.QuickSelectAdapter
import com.wpf.app.quick.widgets.selectview.data.QuickChildSelectData
import com.wpf.app.quick.widgets.selectview.data.QuickParentSelectData
import com.wpf.app.quick.widgets.selectview.data.QuickSelectData
Expand Down Expand Up @@ -155,8 +156,8 @@ interface DataSelectOnAdapter : DataChangeAdapter, SetSelectChange {
return getSelectList()?.size ?: 0
}

fun getSelectAdapter(): com.wpf.app.quick.widgets.selectview.QuickSelectAdapter {
return getAdapter() as com.wpf.app.quick.widgets.selectview.QuickSelectAdapter
fun getSelectAdapter(): QuickSelectAdapter {
return getAdapter() as QuickSelectAdapter
}

fun asSelectData(): MutableList<QuickSelectData>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import com.wpf.app.quickbind.annotations.BindD2VHHelper
* Created by 王朋飞 on 2022/7/13.
*
*/
object Size2TextView :
BindD2VHHelper<TextView, Float> {
object Size2TextView : BindD2VHHelper<TextView, Float> {

override fun initView(
viewHolder: RecyclerView.ViewHolder?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import com.wpf.app.quickbind.annotations.BindD2VHHelper
* Created by 王朋飞 on 2022/7/13.
*
*/
object Text2TextView :
BindD2VHHelper<TextView, CharSequence> {
object Text2TextView : BindD2VHHelper<TextView, CharSequence> {

override fun initView(
viewHolder: RecyclerView.ViewHolder?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import com.wpf.app.quickbind.annotations.BindD2VHHelper
* Created by 王朋飞 on 2022/7/20.
*
*/
object Visibility2View :
BindD2VHHelper<View, Int> {
object Visibility2View : BindD2VHHelper<View, Int> {

override fun initView(
viewHolder: RecyclerView.ViewHolder?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.wpf.app.quickbind.interfaces.BindBaseFragment
*
*/
class FragmentsAdapter(
fm: FragmentManager, private val fragments: List<out BindBaseFragment>
fm: FragmentManager, private val fragments: List<BindBaseFragment>
) : FragmentPagerAdapter(fm) {

override fun getItem(i: Int): Fragment {
Expand Down
3 changes: 0 additions & 3 deletions QuickDialog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ android {
kotlinOptions {
jvmTarget = '11'
}
buildFeatures {
dataBinding true
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public RequestBody convert(@NonNull T value) throws IOException {
JsonWriter jsonWriter = gson.newJsonWriter(writer);
adapter.write(jsonWriter, value);
jsonWriter.close();
return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
return RequestBody.Companion.create(buffer.readByteString(), MEDIA_TYPE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ open class QuickAdapter : RecyclerView.Adapter<QuickViewHolder<QuickItemData>>()
}
}
holder?.let {
// if (findData is QuickBindData) {
// findData.onCreateViewHolder(holder.itemView)
// } else {
// holder.onCreateViewHolder(holder.itemView)
// }
holder.onCreateViewHolder(holder.itemView)
}
return holder as QuickViewHolder<QuickItemData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,4 @@ open class QuickBindData(
override fun getView(): View? {
return mView
}

// override fun initViewType() {
// if (viewType == 0) {
// viewType = abs(this.hashCode()) + Random.nextInt(1000)
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.wpf.app.quickrecyclerview.holder

import android.view.View
import android.view.ViewGroup
import androidx.annotation.CallSuper
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
Expand Down Expand Up @@ -35,6 +36,7 @@ open class QuickViewBindingHolder<T : QuickViewDataBinding<VB>, VB : ViewDataBin

open fun onCreateHolderEnd(itemView: View) {}

@CallSuper
override fun onBindViewHolder(adapter: QuickAdapter, data: T?, position: Int) {
super.onBindViewHolder(adapter, data, position)
if (mViewBinding != null) {
Expand Down
Loading

0 comments on commit 25fc1c7

Please sign in to comment.