-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. 补充 ReactiveFragment 的使用示例
- Loading branch information
Showing
34 changed files
with
541 additions
and
354 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
22 changes: 0 additions & 22 deletions
22
app/src/androidTest/java/github/leavesczy/reactivehttpsamples/ExampleInstrumentedTest.kt
This file was deleted.
Oops, something went wrong.
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
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
11 changes: 11 additions & 0 deletions
11
app/src/main/java/github/leavesczy/reactivehttpsamples/base/BaseFragment.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,11 @@ | ||
package github.leavesczy.reactivehttpsamples.base | ||
|
||
import github.leavesczy.reactivehttp.base.ReactiveFragment | ||
|
||
/** | ||
* @Author: leavesCZY | ||
* @Date: 2022/4/23 20:38 | ||
* @Desc: | ||
* @Github:https://github.com/leavesCZY | ||
*/ | ||
open class BaseFragment : ReactiveFragment() |
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
128 changes: 0 additions & 128 deletions
128
app/src/main/java/github/leavesczy/reactivehttpsamples/core/viewmodel/MapViewModel.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...rc/main/java/github/leavesczy/reactivehttpsamples/core/viewmodel/weather/CityViewModel.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,30 @@ | ||
package github.leavesczy.reactivehttpsamples.core.viewmodel.weather | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import github.leavesczy.reactivehttpsamples.base.BaseViewModel | ||
import github.leavesczy.reactivehttpsamples.core.mode.DistrictMode | ||
import kotlinx.coroutines.delay | ||
|
||
/** | ||
* @Author: leavesCZY | ||
* @Date: 2022/4/23 21:07 | ||
* @Desc: | ||
* @Github:https://github.com/leavesCZY | ||
*/ | ||
class CityViewModel(private val province: String) : BaseViewModel() { | ||
|
||
val cityLiveData = MutableLiveData<List<DistrictMode>>() | ||
|
||
fun getCity() { | ||
remoteDataSource.enqueueLoading({ | ||
//主动延迟一段时间,避免弹窗太快消失 | ||
delay(1200) | ||
getCity(province) | ||
}) { | ||
onSuccess { | ||
cityLiveData.value = it[0].districts | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.