Skip to content

Commit 327de61

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 00b8db8 + 76762fd commit 327de61

File tree

7 files changed

+1612
-23
lines changed

7 files changed

+1612
-23
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ The first demo shows the basic usage of the library. The second one shows the wa
4646
**1、build.gradle**
4747
````gradle
4848
// appcompat-v7 is required
49-
compile 'me.yokeyword:fragmentation:1.2.5'
49+
compile 'me.yokeyword:fragmentation:1.2.6'
5050
5151
// If you don't want to extends SupportActivity/Fragment and would like to customize your own support, just rely on fragmentation-core
52-
// compile 'me.yokeyword:fragmentation-core:1.2.5'
52+
// compile 'me.yokeyword:fragmentation-core:1.2.6'
5353
5454
// To get SwipeBack feature, rely on both fragmentation & fragmentation-swipeback
55-
compile 'me.yokeyword:fragmentation:1.2.5'
55+
compile 'me.yokeyword:fragmentation:1.2.6'
5656
// Swipeback is based on fragmentation. Refer to SwipeBackActivity/Fragment for your Customized SupportActivity/Fragment
57-
compile 'me.yokeyword:fragmentation-swipeback:1.2.5'
57+
compile 'me.yokeyword:fragmentation-swipeback:1.2.6'
5858
5959
// To simplify the communication between Fragments.
6060
compile 'me.yokeyword:eventbus-activity-scope:1.1.0'

README_CN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ compile 'me.yokeyword:fragmentation:1.2.5'
5858
// compile 'me.yokeyword:fragmentation-core:1.2.5'
5959
6060
// 如果想使用SwipeBack 滑动边缘退出Fragment/Activity功能,完整的添加规则如下:
61-
compile 'me.yokeyword:fragmentation:1.2.5'
61+
compile 'me.yokeyword:fragmentation:1.2.6'
6262
// swipeback基于fragmentation, 如果是自定制SupportActivity/Fragment,则参照SwipeBackActivity/Fragment实现即可
63-
compile 'me.yokeyword:fragmentation-swipeback:1.2.5'
63+
compile 'me.yokeyword:fragmentation-swipeback:1.2.6'
6464
6565
// Activity作用域的EventBus,更安全,可有效避免after onSavenInstanceState()异常
6666
compile 'me.yokeyword:eventbus-activity-scope:1.1.0'

fragmentation_core/src/main/java/me/yokeyword/fragmentation/SupportFragmentDelegate.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void onPause() {
194194
public void onDestroyView() {
195195
mSupport.getSupportDelegate().mFragmentClickable = true;
196196
getVisibleDelegate().onDestroyView();
197-
getHandler().removeCallbacksAndMessages(null);
197+
getHandler().removeCallbacks(mNotifyEnterAnimEndRunnable);
198198
}
199199

200200
public void onDestroy() {
@@ -551,6 +551,7 @@ private void fixAnimationListener(Animation enterAnim) {
551551
mSupport.getSupportDelegate().mFragmentClickable = false;
552552
// AnimationListener is not reliable.
553553
getHandler().postDelayed(mNotifyEnterAnimEndRunnable, enterAnim.getDuration());
554+
mSupport.getSupportDelegate().mFragmentClickable = true;
554555

555556
if (mEnterAnimListener != null) {
556557
getHandler().post(new Runnable() {
@@ -566,7 +567,8 @@ public void run() {
566567
private Runnable mNotifyEnterAnimEndRunnable = new Runnable() {
567568
@Override
568569
public void run() {
569-
notifyEnterAnimEnd();
570+
if (mFragment == null) return;
571+
mSupportF.onEnterAnimationEnd(mSaveInstanceState);
570572
}
571573
};
572574

@@ -600,13 +602,7 @@ private int getWindowBackground() {
600602
}
601603

602604
private void notifyEnterAnimEnd() {
603-
getHandler().post(new Runnable() {
604-
@Override
605-
public void run() {
606-
if (mFragment == null) return;
607-
mSupportF.onEnterAnimationEnd(mSaveInstanceState);
608-
}
609-
});
605+
getHandler().post(mNotifyEnterAnimEndRunnable);
610606
mSupport.getSupportDelegate().mFragmentClickable = true;
611607
}
612608

fragmentation_core/src/main/java/me/yokeyword/fragmentation/debug/DebugStackDelegate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ private void addDebugFragmentRecord(List<DebugFragmentRecord> fragmentRecords, F
200200
} else {
201201
for (int j = 0; j < backStackCount; j++) {
202202
FragmentManager.BackStackEntry entry = fragment.getFragmentManager().getBackStackEntryAt(j);
203-
if (entry.getName().equals(fragment.getTag())) {
203+
if ((entry.getName() != null && entry.getName().equals(fragment.getTag()))
204+
|| (entry.getName() == null && fragment.getTag() == null)) {
204205
break;
205206
}
206207
if (j == backStackCount - 1) {

fragmentation_swipeback/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Activity内Fragment数大于1时,滑动返回的是Fragment,否则滑动返
1010
1、项目下app的build.gradle中依赖:
1111
````gradle
1212
// appcompat v7包是必须的
13-
compile 'me.yokeyword:fragmentation:1.2.5'
14-
compile 'me.yokeyword:fragmentation-swipeback:1.2.5'
13+
compile 'me.yokeyword:fragmentation:1.2.6'
14+
compile 'me.yokeyword:fragmentation-swipeback:1.2.6'
1515
````
1616
2、如果Activity也需要支持SwipeBack,则继承SwipeBackActivity:
1717
````java

fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation/SwipeBackLayout.java

+26-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import android.support.v4.app.FragmentActivity;
1111
import android.support.v4.app.FragmentationMagician;
1212
import android.support.v4.view.ViewCompat;
13-
import android.support.v4.widget.ViewDragHelper;
1413
import android.util.AttributeSet;
1514
import android.util.DisplayMetrics;
1615
import android.view.MotionEvent;
@@ -64,6 +63,11 @@ public class SwipeBackLayout extends FrameLayout {
6463
*/
6564
public static final int STATE_SETTLING = ViewDragHelper.STATE_SETTLING;
6665

66+
/**
67+
* A view is currently drag finished.
68+
*/
69+
public static final int STATE_FINISHED = 3;
70+
6771
private static final int DEFAULT_SCRIM_COLOR = 0x99000000;
6872
private static final float DEFAULT_PARALLAX = 0.33f;
6973
private static final int FULL_ALPHA = 255;
@@ -129,6 +133,13 @@ private void init() {
129133
setEdgeOrientation(EDGE_LEFT);
130134
}
131135

136+
/**
137+
* Get ViewDragHelper
138+
*/
139+
public ViewDragHelper getViewDragHelper() {
140+
return mHelper;
141+
}
142+
132143
/**
133144
* Set scroll threshold, we will close the activity, when scrollPercent over
134145
* this value
@@ -221,6 +232,7 @@ public interface OnSwipeListener {
221232
* @see #STATE_IDLE
222233
* @see #STATE_DRAGGING
223234
* @see #STATE_SETTLING
235+
* @see #STATE_FINISHED
224236
*/
225237
void onDragStateChange(int state);
226238

@@ -413,7 +425,7 @@ public boolean tryCaptureView(View child, int pointerId) {
413425
mCurrentSwipeOrientation = EDGE_RIGHT;
414426
}
415427

416-
if (mListeners != null && !mListeners.isEmpty()) {
428+
if (mListeners != null) {
417429
for (OnSwipeListener listener : mListeners) {
418430
listener.onEdgeTouch(mCurrentSwipeOrientation);
419431
}
@@ -468,8 +480,7 @@ public void onViewPositionChanged(View changedView, int left, int top, int dx, i
468480
mContentTop = top;
469481
invalidate();
470482

471-
if (mListeners != null && !mListeners.isEmpty()
472-
&& mHelper.getViewDragState() == STATE_DRAGGING && mScrollPercent <= 1 && mScrollPercent > 0) {
483+
if (mListeners != null && mHelper.getViewDragState() == STATE_DRAGGING && mScrollPercent <= 1 && mScrollPercent > 0) {
473484
for (OnSwipeListener listener : mListeners) {
474485
listener.onDragScrolled(mScrollPercent);
475486
}
@@ -480,10 +491,12 @@ public void onViewPositionChanged(View changedView, int left, int top, int dx, i
480491
if (mCallOnDestroyView) return;
481492

482493
if (!((Fragment) mFragment).isDetached()) {
494+
onDragFinished();
483495
mFragment.getSupportDelegate().popQuiet();
484496
}
485497
} else {
486498
if (!mActivity.isFinishing()) {
499+
onDragFinished();
487500
mActivity.finish();
488501
mActivity.overridePendingTransition(0, 0);
489502
}
@@ -522,7 +535,7 @@ public void onViewReleased(View releasedChild, float xvel, float yvel) {
522535
@Override
523536
public void onViewDragStateChanged(int state) {
524537
super.onViewDragStateChanged(state);
525-
if (mListeners != null && !mListeners.isEmpty()) {
538+
if (mListeners != null) {
526539
for (OnSwipeListener listener : mListeners) {
527540
listener.onDragStateChange(state);
528541
}
@@ -538,6 +551,14 @@ public void onEdgeTouched(int edgeFlags, int pointerId) {
538551
}
539552
}
540553

554+
private void onDragFinished() {
555+
if (mListeners != null) {
556+
for (OnSwipeListener listener : mListeners) {
557+
listener.onDragStateChange(STATE_FINISHED);
558+
}
559+
}
560+
}
561+
541562
@Override
542563
public boolean onInterceptTouchEvent(MotionEvent ev) {
543564
if (!mEnable) return super.onInterceptTouchEvent(ev);

0 commit comments

Comments
 (0)