List of usage examples for android.view ViewTreeObserver addOnGlobalLayoutListener
public void addOnGlobalLayoutListener(OnGlobalLayoutListener listener)
From source file:com.saulcintero.moveon.fragments.Summary1.java
private void fitMapToMarkers() { final BoundingBoxE6 mOverlayItemsBounds = BoundingBoxE6.fromGeoPoints(gPointsList); if (mapView.getHeight() > 0) { mapView.zoomToBoundingBox(mOverlayItemsBounds); } else {//from ww w . j a v a 2 s . c o m ViewTreeObserver vto1 = mapView.getViewTreeObserver(); vto1.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { public void onGlobalLayout() { mapView.zoomToBoundingBox(mOverlayItemsBounds); ViewTreeObserver vto2 = mapView.getViewTreeObserver(); vto2.removeOnGlobalLayoutListener(this); } }); } }
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery_activity); Toolbar appBar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(appBar);//from w w w. j a v a 2 s. c o m getSupportLoaderManager().initLoader(0, null, this); bindService(new Intent(this, GalleryArtSource.class).setAction(GalleryArtSource.ACTION_BIND_GALLERY), mServiceConnection, BIND_AUTO_CREATE); mPlaceholderDrawable = new ColorDrawable( ContextCompat.getColor(this, R.color.gallery_chosen_photo_placeholder)); mPhotoGridView = (RecyclerView) findViewById(R.id.photo_grid); DefaultItemAnimator itemAnimator = new DefaultItemAnimator(); itemAnimator.setSupportsChangeAnimations(false); mPhotoGridView.setItemAnimator(itemAnimator); setupMultiSelect(); final GridLayoutManager gridLayoutManager = new GridLayoutManager(GallerySettingsActivity.this, 1); mPhotoGridView.setLayoutManager(gridLayoutManager); final ViewTreeObserver vto = mPhotoGridView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int width = mPhotoGridView.getWidth() - mPhotoGridView.getPaddingStart() - mPhotoGridView.getPaddingEnd(); if (width <= 0) { return; } // Compute number of columns int maxItemWidth = getResources() .getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_max_item_size); int numColumns = 1; while (true) { if (width / numColumns > maxItemWidth) { ++numColumns; } else { break; } } int spacing = getResources().getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_spacing); mItemSize = (width - spacing * (numColumns - 1)) / numColumns; // Complete setup gridLayoutManager.setSpanCount(numColumns); mChosenPhotosAdapter.setHasStableIds(true); mPhotoGridView.setAdapter(mChosenPhotosAdapter); mPhotoGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this); tryUpdateSelection(false); } }); ViewCompat.setOnApplyWindowInsetsListener(mPhotoGridView, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) { int gridSpacing = getResources().getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_spacing); ViewCompat.onApplyWindowInsets(v, insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft() + gridSpacing, gridSpacing, insets.getSystemWindowInsetRight() + gridSpacing, insets.getSystemWindowInsetBottom() + insets.getSystemWindowInsetTop() + gridSpacing + getResources().getDimensionPixelSize(R.dimen.gallery_fab_space))); return insets; } }); Button enableRandomImages = (Button) findViewById(R.id.gallery_enable_random); enableRandomImages.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { ActivityCompat.requestPermissions(GallerySettingsActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_STORAGE_PERMISSION); } }); Button permissionSettings = (Button) findViewById(R.id.gallery_edit_permission_settings); permissionSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); mAddButton = findViewById(R.id.add_photos_button); mAddButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Use ACTION_OPEN_DOCUMENT by default for adding photos. // This allows us to use persistent URI permissions to access the underlying photos // meaning we don't need to use additional storage space and will pull in edits automatically // in addition to syncing deletions. // (There's a separate 'Import photos' option which uses ACTION_GET_CONTENT to support legacy apps) Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, REQUEST_CHOOSE_PHOTOS); } }); }
From source file:com.timemachine.controller.ControllerActivity.java
private void setupUI() { // Set layout listener View controllerView = findViewById(R.id.controllerView); ViewTreeObserver vto = controllerView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override/*from w w w .j a va 2s. c om*/ public void onGlobalLayout() { runOnUiThread(new Runnable() { public void run() { locationSliderHeight = locationSlider.getHeight(); originLocationSliderContainerY = locationSliderContainer.getY(); originPlayPauseButtonY = playPause.getY(); minLocationSliderContainerY = originLocationSliderContainerY; maxLocationSliderContainerY = originLocationSliderContainerY + locationSliderHeight; midLocationSliderContainerY = (minLocationSliderContainerY + maxLocationSliderContainerY) / 2; } }); System.out.println("locationSliderHeight: " + locationSliderHeight); System.out.println("locationSliderContainerY: " + originLocationSliderContainerY); locationSlider.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); // Connect to controller.html controllerURL = "http://" + ipText + ":8080/controller.html"; locationSlider = (WebView) findViewById(R.id.webview); locationSliderContainer = (FrameLayout) findViewById(R.id.sliderContainer); locationSlider.setBackgroundColor(Color.TRANSPARENT); locationSlider.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); locationSlider.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { System.out.println("onReceivedError"); showConnectDialog("Error while connecting to controller. Connect again."); } @Override public void onLoadResource(WebView view, String url) { if (url.contains("thumbnail")) isMasterConnected = true; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { isMasterConnectedTimerTask = null; isMasterConnectedTimerTask = new TimerTask() { @Override public void run() { if (isMasterConnected == false) showConnectDialog("Master is not loaded in the browser. Connect again."); } }; isMasterConnectedTimer.schedule(isMasterConnectedTimerTask, 6000); } @Override public void onPageFinished(WebView view, String url) { if (url.contains(controllerURL)) { drag.setVisibility(View.VISIBLE); playPause.setVisibility(View.VISIBLE); loadPreferences(); } super.onPageFinished(view, url); } }); try { locationSlider.loadUrl(controllerURL); } catch (Exception e) { e.printStackTrace(); } // Set JavaScript Interface locationSlider.addJavascriptInterface(this, "androidObject"); WebSettings webSettings = locationSlider.getSettings(); webSettings.setJavaScriptEnabled(true); // Set the play-pause button playPause = (ImageButton) findViewById(R.id.playPauseButton); playPause.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { socket.emit("handlePlayPauseServer"); } }); socket.emit("setControllerPlayButton"); // Set the drag button drag = (ImageButton) findViewById(R.id.drag); drag.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { dragYDiffBetweenFingerAndSliderTop = locationSliderContainer.getY() - event.getRawY(); dragYDiffBetweenFingerAndPlayPauseTop = playPause.getY() - event.getRawY(); } if (event.getAction() == MotionEvent.ACTION_MOVE) { // Move the slider based on current finger location float newSliderY = event.getRawY() + dragYDiffBetweenFingerAndSliderTop; float newPlayPauseY = event.getRawY() + dragYDiffBetweenFingerAndPlayPauseTop; if (newSliderY > minLocationSliderContainerY && newSliderY < maxLocationSliderContainerY) { locationSliderContainer.setY(newSliderY); playPause.setY(newPlayPauseY); } } if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getEventTime() - event.getDownTime() <= tapTimeout) { // Tap is detected, toggle the slider System.out.println("onTap"); runOnUiThread(new Runnable() { public void run() { toggleSlider(); } }); } else { // Not a tap gesture, slide up or down based on the slider's current position if (locationSliderContainer.getY() > midLocationSliderContainerY) slideDown(); else slideUp(); } } return true; } }); // Set the Google map setUpMapIfNeeded(); }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
private void initViews() { mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mScrollView = (ObservableScrollView) getActivity().findViewById(R.id.scroll_view); mScrollView.addCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); }//from w ww. ja va 2s . c o m mScrollViewChild = getActivity().findViewById(R.id.scroll_view_child); mScrollViewChild.setVisibility(View.INVISIBLE); mDetailsContainer = getActivity().findViewById(R.id.details_container); mHeaderBox = getActivity().findViewById(R.id.header_session); mTitle = (TextView) getActivity().findViewById(R.id.session_title); mSubtitle = (TextView) getActivity().findViewById(R.id.session_subtitle); mPhotoViewContainer = getActivity().findViewById(R.id.session_photo_container); mPhotoView = (ImageView) getActivity().findViewById(R.id.session_photo); mAbstract = (TextView) getActivity().findViewById(R.id.session_abstract); mPlusOneIcon = (ImageView) getActivity().findViewById(R.id.gplus_icon_box); mTwitterIcon = (ImageView) getActivity().findViewById(R.id.twitter_icon_box); //Find view that shows a Videocam icon if the session is being live streamed. mLiveStreamVideocamIconAndText = (TextView) getActivity() .findViewById(R.id.live_stream_videocam_icon_and_text); // Find view that shows a play button and some text for the user to watch the session live stream. mLiveStreamPlayIconAndText = (TextView) getActivity().findViewById(R.id.live_stream_play_icon_and_text); mRequirements = (TextView) getActivity().findViewById(R.id.session_requirements); mTags = (LinearLayout) getActivity().findViewById(R.id.session_tags); mTagsContainer = (ViewGroup) getActivity().findViewById(R.id.session_tags_container); ViewCompat.setTransitionName(mPhotoView, SessionDetailConstants.TRANSITION_NAME_PHOTO); mAddScheduleButtonContainer = getActivity().findViewById(R.id.add_schedule_button_container); mAddScheduleButton = (CheckableFloatingActionButton) getActivity().findViewById(R.id.add_schedule_button); mNoPlaceholderImageLoader = new ImageLoader(getContext()); mSpeakersImageLoader = new ImageLoader(getContext(), R.drawable.person_image_empty); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExBase.java
/** * /*from w ww . ja v a 2s .c o m*/ * * @param pager * @param child */ private void startAnimationDelay(final ContainerViewPager pager, final View child) { final float width = pager.getContainerVO().getW(); child.setTranslationX(width); final ViewTreeObserver observer = child.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < 16) { child.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { child.getViewTreeObserver().removeOnGlobalLayoutListener(this); } EBrowserAnimation.animFromRight(child, width, pager.getContainerVO().getAnimTime(), pager.getContainerVO().getAnimDelayTime(), new EBrowserAnimation.AnimatorListener() { @Override public void onAnimationEnd() { } }); } }); }
From source file:com.amazon.android.uamp.ui.PlaybackOverlayFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = super.onCreateView(inflater, container, savedInstanceState); if (rootView == null) { Log.e(TAG, "could not find root view for this fragment"); return null; }/*from w ww. ja v a 2s .co m*/ final ViewGroup layout = (ViewGroup) rootView.findViewById(R.id.details_fragment_root); if (layout != null) { ViewTreeObserver viewTreeObserver = layout.getViewTreeObserver(); viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { setActionsInitialStates(); // Continue getting called until we are able to initialize the control views // as we have to watch the details fragment this may take a few updates. if (areControlViewsInitialized()) { layout.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } }); } return rootView; }
From source file:com.example.emachine.FXcalcActivity.java
private void observeGraph() { /**//from w w w . j a v a 2s. c om * Observe each progress bar. */ ViewTreeObserver observer = pb_us.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { pb_us.setProgress(0); // Initially set the progress halfway if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { pb_us.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { //noinspection deprecation pb_us.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); ViewTreeObserver observer_england = pb_england.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { pb_england.setProgress(0); // Initially set the progress halfway if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { pb_england.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { //noinspection deprecation pb_england.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); ViewTreeObserver observer_euro = pb_euro.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { pb_euro.setProgress(0); // Initially set the progress halfway if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { pb_euro.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { //noinspection deprecation pb_euro.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); ViewTreeObserver observer_brazil = pb_brazil.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { pb_brazil.setProgress(0); // Initially set the progress halfway if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { pb_brazil.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { //noinspection deprecation pb_brazil.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); ViewTreeObserver observer_japan = pb_japan.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { pb_japan.setProgress(0); // Initially set the progress halfway if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { pb_japan.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { //noinspection deprecation pb_japan.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); }
From source file:us.theparamountgroup.android.inventory.EditorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_editor); // Examine the intent that was used to launch this activity, // in order to figure out if we're creating a new shell or editing an existing one. Intent intent = getIntent();/*from ww w . j ava 2s . co m*/ mCurrentShellUri = intent.getData(); // If the intent DOES NOT contain a shell content URI, then we know that we are // creating a new shell. if (mCurrentShellUri == null) { // This is a new shell, so change the app bar to say "Add a Shell" setTitle(getString(R.string.editor_activity_title_new_pet)); // Invalidate the options menu, so the "Delete" menu option can be hidden. // (It doesn't make sense to delete a shell that hasn't been created yet.) invalidateOptionsMenu(); } else { // Otherwise this is an existing shell, so change app bar to say "Edit Shell" setTitle(getString(R.string.editor_activity_title_edit_pet)); // Initialize a loader to read the shell data from the database // and display the current values in the editor getLoaderManager().initLoader(EXISTING_SHELL_LOADER, null, this); } // Find all relevant views that we will need to read user input from mNameEditText = (EditText) findViewById(R.id.edit_shell_name); mColorEditText = (EditText) findViewById(R.id.edit_shell_color); mHoleSpinner = (Spinner) findViewById(R.id.spinner_hole); mTypeSpinner = (Spinner) findViewById(R.id.spinner_type); mQuantityTextView = (TextView) findViewById(R.id.edit_product_quantity); mPriceEditText = (EditText) findViewById(R.id.price_enter); // Setup OnTouchListeners on all the input fields, so we can determine if the user // has touched or modified them. This will let us know if there are unsaved changes // or not, if the user tries to leave the editor without saving. mNameEditText.setOnTouchListener(mTouchListener); mColorEditText.setOnTouchListener(mTouchListener); mHoleSpinner.setOnTouchListener(mTouchListener); mTypeSpinner.setOnTouchListener(mTouchListener); mQuantityTextView.setOnTouchListener(mTouchListener); mPriceEditText.setOnTouchListener(mTouchListener); /* The view tree observer can be used to get notifications when global events, like layout, happen. * The returned ViewTreeObserver observer is not guaranteed to remain valid for the lifetime of this View. */ mImageView = (ImageView) findViewById(R.id.image); ViewTreeObserver viewTreeObserver = mImageView.getViewTreeObserver(); viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Log.i(LOG_TAG, " in onGlobalLayout trying to get image to appear"); mImageView.setImageResource(R.drawable.ic_soul_shells_logo); mImageView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); // assign TAKE PHOTO button to mButtonTakePicture variable. mButtonTakePicture = (Button) findViewById(R.id.take_photo); mButtonTakePicture.setEnabled(false); // ask permission to use the camera and image gallery requestPermissions(); setupHoleSpinner(); setupTypeSpinner(); }
From source file:org.puder.trs80.EmulatorActivity.java
private void initKeyboardView() { stopAccelerometer();//from w ww .java 2s. com keyboardContainer = (ViewGroup) findViewById(R.id.keyboard_container); keyboardContainer.removeAllViews(); final KeyboardLayout keyboardType = getKeyboardType(); showKeyboardHint(keyboardType); if (keyboardType == KEYBOARD_GAME_CONTROLLER || keyboardType == KEYBOARD_EXTERNAL) { keyboardContainer.getRootView().findViewById(R.id.switch_keyboard).setVisibility(View.GONE); return; } keyboardContainer.getRootView().findViewById(R.id.switch_keyboard).setVisibility(View.VISIBLE); // if (android.os.Build.VERSION.SDK_INT >= // Build.VERSION_CODES.HONEYCOMB) { // root.setMotionEventSplittingEnabled(true); // } currentHardware.computeKeyDimensions(windowRect, getKeyboardType()); int layoutId = 0; switch (keyboardType) { case KEYBOARD_LAYOUT_COMPACT: layoutId = R.layout.keyboard_compact; break; case KEYBOARD_LAYOUT_ORIGINAL: layoutId = R.layout.keyboard_original; break; case KEYBOARD_LAYOUT_JOYSTICK: layoutId = R.layout.keyboard_joystick; break; case KEYBOARD_TILT: layoutId = R.layout.keyboard_tilt; break; } getLayoutInflater().inflate(layoutId, keyboardContainer, true); /* * The following code is a hack to work around a problem with the * keyboard layout in Android. The second keyboard should have * visibility GONE initially when the keyboard layout is inflated. * However, doing so messes up the layout of the second keyboard * (R.id.keyboard_view_2). This does not happen when visibility is * VISIBLE. So, to work around this issue, the initial visibility in the * keyboard layout is VISIBLE and we use a layout listener to make it * GONE after the layout has been computed and just before it will be * rendered. */ ViewTreeObserver vto = keyboardContainer.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { View kb2 = keyboardContainer.findViewById(R.id.keyboard_view_2); if (kb2 != null) { kb2.setVisibility(View.GONE); } ViewTreeObserver obs = keyboardContainer.getViewTreeObserver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { obs.removeOnGlobalLayoutListener(this); } else { //noinspection deprecation obs.removeGlobalOnLayoutListener(this); } } }); keyboardContainer.requestLayout(); if (keyboardType == KEYBOARD_TILT) { startAccelerometer(); } }
From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_matches_detail); final Toolbar toolbar = getActionBarToolbar(); toolbar.setNavigationIcon(R.drawable.ic_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override// w w w . j a v a2s. c om public void onClick(View v) { onBackPressed(); } }); mHandler.post(new Runnable() { @Override public void run() { toolbar.setTitle(""); } }); //setmUrl(); mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view); mScrollView.addCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); } mScrollViewChild = findViewById(R.id.scroll_view_child); // mScrollViewChild.setVisibility(View.INVISIBLE); mDetailsContainer = (ViewGroup) findViewById(R.id.details_container); mDetailsContainer.setY(2000); mHeaderBox = findViewById(R.id.header_match); mTitle = (TextView) findViewById(R.id.header_title); mSubtitle = (TextView) findViewById(R.id.header_subtitle); mMatchViewContainer = findViewById(R.id.match_photo_container); //mMatchViewContainer.setVisibility(View.INVISIBLE); mMatchTeamOneImageView = (ImageView) findViewById(R.id.match_team_one_photo); mMatchTeamTwoImageView = (ImageView) findViewById(R.id.match_team_two_photo); mMatchImageView = (ImageView) findViewById(R.id.match_photo); mMatchScoreView = (TextView) findViewById(R.id.match_score_view); mBestOfView = (TextView) findViewById(R.id.match_bo); mAddReminderButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button); mAddReminderButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean starred = !mStarred; showStarred(starred, true); setSessionStarred(starred); } }); mGGnetMatchId = getIntent().getLongExtra(ARGS_GG_MATCH_ID, 0); mMatchImageView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); final int dWidth = displayMetrics.widthPixels * 2 / 3; Picasso.with(this).load(R.drawable.drawable_dota_bg_dire_ancient).config(Bitmap.Config.ARGB_8888) .resize(Math.round(dWidth * PHOTO_ASPECT_RATIO), dWidth) .transform(new CropImageTransform(displayMetrics.heightPixels, displayMetrics.widthPixels)) .into(mMatchImageView); LoaderManager manager = getLoaderManager(); mHasPhoto = true; manager.initLoader(DB_LOADER, null, mCursorCallbacks); }