-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 王朋飞 <walgr1010>
- Loading branch information
王朋飞
committed
Nov 9, 2022
1 parent
968220f
commit 72d94f9
Showing
13 changed files
with
236 additions
and
178 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
Quick/src/main/java/com/wpf/app/quick/helper/binddatahelper/Request2View.kt
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
QuickBind/src/main/java/com/wpf/app/quickbind/bindview/QuickRequestData.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,25 @@ | ||
package com.wpf.app.quickbind.bindview | ||
|
||
import android.view.View | ||
import androidx.annotation.LayoutRes | ||
import com.wpf.app.quickbind.QuickBind | ||
import com.wpf.app.quickutil.bind.Bind | ||
|
||
open class QuickRequestData @JvmOverloads constructor( | ||
@LayoutRes open val layoutId: Int = 0, | ||
@Transient open val layoutView: View? = null | ||
) : Bind { | ||
|
||
@Transient | ||
private var mView: View? = null | ||
|
||
open fun onCreateView(view: View) { | ||
mView = view | ||
QuickBind.bind(this) | ||
} | ||
|
||
override fun getView(): View? { | ||
return mView | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
QuickBind/src/main/java/com/wpf/app/quickbind/helper/binddatahelper/Request2View.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,20 @@ | ||
package com.wpf.app.quickbind.helper.binddatahelper | ||
|
||
import android.view.View | ||
import com.wpf.app.quickbind.bindview.QuickRequestData | ||
import com.wpf.app.quickbind.annotations.BindD2VHelper | ||
import com.wpf.app.quickbind.interfaces.Request2ViewWithView | ||
import com.wpf.app.quickutil.Callback | ||
|
||
object Request2View: BindD2VHelper<View, Request2ViewWithView<out QuickRequestData, out View>> { | ||
|
||
override fun initView(view: View, data: Request2ViewWithView<out QuickRequestData, out View>) { | ||
(data as Request2ViewWithView<QuickRequestData, View>).requestAndCallback(view, callback = object : Callback<QuickRequestData> { | ||
override fun callback(data: QuickRequestData?) { | ||
data?.onCreateView(view) | ||
} | ||
|
||
}) | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
QuickBind/src/main/java/com/wpf/app/quickbind/interfaces/Request2View.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,44 @@ | ||
package com.wpf.app.quickbind.interfaces | ||
|
||
import android.view.View | ||
import com.wpf.app.quickbind.bindview.QuickRequestData | ||
import com.wpf.app.quickutil.Callback | ||
|
||
|
||
interface Request2View<Data : QuickRequestData>: Request2ViewWithView<Data, View> { | ||
|
||
/** | ||
* 接口请求 | ||
*/ | ||
fun requestAndCallback(callback: Callback<Data>) | ||
|
||
override fun requestAndCallback(view: View, callback: Callback<Data>) { | ||
requestAndCallback(callback) | ||
} | ||
} | ||
|
||
interface Request2ViewWithView<Data : QuickRequestData, View> { | ||
|
||
/** | ||
* 接口请求 | ||
*/ | ||
fun requestAndCallback(view: View, callback: Callback<Data>) | ||
} | ||
|
||
fun <Data : QuickRequestData> request2View( | ||
callbackF: (callback: Callback<Data>) -> Unit | ||
) = object : Request2View<Data> { | ||
|
||
override fun requestAndCallback(callback: Callback<Data>) { | ||
callbackF.invoke(callback) | ||
} | ||
} | ||
|
||
fun <Data : QuickRequestData, View> request2ViewWithView( | ||
callbackF: (view: View, callback: Callback<Data>) -> Unit | ||
) = object : Request2ViewWithView<Data, View> { | ||
|
||
override fun requestAndCallback(view: View, callback: Callback<Data>) { | ||
callbackF.invoke(view, callback) | ||
} | ||
} |
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
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
78 changes: 78 additions & 0 deletions
78
QuickRecyclerView/src/main/java/com/wpf/app/quickrecyclerview/listeners/Request2List.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,78 @@ | ||
package com.wpf.app.quickrecyclerview.listeners | ||
|
||
import com.wpf.app.quickrecyclerview.data.QuickItemData | ||
import com.wpf.app.quickrecyclerview.data.RequestData | ||
import com.wpf.app.quickutil.CallbackList | ||
|
||
/** | ||
* Created by 王朋飞 on 2022/7/13. | ||
* | ||
*/ | ||
|
||
interface Request2List<Request : RequestData, Data : QuickItemData>: Request2ListWithView<Request, Data, Any> { | ||
|
||
/** | ||
* 接口请求 | ||
*/ | ||
fun requestAndCallback(requestData: Request, callback: CallbackList<Data>) | ||
|
||
override fun requestAndCallback(view: Any, requestData: Request, callback: CallbackList<Data>) { | ||
requestAndCallback(requestData, callback) | ||
} | ||
} | ||
|
||
interface Request2ListWithView<Request : RequestData, Data : QuickItemData, View> { | ||
|
||
/** | ||
* 接口请求 | ||
*/ | ||
fun requestAndCallback(view: View, requestData: Request, callback: CallbackList<Data>) | ||
|
||
/** | ||
* 刷新结束 | ||
* 返回true表示刷新结束后自己刷新adapter | ||
*/ | ||
fun refreshFinish(): Boolean { return false } | ||
|
||
/** | ||
* 加载结束 | ||
* 返回true表示刷新结束后自己刷新adapter | ||
*/ | ||
fun loadMoreFinish(): Boolean { return false } | ||
} | ||
|
||
fun <Request : RequestData, Data : QuickItemData> requestData2List( | ||
callbackF: (requestData: Request, callback: CallbackList<Data>) -> Unit | ||
) = object : Request2List<Request, Data> { | ||
|
||
override fun requestAndCallback(requestData: Request, callback: CallbackList<Data>) { | ||
callbackF.invoke(requestData, callback) | ||
} | ||
} | ||
|
||
fun <Request : RequestData, Data : QuickItemData, View> requestData2ListWithView( | ||
callbackF: (view: View, requestData: Request, callback: CallbackList<Data>) -> Unit | ||
) = object : Request2ListWithView<Request, Data, View> { | ||
|
||
override fun requestAndCallback(view: View, requestData: Request, callback: CallbackList<Data>) { | ||
callbackF.invoke(view, requestData, callback) | ||
} | ||
} | ||
|
||
fun <Data : QuickItemData> request2List( | ||
callbackF: (requestData: RequestData, callback: CallbackList<Data>) -> Unit | ||
) = object : Request2List<RequestData, Data> { | ||
|
||
override fun requestAndCallback(requestData: RequestData, callback: CallbackList<Data>) { | ||
callbackF.invoke(requestData, callback) | ||
} | ||
} | ||
|
||
fun <Data : QuickItemData, View> request2ListWithView( | ||
callbackF: (view: View, requestData: RequestData, callback: CallbackList<Data>) -> Unit | ||
) = object : Request2ListWithView<RequestData, Data, View> { | ||
|
||
override fun requestAndCallback(view: View, requestData: RequestData, callback: CallbackList<Data>) { | ||
callbackF.invoke(view, requestData, callback) | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
...yclerView/src/main/java/com/wpf/app/quickrecyclerview/listeners/RequestAndItemCallback.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.