List of usage examples for android.view ViewTreeObserver isAlive
public boolean isAlive()
From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_stats); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mScrollView = (ObservableScrollView) findViewById(R.id.game_scroll_view); mScrollView.addCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); }//from w w w . j ava 2 s.c o m mScrollViewChild = findViewById(R.id.game_scroll_view_child); mDetailsContainer = findViewById(R.id.game_details_container); mDetailsContainer.setAlpha(0); mDetailsContainer.setY(1200); mHeaderBox = findViewById(R.id.header_game); mGameViewContainer = findViewById(R.id.game_photo_container); mGameImageView = (ImageView) findViewById(R.id.game_photo); mGameTimeView = (TextView) findViewById(R.id.game_time_view); mGameScoreViewLeft = (TextView) findViewById(R.id.game_score_view_left); mGameScoreViewRight = (TextView) findViewById(R.id.game_score_view_right); tickerLayout = (LinearLayout) findViewById(R.id.sidedrawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mTitle = (TextView) findViewById(R.id.header_title); mSubtitle = (TextView) findViewById(R.id.header_subtitle); mUpdateProgressBar = (ProgressBar) findViewById(R.id.header_progressbar); mapView = (ImageView) findViewById(R.id.game_map_view); mHasPhoto = true; mGameImageView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); Picasso.with(this).load(R.drawable.drawable_dota_bg_dire_ancient).config(Bitmap.Config.ARGB_8888) .resize(Math.round(displayMetrics.widthPixels * PHOTO_ASPECT_RATIO * 2 / 3), displayMetrics.widthPixels * 2 / 3) .transform(new CropImageTransform(displayMetrics.heightPixels, displayMetrics.widthPixels)) .into(mGameImageView); setBundleContents(); initMapView(); mPresenter = new LiveStatsPresenter(this); mLiveTickerAdapter = new LiveTickerAdapter(this, R.layout.sidedrawer_list_item); if (savedInstanceState != null) { mLiveTickerAdapter.onRestoreInstanceState(savedInstanceState); gameCompleted = savedInstanceState.getBoolean(KEY_GAME_COMPLETE, false); } mDrawerListView = (ListView) findViewById(R.id.sidedrawer_items_list); mDrawerListView.setAdapter(mLiveTickerAdapter); mUpdateProgressAnim = new ProgressBarAnimation(mUpdateProgressBar, 2000, 0); mUpdateProgressAnim.setDuration(GAME_UPDATE_INTERVAL); mUpdateProgressAnim.setInterpolator(new LinearInterpolator()); if (!PrefUtils.hasLiveDrawerBeenShown(this)) { mDrawerLayout.openDrawer(Gravity.END); Toast.makeText(this, "Match events are shown in the right drawer", Toast.LENGTH_SHORT).show(); PrefUtils.setLiveDrawerShown(this); } }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
private void setupCustomScrolling(View rootView) { mAddSchedulePlaceholderView = rootView.findViewById(R.id.add_to_schedule_button_placeholder); if (mAddSchedulePlaceholderView == null) { mAddScheduleButton.setVisibility(View.VISIBLE); return;//w w w . j a v a 2s. c om } mScrollView = (ObservableScrollView) rootView.findViewById(R.id.scroll_view); mScrollView.setCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); } }
From source file:fr.rolandl.smartshareactionprovider.SmartActivityChooserView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); SmartActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { dataModel.unregisterObserver(mModelDataSetOberver); }//from w ww . j a va2 s. co m ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } if (isShowingPopup()) { dismissPopup(); } mIsAttachedToWindow = false; }
From source file:com.example.FilteredActivityChooserView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); FilteredActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { dataModel.unregisterObserver(mModelDataSetOberver); }// ww w . j ava 2 s .c o m ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } if (isShowingPopup()) { dismissPopup(); } mIsAttachedToWindow = false; }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
@Override public void onDestroy() { super.onDestroy(); if (mScrollView == null) { return;/*from w w w . ja va2s. co m*/ } ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.removeGlobalOnLayoutListener(mGlobalLayoutListener); } }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
private void expandButtonBar() { mButtonBarShowing = true;// w w w. j a v a 2 s. c om mButtonBar.setVisibility(View.VISIBLE); mButtonBar.setAlpha(0.0f); final int startingHeight = mCardView.getHeight(); final ViewTreeObserver observer = mCardView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called for every listview drawing. if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } final int endingHeight = mCardView.getHeight(); final int distance = endingHeight - startingHeight; mCardView.getLayoutParams().height = startingHeight; mCardView.requestLayout(); ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300); heightAnimator.setInterpolator(new DecelerateInterpolator()); heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); mCardView.getLayoutParams().height = (int) (value * distance + startingHeight); mCardView.requestLayout(); } }); heightAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } }); mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f); alphaAnimator.setInterpolator(new DecelerateInterpolator()); alphaAnimator.setDuration(300); alphaAnimator.setStartDelay(100); AnimatorSet set = new AnimatorSet(); set.playTogether(heightAnimator, alphaAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }); set.start(); return false; } }); }
From source file:koma.movieapp.ui.MovieDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //UIUtils.tryTranslateHttpIntent(this); boolean shouldBeFloatingWindow = shouldBeFloatingWindow(); if (shouldBeFloatingWindow) { setupFloatingWindow();/*ww w .ja v a 2 s . co m*/ } super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_detail); final Toolbar toolbar = getActionBarToolbar(); toolbar.setNavigationIcon(shouldBeFloatingWindow ? R.drawable.ic_ab_close : R.drawable.ic_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishAfterTransition(); } }); mHandler.post(new Runnable() { @Override public void run() { toolbar.setTitle(""); } }); if (savedInstanceState == null) { Uri sessionUri = getIntent().getData(); } mArguments = getIntent().getExtras(); // // if (extras == null) { // return; // } // // mMovieId = Integer.parseInt(extras.getString("movieId")); mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mTagColorDotSize = getResources().getDimensionPixelSize(R.dimen.tag_color_dot_size); mHandler = new Handler(); if (mBackdropImageLoader == null) { mBackdropImageLoader = new ImageLoader(this, R.drawable.person_image_empty); } if (mNoPlaceholderImageLoader == null) { mNoPlaceholderImageLoader = new ImageLoader(this); } 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 = findViewById(R.id.details_container); mHeaderBox = findViewById(R.id.header_movie); mTitle = (TextView) findViewById(R.id.movie_title); mMovieRating = (TextView) findViewById(R.id.movie_rating); mMovieRuntime = (TextView) findViewById(R.id.movie_runtime); mPhotoViewContainer = findViewById(R.id.movie_photo_container); mPhotoView = (ImageView) findViewById(R.id.movie_backdrop); mMovieOverview = (TextView) findViewById(R.id.movie_overview); mMovieDirectors = (LinearLayout) findViewById(R.id.movie_directors_container); //mMovieWriters = (LinearLayout) findViewById(R.id.movie_writers_container); //mMovieProducers = (LinearLayout) findViewById(R.id.movie_producers_container); mMovieCast = (LinearLayout) findViewById(R.id.movie_cast_container); mMovieGenres = (LinearLayout) findViewById(R.id.movie_genre); mMovieGenresContainer = (ViewGroup) findViewById(R.id.movie_genres_container); mAddScheduleButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button); //ViewCompat.setTransitionName(mPhotoView, TRANSITION_NAME_PHOTO); LoaderManager manager = getLoaderManager(); manager.initLoader(0, mArguments, this); }
From source file:android.support.v7.internal.widget.ActivityChooserView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { dataModel.unregisterObserver(mModelDataSetOberver); }/*from www . jav a 2s . co m*/ ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } if (isShowingPopup()) { dismissPopup(); } mIsAttachedToWindow = false; }
From source file:com.actionbarsherlock.widget.ActivityChooserView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { dataModel.unregisterObserver(mModelDataSetOberver); }//from ww w. j av a 2 s . co m ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } mIsAttachedToWindow = false; }
From source file:com.actionbarsherlock.widget.ActivityChooserView.java
/** * Dismisses the popup window with activities. * * @return True if dismissed, false if already dismissed. *//*from ww w.j a va2s. c o m*/ public boolean dismissPopup() { if (isShowingPopup()) { getListPopupWindow().dismiss(); ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); } } return true; }