List of usage examples for android.view MotionEvent ACTION_DOWN
int ACTION_DOWN
To view the source code for android.view MotionEvent ACTION_DOWN.
Click Source Link
From source file:ayushi.view.adapter.ShoppingListAdapter.java
@Override public void onBindViewHolder(final ItemViewHolder holder, final int position) { holder.itemName.setText(productList.get(position).getItemName()); holder.itemDesc.setText(productList.get(position).getItemShortDesc()); String sellCostString = Money .rupees(BigDecimal.valueOf(Long.valueOf(productList.get(position).getSellMRP()))).toString() + " "; String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf(productList.get(position).getMRP()))) .toString();/*from w ww . java 2 s . c om*/ String costString = sellCostString + buyMRP; holder.itemCost.setText(costString, BufferType.SPANNABLE); Spannable spannable = (Spannable) holder.itemCost.getText(); spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10); drawable = mDrawableBuilder.build(String.valueOf(productList.get(position).getItemName().charAt(0)), mColorGenerator.getColor(productList.get(position).getItemName())); ImageUrl = productList.get(position).getImageURL(); holder.quanitity .setText(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()); Glide.with(context).load(ImageUrl).placeholder(drawable).error(drawable).animate(R.anim.base_slide_right_in) .centerCrop().into(holder.imagView); // Start a drag whenever the handle view it touched holder.imagView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { mDragStartListener.onStartDrag(holder); } return false; } }); holder.addItem.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).setQuantity(String.valueOf( Integer.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()) + 1)); holder.quanitity.setText( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()); Utils.vibrate(context); ((ECartHomeActivity) context).updateCheckOutAmount( BigDecimal.valueOf(Long.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getSellMRP())), true); } }); holder.removeItem.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Integer.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()) > 2) { GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).setQuantity(String.valueOf( Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position) .getQuantity()) - 1)); holder.quanitity.setText( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()); ((ECartHomeActivity) context).updateCheckOutAmount(BigDecimal.valueOf(Long.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getSellMRP())), false); Utils.vibrate(context); } else if (Integer.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()) == 1) { ((ECartHomeActivity) context).updateItemCount(false); ((ECartHomeActivity) context).updateCheckOutAmount(BigDecimal.valueOf(Long.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getSellMRP())), false); GlobaDataHolder.getGlobaDataHolder().getShoppingList().remove(position); if (Integer.valueOf(((ECartHomeActivity) context).getItemCount()) == 0) { MyCartFragment.updateMyCartFragment(false); } Utils.vibrate(context); } } }); }
From source file:com.app.gongza.libs.view.scrollablelayout.ScrollableLayout.java
@Override public boolean dispatchTouchEvent(MotionEvent ev) { float currentX = ev.getX(); float currentY = ev.getY(); float deltaY; int shiftX = (int) Math.abs(currentX - mDownX); int shiftY = (int) Math.abs(currentY - mDownY); switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mDisallowIntercept = false;// w w w .ja v a 2 s.c o m needCheckUpdown = true; updown = true; mDownX = currentX; mDownY = currentY; mLastY = currentY; checkIsClickHead((int) currentY, mHeadHeight, getScrollY()); checkIsClickHeadExpand((int) currentY, mHeadHeight, getScrollY()); initOrResetVelocityTracker(); mVelocityTracker.addMovement(ev); mScroller.forceFinished(true); break; case MotionEvent.ACTION_MOVE: if (mDisallowIntercept) { break; } initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(ev); deltaY = mLastY - currentY; if (needCheckUpdown) { if (shiftX > mTouchSlop && shiftX > shiftY) { needCheckUpdown = false; updown = false; } else if (shiftY > mTouchSlop && shiftY > shiftX) { needCheckUpdown = false; updown = true; } } if (updown && shiftY > mTouchSlop && shiftY > shiftX && (!isSticked() || mHelper.isTop() || isClickHeadExpand)) { if (childViewPager != null) { childViewPager.requestDisallowInterceptTouchEvent(true); } scrollBy(0, (int) (deltaY + 0.5)); } mLastY = currentY; break; case MotionEvent.ACTION_UP: if (updown && shiftY > shiftX && shiftY > mTouchSlop) { mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); float yVelocity = -mVelocityTracker.getYVelocity(); boolean dislowChild = false; if (Math.abs(yVelocity) > mMinimumVelocity) { mDirection = yVelocity > 0 ? DIRECTION.UP : DIRECTION.DOWN; if ((mDirection == DIRECTION.UP && isSticked()) || (!isSticked() && getScrollY() == 0 && mDirection == DIRECTION.DOWN)) { dislowChild = true; } else { mScroller.fling(0, getScrollY(), 0, (int) yVelocity, 0, 0, -Integer.MAX_VALUE, Integer.MAX_VALUE); mScroller.computeScrollOffset(); mLastScrollerY = getScrollY(); invalidate(); } } if (!dislowChild && (isClickHead || !isSticked())) { int action = ev.getAction(); ev.setAction(MotionEvent.ACTION_CANCEL); boolean dispathResult = super.dispatchTouchEvent(ev); ev.setAction(action); return dispathResult; } } break; default: break; } super.dispatchTouchEvent(ev); return true; }
From source file:br.com.devmix.baseapp.listener.OnSwipeableRecyclerViewTouchListener.java
private boolean handleTouchEvent(MotionEvent motionEvent) { if (mViewWidth < 2) { mViewWidth = mRecyclerView.getWidth(); }//w w w . j a va2 s. c om switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: { if (mPaused) { break; } // Find the child view that was touched (perform a hit test) Rect rect = new Rect(); int childCount = mRecyclerView.getChildCount(); int[] listViewCoords = new int[2]; mRecyclerView.getLocationOnScreen(listViewCoords); int x = (int) motionEvent.getRawX() - listViewCoords[0]; int y = (int) motionEvent.getRawY() - listViewCoords[1]; View child; for (int i = 0; i < childCount; i++) { child = mRecyclerView.getChildAt(i); child.getHitRect(rect); if (rect.contains(x, y)) { mDownView = child; break; } } if (mDownView != null && mAnimatingPosition != mRecyclerView.getChildAdapterPosition(mDownView)) { mAlpha = ViewCompat.getAlpha(mDownView); mDownX = motionEvent.getRawX(); mDownY = motionEvent.getRawY(); mDownPosition = mRecyclerView.getChildAdapterPosition(mDownView); if (mSwipeListener.canSwipe(mDownPosition)) { mVelocityTracker = VelocityTracker.obtain(); mVelocityTracker.addMovement(motionEvent); } else { mDownView = null; } } break; } case MotionEvent.ACTION_CANCEL: { if (mVelocityTracker == null) { break; } if (mDownView != null && mSwiping) { // cancel ViewCompat.animate(mDownView).translationX(0).alpha(mAlpha).setDuration(mAnimationTime) .setListener(null); } mVelocityTracker.recycle(); mVelocityTracker = null; mDownX = 0; mDownY = 0; mDownView = null; mDownPosition = ListView.INVALID_POSITION; mSwiping = false; break; } case MotionEvent.ACTION_UP: { if (mVelocityTracker == null) { break; } mFinalDelta = motionEvent.getRawX() - mDownX; mVelocityTracker.addMovement(motionEvent); mVelocityTracker.computeCurrentVelocity(1000); float velocityX = mVelocityTracker.getXVelocity(); float absVelocityX = Math.abs(velocityX); float absVelocityY = Math.abs(mVelocityTracker.getYVelocity()); boolean dismiss = false; boolean dismissRight = false; if (Math.abs(mFinalDelta) > mViewWidth / 2 && mSwiping) { dismiss = true; dismissRight = mFinalDelta > 0; } else if (mMinFlingVelocity <= absVelocityX && absVelocityX <= mMaxFlingVelocity && absVelocityY < absVelocityX && mSwiping) { // dismiss only if flinging in the same direction as dragging dismiss = (velocityX < 0) == (mFinalDelta < 0); dismissRight = mVelocityTracker.getXVelocity() > 0; } if (dismiss && mDownPosition != mAnimatingPosition && mDownPosition != ListView.INVALID_POSITION) { // dismiss final View downView = mDownView; // mDownView gets null'd before animation ends final int downPosition = mDownPosition; ++mDismissAnimationRefCount; mAnimatingPosition = mDownPosition; ViewCompat.animate(mDownView).translationX(dismissRight ? mViewWidth : -mViewWidth).alpha(0) .setDuration(mAnimationTime).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { performDismiss(downView, downPosition); } }); } else { // cancel ViewCompat.animate(mDownView).translationX(0).alpha(mAlpha).setDuration(mAnimationTime) .setListener(null); } mVelocityTracker.recycle(); mVelocityTracker = null; mDownX = 0; mDownY = 0; mDownView = null; mDownPosition = ListView.INVALID_POSITION; mSwiping = false; break; } case MotionEvent.ACTION_MOVE: { if (mVelocityTracker == null || mPaused) { break; } mVelocityTracker.addMovement(motionEvent); float deltaX = motionEvent.getRawX() - mDownX; float deltaY = motionEvent.getRawY() - mDownY; if (!mSwiping && Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) { mSwiping = true; mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop); } if (mSwiping) { ViewCompat.setTranslationX(mDownView, deltaX - mSwipingSlop); ViewCompat.setAlpha(mDownView, Math.max(0f, Math.min(mAlpha, mAlpha * (1f - Math.abs(deltaX) / mViewWidth)))); return true; } break; } } return false; }
From source file:android.support.v7.widget.ForwardingListener.java
/** * Observes motion events and determines when to start forwarding. * * @param srcEvent motion event in source view coordinates * @return true to start forwarding motion events, false otherwise */// ww w.jav a 2 s. co m private boolean onTouchObserved(MotionEvent srcEvent) { final View src = mSrc; if (!src.isEnabled()) { return false; } final int actionMasked = MotionEventCompat.getActionMasked(srcEvent); switch (actionMasked) { case MotionEvent.ACTION_DOWN: mActivePointerId = srcEvent.getPointerId(0); if (mDisallowIntercept == null) { mDisallowIntercept = new DisallowIntercept(); } src.postDelayed(mDisallowIntercept, mTapTimeout); if (mTriggerLongPress == null) { mTriggerLongPress = new TriggerLongPress(); } src.postDelayed(mTriggerLongPress, mLongPressTimeout); break; case MotionEvent.ACTION_MOVE: final int activePointerIndex = srcEvent.findPointerIndex(mActivePointerId); if (activePointerIndex >= 0) { final float x = srcEvent.getX(activePointerIndex); final float y = srcEvent.getY(activePointerIndex); // Has the pointer moved outside of the view? if (!pointInView(src, x, y, mScaledTouchSlop)) { clearCallbacks(); // Don't let the parent intercept our events. src.getParent().requestDisallowInterceptTouchEvent(true); return true; } } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: clearCallbacks(); break; } return false; }
From source file:com.suan.weclient.fragment.mass.VoiceFragment.java
private void initWidgets() { recordLayout = (RelativeLayout) view.findViewById(R.id.voice_record_start); recordLayout.setOnTouchListener(new View.OnTouchListener() { @Override//from ww w . j a v a 2 s .c om public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: recordLayout.setSelected(true); if (!isRecord) { startRecord(); } break; case MotionEvent.ACTION_MOVE: recordLayout.setSelected(true); if (!isRecord) { startRecord(); } break; default: recordLayout.setSelected(false); if (isRecord) { stopRecord(); } break; } return true; } }); }
From source file:ca.psiphon.ploggy.FragmentSelfStatusDetails.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.self_status_details, container, false); mFragmentComposeMessage = new FragmentComposeMessage(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.add(R.id.fragment_self_status_details_compose_message, mFragmentComposeMessage).commit(); mScrollView = (ScrollView) view.findViewById(R.id.self_status_details_scroll_view); mAvatarImage = (ImageView) view.findViewById(R.id.self_status_details_avatar_image); mNicknameText = (TextView) view.findViewById(R.id.self_status_details_nickname_text); mFingerprintText = (TextView) view.findViewById(R.id.self_status_details_fingerprint_text); mMessagesList = (ListView) view.findViewById(R.id.self_status_details_messages_list); mLocationLabel = (TextView) view.findViewById(R.id.self_status_details_location_label); mLocationStreetAddressLabel = (TextView) view .findViewById(R.id.self_status_details_location_street_address_label); mLocationStreetAddressText = (TextView) view .findViewById(R.id.self_status_details_location_street_address_text); mLocationCoordinatesLabel = (TextView) view .findViewById(R.id.self_status_details_location_coordinates_label); mLocationCoordinatesText = (TextView) view.findViewById(R.id.self_status_details_location_coordinates_text); mLocationPrecisionLabel = (TextView) view.findViewById(R.id.self_status_details_location_precision_label); mLocationPrecisionText = (TextView) view.findViewById(R.id.self_status_details_location_precision_text); mLocationTimestampLabel = (TextView) view.findViewById(R.id.self_status_details_location_timestamp_label); mLocationTimestampText = (TextView) view.findViewById(R.id.self_status_details_location_timestamp_text); // TODO: use header/footer of listview instead of hack embedding of listview in scrollview // from: http://stackoverflow.com/questions/4490821/scrollview-inside-scrollview/11554823#11554823 mScrollView.setOnTouchListener(new View.OnTouchListener() { @Override/*from ww w.j a va 2s .c o m*/ public boolean onTouch(View view, MotionEvent event) { mMessagesList.requestDisallowInterceptTouchEvent(false); return false; } }); mMessagesList.setOnTouchListener(new View.OnTouchListener() { private float downX, downY; @Override public boolean onTouch(View view, MotionEvent event) { // We want to capture vertical scrolling motions for use by // the messages list, but we don't want to capture horizontal // swiping that should be used to switch tabs. So we're going // to decide based on whether the move looks more X-ish or Y-ish. if (event.getAction() == MotionEvent.ACTION_DOWN) { downX = event.getX(); downY = event.getY(); // Make sure the parent is allowed to intercept. view.getParent().requestDisallowInterceptTouchEvent(false); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { float deltaX = downX - event.getX(); float deltaY = downY - event.getY(); if (Math.abs(deltaY) > Math.abs(deltaX)) { // Looks like a Y-ish scroll attempt. Disallow parent from intercepting. view.getParent().requestDisallowInterceptTouchEvent(true); } } return false; } }); try { mMessageAdapter = new MessageAdapter(getActivity(), MessageAdapter.Mode.SELF_MESSAGES); mMessagesList.setAdapter(mMessageAdapter); } catch (Utils.ApplicationError e) { Log.addEntry(LOG_TAG, "failed to load self messages"); } show(view); // Refresh the message list every 5 seconds. This updates "time ago" displays. // TODO: event driven redrawing? mRefreshUIExecutor = new Utils.FixedDelayExecutor(new Runnable() { @Override public void run() { show(); } }, 5000); Events.register(this); return view; }
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
@Override public void onCreate(Bundle saveInstanceState) { super.onCreate(saveInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); Bundle b = getIntent().getExtras();//from www . ja v a 2 s . com SharedPreferences prefs = getSharedPreferences("settings", MODE_PRIVATE); imageOptions = new DisplayImageOptions.Builder().cacheInMemory(false).cacheOnDisk(true) .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY) .showImageOnLoading(R.drawable.connecting_anim).build(); config = new ImageLoaderConfiguration.Builder(getApplicationContext()).diskCacheExtraOptions(480, 320, null) .defaultDisplayImageOptions(imageOptions).build(); if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config); setContentView(R.layout.link_dialog); imageFrame = (FrameLayout) findViewById(R.id.image_frame); iBottomPanel = (ImageView) findViewById(R.id.bottom_panel); lArtistLink = (RelativeLayout) findViewById(R.id.l_artist_link); bPopUpClose = (ImageView) findViewById(R.id.b_popup_close); bPopUpClose.setOnClickListener(this); tEchoNest = (TextView) findViewById(R.id.t_echo_nest); tAttribution = (TextView) findViewById(R.id.t_attribution); tArtistName = (TextView) findViewById(R.id.t_artist_name); tArtistName.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: //isMove = false; mTouchX = event.getRawX(); mTouchY = event.getRawY(); break; case MotionEvent.ACTION_UP: //Log.i("musicInfo", "ACTION_UP! TouchY:" + mTouchY + " UpY: " + event.getRawY() + " Move: " + (mTouchY - event.getRawY())); int RawY = (int) event.getRawY(); int dY = (int) (mTouchY - event.getRawY()); if (dY > 200) { imageLoader.resume(); //Log.i("musicInfo", "mGridView TOP = " + mGridView.getTop() + " mGridView TransitionY =" + mGridView.getTranslationY()); while (mGridView.getTranslationY() > tArtistName.getHeight()) { //Log.i("musicInfo", "Moving UP! mGridView: " + mGridView.getTranslationY() + " tArtistName: " + tArtistName.getTranslationY()); mGridView.setTranslationY(mGridView.getTranslationY() - 1); tArtistName.setTranslationY(tArtistName.getTranslationY() - 1); } } else if (dY > 5 && dY <= 200 || (dY <= 5 && tArtistName.getTranslationY() < 0)) { while (tArtistName.getTranslationY() < 0) { //Log.i("musicInfo", "Moving DOWN! mGridView: " + mGridView.getTranslationY() + " tArtistName: " + tArtistName.getTranslationY()); mGridView.setTranslationY(mGridView.getTranslationY() + 1); tArtistName.setTranslationY(tArtistName.getTranslationY() + 1); } imageLoader.pause(); } break; case MotionEvent.ACTION_MOVE: //isMove = true; //int top = tArtistName.getTop(); //int bottom = tArtistName.getBottom(); //int left = tArtistName.getLeft(); //int right = tArtistName.getRight(); int x = (int) (event.getRawX() - mTouchX); int y = (int) (event.getRawY() - mTouchY); final int num = 5; if (y > -num && y < num) { //isMove = false; break; } else if (y > 0) { } else { imageFrame.bringChildToFront(mGridView); tArtistName.setTranslationY((float) y); mGridView.setTranslationY((float) (SGVtransition + y)); //Log.i("musicInfo", String.format("T: %d, B: %d", mGridView.getTop(), mGridView.getBottom())); } break; } return true; } }); ArtistImage = (ImageView) findViewById(R.id.artist_image); lLinkList = (LinearLayout) findViewById(R.id.l_link_list); mGridView = (StaggeredGridView) findViewById(R.id.SG_view); SGVtransition = 900; mGridView.setTranslationY(SGVtransition); JSONObject artist_info = null; try { artist_info = new JSONObject(b.getString("artist_info")); Log.i("musicInfo", "LinkPopUp. OnCreate" + artist_info.toString()); displayArtistInfo(artist_info); } catch (JSONException e) { e.printStackTrace(); } if (artist_info != null) jArtists.put(artist_info); if (prefs.getBoolean("SimilarOn", false)) { getSimilarArtistsInfo((String) tArtistName.getText()); ArtistImage.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: //isMove = false; mTouchX = event.getRawX(); mTouchY = event.getRawY(); break; case MotionEvent.ACTION_UP: //Log.i("musicInfo", "ACTION_UP! TouchY:" + mTouchY + " UpY: " + event.getRawY() + " Move: " + (mTouchY - event.getRawY())); int dX = (int) (mTouchX - event.getRawX()); if (dX > 5) { if (jArtists.length() > 1) { imageLoader.stop(); try { if (artistNum == 0) { artistNum = jArtists.length() - 1; } else { artistNum--; } displayArtistInfo(jArtists.getJSONObject(artistNum)); imageLoader.resume(); } catch (JSONException e) { e.printStackTrace(); } } } else if (dX < -5) { if (jArtists.length() > 1) { imageLoader.stop(); try { if (artistNum == jArtists.length() - 1) { artistNum = 0; } else { artistNum++; } displayArtistInfo(jArtists.getJSONObject(artistNum)); imageLoader.resume(); } catch (JSONException e) { e.printStackTrace(); } } } break; case MotionEvent.ACTION_MOVE: break; } return true; } }); } mGridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { //Log.d("musicInfo", "SGV onScrollStateChanged:" + scrollState); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //Log.d("musicInfo", "SGV onScroll firstVisibleItem:" + firstVisibleItem + " visibleItemCount:" + visibleItemCount + " totalItemCount:" + totalItemCount); // our handling if (!mHasRequestedMore) { int lastInScreen = firstVisibleItem + visibleItemCount; if (lastInScreen >= totalItemCount) { //Log.d("musicInfo", "SGV onScroll lastInScreen - so load more"); mHasRequestedMore = true; onLoadMoreItems(); } } } private void onLoadMoreItems() { if (jVideoArray == null) return; final ArrayList<JSONObject> sampleData = generateImageData(jVideoArray); for (JSONObject data : sampleData) { mAdapter.add(data); } // stash all the data in our backing store mData.addAll(sampleData); // notify the adapter that we can update now mAdapter.notifyDataSetChanged(); mHasRequestedMore = false; } }); mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getApplicationContext(), "Open the Video...", Toast.LENGTH_SHORT).show(); StaggeredViewAdapter.ViewHolder vh = (StaggeredViewAdapter.ViewHolder) view.getTag(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) vh.url)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); //finish(); } }); //int[] lArtistLinkPosition = new int[2]; //int[] tArtistNamePosition = new int[2]; //lArtistLink.getLocationOnScreen(lArtistLinkPosition); //tArtistName.getLocationOnScreen(tArtistNamePosition); //Log.d("musicInfo", "SGV transition = " + SGVtransition); }
From source file:ca.shoaib.ping.PingListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_ping_list, container, false); mListView = (ListView) rootView.findViewById(R.id.list_ping); pingListAdapter = new PingListAdapter(getActivity(), R.layout.ping_row, pingList); mListView.setAdapter(pingListAdapter); //mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// ww w . j a v a 2 s. c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mPingListCallback.onPingSelected(pingList.get(position)); mActivatedPosition = position; setActivatedPosition(position); //Log.d(TAG, "ArtistId: " + artistList.get(position).getArtistId()); } }); pb = (ProgressBar) rootView.findViewById(R.id.progress_bar); et = (EditText) rootView.findViewById(R.id.ping_destination); tv = (TextView) rootView.findViewById(R.id.ping_result); btn = (Button) rootView.findViewById(R.id.ping_start); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String stringUrl = et.getText().toString(); ConnectivityManager connMgr = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { AsyncTask pingTask = new PingTask(getActivity(), pingList, pingListAdapter).execute(stringUrl); } else { tv.setTextSize(20); tv.setTextColor(Color.RED); tv.setText(R.string.no_internet); } InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); } }); et.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_LEFT = 0; final int DRAWABLE_TOP = 1; final int DRAWABLE_RIGHT = 2; final int DRAWABLE_BOTTOM = 3; if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getRawX() >= (et.getRight() - et.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { et.setText(""); et.selectAll(); return true; } } return false; } }); return rootView; }
From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { boolean isIntercepted = super.onInterceptTouchEvent(ev); int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: mDownX = mLastX = (int) ev.getX(); mDownY = (int) ev.getY(); isIntercepted = false;//ww w .jav a 2s . c o m break; case MotionEvent.ACTION_MOVE: int disX = (int) (ev.getX() - mDownX); int disY = (int) (ev.getY() - mDownY); isIntercepted = Math.abs(disX) > mScaledTouchSlop && Math.abs(disX) > Math.abs(disY); break; case MotionEvent.ACTION_UP: isIntercepted = false; if (isMenuOpen() && mSwipeCurrentHorizontal.isClickOnContentView(getWidth(), ev.getX())) { smoothCloseMenu(); isIntercepted = true; } break; case MotionEvent.ACTION_CANCEL: isIntercepted = false; if (!mScroller.isFinished()) mScroller.abortAnimation(); break; } return isIntercepted; }
From source file:com.easemob.helpdeskdemo.ui.SatisfactionActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent ev) { // Edittext //from w ww . j a va 2 s . c o m if (ev.getAction() == MotionEvent.ACTION_DOWN) { View v = getCurrentFocus(); if (isShouldHideInput(v, ev)) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); if (inputManager != null) { inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0); } } return super.dispatchTouchEvent(ev); } // ????TouchEvent if (getWindow().superDispatchTouchEvent(ev)) { return true; } return onTouchEvent(ev); }