-
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.
- Loading branch information
Showing
8 changed files
with
71 additions
and
41 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
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
12 changes: 10 additions & 2 deletions
12
app/src/main/java/com/loongwind/ardf/demo/MainViewModel.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 |
---|---|---|
@@ -1,19 +1,27 @@ | ||
package com.loongwind.ardf.demo | ||
|
||
import com.loongwind.ardf.base.BaseViewModel | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
|
||
class MainViewModel : BaseViewModel() { | ||
class MainViewModel : BaseViewModel() , KoinComponent{ | ||
|
||
private val apiService:ApiService by inject() | ||
|
||
companion object { | ||
const val EVENT_SIMPLE = 0x00 | ||
const val EVENT_ITEM_CLICK = 0x01 | ||
const val EVENT_ITEM_EVENT = 0x02 | ||
const val EVENT_MULTI_ITEM_VIEW = 0x03 | ||
const val EVENT_API = 0x04 | ||
} | ||
|
||
|
||
fun onClick(event : Int){ | ||
postEvent(event) | ||
} | ||
|
||
fun getUser() = launch { | ||
val user = apiService.getUser() | ||
postHintText("------" + user.name + "------") | ||
} | ||
} |
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
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
22 changes: 22 additions & 0 deletions
22
base/src/main/java/com/loongwind/ardf/base/ext/ViewBindingAdapter.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,22 @@ | ||
package com.loongwind.ardf.base.ext | ||
|
||
import android.view.View | ||
import android.widget.ImageView | ||
import androidx.databinding.BindingAdapter | ||
|
||
/** | ||
*Author: chengminghui | ||
*Time: 2019-09-04 | ||
*Description: xxx | ||
*/ | ||
|
||
@BindingAdapter("android:visibility") | ||
fun setVisibility(view: View, isVisibility: Boolean) { | ||
view.visibility = if (isVisibility) View.VISIBLE else View.GONE | ||
} | ||
|
||
|
||
@BindingAdapter("android:src") | ||
fun setImage(imageView: ImageView, imgRes: Int) { | ||
imageView.setImageResource(imgRes) | ||
} |
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