fix(icon): 简化图标选择器,去掉分页逻辑调试渲染
问题:弹窗能打开但网格内容为空。 修复:暂时去掉动态分页/页面大小计算,固定 4 列直接渲染所有图标。 保留搜索和分类标签功能。
This commit is contained in:
@@ -4036,25 +4036,12 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
||||
grid.removeAllViews();
|
||||
var q = String(searchEt.getText() || "");
|
||||
var matched = filterCatalog(q, popupState.activeTab);
|
||||
var size = popupState.pageSize;
|
||||
if (size <= 0) {
|
||||
grid.post(new java.lang.Runnable({ run: function() {
|
||||
resolvePageSize(grid.getWidth(), grid.getHeight());
|
||||
renderGrid();
|
||||
}}));
|
||||
statusTv.setText("正在计算布局...");
|
||||
return;
|
||||
}
|
||||
var totalPages = Math.max(1, Math.ceil(matched.length / size));
|
||||
if (popupState.currentPage >= totalPages) popupState.currentPage = totalPages - 1;
|
||||
if (popupState.currentPage < 0) popupState.currentPage = 0;
|
||||
var start = popupState.currentPage * size;
|
||||
var pageItems = matched.slice(start, start + size);
|
||||
|
||||
statusTv.setText("共 " + matched.length + " 个,第 " + (popupState.currentPage + 1) + "/" + totalPages + " 页,每页 " + size + " 个");
|
||||
pageInfo.setText((popupState.currentPage + 1) + " / " + totalPages);
|
||||
// 调试:直接显示所有匹配图标,不分页
|
||||
statusTv.setText("共 " + matched.length + " 个图标");
|
||||
pageInfo.setText("-");
|
||||
|
||||
if (pageItems.length === 0) {
|
||||
if (matched.length === 0) {
|
||||
var emptyTv = new android.widget.TextView(context);
|
||||
emptyTv.setText("未找到匹配的图标");
|
||||
emptyTv.setTextColor(subTextColor);
|
||||
@@ -4065,11 +4052,12 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cols = popupState.pageCols;
|
||||
// 固定 4 列,不计算动态布局
|
||||
var cols = 4;
|
||||
grid.setColumnCount(cols);
|
||||
|
||||
var idx;
|
||||
for (idx = 0; idx < pageItems.length; idx++) {
|
||||
for (idx = 0; idx < matched.length; idx++) {
|
||||
(function(item) {
|
||||
var cell = new android.widget.LinearLayout(context);
|
||||
cell.setOrientation(android.widget.LinearLayout.VERTICAL);
|
||||
@@ -4086,13 +4074,10 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
||||
if (dr) {
|
||||
iv.setImageDrawable(dr);
|
||||
} else {
|
||||
// 图\u6807\u83b7\u53d6\u5931\u8d25,\u663e\u793a\u6587\u5b57\u5360\u4f4d\u7b26
|
||||
try {
|
||||
var placeholder = new android.graphics.drawable.GradientDrawable();
|
||||
placeholder.setColor(self.withAlpha(subTextColor, 0.1));
|
||||
placeholder.setCornerRadius(self.dp(6));
|
||||
iv.setBackground(placeholder);
|
||||
} catch(e) {}
|
||||
var placeholder = new android.graphics.drawable.GradientDrawable();
|
||||
placeholder.setColor(self.withAlpha(subTextColor, 0.1));
|
||||
placeholder.setCornerRadius(self.dp(6));
|
||||
iv.setBackground(placeholder);
|
||||
}
|
||||
} catch(e) {}
|
||||
cell.addView(iv);
|
||||
@@ -4123,14 +4108,14 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
||||
}));
|
||||
|
||||
var cellLp = new android.widget.GridLayout.LayoutParams();
|
||||
cellLp.width = popupState.cellWidthPx || self.dp(72);
|
||||
cellLp.width = self.dp(72);
|
||||
cellLp.height = android.widget.GridLayout.LayoutParams.WRAP_CONTENT;
|
||||
cell.setLayoutParams(cellLp);
|
||||
grid.addView(cell);
|
||||
})(pageItems[idx]);
|
||||
})(matched[idx]);
|
||||
}
|
||||
} catch(eRender) {
|
||||
safeLog(self.L, 'e', "renderShortXIconGrid err=" + String(eRender));
|
||||
safeLog(self.L, 'e', "renderGrid err=" + String(eRender));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4144,8 +4129,7 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
||||
afterTextChanged: function() {}
|
||||
}));
|
||||
|
||||
// 直接计算默认页面大小并渲染,不依赖 grid.post
|
||||
resolvePageSize(self.dp(300), self.dp(360));
|
||||
// 直接渲染,不依赖分页
|
||||
renderGrid();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user