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:ac.robinson.mediaphone.MediaPhoneActivity.java

protected void registerForSwipeEvents() {
    mHasSwiped = false;/*from w w w . ja v  a 2s . c  o m*/
    mCanSwipe = true;
    if (mGestureDetector == null) { // so we can re-call any time
        mGestureDetector = new GestureDetector(MediaPhoneActivity.this, new SwipeDetector());
    }
}

From source file:com.bigbug.android.pp.ui.widget.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();/*  ww w  .j a  v 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);
    }

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    mNestedScrollingChildHelper.setNestedScrollingEnabled(true);
}

From source file:com.melodigm.post.widget.HorizontalListView.java

public HorizontalListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!isInEditMode()) {
        mEdgeGlowLeft = new EdgeEffectCompat(context);
        mEdgeGlowRight = new EdgeEffectCompat(context);
        mGestureDetector = new GestureDetector(context, mGestureListener);
        bindGestureDetector();//  w ww.  j a v a  2  s  . 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.tr.ui.widgets.HorizontalListView.java

private synchronized void initView() {
    mLeftViewIndex = -1;//w w  w .java  2  s. c  o  m
    mRightViewIndex = 0;
    mDisplayOffset = 0;
    mCurrentX = 0;
    mNextX = 0;
    mFirstPosition = 0;
    mSpecificPosition = 0;
    mSpecificLeft = 0;
    mMaxX = Integer.MAX_VALUE;
    mMinX = Integer.MIN_VALUE;
    mScroller = new Scroller(getContext());
    if (!isInEditMode()) {
        mGesture = new GestureDetector(getContext(), mOnGesture);
    }
}

From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setup(Context context) {
    mParent = (DBMain) context;/*from w  ww.  j  ava2 s.  c om*/
    //setRenderMode(RENDERMODE_WHEN_DIRTY);

    gestureScanner = new GestureDetector(context, new MyGestureDetector());
    mBitmapPaint = new Paint();
    mBitmapPaint.setFilterBitmap(true);
    mTextPaint = new Paint();
    mTextPaint.setTextSize(15 * getResources().getDisplayMetrics().density);
    mTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setSubpixelText(false);

    mBitmap = Bitmap.createBitmap(DEFAULT_WIDTH, DEFAULT_HEIGHT, Bitmap.Config.RGB_565);

    //setEGLContextClientVersion(1);
    mRenderer = new OpenGLRenderer(mParent);
    mRenderer.setBitmap(mBitmap);
    setRenderer(mRenderer);
    setRenderMode(RENDERMODE_WHEN_DIRTY);
    if (mGPURendering) {
        requestRender();
    }

    mMouseThread = new DosBoxMouseThread();
    mMouseThread.setPriority(Thread.MIN_PRIORITY);
    mMouseThread.setRunning(true);
    mMouseThread.start();
    mVideoThread = new DosBoxVideoThread();
    mKeyHandler = new KeyHandler(this);

    // Receive keyboard events
    requestFocus();
    setFocusableInTouchMode(true);
    setFocusable(true);
    requestFocus();
    requestFocusFromTouch();

    getHolder().addCallback(this);
    getHolder().setFormat(PixelFormat.RGB_565);
    getHolder().setKeepScreenOn(true);
    if (Build.VERSION.SDK_INT >= 14) {
        setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        setOnSystemUiVisibilityChangeListener(new MySystemUiVisibilityChangeListener());
    } else if (Build.VERSION.SDK_INT >= 11) {
        setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        setOnSystemUiVisibilityChangeListener(new MySystemUiVisibilityChangeListener());
    }
}

From source file:com.notepadlite.NoteViewFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from ww  w.ja v a 2 s  .c om
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Set values
    setRetainInstance(true);
    setHasOptionsMenu(true);

    // Get filename of saved note
    filename = getArguments().getString("filename");

    // Change window title
    String title;

    try {
        title = listener.loadNoteTitle(filename);
    } catch (IOException e) {
        title = getResources().getString(R.string.view_note);
    }

    getActivity().setTitle(title);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null,
                getResources().getColor(R.color.primary));
        getActivity().setTaskDescription(taskDescription);
    }

    // Show the Up button in the action bar.
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Animate elevation change
    if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList);

        noteList.animate().z(0f);
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            noteViewEdit.animate()
                    .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land));
        else
            noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation));
    }

    // Set up content view
    noteContents = (TextView) getActivity().findViewById(R.id.textView);

    // Apply theme
    SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteContents.setTextColor(getResources().getColor(R.color.text_color_primary));
        noteContents.setBackgroundColor(getResources().getColor(R.color.window_background));
        scrollView.setBackgroundColor(getResources().getColor(R.color.window_background));
    }

    if (theme.contains("dark")) {
        noteContents.setTextColor(getResources().getColor(R.color.text_color_primary_dark));
        noteContents.setBackgroundColor(getResources().getColor(R.color.window_background_dark));
        scrollView.setBackgroundColor(getResources().getColor(R.color.window_background_dark));
    }

    if (theme.contains("sans"))
        noteContents.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteContents.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteContents.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteContents.setTextSize(12);
        break;
    case "small":
        noteContents.setTextSize(14);
        break;
    case "normal":
        noteContents.setTextSize(16);
        break;
    case "large":
        noteContents.setTextSize(18);
        break;
    case "largest":
        noteContents.setTextSize(20);
        break;
    }

    // Load note contents
    try {
        contentsOnLoad = listener.loadNote(filename);
    } catch (IOException e) {
        showToast(R.string.error_loading_note);

        // Add NoteListFragment or WelcomeFragment
        Fragment fragment;
        if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal"))
            fragment = new NoteListFragment();
        else
            fragment = new WelcomeFragment();

        getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
    }

    // Set TextView contents
    noteContents.setText(contentsOnLoad);

    // Show a toast message if this is the user's first time viewing a note
    final SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
    firstLoad = sharedPref.getInt("first-load", 0);
    if (firstLoad == 0) {
        // Show dialog with info
        DialogFragment firstLoad = new FirstViewDialogFragment();
        firstLoad.show(getFragmentManager(), "firstloadfragment");

        // Set first-load preference to 1; we don't need to show the dialog anymore
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putInt("first-load", 1);
        editor.apply();
    }

    // Detect single and double-taps using GestureDetector
    final GestureDetector detector = new GestureDetector(getActivity(),
            new GestureDetector.OnGestureListener() {
                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    return false;
                }

                @Override
                public void onShowPress(MotionEvent e) {
                }

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

                @Override
                public void onLongPress(MotionEvent e) {
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    return false;
                }

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

    detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (sharedPref.getBoolean("show_double_tap_message", true)) {
                SharedPreferences.Editor editor = sharedPref.edit();
                editor.putBoolean("show_double_tap_message", false);
                editor.apply();
            }

            Bundle bundle = new Bundle();
            bundle.putString("filename", filename);

            Fragment fragment = new NoteEditFragment();
            fragment.setArguments(bundle);

            getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment")
                    .commit();

            return false;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            return false;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (sharedPref.getBoolean("show_double_tap_message", true) && showMessage) {
                showToastLong(R.string.double_tap);
                showMessage = false;
            }

            return false;
        }

    });

    noteContents.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            detector.onTouchEvent(event);
            return false;
        }
    });
}

From source file:life.knowledge4.videotrimmer.K4LVideoTrimmer.java

private void setUpListeners() {
    mListeners = new ArrayList<>();
    mListeners.add(new OnProgressVideoListener() {
        @Override//from  w  ww.  j  a v a  2  s  .  com
        public void updateProgress(int time, int max, float scale) {
            updateVideoProgress(time);
        }
    });
    mListeners.add(mVideoProgressIndicator);

    findViewById(R.id.btCancel).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            onCancelClicked();
        }
    });

    findViewById(R.id.btSave).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            onSaveClicked();
        }
    });

    final GestureDetector gestureDetector = new GestureDetector(getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onSingleTapConfirmed(MotionEvent e) {
                    onClickVideoPlayPause();
                    return true;
                }
            });

    mVideoView.setOnErrorListener(new OnErrorListener() {
        @Override
        public boolean onError() {
            if (mOnTrimVideoListener != null)
                mOnTrimVideoListener.onError("Something went wrong");
            return false;
        }
    });

    mVideoView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, @NonNull MotionEvent event) {
            gestureDetector.onTouchEvent(event);
            return true;
        }
    });

    mRangeSeekBarView.addOnRangeSeekBarListener(new OnRangeSeekBarListener() {
        @Override
        public void onCreate(RangeSeekBarView rangeSeekBarView, int index, float value) {
            // Do nothing
        }

        @Override
        public void onSeek(RangeSeekBarView rangeSeekBarView, int index, float value) {
            onSeekThumbs(index, value);
        }

        @Override
        public void onSeekStart(RangeSeekBarView rangeSeekBarView, int index, float value) {
            // Do nothing
        }

        @Override
        public void onSeekStop(RangeSeekBarView rangeSeekBarView, int index, float value) {
            onStopSeekThumbs();
        }
    });
    mRangeSeekBarView.addOnRangeSeekBarListener(mVideoProgressIndicator);

    mHolderTopView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            onPlayerIndicatorSeekChanged(progress, fromUser);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            onPlayerIndicatorSeekStart();
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            onPlayerIndicatorSeekStop(seekBar);
        }
    });

    mVideoView.setOnPreparedListener(new OnPreparedListener() {
        @Override
        public void onPrepared() {
            onVideoPrepared();
        }
    });

    mVideoView.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion() {
            onVideoCompleted();
        }
    });
}

From source file:org.torproject.android.OrbotMainActivity.java

private void doLayout() {
    setContentView(R.layout.layout_main);

    setTitle(R.string.app_name);/*  w  ww .  j av a 2  s .  c  o  m*/

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, android.R.string.ok,
            android.R.string.cancel);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawer.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    mTxtOrbotLog = (TextView) findViewById(R.id.orbotLog);

    lblStatus = (TextView) findViewById(R.id.lblStatus);
    lblStatus.setOnLongClickListener(this);
    imgStatus = (ImageProgressView) findViewById(R.id.imgStatus);
    imgStatus.setOnLongClickListener(this);
    imgStatus.setOnTouchListener(this);

    downloadText = (TextView) findViewById(R.id.trafficDown);
    uploadText = (TextView) findViewById(R.id.trafficUp);

    downloadText.setText(formatCount(0) + " / " + formatTotal(0));
    uploadText.setText(formatCount(0) + " / " + formatTotal(0));

    // Gesture detection
    mGestureDetector = new GestureDetector(this, new MyGestureDetector());

    mBtnBrowser = (Button) findViewById(R.id.btnBrowser);
    mBtnBrowser.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            doTorCheck();

        }

    });

    mBtnBrowser.setEnabled(false);

    mBtnVPN = (ToggleButton) findViewById(R.id.btnVPN);

    boolean useVPN = Prefs.useVpn();
    mBtnVPN.setChecked(useVPN);

    //auto start VPN if VPN is enabled
    if (useVPN) {
        startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
    }

    mBtnVPN.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (mBtnVPN.isChecked())
                startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
            else
                stopVpnService();

        }

    });

    mBtnBridges = (ToggleButton) findViewById(R.id.btnBridges);
    mBtnBridges.setChecked(Prefs.bridgesEnabled());
    mBtnBridges.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (Build.CPU_ABI.contains("arm")) {
                promptSetupBridges(); //if ARM processor, show all bridge options

            } else {
                Toast.makeText(OrbotMainActivity.this,
                        R.string.note_only_standard_tor_bridges_work_on_intel_x86_atom_devices,
                        Toast.LENGTH_LONG).show();
                showGetBridgePrompt(""); //if other chip ar, only stock bridges are supported
            }
        }

    });

    String currentExit = Prefs.getExitNodes();
    int selIdx = -1;

    ArrayList<String> cList = new ArrayList<String>();
    cList.add(0, getString(R.string.vpn_default_world));

    for (int i = 0; i < TorServiceConstants.COUNTRY_CODES.length; i++) {
        Locale locale = new Locale("", TorServiceConstants.COUNTRY_CODES[i]);
        cList.add(locale.getDisplayCountry());

        if (currentExit.contains(TorServiceConstants.COUNTRY_CODES[i]))
            selIdx = i + 1;
    }

    spnCountries = (Spinner) findViewById(R.id.spinnerCountry);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, cList);
    spnCountries.setAdapter(adapter);

    if (selIdx != -1)
        spnCountries.setSelection(selIdx);

    spnCountries.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            // your code here

            String country = null;

            if (position == 0)
                country = "";
            else
                country = '{' + TorServiceConstants.COUNTRY_CODES[position - 1] + '}';

            Intent torService = new Intent(OrbotMainActivity.this, TorService.class);
            torService.setAction(TorServiceConstants.CMD_SET_EXIT);
            torService.putExtra("exit", country);
            startService(torService);

        }

        @Override
        public void onNothingSelected(AdapterView<?> parentView) {
            // your code here
        }

    });
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    AnalyticsHelper.reportScreen(this, AnalyticsManager.SCREEN_SAMSUNG_SNOTE_EDITOR);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.snote_editor);
    context = this;

    // TOOLBAR/*from w w  w  .ja va2 s  .c  om*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    // Retrieve information
    String action = getIntent().getAction();
    if (Intent.ACTION_VIEW.equals(action)) {
        if (getIntent().getData() != null) {
            String filePath = BaseActionUtils.getPath(this, getIntent().getData());
            file = new File(filePath);
        } else {
            AlfrescoNotificationManager.getInstance(this).showLongToast(getString(R.string.editor_error_open));
            finish();
            return;
        }
    }

    // Init Spen
    boolean isSpenFeatureEnabled = false;
    Spen spenPackage = new Spen();
    try {
        spenPackage.initialize(this);
        isSpenFeatureEnabled = spenPackage.isFeatureEnabled(Spen.DEVICE_PEN);
    } catch (SsdkUnsupportedException e) {
        if (SNoteUtils.processUnsupportedException(this, e)) {
            return;
        }
    } catch (Exception e1) {
        Log.e(TAG, Log.getStackTraceString(e1));
        finish();
    }

    FrameLayout spenViewContainer = (FrameLayout) findViewById(R.id.spenViewContainer);
    RelativeLayout spenViewLayout = (RelativeLayout) findViewById(R.id.spenViewLayout);

    // PEN SETTINGS
    spenSettingView = new SpenSettingPenLayout(context, "", spenViewLayout);
    if (spenSettingView == null) {
        finish();
    }
    spenViewContainer.addView(spenSettingView);

    // ERASER SETTINGS
    eraserSettingView = new SpenSettingEraserLayout(context, "", spenViewLayout);
    if (eraserSettingView == null) {
        finish();
    }
    spenViewContainer.addView(eraserSettingView);

    // TEXT SETTINGS
    textSettingView = new SpenSettingTextLayout(context, "", new HashMap<String, String>(), spenViewLayout);
    if (textSettingView == null) {
        finish();
    }
    spenViewContainer.addView(textSettingView);

    // SELECTION SETTINGS
    selectionSettingView = new SpenSettingSelectionLayout(context, "", spenViewLayout);
    if (textSettingView == null) {
        finish();
    }
    spenViewContainer.addView(selectionSettingView);

    // SURFACE VIEW
    spenSurfaceView = new SpenSurfaceView(context);
    if (spenSurfaceView == null) {
        finish();
    }
    spenViewLayout.addView(spenSurfaceView);
    spenSettingView.setCanvasView(spenSurfaceView);
    eraserSettingView.setCanvasView(spenSurfaceView);
    textSettingView.setCanvasView(spenSurfaceView);
    selectionSettingView.setCanvasView(spenSurfaceView);

    // NOTE DOCUMENT
    Display display = getWindowManager().getDefaultDisplay();
    Rect mScreenRect = new Rect();
    display.getRectSize(mScreenRect);
    try {
        if (file != null && file.length() > 0) {
            spenNoteDoc = new SpenNoteDoc(context, file.getAbsolutePath(), mScreenRect.width(),
                    SpenNoteDoc.MODE_WRITABLE);
            if (spenNoteDoc.getPageCount() == 0) {
                spenPageDoc = spenNoteDoc.appendPage();
            } else {
                spenPageDoc = spenNoteDoc.getPage(spenNoteDoc.getLastEditedPageIndex());
            }
        } else {
            spenNoteDoc = new SpenNoteDoc(context, SpenNoteDoc.ORIENTATION_LANDSCAPE,
                    (mScreenRect.width() > mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height(),
                    (mScreenRect.width() < mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height());
            spenPageDoc = spenNoteDoc.appendPage();
            spenPageDoc.setBackgroundColor(getResources().getColor(android.R.color.white));
            spenPageDoc.clearHistory();
        }
    } catch (Exception e) {
        finish();
    }

    // Display Document
    spenSurfaceView.setPageDoc(spenPageDoc, true);
    spenSurfaceView.setBlankColor(getResources().getColor(R.color.grey_light));

    if (!isSpenFeatureEnabled) {
        mToolType = SpenSurfaceView.TOOL_FINGER;
        spenSurfaceView.setToolTypeAction(mToolType, SpenSurfaceView.ACTION_STROKE);

        // Touch listener for swipe if on Finger mode
        gdt = new GestureDetector(context, new GestureListener());
        spenSurfaceView.setOnTouchListener(touchListener);
    }

    // Init Pages
    mTxtView = (TextView) findViewById(R.id.spen_page);
    mTxtView.setText(String.format(getString(R.string.editor_paging),
            String.valueOf((spenNoteDoc.getPageIndexById(spenPageDoc.getId()) + 1)),
            spenNoteDoc.getPageCount()));

    // INIT Setting & Listeners
    initSettingInfo();
    spenSurfaceView.setTouchListener(penTouchListener);
    spenSurfaceView.setControlListener(controlListener);
    spenSurfaceView.setFlickListener(mFlickListener);

}

From source file:com.tr.ui.widgets.HorizontalListView.java

private synchronized void initViewForSpecific() {
    mLeftViewIndex = mSpecificPosition - 1;
    mRightViewIndex = mSpecificPosition + 1;
    mFirstPosition = mSpecificPosition;/* w w w. j  a v a2s. co  m*/
    mDisplayOffset = 0;
    mCurrentX = 0;
    mNextX = 0;
    mMaxX = Integer.MAX_VALUE;
    mMinX = Integer.MIN_VALUE;
    if (!isInEditMode()) {
        mGesture = new GestureDetector(getContext(), mOnGesture);
    }
}