Browse Source

fixed swipe animation

Alexander Brakowski 10 years ago
parent
commit
2a9e81226b

+ 17 - 4
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ProfileManagerListAdapter.java

@@ -42,14 +42,22 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
     private final List<ProfileListItem> values;
 	private float mLastX, upX;
 	private static final int MIN_DISTANCE = 50;
-	private Animation inAnimation;
+	private Animation inAnimationRL;
+	private Animation outAnimationRL;
+
+	private Animation inAnimationLR;
+	private Animation outAnimationLR;
 
     public ProfileManagerListAdapter(Context context, List<ProfileListItem> objects) {
         super(context, R.layout.profile_manager_list_item, objects);
         this.context = context;
         this.values  = objects;
 
-	    inAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.in_right_to_left);
+	    inAnimationRL = AnimationUtils.loadAnimation(getContext(), R.anim.in_right_to_left);
+	    outAnimationRL = AnimationUtils.loadAnimation(getContext(), R.anim.out_right_to_left);
+
+	    inAnimationLR = AnimationUtils.loadAnimation(getContext(), R.anim.in_left_to_right);
+	    outAnimationLR = AnimationUtils.loadAnimation(getContext(), R.anim.out_left_to_right);
     }
 
 
@@ -87,6 +95,8 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
 	    holder.switcher.setOnTouchListener(new OnSwipeTouchListener(){
 		    public void onSwipeRight() {
 			    if(item.isBackVisible){
+				    switcher.setInAnimation(inAnimationLR);
+				    switcher.setOutAnimation(outAnimationLR);
 				    switcher.setDisplayedChild(0);
 				    item.isBackVisible = false;
 			    }
@@ -94,6 +104,8 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
 
 		    public void onSwipeLeft() {
 			    if(!item.isBackVisible){
+				    switcher.setInAnimation(inAnimationRL);
+				    switcher.setOutAnimation(outAnimationRL);
 				    switcher.setDisplayedChild(1);
 				    item.isBackVisible = true;
 			    }
@@ -113,14 +125,15 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
 	    holder.itemIcon.setImageBitmap(item.icon);
 
 		holder.switcher.setInAnimation(null);
+	    holder.switcher.setOutAnimation(null);
 	    if(item.isBackVisible){
 		    holder.switcher.setDisplayedChild(1);
 	    } else {
 		    holder.switcher.setDisplayedChild(0);
 	    }
 
-	    holder.switcher.setInAnimation(inAnimation);
-
+	    holder.switcher.setInAnimation(inAnimationRL);
+		holder.switcher.setOutAnimation(outAnimationRL);
         if(!item.activated){
             RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams )holder.textView.getLayoutParams();
             lp.setMargins(0,0,0,0);