Skip to content

Commit

Permalink
Fragment增加destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
geyifeng committed Sep 6, 2019
1 parent 5586b3c commit b0e0fd4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.41'
ext.immersionbar_version = '3.0.0-beta07'
ext.kotlin_version = '1.3.50'
ext.immersionbar_version = '3.0.0'
repositories {
google()
jcenter()
Expand Down
27 changes: 24 additions & 3 deletions immersionbar/src/main/java/com/gyf/immersionbar/ImmersionBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static ImmersionBar with(@NonNull Fragment fragment) {
* With immersion bar.
*
* @param fragment the fragment
* @param isOnly the is only fragment实例对象是否唯一,默认是false,不唯一
* @param isOnly the is only fragment实例对象是否唯一,默认是false,不唯一,isOnly影响tag以何种形式生成
* @return the immersion bar
*/
public static ImmersionBar with(@NonNull Fragment fragment, boolean isOnly) {
Expand All @@ -166,10 +166,10 @@ public static ImmersionBar with(@NonNull android.app.Fragment fragment) {

/**
* 在Fragment使用
* With immersion bar. fragment实例对象是否唯一,默认是false,不唯一
* With immersion bar.
*
* @param fragment the fragment
* @param isOnly the is only
* @param isOnly the is only fragment实例对象是否唯一,默认是false,不唯一,isOnly影响tag以何种形式生成
* @return the immersion bar
*/
public static ImmersionBar with(@NonNull android.app.Fragment fragment, boolean isOnly) {
Expand Down Expand Up @@ -210,6 +210,27 @@ public static ImmersionBar with(@NonNull Activity activity, @NonNull Dialog dial
return getRetriever().get(activity, dialog);
}

/**
* 非必须调用
* Destroy.
*
* @param fragment the fragment
*/
public static void destroy(@NonNull Fragment fragment) {
getRetriever().destroy(fragment, false);
}

/**
* 非必须调用
* Destroy.
*
* @param fragment the fragment
* @param isOnly the is only fragment实例对象是否唯一,默认是false,不唯一,isOnly影响tag以何种形式生成
*/
public static void destroy(@NonNull Fragment fragment, boolean isOnly) {
getRetriever().destroy(fragment, isOnly);
}

/**
* 在Dialog里销毁,不包括DialogFragment
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ public ImmersionBar get(Activity activity, Dialog dialog) {
}
}

/**
* Destroy.
*
* @param fragment the fragment
*/
public void destroy(Fragment fragment, boolean isOnly) {
if (fragment == null) {
return;
}
String tag = mTag;
if (isOnly) {
tag += fragment.getClass().getName();
} else {
tag += System.identityHashCode(fragment);
}
getSupportFragment(fragment.getChildFragmentManager(), tag, true);
}

/**
* Destroy.
*
Expand Down

0 comments on commit b0e0fd4

Please sign in to comment.