List of usage examples for android.view GestureDetector GestureDetector
public GestureDetector(Context context, OnGestureListener listener)
From source file:com.focustech.common.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(); initView();/*from ww w . j a v a 2s . c o m*/ 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.sumavision.talktv2.components.HorizontalListView2.java
public HorizontalListView2(Context context, AttributeSet attrs) { super(context, attrs); mEdgeGlowLeft = new EdgeEffectCompat(context); mEdgeGlowRight = new EdgeEffectCompat(context); mGestureDetector = new GestureDetector(context, mGestureListener); bindGestureDetector();/*from w ww .j av 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.example.nitish.welcomapp.widgetpt.PeriodicTableView.java
public PeriodicTableView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mSelectedPaint = new Paint(); mSelectedPaint.setAntiAlias(true);/* www . j av a 2 s .c o m*/ mSelectedPaint.setStyle(Paint.Style.STROKE); mSelectedPaint.setStrokeJoin(Paint.Join.ROUND); mSelectedPaint.setColor(COLOR_SELECTED); mNumberPaint = new Paint(); mNumberPaint.setAntiAlias(true); mNumberPaint.setColor(COLOR_BLOCK_FOREGROUND); mSymbolPaint = new Paint(mNumberPaint); mSymbolPaint.setTextAlign(Paint.Align.CENTER); mTitlePaint = new Paint(mSymbolPaint); mHeaderPaint = new Paint(mSymbolPaint); mSmallTextPaint = new Paint(mSymbolPaint); mNumberPaint.setSubpixelText(true); mSmallTextPaint.setSubpixelText(true); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PeriodicTableView, defStyle, 0); mTitle = a.getText(R.styleable.PeriodicTableView_title); setFgColor(a.getColor(R.styleable.PeriodicTableView_fgColor, COLOR_DEFAULT_FOREGROUND)); setBgColor(a.getColor(R.styleable.PeriodicTableView_bgColor, COLOR_DEFAULT_BACKGROUND)); a.recycle(); mLegend = new PeriodicTableLegend(context); mScaleGestureDetector = new ScaleGestureDetector(context, getOnScaleGestureListener()); mGestureDetector = new GestureDetector(context, getOnGestureListener()); mZoomer = new Zoomer(context); mScroller = new Scroller(context); mEdgeEffectLeft = new EdgeEffectCompat(context); mEdgeEffectTop = new EdgeEffectCompat(context); mEdgeEffectRight = new EdgeEffectCompat(context); mEdgeEffectBottom = new EdgeEffectCompat(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mAccessibilityDelegate = new AccessibilityDelegate(this); ViewCompat.setAccessibilityDelegate(this, mAccessibilityDelegate); } }
From source file:com.raja.knowme.FragmentQualification.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mHolderView = inflater.inflate(R.layout.fragment_qualification, null); shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake); adapter = new QualificationListAdapter(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)); qualification_list = (ListView) mHolderView.findViewById(R.id.qualification_listview); institution_switcher = (TextSwitcher) mHolderView.findViewById(R.id.qualification_institution_name_text); instruction_btn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout); qualification_list.setSelector(this.getResources().getDrawable(R.drawable.transparent_shape)); if (!pref.getQualificationFirstRun()) { instruction_btn.setVisibility(RelativeLayout.GONE); }//from ww w . j av a 2 s . c om instruction_btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { pref.setQualificationRunned(); 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(); institution_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(); institution_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(); institution_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(); institution_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(); institution_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)) nextInstitution(); else { institution_switcher.startAnimation(shake); qualification_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) previousInstitution(); else { institution_switcher.startAnimation(shake); qualification_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); } }; qualification_list.setOnTouchListener(gestureListener); return mHolderView; }
From source file:nl.hnogames.domoticz.MainActivity.java
/** * Adds the items to the drawer and registers a click listener on the items *//*from ww w. j a va 2 s . com*/ private void addDrawerItems() { String[] drawerActions = mSharedPrefs.getNavigationActions(); fragments = mSharedPrefs.getNavigationFragments(); int ICONS[] = mSharedPrefs.getNavigationIcons(); String NAME = getString(R.string.app_name_domoticz); String WEBSITE = getString(R.string.domoticz_url); int PROFILE = R.drawable.ic_launcher; mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); mRecyclerView.setHasFixedSize(true); // Letting the system know that the list objects are of fixed size mAdapter = new NavigationAdapter(drawerActions, ICONS, NAME, WEBSITE, PROFILE, this); // Creating the Adapter of MyAdapter class(which we are going to see in a bit) mRecyclerView.setAdapter(mAdapter); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this); mRecyclerView.setLayoutManager(mLayoutManager); // Setting the layout Manager final GestureDetector mGestureDetector = new GestureDetector(MainActivity.this, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { @Override public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) { View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY()); if (child != null && mGestureDetector.onTouchEvent(motionEvent)) { try { searchViewAction.setQuery("", false); searchViewAction.clearFocus(); } catch (Exception e) { e.printStackTrace(); } try { FragmentTransaction tx = getSupportFragmentManager().beginTransaction(); //tx.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left); tx.replace(R.id.main, Fragment.instantiate(MainActivity.this, fragments[recyclerView.getChildPosition(child) - 1])); tx.commitAllowingStateLoss(); addFragmentStack(fragments[recyclerView.getChildPosition(child) - 1]); } catch (Exception e) { e.printStackTrace(); } invalidateOptionsMenu(); mDrawer.closeDrawer(GravityCompat.START); return true; } return false; } @Override public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) { } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } }); setupDrawer(); }
From source file:sample.hawk.com.mybasicappcomponents.view.ListView.MyListViewH.java
public MyListViewH(Context context, AttributeSet attrs) { super(context, attrs); mEdgeGlowLeft = new EdgeEffectCompat(context); mEdgeGlowRight = new EdgeEffectCompat(context); mGestureDetector = new GestureDetector(context, mGestureListener); bindGestureDetector();/* www .ja v a 2s .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:ps.emperor.easy_water.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();// ww w. j a v a 2 s . c om initView(); retrieveXmlConfiguration(context, attrs); setWillNotDraw(false); scrollerTask = new Runnable() { @Override public void run() { int newPosition = getScrollX(); if (intitPosition - newPosition == 0) { if (onScrollstopListner == null) { return; } onScrollstopListner.onScrollStoped(); Rect outRect = new Rect(); getDrawingRect(outRect); if (getScrollX() == 0) { onScrollstopListner.onScrollToLeftEdge(); } else if (childWidth + getPaddingLeft() + getPaddingRight() == outRect.right) { onScrollstopListner.onScrollToRightEdge(); } else { onScrollstopListner.onScrollToMiddle(); } } else { intitPosition = getScrollX(); postDelayed(scrollerTask, newCheck); } } }; // 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:org.mythdroid.activities.Guide.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.guide);/* ww w. ja v a2s . c o m*/ hScroll = (HorizontalScrollView) findViewById(R.id.guidehscroll); vScroll = (ScrollView) findViewById(R.id.guidevscroll); Resources res = getResources(); scale = res.getDisplayMetrics().density; gDetector = new GestureDetector(this, new GuideGestureListener()); if (getWindowManager().getDefaultDisplay().getWidth() > 1000 || getWindowManager().getDefaultDisplay().getHeight() > 1000) numHours *= 2; numTimes = numHours * 60 / colMins; times = new long[numTimes + 1]; hdrTimes = new String[numTimes / hdrSpan]; colWidth = (int) (40 * scale + 0.5f); rowHeight = (int) (60 * scale + 0.5f); chanWidth = (int) (100 * scale + 0.5f); tbl = (TableLayout) findViewById(R.id.table); rowLayout.topMargin = rowLayout.bottomMargin = chanLayout.topMargin = chanLayout.bottomMargin = chanLayout.leftMargin = chanLayout.rightMargin = hdrDateLayout.leftMargin = hdrDateLayout.rightMargin = hdrTimeLayout.leftMargin = hdrTimeLayout.rightMargin = 1; rowLayout.height = chanLayout.height = rowHeight; chanLayout.column = hdrDateLayout.column = 0; chanLayout.span = hdrDateLayout.span = 1; chanLayout.width = hdrDateLayout.width = chanWidth; hdrTimeLayout.width = colWidth * hdrSpan; hdrTimeLayout.span = hdrSpan; spacerLayout.height = 1; spacerLayout.width = colWidth; spacerLayout.span = 1; recordedIcon = res.getDrawable(R.drawable.recorded); willRecordIcon = res.getDrawable(R.drawable.willrecord); failedIcon = res.getDrawable(R.drawable.failed); conflictIcon = res.getDrawable(R.drawable.conflict); otherIcon = res.getDrawable(R.drawable.other); date.setTimeZone(TimeZone.getDefault()); time.setTimeZone(TimeZone.getDefault()); if (Globals.haveServices()) try { guideService = new GuideService(Globals.getBackend().addr); } catch (IOException e) { ErrUtil.err(this, e); finish(); return; } }
From source file:com.jeekiarn.horizontal_listview.HorizoantalListView.java
public HorizoantalListView(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 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:com.android.slidingmenu.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.ja v a 2 s .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); } }