doric group diff
This commit is contained in:
parent
0fa9c86ef8
commit
b2057a088c
@ -77,13 +77,14 @@ public abstract class GroupNode<F extends ViewGroup> extends ViewNode<F> {
|
|||||||
mIndexInfo.put(i, child);
|
mIndexInfo.put(i, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int count = mView.getChildCount();
|
||||||
while (i < mIndexInfo.size()) {
|
while (i < count) {
|
||||||
ViewNode node = mIndexInfo.get(i);
|
ViewNode node = mIndexInfo.get(i);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
mChildrenNode.remove(node.getId());
|
mChildrenNode.remove(node.getId());
|
||||||
mIndexInfo.remove(i);
|
mIndexInfo.remove(i);
|
||||||
tobeRemoved.remove(node);
|
tobeRemoved.remove(node);
|
||||||
|
mView.removeView(node.getView());
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
|||||||
if([name isEqualToString:@"children"]) {
|
if([name isEqualToString:@"children"]) {
|
||||||
NSArray *array = prop;
|
NSArray *array = prop;
|
||||||
NSInteger i;
|
NSInteger i;
|
||||||
|
NSMutableArray *tobeRemoved = [[NSMutableArray alloc] init];
|
||||||
for (i = 0; i< array.count; i++) {
|
for (i = 0; i< array.count; i++) {
|
||||||
NSDictionary *val = array[i];
|
NSDictionary *val = array[i];
|
||||||
if (!val || (NSNull *)val == [NSNull null]) {
|
if (!val || (NSNull *)val == [NSNull null]) {
|
||||||
@ -40,11 +41,21 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
|||||||
node.parent = self;
|
node.parent = self;
|
||||||
node.viewId = viewId;
|
node.viewId = viewId;
|
||||||
[self.children setObject:node forKey:viewId];
|
[self.children setObject:node forKey:viewId];
|
||||||
} else if (i != node.index){
|
} else {
|
||||||
[self.indexedChildren removeObjectAtIndex:i];
|
if (i != node.index) {
|
||||||
node.index = i;
|
[self.indexedChildren removeObjectAtIndex:i];
|
||||||
[node.view removeFromSuperview];
|
node.index = i;
|
||||||
|
[node.view removeFromSuperview];
|
||||||
|
}
|
||||||
|
[tobeRemoved removeObject:node];
|
||||||
}
|
}
|
||||||
|
DoricViewNode *old = i >= self.indexedChildren.count ? nil :[self.indexedChildren objectAtIndex:i];
|
||||||
|
if (old && old != node) {
|
||||||
|
[old.view removeFromSuperview];
|
||||||
|
self.indexedChildren[i] = [NSNull null];
|
||||||
|
[tobeRemoved addObject:old];
|
||||||
|
}
|
||||||
|
|
||||||
LayoutParams *params = node.layoutParams;
|
LayoutParams *params = node.layoutParams;
|
||||||
if (params == nil) {
|
if (params == nil) {
|
||||||
params = [self generateDefaultLayoutParams];
|
params = [self generateDefaultLayoutParams];
|
||||||
@ -54,23 +65,27 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
|||||||
if (self.indexedChildren.count <= i) {
|
if (self.indexedChildren.count <= i) {
|
||||||
[self.view addSubview:node.view];
|
[self.view addSubview:node.view];
|
||||||
[self.indexedChildren addObject:node];
|
[self.indexedChildren addObject:node];
|
||||||
}else if ([self.indexedChildren objectAtIndex:i] == nil) {
|
}else if ([self.indexedChildren objectAtIndex:i] == [NSNull null]) {
|
||||||
self.indexedChildren[i] = node;
|
self.indexedChildren[i] = node;
|
||||||
[self.view insertSubview:node.view atIndex:i];
|
[self.view insertSubview:node.view atIndex:i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NSUInteger start = i;
|
||||||
while (i < self.view.subviews.count) {
|
while (start < self.indexedChildren.count) {
|
||||||
UIView *view = self.view.subviews[i];
|
DoricViewNode *node = [self.indexedChildren objectAtIndex:start];
|
||||||
if (i < self.indexedChildren.count) {
|
if (node) {
|
||||||
DoricViewNode *node = [self.indexedChildren objectAtIndex:i];
|
[self.children removeObjectForKey: node.viewId];
|
||||||
if (node && node.view == view) {
|
[node.view removeFromSuperview];
|
||||||
[self.children removeObjectForKey: node.viewId];
|
[tobeRemoved removeObject:node];
|
||||||
[self.indexedChildren removeObjectAtIndex:i];
|
|
||||||
[view removeFromSuperview];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
i++;
|
start++;
|
||||||
|
}
|
||||||
|
if (i < self.indexedChildren.count) {
|
||||||
|
[self.indexedChildren removeObjectsInRange:NSMakeRange(i, self.indexedChildren.count - i)];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DoricViewNode *node in tobeRemoved) {
|
||||||
|
[self.children removeObjectForKey:node.viewId];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
[super blendView:view forPropName:name propValue:prop];
|
[super blendView:view forPropName:name propValue:prop];
|
||||||
|
Reference in New Issue
Block a user