List of usage examples for android.widget RelativeLayout getBottom
@ViewDebug.CapturedViewProperty public final int getBottom()
From source file:com.mycompany.popularmovies.DetailActivity.DetailFragment.java
@Override public void onClick(View v) { if (v.getId() == R.id.favorite) { Uri uri = MovieContract.MovieTable.CONTENT_URI; ContentResolver resolver = mActivity.getContentResolver(); Cursor favoriteStatusCursor = resolver.query(uri, new String[] { MovieContract.MovieTable.COLUMN_FAVORITED }, MovieContract.MovieTable._ID + "== ?", new String[] { Integer.toString(mMovieId) }, null); if (favoriteStatusCursor != null && favoriteStatusCursor.moveToFirst()) { Integer favoriteStatus = favoriteStatusCursor .getInt(favoriteStatusCursor.getColumnIndex(MovieContract.MovieTable.COLUMN_FAVORITED)); Integer flippedFavoriteStatus = favoriteStatus == 0 ? 1 : 0; ContentValues updateFavoriteStatusValues = new ContentValues(); updateFavoriteStatusValues.put(MovieContract.MovieTable.COLUMN_FAVORITED, flippedFavoriteStatus); resolver.update(uri, updateFavoriteStatusValues, MovieContract.MovieTable._ID + " == ?", new String[] { Integer.toString(mMovieId) }); favoriteStatusCursor.close(); }//w w w .ja va 2s. co m } else if (v.getId() == R.id.trailer_thumbnail) { String link = (String) v.getTag(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } else if (v.getId() == R.id.review) { final RelativeLayout reviewItem = (RelativeLayout) v; final TextView author = (TextView) v.findViewById(R.id.author_full_name); final TextView review = (TextView) v.findViewById(R.id.review_text); if (reviewItem.getTag() == DetailFragment.TAG_REVIEW_COLLAPSED) { author.setVisibility(View.VISIBLE); review.setMaxLines(Integer.MAX_VALUE); new Handler().post(new Runnable() { @Override public void run() { int excess = mReviewList.getTop() + reviewItem.getBottom() - (mScrollView.getScrollY() + mScrollView.getHeight()); if (excess > 0) { if (reviewItem.getHeight() <= mScrollView.getHeight()) { mScrollView.smoothScrollBy(0, excess); } else { mScrollView.smoothScrollTo(0, mReviewList.getTop() + reviewItem.getTop()); } } } }); reviewItem.setTag(DetailFragment.TAG_REVIEW_EXPANDED); } else { author.setVisibility(View.GONE); review.setMaxLines(REVIEW_MAXLINES); reviewItem.setTag(DetailFragment.TAG_REVIEW_COLLAPSED); } } }