List of usage examples for android.view ViewGroup isLaidOut
public boolean isLaidOut()
From source file:com.givewaygames.transition.TransitionManager.java
/** * Convenience method to animate to a new scene defined by all changes within * the given scene root between calling this method and the next rendering frame. * Calling this method causes TransitionManager to capture current values in the * scene root and then post a request to run a transition on the next frame. * At that time, the new values in the scene root will be captured and changes * will be animated. There is no need to create a Scene; it is implied by * changes which take place between calling this method and the next frame when * the transition begins./* w ww .ja v a 2 s .c o m*/ * * <p>Calling this method several times before the next frame (for example, if * unrelated code also wants to make dynamic changes and run a transition on * the same scene root), only the first call will trigger capturing values * and exiting the current scene. Subsequent calls to the method with the * same scene root during the same frame will be ignored.</p> * * <p>Passing in <code>null</code> for the transition parameter will * cause the TransitionManager to use its default transition.</p> * * @param sceneRoot The root of the View hierarchy to run the transition on. * @param transition The transition to use for this change. A * value of null causes the TransitionManager to use the default transition. */ public static void beginDelayedTransition(final ViewGroup sceneRoot, Transition transition) { if (!sPendingTransitions.contains(sceneRoot) && sceneRoot.isLaidOut()) { if (Transition.DBG) { Log.d(LOG_TAG, "beginDelayedTransition: root, transition = " + sceneRoot + ", " + transition); } sPendingTransitions.add(sceneRoot); if (transition == null) { transition = sDefaultTransition; } final Transition transitionClone = transition.clone(); sceneChangeSetup(sceneRoot, transitionClone); Scene.setCurrentScene(sceneRoot, null); sceneChangeRunTransition(sceneRoot, transitionClone); } }
From source file:com.achep.acdisplay.ui.components.MediaWidget.java
/** * Updates the content of the view to latest metadata * provided by {@link com.achep.acdisplay.services.media.MediaController2#getMetadata()}. *///from w ww . j av a2s . com private void populateMetadata() { if (mIdle) { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } } Metadata metadata = mMediaController.getMetadata(); ViewUtils.safelySetText(mTitleView, metadata.title); ViewUtils.safelySetText(mSubtitleView, metadata.subtitle); mDurationText.setText(formatTime(metadata.duration)); mSeekUiAtomic.stop(); mSeekBar.setMax(Math.min(100, (int) (metadata.duration / 1000L))); if (mArtworkView != null) { mArtworkView.setImageBitmap(metadata.bitmap); } }
From source file:com.bullmobi.message.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.easynotification_scene_music, container, false); assert sceneView != null; }/*from w ww . j a v a 2 s.c om*/ mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:com.achep.acdisplay.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.acdisplay_scene_music, container, false); assert sceneView != null; }//from w ww .j av a 2s . c o m mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
@SuppressLint("NewApi") private void maybeBeginDelayedTransition(@Nullable ViewGroup sceneRoot, @Nullable Transition transition) { if (Device.hasKitKatApi() && isAnimatableAuto() && sceneRoot != null && sceneRoot.isLaidOut()) { TransitionManager.beginDelayedTransition(sceneRoot, transition); }/*from ww w . j a va 2 s . co m*/ }