Skip to content

Commit

Permalink
Not to invoke convertActivityFromTranslucent when starting to scroll.
Browse files Browse the repository at this point in the history
  • Loading branch information
Issac committed Sep 13, 2014
1 parent 3aab752 commit faeb287
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
@@ -1,4 +1,3 @@

package me.imid.swipebacklayout.lib;

import android.app.Activity;
Expand Down Expand Up @@ -161,18 +160,18 @@ public SwipeBackLayout(Context context, AttributeSet attrs, int defStyle) {

/**
* Sets the sensitivity of the NavigationLayout.
*
* @param context The application context.
*
* @param context The application context.
* @param sensitivity value between 0 and 1, the final value for touchSlop =
* ViewConfiguration.getScaledTouchSlop * (1 / s);
* ViewConfiguration.getScaledTouchSlop * (1 / s);
*/
public void setSensitivity(Context context, float sensitivity) {
mDragHelper.setSensitivity(context, sensitivity);
}

/**
* Set up contentView which will be moved by user gesture
*
*
* @param view
*/
private void setContentView(View view) {
Expand All @@ -191,7 +190,7 @@ public void setEnableGesture(boolean enable) {
* {@link me.imid.swipebacklayout.lib.ViewDragHelper.Callback#onEdgeDragStarted(int, int)}
* methods will only be invoked for edges for which edge tracking has been
* enabled.
*
*
* @param edgeFlags Combination of edge flags describing the edges to watch
* @see #EDGE_LEFT
* @see #EDGE_RIGHT
Expand All @@ -205,7 +204,7 @@ public void setEdgeTrackingEnabled(int edgeFlags) {
/**
* Set a color to use for the scrim that obscures primary content while a
* drawer is open.
*
*
* @param color Color to use in 0xAARRGGBB format.
*/
public void setScrimColor(int color) {
Expand All @@ -217,7 +216,7 @@ public void setScrimColor(int color) {
* Set the size of an edge. This is the range in pixels along the edges of
* this view that will actively detect edge touches or drags if edge
* tracking is enabled.
*
*
* @param size The size of an edge in pixels
*/
public void setEdgeSize(int size) {
Expand All @@ -227,7 +226,7 @@ public void setEdgeSize(int size) {
/**
* Register a callback to be invoked when a swipe event is sent to this
* view.
*
*
* @param listener the swipe listener to attach to this view
* @deprecated use {@link #addSwipeListener} instead
*/
Expand All @@ -238,7 +237,7 @@ public void setSwipeListener(SwipeListener listener) {

/**
* Add a callback to be invoked when a swipe event is sent to this view.
*
*
* @param listener the swipe listener to attach to this view
*/
public void addSwipeListener(SwipeListener listener) {
Expand All @@ -250,7 +249,7 @@ public void addSwipeListener(SwipeListener listener) {

/**
* Removes a listener from the set of listeners
*
*
* @param listener
*/
public void removeSwipeListener(SwipeListener listener) {
Expand All @@ -263,18 +262,18 @@ public void removeSwipeListener(SwipeListener listener) {
public static interface SwipeListener {
/**
* Invoke when state change
*
* @param state flag to describe scroll state
*
* @param state flag to describe scroll state
* @param scrollPercent scroll percent of this view
* @see #STATE_IDLE
* @see #STATE_DRAGGING
* @see #STATE_SETTLING
* @param scrollPercent scroll percent of this view
*/
public void onScrollStateChange(int state, float scrollPercent);

/**
* Invoke when edge touched
*
*
* @param edgeFlag edge flag describing the edge being touched
* @see #EDGE_LEFT
* @see #EDGE_RIGHT
Expand All @@ -291,7 +290,7 @@ public static interface SwipeListener {
/**
* Set scroll threshold, we will close the activity, when scrollPercent over
* this value
*
*
* @param threshold
*/
public void setScrollThresHold(float threshold) {
Expand All @@ -303,8 +302,8 @@ public void setScrollThresHold(float threshold) {

/**
* Set a drawable used for edge shadow.
*
* @param shadow Drawable to use
*
* @param shadow Drawable to use
* @param edgeFlags Combination of edge flags describing the edge to set
* @see #EDGE_LEFT
* @see #EDGE_RIGHT
Expand All @@ -323,8 +322,8 @@ public void setShadow(Drawable shadow, int edgeFlag) {

/**
* Set a drawable used for edge shadow.
*
* @param resId Resource of drawable to use
*
* @param resId Resource of drawable to use
* @param edgeFlags Combination of edge flags describing the edge to set
* @see #EDGE_LEFT
* @see #EDGE_RIGHT
Expand Down Expand Up @@ -453,8 +452,8 @@ private void drawShadow(Canvas canvas, View child) {

public void attachToActivity(Activity activity) {
mActivity = activity;
TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] {
android.R.attr.windowBackground
TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
android.R.attr.windowBackground
});
int background = a.getResourceId(0, 0);
a.recycle();
Expand Down
@@ -1,4 +1,3 @@

package me.imid.swipebacklayout.lib.app;

import android.app.Activity;
Expand Down Expand Up @@ -31,9 +30,6 @@ public void onActivityCreate() {
mSwipeBackLayout.addSwipeListener(new SwipeBackLayout.SwipeListener() {
@Override
public void onScrollStateChange(int state, float scrollPercent) {
if (state == SwipeBackLayout.STATE_IDLE && scrollPercent == 0) {
Utils.convertActivityFromTranslucent(mActivity);
}
}

@Override
Expand All @@ -50,7 +46,6 @@ public void onScrollOverThreshold() {

public void onPostCreate() {
mSwipeBackLayout.attachToActivity(mActivity);
Utils.convertActivityFromTranslucent(mActivity);
}

public View findViewById(int id) {
Expand Down

2 comments on commit faeb287

@AdaDai
Copy link

@AdaDai AdaDai commented on faeb287 Dec 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

亲,“Not to invoke convertActivityFromTranslucent when starting to scroll.” 这个commit在MIUI v6上会出现右滑显示的是桌面;重现步骤:第一次安装正常,按Home返回桌面,再从最近列表回到应用,这时候右滑底部显示的是桌面;其他机型暂时都是正常的;Utils.convertActivityFromTranslucent(mActivity);不删掉也是正常的。。

@molikto
Copy link

@molikto molikto commented on faeb287 Jan 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is needed? I think make the top activity to non-translucent will make the activity lifecycle correct (because then the activity behind it can have onStop called)

Please sign in to comment.