Skip to content

Commit

Permalink
* [android] fix the wrong header location (#135)
Browse files Browse the repository at this point in the history
* * [android] fix #2200

* * [android] restore
  • Loading branch information
misakuo authored and sospartan committed Jan 11, 2017
1 parent 8141de7 commit d58fce9
Showing 1 changed file with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import com.taobao.weex.common.WXThread;
import com.taobao.weex.ui.component.WXComponent;
Expand Down Expand Up @@ -328,20 +327,23 @@ private void showSticky() {
if (headerView == null)
return;
headerViewStack.push(headerView);
//record translation, it should not change after transformation
final float translationX = headerView.getTranslationX();
final float translationY = headerView.getTranslationY();
headComponent.removeSticky();
final ViewGroup parent = (ViewGroup) getParent();
if(parent != null){
parent.post(WXThread.secure(new Runnable() {
@Override
public void run() {
ViewGroup existedParent;
if((existedParent = (ViewGroup)headerView.getParent())!= null){
existedParent.removeView(headerView);
}
parent.addView(headerView);
post(WXThread.secure(new Runnable() {
@Override
public void run() {
ViewGroup existedParent;
if((existedParent = (ViewGroup)headerView.getParent())!= null){
existedParent.removeView(headerView);
}
}));
}
addView(headerView);
//recover translation, sometimes it will be changed on fling
headerView.setTranslationX(translationX);
headerView.setTranslationY(translationY);
}
}));
}

/**
Expand All @@ -355,17 +357,13 @@ private void removeSticky(WXComponent component) {
return;
}
final View headerView = headerViewStack.pop();
final ViewGroup parent = (ViewGroup) getParent();
if(parent != null){
parent.post(WXThread.secure(new Runnable() {
@Override
public void run() {
parent.removeView(headerView);
headComponent.recoverySticky();
}
}));
}

post(WXThread.secure(new Runnable() {
@Override
public void run() {
removeView(headerView);
headComponent.recoverySticky();
}
}));
}

/**
Expand Down

0 comments on commit d58fce9

Please sign in to comment.