Example usage for android.view GestureDetector GestureDetector

List of usage examples for android.view GestureDetector GestureDetector

Introduction

In this page you can find the example usage for android.view GestureDetector GestureDetector.

Prototype

public GestureDetector(Context context, OnGestureListener listener) 

Source Link

Document

Creates a GestureDetector with the supplied listener.

Usage

From source file:org.mariotaku.harmony.activity.MusicPlaybackActivity.java

/** Called when the activity is first created. */
@Override//from  w  w w . jav a  2  s.c om
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mImageLoader = HarmonyApplication.getInstance(this).getImageLoaderWrapper();
    mPreferences = new PreferencesEditor(this);
    mRefreshRunnable = new RefreshRunnable(this);
    mHideActionBarRunnable = new HideActionBarRunnable(this);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    setContentView(R.layout.music_playback);
    mActionBar = getActionBar();
    mActionBar.addOnMenuVisibilityListener(this);
    mActionBar.hide();

    mSeekBar.setMax(1000);
    mSeekBar.setOnSeekBarChangeListener(this);

    mPlayPauseButton.setOnClickListener(this);
    mPrevButton.setOnClickListener(this);
    mNextButton.setOnClickListener(this);

    mPrevButton.setRepeatListener(this, 260);
    mNextButton.setRepeatListener(this, 260);

    mDeviceHasDpad = getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD;
    mGestureDector = new GestureDetector(this, this);
    mPlaybackContainer.setTouchInterceptor(this);

    mAdapter = new PagerAdapter(this);
    mViewPager.setAdapter(mAdapter);
    mAdapter.addFragment(QueueFragment.class);
    mAdapter.addFragment(Fragment.class);
    mAdapter.addFragment(LyricsFragment.class);
    mViewPager.setOnPageChangeListener(this);
    mViewPager.setOffscreenPageLimit(3);
    mViewPager.setCurrentItem(1, false);
}

From source file:com.qubaopen.customui.HorizontalListView.java

public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();/*  www .jav  a2 s  .c  o  m*/
    initView();
    retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    //            HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    //        }
}

From source file:com.example.stickablelistview.StickListView.java

public StickListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowTop = new EdgeEffectCompat(context);
    mEdgeGlowBottom = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();//from   w  w w  .  j a  va  2s. co  m
    initView();
    retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:com.appybite.customer.HorizontalListView.java

public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();/*w  w  w  . j a  va 2 s .  c o m*/
    initView();
    //        retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:com.thunisoft.sswy.mobile.view.HorizontalListView.java

public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();//from   ww w .  j  a  v a  2  s.c  om
    initView();
    setDividerWidth(DensityUtil.px2dip(context, 10));
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:com.raja.knowme.FragmentProjects.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_projects, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    adapter = new ProjectsListAdapter(getActivity());
    functions = new AppCommonFunctions(getActivity());
    pref = new AppPreferences(getActivity());
    knowmeData = new KnowMeDataObject(getActivity());
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading));

    projects_list = (ListView) mHolderView.findViewById(R.id.projects_listview);
    comapny_switcher = (TextSwitcher) mHolderView.findViewById(R.id.projects_company_name_text);
    instruction_btn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    projects_list.setSelector(this.getResources().getDrawable(R.drawable.transparent_shape));

    if (!pref.getProjectsFirstRun()) {
        instruction_btn.setVisibility(RelativeLayout.GONE);
    }/*from   w ww.j a  v a  2 s  .co  m*/

    instruction_btn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setProjectsRunned();
            instruction_btn.setVisibility(RelativeLayout.GONE);
        }
    });
    /*                 Multiple Screen Size Condition             */

    // Small Size

    if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        //  Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(16 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(14 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(32 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    //X-large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        //  Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(48 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    //Undefined Size

    else {
        //  Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(20 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });
    }
    mProgressDialog.show();
    new LoadData().execute();

    // Gesture detection
    gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() {

        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        public void onShowPress(MotionEvent e) {
        }

        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        public void onLongPress(MotionEvent e) {
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH)
                    return false;
                /** Left swipe */
                if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count < (MAX_COUNT - 1))
                        nextCompany();
                    else {
                        comapny_switcher.startAnimation(shake);
                        projects_list.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousComapny();
                    else {
                        comapny_switcher.startAnimation(shake);
                        projects_list.startAnimation(shake);
                    }
                }
            } catch (Exception e) {
            }

            return false;
        }

        public boolean onDown(MotionEvent e) {
            return false;
        }
    });

    gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    };

    projects_list.setOnTouchListener(gestureListener);
    return mHolderView;
}

From source file:aksha.upcomingdemo.HorizontalListView.java

public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();//w ww .j  a v a2s . c  om
    initView();
    retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:dk.nodes.widgets.listviews.NHorizontalListView.java

public NHorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();//from w  w w  .j ava2  s .  c o m
    initView();
    retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:ru.jango.j0widget.HorizontalListView.java

public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();//  w  ww  .  j av  a2 s .co  m
    initView();
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:com.bczm.widgetcollections.ui.widget.HorizontalListView.java

public HorizontalListView(Context context) {
    super(context);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();/*ww w .j  a  v  a 2  s .c  o  m*/
    initView();
    //        retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}