List of usage examples for android.view View getLocationOnScreen
public void getLocationOnScreen(@Size(2) int[] outLocation)
Computes the coordinates of this view on the screen.
From source file:com.jaspervanriet.huntingthatproduct.Activities.CollectionActivity.java
private void activityExitAnimation(View v, Product product, Intent i) { int[] startingLocation = new int[2]; v.getLocationOnScreen(startingLocation); i.putExtra(CommentsActivity.ARG_DRAWING_START_LOCATION, startingLocation[1]); i.putExtra("productId", product.getId()); i.putExtra("collection", true); i.putExtra("productTitle", product.getTitle()); i.putExtra("productUrl", product.getProductUrl()); startActivity(i);/*from ww w. j a v a 2 s. c o m*/ overridePendingTransition(0, 0); }
From source file:com.fflorio.library.hookedslidingmenu.ui.HookedMenuLayout.java
private boolean isViewHit(View view, int x, int y) { int[] viewLocation = new int[2]; view.getLocationOnScreen(viewLocation); int[] parentLocation = new int[2]; this.getLocationOnScreen(parentLocation); int screenX = parentLocation[0] + x; int screenY = parentLocation[1] + y; return screenX >= viewLocation[0] && screenX < viewLocation[0] + view.getWidth() && screenY >= viewLocation[1] && screenY < viewLocation[1] + view.getHeight(); }
From source file:com.scigames.slidegame.Registration1UserNameActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { View v = getCurrentFocus();/*w w w . ja va 2 s. co m*/ boolean ret = super.dispatchTouchEvent(event); if (v instanceof EditText) { View w = getCurrentFocus(); int scrcoords[] = new int[2]; w.getLocationOnScreen(scrcoords); float x = event.getRawX() + w.getLeft() - scrcoords[0]; float y = event.getRawY() + w.getTop() - scrcoords[1]; Log.d("Activity", "Touch event " + event.getRawX() + "," + event.getRawY() + " " + x + "," + y + " rect " + w.getLeft() + "," + w.getTop() + "," + w.getRight() + "," + w.getBottom() + " coords " + scrcoords[0] + "," + scrcoords[1]); if (event.getAction() == MotionEvent.ACTION_UP && (x < w.getLeft() || x >= w.getRight() || y < w.getTop() || y > w.getBottom())) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); } } return ret; }
From source file:com.github.ppamorim.library.DraggerView.java
private boolean isViewHit(View view, int x, int y) { int[] viewLocation = new int[2]; view.getLocationOnScreen(viewLocation); int[] parentLocation = new int[2]; this.getLocationOnScreen(parentLocation); int screenX = parentLocation[0] + x; int screenY = parentLocation[1] + y; return screenX >= viewLocation[0] && screenX < viewLocation[0] + view.getWidth() && screenY >= viewLocation[1] && screenY < viewLocation[1] + view.getHeight(); }
From source file:com.androchill.call411.MainActivity.java
private void startPhoneActivity(View view, Intent intent) { if (view != null) { int[] screenLocation = new int[2]; view.getLocationOnScreen(screenLocation); intent.putExtra("left", screenLocation[0]).putExtra("top", screenLocation[1]) .putExtra("width", view.getWidth()).putExtra("height", view.getHeight()); }// w w w . j a v a 2 s . com startActivity(intent); // Override transitions: we don't want the normal window animation in addition to our // custom one overridePendingTransition(0, 0); // The detail activity handles the enter and exit animations. Both animations involve a // ghost view animating into its final or initial position respectively. Since the detail // activity starts translucent, the clicked view needs to be invisible in order for the // animation to look correct. if (view != null) ViewPropertyAnimator.animate(view).alpha(0.0f); }
From source file:com.jainbooks.activitys.DashboardActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { View currentView = getCurrentFocus(); boolean retVal = super.dispatchTouchEvent(event); if (currentView instanceof EditText) { View cView = getCurrentFocus(); int scrCoordinates[] = new int[2]; cView.getLocationOnScreen(scrCoordinates); float xPos = event.getRawX() + cView.getLeft() - scrCoordinates[0]; float yPos = event.getRawY() + cView.getTop() - scrCoordinates[1]; if (event.getAction() == MotionEvent.ACTION_UP && (xPos < cView.getLeft() || xPos >= cView.getRight() || yPos < cView.getTop() || yPos > cView.getBottom())) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); }/*from ww w. j a v a2s . co m*/ } return retVal; }
From source file:com.llf.nestlayout.library.NestLayout.java
@Override public void onStopNestedScroll(View target) { target = mNestedView;/*w ww . j a va 2s. c o m*/ mNestedView = null; if (target == null) return; int pY = getScrollY() + getPaddingTop(); View child = getChildFromTarget(target); //found section view from nested view; View section = findSectionView(indexOfChild(child)); int dy = 0; //whether the section view needs scroll to really position if (pY == section.getTop()) { return; } getLocationOnScreen(mTmpCoord); int parentOffset = mTmpCoord[1]; if (section.getTop() < pY) { View nextSection = findNextSectionView(indexOfChild(section)); if (nextSection != null && section != nextSection) { nextSection.getLocationOnScreen(mTmpCoord); mTmpCoord[1] -= parentOffset; if (mTmpCoord[1] < getHeight() * 4 / 5) { performSectionChange(section, nextSection); dy = mTmpCoord[1]; } else { dy = mTmpCoord[1] - getHeight(); } } } else { View preSection = findSectionView(indexOfChild(section) - 1); if (preSection != null && section != preSection) { preSection.getLocationOnScreen(mTmpCoord); mTmpCoord[1] -= parentOffset; if (mTmpCoord[1] > getHeight() / 5) { performSectionChange(section, preSection); dy = mTmpCoord[1] - getHeight(); } else { dy = mTmpCoord[1]; } } } if (dy != 0) { mScroller.startScroll(0, pY, 0, dy); invalidate(); } }
From source file:com.bw.myapplication.ui.fragment.ImagesListFragment.java
@Override public void onItemClick(PLAAdapterView<?> parent, View view, int position, long id) { Rect frame = new Rect(); getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; int[] location = new int[2]; view.getLocationOnScreen(location); location[1] += statusBarHeight;//from w w w. j av a 2s .com int width = view.getWidth(); int height = view.getHeight(); if (null != mListViewAdapter) { if (position >= 0 && position < mListViewAdapter.getDataList().size()) { mImagesListPresenter.onItemClickListener(position, mListViewAdapter.getDataList().get(position), location[0], location[1], width, height); } } }
From source file:com.hackvg.android.views.activities.MoviesActivity.java
private void startDetailActivityByAnimation(View touchedView, int touchedX, int touchedY, Intent movieDetailActivityIntent) { int[] touchedLocation = { touchedX, touchedY }; int[] locationAtScreen = new int[2]; touchedView.getLocationOnScreen(locationAtScreen); int finalLocationX = locationAtScreen[0] + touchedLocation[0]; int finalLocationY = locationAtScreen[1] + touchedLocation[1]; int[] finalLocation = { finalLocationX, finalLocationY }; movieDetailActivityIntent.putExtra(EXTRA_MOVIE_LOCATION, finalLocation); startActivity(movieDetailActivityIntent); }
From source file:com.meinv.ui.fragment.ImagesListFragment.java
@Override public void onItemClick(PLAAdapterView<?> parent, View view, int position, long id) { Rect frame = new Rect(); getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; int[] location = new int[2]; view.getLocationOnScreen(location); location[1] += statusBarHeight;//from w ww . j a va 2 s . c o m int width = view.getWidth(); int height = view.getHeight(); if (null != mListViewAdapter) { if (position >= 0 && position < mListViewAdapter.getDataList().size()) { mImagesListPresenter.onItemClickListener(position, mListViewAdapter.getDataList(), location[0], location[1], width, height); } } }