-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
androidx.core:core-ktx 和 kotlin-jdk7包都升级
- Loading branch information
1 parent
8c23b2d
commit d6497de
Showing
18 changed files
with
410 additions
and
404 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
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
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
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
64 changes: 0 additions & 64 deletions
64
multilibrary/src/main/java/com/zhongjh/albumcamerarecorder/utils/HandleBackUtil.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
multilibrary/src/main/java/com/zhongjh/albumcamerarecorder/utils/HandleBackUtil.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,58 @@ | ||
package com.zhongjh.albumcamerarecorder.utils | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
import androidx.fragment.app.FragmentManager | ||
import com.zhongjh.albumcamerarecorder.listener.HandleBackInterface | ||
|
||
/** | ||
* 处理fragment的回退事件 | ||
* @author zhongjh | ||
*/ | ||
object HandleBackUtil { | ||
|
||
@JvmStatic | ||
fun handleBackPress(fragment: Fragment): Boolean { | ||
return handleBackPress(fragment.childFragmentManager) | ||
} | ||
|
||
@JvmStatic | ||
fun handleBackPress(fragmentActivity: FragmentActivity): Boolean { | ||
return handleBackPress(fragmentActivity.supportFragmentManager) | ||
} | ||
|
||
/** | ||
* 将back事件分发给 FragmentManager 中管理的子Fragment,如果该 FragmentManager 中的所有Fragment都 | ||
* 没有处理back事件,则尝试 FragmentManager.popBackStack() | ||
* | ||
* @return 如果处理了back键则返回 **true** | ||
* @see .handleBackPress | ||
* @see .handleBackPress | ||
*/ | ||
private fun handleBackPress(fragmentManager: FragmentManager): Boolean { | ||
val fragments = fragmentManager.fragments | ||
for (i in fragments.indices.reversed()) { | ||
val child = fragments[i] | ||
if (isFragmentBackHandled(child)) { | ||
return true | ||
} | ||
} | ||
if (fragmentManager.backStackEntryCount > 0) { | ||
fragmentManager.popBackStack() | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
/** | ||
* 判断Fragment是否处理了Back键 | ||
* | ||
* @return 如果处理了back键则返回 **true** | ||
*/ | ||
private fun isFragmentBackHandled(fragment: Fragment): Boolean { | ||
return (fragment.isVisible | ||
&& fragment.userVisibleHint // for ViewPager | ||
&& fragment is HandleBackInterface | ||
&& (fragment as HandleBackInterface).onBackPressed()) | ||
} | ||
} |
Oops, something went wrong.