List of usage examples for android.view GestureDetector GestureDetector
public GestureDetector(Context context, OnGestureListener listener)
From source file:com.guanqing.hao.OcrCaptureActivity.java
private void init() { mDimView = findViewById(R.id.dim_view); final CameraSourcePreview preview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); mDict = new Dict(this); mCameraSourceHelper = new CameraSourceHelper(this, preview, mGraphicOverlay, mDict); gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, mCameraSourceHelper); // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override/* w ww. j av a 2 s . c o m*/ public void onInit(final int status) { if (status == TextToSpeech.SUCCESS) { tts.setLanguage(Locale.US); } } }; tts = new TextToSpeech(this.getApplicationContext(), listener); }
From source file:org.deviceconnect.android.deviceplugin.wear.activity.WearTouchProfileActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = powerManager.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TouchWakelockTag"); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); if (!mWakeLock.isHeld()) { mWakeLock.acquire();//w w w . j a va 2 s .c o m } // Get intent data. setRegisterEvent(getIntent()); setContentView(R.layout.activity_wear_touch_profile); mGestureDetector = new GestureDetector(this, mSimpleOnGestureListener); // For service destruction suppression. Intent i = new Intent(WearConst.ACTION_WEAR_PING_SERVICE); LocalBroadcastManager.getInstance(this).sendBroadcast(i); }
From source file:com.example.android.immersive.ImmersiveDrawerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.immersive_drawer_activity); final View controlsView = findViewById(R.id.fullscreen_content_controls); final View contentView = findViewById(R.id.fullscreen_content); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);//from www . j a va 2s. co m configureDrawer(toolbar); getSupportActionBar().setTitle(""); } mDecorView = getWindow().getDecorView(); mDecorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int flags) { boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; controlsView.animate().alpha(visible ? 1 : 0).translationY(visible ? 0 : controlsView.getHeight()); if (getSupportActionBar() == null) { return; } if (visible) { getSupportActionBar().show(); } else { getSupportActionBar().hide(); } } }); contentView.setClickable(true); final GestureDetector clickDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { if (!USE_FULLSCREEN) { return true; } boolean visible = (mDecorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; if (visible) { hideSystemUI(); } else { showSystemUI(); } return true; } }); contentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { return clickDetector.onTouchEvent(motionEvent); } }); }
From source file:com.zhihu.android.app.mirror.widget.ArtboardView.java
private void init(AttributeSet attrs) { mDragDismissDistance = DisplayUtils.dp2px(getContext(), 112.0F); mDragElacticity = 0.8F;/* w w w . j a va 2 s .c om*/ if (attrs != null) { TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.ArtboardView); mDragDismissDistance = array.getDimensionPixelOffset(R.styleable.ArtboardView_avDragDismissDistance, (int) mDragDismissDistance); mDragElacticity = array.getFloat(R.styleable.ArtboardView_avDragElasticity, mDragElacticity); array.recycle(); } mGestureDetector = new GestureDetector(getContext(), buildSimpleOnGestureListener()); setOnTouchListener(this); }
From source file:la.marsave.fullscreentest.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WindowManager.LayoutParams layout = getWindow().getAttributes(); layout.screenBrightness = 1F;//from ww w . ja va 2 s . c om getWindow().setAttributes(layout); setContentView(R.layout.activity_main); getFragmentManager().addOnBackStackChangedListener(this); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. /* The {@link android.support.v4.view.PagerAdapter} that will provide fragments for each of the sections. We use a {@link SectionsPagerAdapter} derivative, which will keep every loaded fragment in memory. If this becomes too memory intensive, it may be best to switch to a {@link android.support.v13.app.FragmentStatePagerAdapter}. */ SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mScrollDetector = new GestureDetector(this, new ViewPagerGestureDetector()); // Set up the ViewPager with the sections adapter. mInfiniteViewPager = (InfiniteViewPager) findViewById(R.id.pager); mInfiniteViewPager.setAdapter(new InfinitePagerAdapter(mSectionsPagerAdapter)); mInfiniteViewPager.setPageTransformer(true, new ZoomOutPageTransformer()); mInfiniteViewPager.setOnTouchListener(mTouchViewPagerListener); // Set up the DarkHover that will be seen to cover the adapter once slided in. mDarkHoverView = findViewById(R.id.dark_hover_view); mDarkHoverView.setAlpha(0); mDarkHoverView.setOnTouchListener(mTouchDarkHoverListener); mTextFragment = new TextFragment(); mTextFragment.setOnTextFragmentAnimationEnd(this); //we look for the help fragment if already exists. mHelpFragment = (HelpFragment) getFragmentManager().findFragmentByTag(HELPED); //If it doesn't, we create it, if needed. if (mHelpFragment == null && !getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE).getBoolean(HELPED, false)) { mHelpFragment = new HelpFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.add(R.id.move_to_back_container, mHelpFragment, HELPED); transaction.commit(); } if (mHelpFragment != null) { mDarkHoverView.setAlpha(0.7F); mHelpFragment.setClickListener(mClickHelper); } }
From source file:org.mariotaku.twidere.fragment.support.BasePullToRefreshMultiColumnListFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView().setOnTouchListener(this); mGestureDector = new GestureDetector(getActivity(), this); }
From source file:org.mariotaku.twidere.view.HeaderDrawerLayout.java
public HeaderDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HeaderDrawerLayout); final int headerLayoutId = a.getResourceId(R.styleable.HeaderDrawerLayout_hdl_headerLayout, 0); final int contentLayoutId = a.getResourceId(R.styleable.HeaderDrawerLayout_hdl_contentLayout, 0); addView(mContainer = new InternalContainer(this, context, headerLayoutId, contentLayoutId), LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); a.recycle();//from ww w. ja v a2 s . c o m mDragHelper = ViewDragHelper.create(this, mDragCallback = new DragCallback(this)); mGestureDetector = new GestureDetector(context, new GestureListener(this)); mScroller = ScrollerCompat.create(context); }
From source file:de.vanita5.twittnuker.view.HeaderDrawerLayout.java
public HeaderDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HeaderDrawerLayout); final int headerLayoutId = a.getResourceId(R.styleable.HeaderDrawerLayout_headerLayout, 0); final int contentLayoutId = a.getResourceId(R.styleable.HeaderDrawerLayout_contentLayout, 0); addView(mContainer = new InternalContainer(this, context, headerLayoutId, contentLayoutId), LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); a.recycle();//from w ww .java 2s. c o m mDragHelper = ViewDragHelper.create(this, mDragCallback = new DragCallback(this)); mGestureDetector = new GestureDetector(context, new GestureListener(this)); mScroller = ScrollerCompat.create(context); }
From source file:org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView.java
/** * Constructor needed to inflate from XML. */// ww w. j a v a 2s. c o m public NewTabPageRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { boolean retVal = super.onSingleTapUp(e); requestFocus(); return retVal; } }); mLayoutManager = new LinearLayoutManager(getContext()); setLayoutManager(mLayoutManager); Resources res = context.getResources(); mToolbarHeight = res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow) + res.getDimensionPixelSize(R.dimen.toolbar_progress_bar_height); mMaxHeaderHeight = res.getDimensionPixelSize(R.dimen.snippets_article_header_height); }
From source file:com.shizhefei.view.largeimage.LargeImageView.java
public LargeImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mScroller = ScrollerCompat.create(getContext(), null); scaleHelper = new ScaleHelper(); setFocusable(true);// w w w .ja va 2s. c om setWillNotDraw(false); gestureDetector = new GestureDetector(context, simpleOnGestureListener); scaleGestureDetector = new ScaleGestureDetector(context, onScaleGestureListener); imageBlockLoader = new BlockImageLoader(context); imageBlockLoader.setOnImageLoadListener(this); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }