Update ViewGroupManager interface to use index for remove method.
Differential Revision: D2610700 fb-gh-sync-id: b59dfc581d9ca8d29203b5915fb743f3270989ab
This commit is contained in:
parent
e63fb0e8c9
commit
6c204dcbea
|
@ -310,19 +310,7 @@ import com.facebook.react.touch.JSResponderHandler;
|
||||||
viewsToAdd,
|
viewsToAdd,
|
||||||
tagsToDelete));
|
tagsToDelete));
|
||||||
}
|
}
|
||||||
View childView = viewManager.getChildAt(viewToManage, indicesToRemove[i]);
|
viewManager.removeViewAt(viewToManage, indicesToRemove[i]);
|
||||||
if (childView == null) {
|
|
||||||
throw new IllegalViewOperationException(
|
|
||||||
"Trying to remove a null view at index:"
|
|
||||||
+ indexToRemove + " view tag: " + tag + "\n detail: " +
|
|
||||||
constructManageChildrenErrorMessage(
|
|
||||||
viewToManage,
|
|
||||||
viewManager,
|
|
||||||
indicesToRemove,
|
|
||||||
viewsToAdd,
|
|
||||||
tagsToDelete));
|
|
||||||
}
|
|
||||||
viewManager.removeView(viewToManage, childView);
|
|
||||||
lastIndexToRemove = indexToRemove;
|
lastIndexToRemove = indexToRemove;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ public abstract class ViewGroupManager <T extends ViewGroup>
|
||||||
return parent.getChildAt(index);
|
return parent.getChildAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeView(T parent, View child) {
|
public void removeViewAt(T parent, int index) {
|
||||||
parent.removeView(child);
|
parent.removeViewAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -169,8 +169,10 @@ public class RecyclerViewBackedScrollView extends RecyclerView {
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeView(View child) {
|
public void removeViewAt(int index) {
|
||||||
if (mViews.remove(child)) {
|
View child = mViews.get(index);
|
||||||
|
if (child != null) {
|
||||||
|
mViews.remove(index);
|
||||||
mTopOffsetsFromLayout.remove(child);
|
mTopOffsetsFromLayout.remove(child);
|
||||||
child.removeOnLayoutChangeListener(mChildLayoutChangeListener);
|
child.removeOnLayoutChangeListener(mChildLayoutChangeListener);
|
||||||
mTotalChildrenHeight -= child.getMeasuredHeight();
|
mTotalChildrenHeight -= child.getMeasuredHeight();
|
||||||
|
@ -271,8 +273,8 @@ public class RecyclerViewBackedScrollView extends RecyclerView {
|
||||||
((ReactListAdapter) getAdapter()).addView(child, index);
|
((ReactListAdapter) getAdapter()).addView(child, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ void removeViewFromAdapter(View child) {
|
/*package*/ void removeViewFromAdapter(int index) {
|
||||||
((ReactListAdapter) getAdapter()).removeView(child);
|
((ReactListAdapter) getAdapter()).removeViewAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ View getChildAtFromAdapter(int index) {
|
/*package*/ View getChildAtFromAdapter(int index) {
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class RecyclerViewBackedScrollViewManager extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeView(RecyclerViewBackedScrollView parent, View child) {
|
public void removeViewAt(RecyclerViewBackedScrollView parent, int index) {
|
||||||
parent.removeViewFromAdapter(child);
|
parent.removeViewFromAdapter(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -195,16 +195,16 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeView(ReactViewGroup parent, View child) {
|
public void removeViewAt(ReactViewGroup parent, int index) {
|
||||||
boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
|
boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
|
||||||
if (removeClippedSubviews) {
|
if (removeClippedSubviews) {
|
||||||
|
View child = getChildAt(parent, index);
|
||||||
if (child.getParent() != null) {
|
if (child.getParent() != null) {
|
||||||
parent.removeView(child);
|
parent.removeView(child);
|
||||||
}
|
}
|
||||||
parent.removeViewWithSubviewClippingEnabled(child);
|
parent.removeViewWithSubviewClippingEnabled(child);
|
||||||
} else {
|
} else {
|
||||||
parent.removeView(child);
|
parent.removeViewAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,19 @@ import com.facebook.react.uimanager.events.NativeGestureUtil;
|
||||||
setOffscreenPageLimit(mViews.size());
|
setOffscreenPageLimit(mViews.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeViewAt(int index) {
|
||||||
|
mViews.remove(index);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
|
||||||
|
// TODO(7323049): Remove this workaround once we figure out a way to re-layout some views on
|
||||||
|
// request
|
||||||
|
setOffscreenPageLimit(mViews.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
View getViewAt(int index) {
|
||||||
|
return mViews.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mViews.size();
|
return mViews.size();
|
||||||
|
@ -124,6 +137,18 @@ import com.facebook.react.uimanager.events.NativeGestureUtil;
|
||||||
getAdapter().addView(child, index);
|
getAdapter().addView(child, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*package*/ void removeViewFromAdapter(int index) {
|
||||||
|
getAdapter().removeViewAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ int getViewCountInAdapter() {
|
||||||
|
return getAdapter().getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ View getViewFromAdapter(int index) {
|
||||||
|
return getAdapter().getViewAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
/*package*/ void setCurrentItemFromJs(int item) {
|
/*package*/ void setCurrentItemFromJs(int item) {
|
||||||
mIsCurrentItemFromJs = true;
|
mIsCurrentItemFromJs = true;
|
||||||
setCurrentItem(item);
|
setCurrentItem(item);
|
||||||
|
|
|
@ -58,4 +58,19 @@ public class ReactViewPagerManager extends ViewGroupManager<ReactViewPager> {
|
||||||
public void addView(ReactViewPager parent, View child, int index) {
|
public void addView(ReactViewPager parent, View child, int index) {
|
||||||
parent.addViewToAdapter(child, index);
|
parent.addViewToAdapter(child, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChildCount(ReactViewPager parent) {
|
||||||
|
return parent.getViewCountInAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getChildAt(ReactViewPager parent, int index) {
|
||||||
|
return parent.getViewFromAdapter(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeViewAt(ReactViewPager parent, int index) {
|
||||||
|
parent.removeViewFromAdapter(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue