js: list add reload api
This commit is contained in:
parent
7dda15efbd
commit
3de2162ef6
@ -413,6 +413,24 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
@DoricMethod
|
||||
public void reload() {
|
||||
this.listAdapter.loadAnchor = -1;
|
||||
// If reload,should reset native cache.
|
||||
for (int index = 0; index < this.itemValues.size(); index++) {
|
||||
removeSubModel(this.itemValues.valueAt(index));
|
||||
}
|
||||
this.itemValues.clear();
|
||||
mView.post(new Runnable() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void run() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void moveToPosition(int pos, boolean smooth) {
|
||||
if (mView.getLayoutManager() == null) {
|
||||
return;
|
||||
|
@ -83,8 +83,9 @@ class ListVM extends ViewModel<ListModel, ListVH> {
|
||||
heightSpec: LayoutSpec.JUST,
|
||||
},
|
||||
height: 50,
|
||||
onClick: function () {
|
||||
(this as Text).height += 10
|
||||
onClick: () => {
|
||||
data.text += "1"
|
||||
vh.list.reload(this.context)
|
||||
}
|
||||
})
|
||||
]), {
|
||||
|
@ -566,4 +566,16 @@ - (void)subNodeContentChanged:(DoricViewNode *)subNode {
|
||||
[subNode.view.doricLayout apply];
|
||||
[super subNodeContentChanged:subNode];
|
||||
}
|
||||
|
||||
- (void)reload {
|
||||
self.loadAnchor = -1;
|
||||
[self.itemViewIds.allValues forEach:^(NSString *obj) {
|
||||
[self removeSubModel:obj];
|
||||
}];
|
||||
[self.itemViewIds removeAllObjects];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.rowCount = self.itemCount + (self.loadMore ? 1 : 0);
|
||||
[self.view reloadData];
|
||||
});
|
||||
}
|
||||
@end
|
||||
|
@ -2507,6 +2507,9 @@ var List = /** @class */ (function (_super) {
|
||||
this.cachedViews.clear();
|
||||
this.itemCount = 0;
|
||||
};
|
||||
List.prototype.reload = function (context) {
|
||||
return this.nativeChannel(context, 'reload')();
|
||||
};
|
||||
List.prototype.getItem = function (itemIdx) {
|
||||
var view = this.renderItem(itemIdx);
|
||||
view.superview = this;
|
||||
|
@ -1893,6 +1893,9 @@ class List extends Superview {
|
||||
this.cachedViews.clear();
|
||||
this.itemCount = 0;
|
||||
}
|
||||
reload(context) {
|
||||
return this.nativeChannel(context, 'reload')();
|
||||
}
|
||||
getItem(itemIdx) {
|
||||
let view = this.renderItem(itemIdx);
|
||||
view.superview = this;
|
||||
|
@ -3423,6 +3423,9 @@ class List extends Superview {
|
||||
this.cachedViews.clear();
|
||||
this.itemCount = 0;
|
||||
}
|
||||
reload(context) {
|
||||
return this.nativeChannel(context, 'reload')();
|
||||
}
|
||||
getItem(itemIdx) {
|
||||
let view = this.renderItem(itemIdx);
|
||||
view.superview = this;
|
||||
|
1
doric-js/index.d.ts
vendored
1
doric-js/index.d.ts
vendored
@ -1040,6 +1040,7 @@ declare module "doric" {
|
||||
*/
|
||||
findCompletelyVisibleItems(context: BridgeContext): Promise<number[]>;
|
||||
reset(): void;
|
||||
reload(context: BridgeContext): Promise<void>;
|
||||
private getItem;
|
||||
private renderBunchedItems;
|
||||
toModel(): NativeViewModel;
|
||||
|
1
doric-js/lib/src/widget/list.d.ts
vendored
1
doric-js/lib/src/widget/list.d.ts
vendored
@ -54,6 +54,7 @@ export declare class List extends Superview {
|
||||
*/
|
||||
findCompletelyVisibleItems(context: BridgeContext): Promise<number[]>;
|
||||
reset(): void;
|
||||
reload(context: BridgeContext): Promise<void>;
|
||||
private getItem;
|
||||
private renderBunchedItems;
|
||||
toModel(): NativeViewModel;
|
||||
|
@ -71,6 +71,9 @@ export class List extends Superview {
|
||||
this.cachedViews.clear();
|
||||
this.itemCount = 0;
|
||||
}
|
||||
reload(context) {
|
||||
return this.nativeChannel(context, 'reload')();
|
||||
}
|
||||
getItem(itemIdx) {
|
||||
let view = this.renderItem(itemIdx);
|
||||
view.superview = this;
|
||||
|
@ -116,6 +116,11 @@ export class List extends Superview {
|
||||
this.cachedViews.clear()
|
||||
this.itemCount = 0
|
||||
}
|
||||
|
||||
reload(context: BridgeContext) {
|
||||
return this.nativeChannel(context, 'reload')() as Promise<void>
|
||||
}
|
||||
|
||||
private getItem(itemIdx: number) {
|
||||
let view = this.renderItem(itemIdx)
|
||||
view.superview = this
|
||||
|
3
doric-web/dist/index.js
vendored
3
doric-web/dist/index.js
vendored
@ -3500,6 +3500,9 @@ class List extends Superview {
|
||||
this.cachedViews.clear();
|
||||
this.itemCount = 0;
|
||||
}
|
||||
reload(context) {
|
||||
return this.nativeChannel(context, 'reload')();
|
||||
}
|
||||
getItem(itemIdx) {
|
||||
let view = this.renderItem(itemIdx);
|
||||
view.superview = this;
|
||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user