Remove header and footer support,this is unnecessary
This commit is contained in:
@@ -40,8 +40,6 @@ import pub.doric.shader.ViewNode;
|
||||
*/
|
||||
class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
private static final int TYPE_LOAD_MORE = -1;
|
||||
private static final int TYPE_HEADER = -2;
|
||||
private static final int TYPE_FOOTER = -3;
|
||||
private final FlowLayoutNode flowLayoutNode;
|
||||
String renderItemFuncId;
|
||||
int itemCount = 0;
|
||||
@@ -70,10 +68,8 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject());
|
||||
}
|
||||
if (holder.flowLayoutItemNode.fullSpan
|
||||
|| (this.flowLayoutNode.hasHeader() && position == 0)
|
||||
|| (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1)
|
||||
|| this.flowLayoutNode.loadMore
|
||||
&& position == this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
|
||||
&& position >= this.itemCount) {
|
||||
StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
holder.itemView.getLayoutParams().height
|
||||
@@ -82,7 +78,7 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
holder.itemView.setLayoutParams(layoutParams);
|
||||
}
|
||||
if (this.flowLayoutNode.loadMore
|
||||
&& position == this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)
|
||||
&& position >= this.itemCount
|
||||
&& !TextUtils.isEmpty(this.flowLayoutNode.onLoadMoreFuncId)) {
|
||||
callLoadMore();
|
||||
}
|
||||
@@ -90,23 +86,12 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.itemCount
|
||||
+ (this.flowLayoutNode.loadMore ? 1 : 0)
|
||||
+ (this.flowLayoutNode.hasHeader() ? 1 : 0)
|
||||
+ (this.flowLayoutNode.hasFooter() ? 1 : 0);
|
||||
return this.itemCount + (this.flowLayoutNode.loadMore ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (this.flowLayoutNode.hasHeader() && position == 0) {
|
||||
return TYPE_HEADER;
|
||||
}
|
||||
|
||||
if (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1) {
|
||||
return TYPE_FOOTER;
|
||||
}
|
||||
|
||||
if (position >= this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
|
||||
if (position >= this.itemCount) {
|
||||
return TYPE_LOAD_MORE;
|
||||
}
|
||||
JSValue value = getItemModel(position);
|
||||
@@ -119,20 +104,9 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
}
|
||||
|
||||
private JSValue getItemModel(int position) {
|
||||
if (this.flowLayoutNode.hasHeader() && position == 0) {
|
||||
return this.flowLayoutNode.getSubModel(this.flowLayoutNode.headerViewId);
|
||||
}
|
||||
|
||||
if (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1) {
|
||||
return this.flowLayoutNode.getSubModel(this.flowLayoutNode.footerViewId);
|
||||
}
|
||||
|
||||
if (position >= this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
|
||||
if (position >= this.itemCount) {
|
||||
return this.flowLayoutNode.getSubModel(this.flowLayoutNode.loadMoreViewId);
|
||||
}
|
||||
if (this.flowLayoutNode.hasHeader()) {
|
||||
position--;
|
||||
}
|
||||
String id = itemValues.get(position);
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
AsyncResult<JSDecoder> asyncResult = flowLayoutNode.pureCallJSResponse(
|
||||
|
@@ -332,21 +332,6 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
||||
}
|
||||
|
||||
private int calibratePosition(int position) {
|
||||
if (hasHeader() && position == 0) {
|
||||
return -11;
|
||||
}
|
||||
if (hasFooter() && position == this.itemCount
|
||||
+ (this.loadMore ? 1 : 0)
|
||||
+ (this.hasHeader() ? 1 : 0)
|
||||
+ (this.hasFooter() ? 1 : 0) - 1) {
|
||||
return -12;
|
||||
}
|
||||
if (position >= this.itemCount + (this.hasHeader() ? 1 : 0)) {
|
||||
return -10;
|
||||
}
|
||||
if (this.hasHeader()) {
|
||||
return position - 1;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -377,12 +362,4 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
boolean hasHeader() {
|
||||
return !TextUtils.isEmpty(this.headerViewId);
|
||||
}
|
||||
|
||||
boolean hasFooter() {
|
||||
return !TextUtils.isEmpty(this.footerViewId);
|
||||
}
|
||||
}
|
||||
|
@@ -40,8 +40,6 @@ import pub.doric.shader.ViewNode;
|
||||
*/
|
||||
class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
private static final int TYPE_LOAD_MORE = -1;
|
||||
private static final int TYPE_HEADER = -2;
|
||||
private static final int TYPE_FOOTER = -3;
|
||||
private final ListNode listNode;
|
||||
|
||||
ListAdapter(ListNode listNode) {
|
||||
@@ -68,7 +66,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
|
||||
}
|
||||
if (this.listNode.loadMore
|
||||
&& position == this.itemCount + (this.listNode.hasHeader() ? 1 : 0)
|
||||
&& position >= this.itemCount
|
||||
&& !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) {
|
||||
callLoadMore();
|
||||
}
|
||||
@@ -76,23 +74,12 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.itemCount
|
||||
+ (this.listNode.loadMore ? 1 : 0)
|
||||
+ (this.listNode.hasHeader() ? 1 : 0)
|
||||
+ (this.listNode.hasFooter() ? 1 : 0);
|
||||
return this.itemCount + (this.listNode.loadMore ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (this.listNode.hasHeader() && position == 0) {
|
||||
return TYPE_HEADER;
|
||||
}
|
||||
|
||||
if (this.listNode.hasFooter() && position == this.getItemCount() - 1) {
|
||||
return TYPE_FOOTER;
|
||||
}
|
||||
|
||||
if (position >= this.itemCount + (this.listNode.hasHeader() ? 1 : 0)) {
|
||||
if (position >= this.itemCount) {
|
||||
return TYPE_LOAD_MORE;
|
||||
}
|
||||
|
||||
@@ -106,20 +93,9 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
}
|
||||
|
||||
private JSValue getItemModel(int position) {
|
||||
if (this.listNode.hasHeader() && position == 0) {
|
||||
return this.listNode.getSubModel(this.listNode.headerViewId);
|
||||
}
|
||||
|
||||
if (this.listNode.hasFooter() && position == this.getItemCount() - 1) {
|
||||
return this.listNode.getSubModel(this.listNode.footerViewId);
|
||||
}
|
||||
|
||||
if (position >= this.itemCount + (this.listNode.hasHeader() ? 1 : 0)) {
|
||||
if (position >= this.itemCount) {
|
||||
return this.listNode.getSubModel(this.listNode.loadMoreViewId);
|
||||
}
|
||||
if (this.listNode.hasHeader()) {
|
||||
position--;
|
||||
}
|
||||
String id = listNode.itemValues.get(position);
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
int batchCount = listNode.batchCount;
|
||||
|
@@ -65,8 +65,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
SparseArray<String> itemValues = new SparseArray<>();
|
||||
boolean loadMore = false;
|
||||
String loadMoreViewId;
|
||||
String headerViewId;
|
||||
String footerViewId;
|
||||
private final Set<DoricScrollChangeListener> listeners = new HashSet<>();
|
||||
private String onScrollFuncId;
|
||||
private String onScrollEndFuncId;
|
||||
@@ -247,12 +245,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "header":
|
||||
this.headerViewId = prop.asString().value();
|
||||
break;
|
||||
case "footer":
|
||||
this.footerViewId = prop.asString().value();
|
||||
break;
|
||||
default:
|
||||
super.blend(view, name, prop);
|
||||
break;
|
||||
@@ -304,21 +296,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
}
|
||||
|
||||
private int calibratePosition(int position) {
|
||||
if (hasHeader() && position == 0) {
|
||||
return -11;
|
||||
}
|
||||
if (hasFooter() && position == this.itemCount
|
||||
+ (this.loadMore ? 1 : 0)
|
||||
+ (this.hasHeader() ? 1 : 0)
|
||||
+ (this.hasFooter() ? 1 : 0) - 1) {
|
||||
return -12;
|
||||
}
|
||||
if (position >= this.itemCount + (this.hasHeader() ? 1 : 0)) {
|
||||
return -10;
|
||||
}
|
||||
if (this.hasHeader()) {
|
||||
return position - 1;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -370,12 +347,4 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
mView.scrollToPosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasHeader() {
|
||||
return !TextUtils.isEmpty(this.headerViewId);
|
||||
}
|
||||
|
||||
boolean hasFooter() {
|
||||
return !TextUtils.isEmpty(this.footerViewId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user