@@ -35,7 +35,7 @@ public class SupportFragmentDelegate {
35
35
FragmentAnimator mFragmentAnimator ;
36
36
AnimatorHelper mAnimHelper ;
37
37
boolean mLockAnim ;
38
- private int mCustomEnterAnim = Integer .MIN_VALUE , mCustomExitAnim = Integer .MIN_VALUE ;
38
+ private int mCustomEnterAnim = Integer .MIN_VALUE , mCustomExitAnim = Integer .MIN_VALUE , mCustomPopExitAnim = Integer . MIN_VALUE ;
39
39
40
40
private Handler mHandler ;
41
41
private boolean mFirstCreateView = true ;
@@ -57,6 +57,8 @@ public class SupportFragmentDelegate {
57
57
boolean mAnimByActivity = true ;
58
58
EnterAnimListener mEnterAnimListener ;
59
59
60
+ private boolean mRootViewClickable ;
61
+
60
62
public SupportFragmentDelegate (ISupportFragment support ) {
61
63
if (!(support instanceof Fragment ))
62
64
throw new RuntimeException ("Must extends Fragment" );
@@ -96,6 +98,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
96
98
mReplaceMode = bundle .getBoolean (TransactionDelegate .FRAGMENTATION_ARG_REPLACE , false );
97
99
mCustomEnterAnim = bundle .getInt (TransactionDelegate .FRAGMENTATION_ARG_CUSTOM_ENTER_ANIM , Integer .MIN_VALUE );
98
100
mCustomExitAnim = bundle .getInt (TransactionDelegate .FRAGMENTATION_ARG_CUSTOM_EXIT_ANIM , Integer .MIN_VALUE );
101
+ mCustomPopExitAnim = bundle .getInt (TransactionDelegate .FRAGMENTATION_ARG_CUSTOM_POP_EXIT_ANIM , Integer .MIN_VALUE );
99
102
}
100
103
101
104
if (savedInstanceState == null ) {
@@ -164,18 +167,17 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
164
167
165
168
View view = mFragment .getView ();
166
169
if (view != null ) {
170
+ mRootViewClickable = view .isClickable ();
167
171
view .setClickable (true );
168
172
setBackground (view );
169
173
}
170
174
175
+
171
176
if (savedInstanceState != null
172
177
|| mRootStatus == STATUS_ROOT_ANIM_DISABLE
173
178
|| (mFragment .getTag () != null && mFragment .getTag ().startsWith ("android:switcher:" ))
174
179
|| (mReplaceMode && !mFirstCreateView )) {
175
180
notifyEnterAnimEnd ();
176
- } else if (mCustomEnterAnim != Integer .MIN_VALUE ) {
177
- fixAnimationListener (mCustomEnterAnim == 0 ?
178
- mAnimHelper .getNoneAnim () : AnimationUtils .loadAnimation (_mActivity , mCustomEnterAnim ));
179
181
}
180
182
181
183
if (mFirstCreateView ) {
@@ -569,6 +571,22 @@ public void run() {
569
571
public void run () {
570
572
if (mFragment == null ) return ;
571
573
mSupportF .onEnterAnimationEnd (mSaveInstanceState );
574
+
575
+ if (mRootViewClickable ) return ;
576
+ final View view = mFragment .getView ();
577
+ if (view == null ) return ;
578
+ ISupportFragment preFragment = SupportHelper .getPreFragment (mFragment );
579
+ if (preFragment == null ) return ;
580
+
581
+ long prePopExitDuration = preFragment .getSupportDelegate ().getPopExitAnimDuration ();
582
+ long enterDuration = getEnterAnimDuration ();
583
+
584
+ mHandler .postDelayed (new Runnable () {
585
+ @ Override
586
+ public void run () {
587
+ view .setClickable (false );
588
+ }
589
+ }, prePopExitDuration - enterDuration );
572
590
}
573
591
};
574
592
@@ -624,6 +642,22 @@ public FragmentActivity getActivity() {
624
642
return _mActivity ;
625
643
}
626
644
645
+ public long getEnterAnimDuration () {
646
+ if (mCustomEnterAnim == Integer .MIN_VALUE ) {
647
+ if (mAnimHelper != null && mAnimHelper .enterAnim != null ) {
648
+ return mAnimHelper .enterAnim .getDuration ();
649
+ }
650
+ } else {
651
+ try {
652
+ return AnimationUtils .loadAnimation (_mActivity , mCustomEnterAnim ).getDuration ();
653
+ } catch (Exception e ) {
654
+ e .printStackTrace ();
655
+ }
656
+
657
+ }
658
+ return NOT_FOUND_ANIM_TIME ;
659
+ }
660
+
627
661
public long getExitAnimDuration () {
628
662
if (mCustomExitAnim == Integer .MIN_VALUE ) {
629
663
if (mAnimHelper != null && mAnimHelper .exitAnim != null ) {
@@ -640,6 +674,22 @@ public long getExitAnimDuration() {
640
674
return NOT_FOUND_ANIM_TIME ;
641
675
}
642
676
677
+ public long getPopExitAnimDuration () {
678
+ if (mCustomPopExitAnim == Integer .MIN_VALUE ) {
679
+ if (mAnimHelper != null && mAnimHelper .popExitAnim != null ) {
680
+ return mAnimHelper .popExitAnim .getDuration ();
681
+ }
682
+ } else {
683
+ try {
684
+ return AnimationUtils .loadAnimation (_mActivity , mCustomPopExitAnim ).getDuration ();
685
+ } catch (Exception e ) {
686
+ e .printStackTrace ();
687
+ }
688
+
689
+ }
690
+ return NOT_FOUND_ANIM_TIME ;
691
+ }
692
+
643
693
interface EnterAnimListener {
644
694
void onEnterAnimStart ();
645
695
}
0 commit comments