use of android.view.ViewGroup in project platform_frameworks_base by android.
the class ChangeTransform method createAnimator.
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
if (startValues == null || endValues == null || !startValues.values.containsKey(PROPNAME_PARENT) || !endValues.values.containsKey(PROPNAME_PARENT)) {
return null;
}
ViewGroup startParent = (ViewGroup) startValues.values.get(PROPNAME_PARENT);
ViewGroup endParent = (ViewGroup) endValues.values.get(PROPNAME_PARENT);
boolean handleParentChange = mReparent && !parentsMatch(startParent, endParent);
Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_INTERMEDIATE_MATRIX);
if (startMatrix != null) {
startValues.values.put(PROPNAME_MATRIX, startMatrix);
}
Matrix startParentMatrix = (Matrix) startValues.values.get(PROPNAME_INTERMEDIATE_PARENT_MATRIX);
if (startParentMatrix != null) {
startValues.values.put(PROPNAME_PARENT_MATRIX, startParentMatrix);
}
// First handle the parent change:
if (handleParentChange) {
setMatricesForParent(startValues, endValues);
}
// Next handle the normal matrix transform:
ObjectAnimator transformAnimator = createTransformAnimator(startValues, endValues, handleParentChange);
if (handleParentChange && transformAnimator != null && mUseOverlay) {
createGhostView(sceneRoot, startValues, endValues);
}
return transformAnimator;
}
use of android.view.ViewGroup in project platform_frameworks_base by android.
the class Visibility method onDisappear.
/**
* Subclasses should override this method or
* {@link #onDisappear(ViewGroup, View, TransitionValues, TransitionValues)}
* if they need to create an Animator when targets disappear.
* The method should only be called by the Visibility class; it is
* not intended to be called from external classes.
* <p>
* The default implementation of this method attempts to find a View to use to call
* {@link #onDisappear(ViewGroup, View, TransitionValues, TransitionValues)},
* based on the situation of the View in the View hierarchy. For example,
* if a View was simply removed from its parent, then the View will be added
* into a {@link android.view.ViewGroupOverlay} and passed as the <code>view</code>
* parameter in {@link #onDisappear(ViewGroup, View, TransitionValues, TransitionValues)}.
* If a visible View is changed to be {@link View#GONE} or {@link View#INVISIBLE},
* then it can be used as the <code>view</code> and the visibility will be changed
* to {@link View#VISIBLE} for the duration of the animation. However, if a View
* is in a hierarchy which is also altering its visibility, the situation can be
* more complicated. In general, if a view that is no longer in the hierarchy in
* the end scene still has a parent (so its parent hierarchy was removed, but it
* was not removed from its parent), then it will be left alone to avoid side-effects from
* improperly removing it from its parent. The only exception to this is if
* the previous {@link Scene} was {@link Scene#getSceneForLayout(ViewGroup, int,
* android.content.Context) created from a layout resource file}, then it is considered
* safe to un-parent the starting scene view in order to make it disappear.</p>
*
* @param sceneRoot The root of the transition hierarchy
* @param startValues The target values in the start scene
* @param startVisibility The target visibility in the start scene
* @param endValues The target values in the end scene
* @param endVisibility The target visibility in the end scene
* @return An Animator to be started at the appropriate time in the
* overall transition for this scene change. A null value means no animation
* should be run.
*/
public Animator onDisappear(ViewGroup sceneRoot, TransitionValues startValues, int startVisibility, TransitionValues endValues, int endVisibility) {
if ((mMode & MODE_OUT) != MODE_OUT) {
return null;
}
View startView = (startValues != null) ? startValues.view : null;
View endView = (endValues != null) ? endValues.view : null;
View overlayView = null;
View viewToKeep = null;
if (endView == null || endView.getParent() == null) {
if (endView != null) {
// endView was removed from its parent - add it to the overlay
overlayView = endView;
} else if (startView != null) {
// it being removed from its current parent
if (startView.getParent() == null) {
// no parent - safe to use
overlayView = startView;
} else if (startView.getParent() instanceof View) {
View startParent = (View) startView.getParent();
TransitionValues startParentValues = getTransitionValues(startParent, true);
TransitionValues endParentValues = getMatchedTransitionValues(startParent, true);
VisibilityInfo parentVisibilityInfo = getVisibilityChangeInfo(startParentValues, endParentValues);
if (!parentVisibilityInfo.visibilityChange) {
overlayView = TransitionUtils.copyViewImage(sceneRoot, startView, startParent);
} else if (startParent.getParent() == null) {
int id = startParent.getId();
if (id != View.NO_ID && sceneRoot.findViewById(id) != null && mCanRemoveViews) {
// no parent, but its parent is unparented but the parent
// hierarchy has been replaced by a new hierarchy with the same id
// and it is safe to un-parent startView
overlayView = startView;
}
}
}
}
} else {
// visibility change
if (endVisibility == View.INVISIBLE) {
viewToKeep = endView;
} else {
// Becoming GONE
if (startView == endView) {
viewToKeep = endView;
} else {
overlayView = startView;
}
}
}
final int finalVisibility = endVisibility;
final ViewGroup finalSceneRoot = sceneRoot;
if (overlayView != null) {
// TODO: Need to do this for general case of adding to overlay
int[] screenLoc = (int[]) startValues.values.get(PROPNAME_SCREEN_LOCATION);
int screenX = screenLoc[0];
int screenY = screenLoc[1];
int[] loc = new int[2];
sceneRoot.getLocationOnScreen(loc);
overlayView.offsetLeftAndRight((screenX - loc[0]) - overlayView.getLeft());
overlayView.offsetTopAndBottom((screenY - loc[1]) - overlayView.getTop());
sceneRoot.getOverlay().add(overlayView);
Animator animator = onDisappear(sceneRoot, overlayView, startValues, endValues);
if (animator == null) {
sceneRoot.getOverlay().remove(overlayView);
} else {
final View finalOverlayView = overlayView;
addListener(new TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
finalSceneRoot.getOverlay().remove(finalOverlayView);
}
});
}
return animator;
}
if (viewToKeep != null) {
int originalVisibility = viewToKeep.getVisibility();
viewToKeep.setTransitionVisibility(View.VISIBLE);
Animator animator = onDisappear(sceneRoot, viewToKeep, startValues, endValues);
if (animator != null) {
DisappearListener disappearListener = new DisappearListener(viewToKeep, finalVisibility, mSuppressLayout);
animator.addListener(disappearListener);
animator.addPauseListener(disappearListener);
addListener(disappearListener);
} else {
viewToKeep.setTransitionVisibility(originalVisibility);
}
return animator;
}
return null;
}
use of android.view.ViewGroup in project simplefacebook by androidquery.
the class ImageActivity method initView.
private void initView() {
photos = new ArrayList<FeedItem>();
pv = (PagedView) findViewById(R.id.paged);
pi = (PageIndicator) findViewById(R.id.page_indicator);
pv.setOnPageChangeListener(new OnPagedViewChangeListener() {
@Override
public void onStopTracking(PagedView pagedView) {
}
@Override
public void onStartTracking(PagedView pagedView) {
}
@Override
public void onPageChanged(PagedView pagedView, int previousPage, int newPage) {
pi.setActiveDot(newPage);
}
});
adapter = new PagedAdapter() {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (position >= photos.size())
return PageAdapter.getEmptyView(parent);
FeedItem item = photos.get(position);
String url = item.getSource();
if (url == null)
return PageAdapter.getEmptyView(parent);
String name = item.getItemName();
View cached = photoViews.get(url);
if (cached == null) {
convertView = aq.inflate(null, R.layout.item_photo, parent);
photoViews.put(url, convertView);
} else {
convertView = cached;
return convertView;
}
PQuery aq = aq2.recycle(convertView);
aq.id(R.id.web).progress(R.id.progress).invisible();
AQUtility.debug("image load url", url);
aq.webImage(url, true, false, 0xFF000000);
aq.id(R.id.text).text(name, BufferType.NORMAL, true);
convertView.setDrawingCacheEnabled(true);
return convertView;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return photos.get(position);
}
@Override
public int getCount() {
return photos.size();
}
};
pv.setAdapter(adapter);
}
use of android.view.ViewGroup in project platform_frameworks_base by android.
the class SubActivity method onResume.
@Override
protected void onResume() {
super.onResume();
ViewGroup container = (ViewGroup) findViewById(R.id.my_container);
int dx = getWindowManager().getDefaultDisplay().getWidth();
for (int i = 0; i < container.getChildCount(); i++) {
View child = container.getChildAt(i);
int dir = child.getId() == R.id.from_left ? 1 : -1;
child.setTranslationX(dx * dir);
child.animate().translationX(0).setDuration(MainActivity.DURATION);
}
View bg = findViewById(R.id.bg_container);
bg.setAlpha(0f);
bg.animate().alpha(1f).setDuration(MainActivity.DURATION);
}
use of android.view.ViewGroup in project platform_frameworks_base by android.
the class CrossfadeImage method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crossfade_image);
ViewGroup container = (ViewGroup) findViewById(R.id.container);
mSceneRoot = container;
mImageView = (ImageView) findViewById(R.id.contact_picture);
mImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
Crossfade mCrossfade = new Crossfade();
mCrossfade.addTarget(R.id.contact_picture);
TransitionSet group = new TransitionSet();
group.setDuration(1500);
group.addTransition(mCrossfade).addTransition(new ChangeBounds());
mTransition = group;
}
Aggregations