Advertisement
babusaatbhoni

Touchlistner class

Apr 12th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. package com.primus.layoutitemanimation;
  2.  
  3. import android.content.ClipData;
  4. import android.util.Log;
  5. import android.view.MotionEvent;
  6. import android.view.View;
  7. import android.view.View.DragShadowBuilder;
  8. import android.view.View.OnTouchListener;
  9.  
  10. public  class MyTouchListener  implements OnTouchListener {
  11.  
  12.    
  13.     public static int view_position=0;
  14.     public static View first_image_view;
  15.    
  16.     public static int first_last_touch_x_axis,first_last_touch_y_axis;
  17.     @Override
  18.     public boolean onTouch(View view, MotionEvent event) {
  19.         // TODO Auto-generated method stub
  20.        
  21.         view_position=view.getId();
  22.         first_image_view=view;
  23.         first_last_touch_x_axis=(int) event.getX();
  24.         first_last_touch_y_axis=(int) event.getY();
  25.         if(event.getActionMasked()==MotionEvent.ACTION_DOWN)
  26.         {
  27.             ClipData data = ClipData.newPlainText("", "");
  28.             DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
  29.             view.startDrag(data, shadowBuilder, view, 0);
  30.             view.setVisibility(View.VISIBLE);
  31.            
  32.             Log.e("TOUCH", "down");
  33.            
  34.             Log.e("X_AXIS,Y_AXIS",".."+first_last_touch_x_axis+","+first_last_touch_y_axis);
  35.            
  36.  
  37.             return true;
  38.         }
  39.         else if(event.getActionMasked()==MotionEvent.ACTION_UP)
  40.         {
  41.             first_last_touch_x_axis=0;
  42.            
  43.             first_last_touch_y_axis=0;
  44.             Log.e("TOUCH", "UP");
  45.             return true;
  46.         }
  47.         else if(event.getActionMasked()==MotionEvent.ACTION_MOVE)
  48.         {
  49.             Log.e("TOUCH", "MOVE");
  50.             return true;
  51.  
  52.         }
  53.         return true;
  54.        
  55.     }
  56.  
  57. //  @Override
  58. //  public boolean onLongClick(View view) {
  59. //
  60. //        ClipData data = ClipData.newPlainText("", "");
  61. //        DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
  62. //        view.startDrag(data, shadowBuilder, view, 0);
  63. //        view.setVisibility(View.VISIBLE);
  64. //        view_position=view.getId();
  65. //        first_x_axis=(int) view.getX();
  66. //        first_y_axis=(int) view.getY();
  67. //        first_image_view=view;
  68. //        Log.v("IMAGE TOUCH", "CLICKED"+".."+first_x_axis+".."+first_y_axis);
  69. //        return true;
  70. //        
  71. //        
  72. //    
  73. //  }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement