Skip to content

Commit

Permalink
commit 1.2.3,修改navigation,使Fragment执行onPause/onResume
Browse files Browse the repository at this point in the history
  • Loading branch information
hegaojian committed Jun 29, 2021
1 parent 0d1fc1d commit 3696396
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 1,103 deletions.
17 changes: 9 additions & 8 deletions JetpackMvvm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.github.hegaojian'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 22
versionName "1.2.2"
versionCode 23
versionName "1.2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
Expand All @@ -35,22 +35,23 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
//kotlin
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
//lifecycle
api 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
api 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
api 'androidx.lifecycle:lifecycle-common-java8:2.2.0'
api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
// viewModel
api "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
api "androidx.fragment:fragment-ktx:1.2.5"
api "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
api "androidx.fragment:fragment-ktx:1.3.1"
// liveData
api "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
api 'com.kunminx.archi:unpeek-livedata:4.4.1-beta1'
//navigation
api 'androidx.navigation:navigation-runtime-ktx:2.3.2'
api 'androidx.navigation:navigation-fragment-ktx:2.3.5'
api 'androidx.navigation:navigation-ui-ktx:2.3.5'
//retrofit
api "com.squareup.retrofit2:retrofit:2.9.0"
api "com.squareup.retrofit2:converter-gson:2.9.0"
Expand Down
2 changes: 1 addition & 1 deletion JetpackMvvm/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.hgj.jetpackmvvm" >
package="me.hgj.jetpackmvvm">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.view.View
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.Navigation
import me.hgj.jetpackmvvm.navigation.NavHostFragment
import androidx.navigation.fragment.NavHostFragment

/**
* 作者 : hegaojian
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import java.util.*

/**
* 作者 : hegaojian
* 时间 : 2020/1/7
* 时间 : 2021/6/8
* 描述 :
*/
object KtxActivityManger {
//activity集合
private val mActivityList = LinkedList<Activity>()

//当前activity
val currentActivity: Activity?
get() =
if (mActivityList.isEmpty()) null
else mActivityList.last

/**
* activity入栈
* @param activity Activity
*/
fun pushActivity(activity: Activity) {
if (mActivityList.contains(activity)) {
Expand All @@ -31,6 +35,7 @@ object KtxActivityManger {

/**
* activity出栈
* @param activity Activity
*/
fun popActivity(activity: Activity) {
mActivityList.remove(activity)
Expand All @@ -45,6 +50,7 @@ object KtxActivityManger {

/**
* 关闭传入的activity
* @param activity Activity
*/
fun finishActivity(activity: Activity) {
mActivityList.remove(activity)
Expand All @@ -53,18 +59,25 @@ object KtxActivityManger {

/**
* 关闭传入的activity类名
* @param clazz Class<*>
*/
fun finishActivity(clazz: Class<*>) {
for (activity in mActivityList)
if (activity.javaClass == clazz)
for (activity in mActivityList) {
if (activity.javaClass == clazz) {
mActivityList.remove(activity)
activity.finish()
return
}
}
}

/**
* 关闭所有的activity
*/
fun finishAllActivity() {
for (activity in mActivityList)
for (activity in mActivityList) {
activity.finish()
}
mActivityList.clear()
}
}

This file was deleted.

Loading

0 comments on commit 3696396

Please sign in to comment.