本文整理匯總了Java中android.app.Fragment.getParentFragment方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.getParentFragment方法的具體用法?Java Fragment.getParentFragment怎麽用?Java Fragment.getParentFragment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.Fragment
的用法示例。
在下文中一共展示了Fragment.getParentFragment方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isDescendant
import android.app.Fragment; //導入方法依賴的package包/類
/**
* Returns true if the fragment is a descendant of our parent.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isDescendant(Fragment fragment) {
Fragment root = this.getParentFragment();
while (fragment.getParentFragment() != null) {
if (fragment.getParentFragment() == root) {
return true;
}
fragment = fragment.getParentFragment();
}
return false;
}
示例2: onDestroy
import android.app.Fragment; //導入方法依賴的package包/類
@Override
public void onDestroy() {
super.onDestroy();
//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}
// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}
// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;
if (Build.VERSION.SDK_INT >= 17) {
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}
}
if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}