use of android.view.ViewParent in project android_frameworks_base by ParanoidAndroid.
the class Bridge method getViewIndex.
@Override
public Result getViewIndex(Object viewObject) {
if (viewObject instanceof View) {
View view = (View) viewObject;
ViewParent parentView = view.getParent();
if (parentView instanceof ViewGroup) {
Status.SUCCESS.createResult(((ViewGroup) parentView).indexOfChild(view));
}
return Status.SUCCESS.createResult();
}
throw new IllegalArgumentException("viewObject is not a View");
}
use of android.view.ViewParent in project HoloEverywhere by Prototik.
the class ListPopupWindow method removePromptView.
private void removePromptView() {
if (mPromptView != null) {
final ViewParent parent = mPromptView.getParent();
if (parent instanceof ViewGroup) {
final ViewGroup group = (ViewGroup) parent;
group.removeView(mPromptView);
}
}
}
use of android.view.ViewParent in project meatspace-android by RomainPiel.
the class PreferenceDialogFragment method onDestroyView.
@Override
public void onDestroyView() {
super.onDestroyView();
ViewParent p = lv.getParent();
if (p != null)
((ViewGroup) p).removeView(lv);
}
use of android.view.ViewParent in project android_frameworks_base by ParanoidAndroid.
the class LayoutTransition method runChangeTransition.
/**
* This function sets up animations on all of the views that change during layout.
* For every child in the parent, we create a change animation of the appropriate
* type (appearing, disappearing, or changing) and ask it to populate its start values from its
* target view. We add layout listeners to all child views and listen for changes. For
* those views that change, we populate the end values for those animations and start them.
* Animations are not run on unchanging views.
*
* @param parent The container which is undergoing a change.
* @param newView The view being added to or removed from the parent. May be null if the
* changeReason is CHANGING.
* @param changeReason A value of APPEARING, DISAPPEARING, or CHANGING, indicating whether the
* transition is occurring because an item is being added to or removed from the parent, or
* if it is running in response to a layout operation (that is, if the value is CHANGING).
*/
private void runChangeTransition(final ViewGroup parent, View newView, final int changeReason) {
Animator baseAnimator = null;
Animator parentAnimator = null;
final long duration;
switch(changeReason) {
case APPEARING:
baseAnimator = mChangingAppearingAnim;
duration = mChangingAppearingDuration;
parentAnimator = defaultChangeIn;
break;
case DISAPPEARING:
baseAnimator = mChangingDisappearingAnim;
duration = mChangingDisappearingDuration;
parentAnimator = defaultChangeOut;
break;
case CHANGING:
baseAnimator = mChangingAnim;
duration = mChangingDuration;
parentAnimator = defaultChange;
break;
default:
// Shouldn't reach here
duration = 0;
break;
}
// If the animation is null, there's nothing to do
if (baseAnimator == null) {
return;
}
// reset the inter-animation delay, in case we use it later
staggerDelay = 0;
// used for later cleanup
final ViewTreeObserver observer = parent.getViewTreeObserver();
if (!observer.isAlive()) {
// If the observer's not in a good state, skip the transition
return;
}
int numChildren = parent.getChildCount();
for (int i = 0; i < numChildren; ++i) {
final View child = parent.getChildAt(i);
// only animate the views not being added or removed
if (child != newView) {
setupChangeAnimation(parent, changeReason, baseAnimator, duration, child);
}
}
if (mAnimateParentHierarchy) {
ViewGroup tempParent = parent;
while (tempParent != null) {
ViewParent parentParent = tempParent.getParent();
if (parentParent instanceof ViewGroup) {
setupChangeAnimation((ViewGroup) parentParent, changeReason, parentAnimator, duration, tempParent);
tempParent = (ViewGroup) parentParent;
} else {
tempParent = null;
}
}
}
// This is the cleanup step. When we get this rendering event, we know that all of
// the appropriate animations have been set up and run. Now we can clear out the
// layout listeners.
observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
parent.getViewTreeObserver().removeOnPreDrawListener(this);
int count = layoutChangeListenerMap.size();
if (count > 0) {
Collection<View> views = layoutChangeListenerMap.keySet();
for (View view : views) {
View.OnLayoutChangeListener listener = layoutChangeListenerMap.get(view);
view.removeOnLayoutChangeListener(listener);
}
}
layoutChangeListenerMap.clear();
return true;
}
});
}
use of android.view.ViewParent in project android_frameworks_base by ParanoidAndroid.
the class EditTextPreference method onBindDialogView.
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
EditText editText = mEditText;
editText.setText(getText());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null) {
((ViewGroup) oldParent).removeView(editText);
}
onAddEditTextToDialogView(view, editText);
}
}
Aggregations