I have a animation custom drawer menu class calling from 5 different activity , in 4 of them it works fine, but in one of them that i'm using ListActivity instead of Activity not working.
the behavior of menu in ListActivity is weird , in debug mode the code running well but it seems the drawer menu class have not UIthread, even when i'm using runOnUiThread.
I'm initialize the custom drawer class on onCreate() method of each Activity and in button click just call the DraverVisibility() method in Drawer class.
public void DraverVisibility() {
int vis = draver.getVisibility();
if (vis == View.VISIBLE) {
TranslateAnimation movetoleft = new TranslateAnimation(0, -left_px, 0, 0);
movetoleft.setDuration(CLOSE_DRAVER_DURATION);
draver.startAnimation(movetoleft);
movetoleft.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
FrameLayout.LayoutParams parm = (FrameLayout.LayoutParams)
draver.getLayoutParams();
// if api<
parm.gravity = Gravity.TOP;
parm.leftMargin = -(int) left_px;
parm.topMargin = (int) top_px;
draver.setLayoutParams(parm);
draver.setVisibility(View.INVISIBLE);
draver.setAnimation(null);
draver.invalidate();
content.setAnimation(null);
content.invalidate();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
if (vis == View.INVISIBLE) {
InputMethodManager imm = (InputMethodManager) A.getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(draver.getWindowToken(), 0);
TranslateAnimation movetoRight = new TranslateAnimation(0, left_px, 0, 0);
movetoRight.setDuration(OPEN_DRAVER_DURATION);
movetoRight.setFillEnabled(true);
movetoRight.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
draver.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animation animation) {
FrameLayout.LayoutParams parm = (FrameLayout.LayoutParams) draver.getLayoutParams();
// if api<
parm.gravity = Gravity.TOP;
parm.leftMargin = 0; //-(int)left_px;
parm.topMargin = (int) top_px;
draver.setLayoutParams(parm);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
draver.startAnimation(movetoRight);
}
}
any suggestion ?
0 comments:
Post a Comment