Skip to content

Commit

Permalink
feat: respect liquid_keyword/single_width in trime.yaml
Browse files Browse the repository at this point in the history
Do not depend on width in `dimens.xml`.
  • Loading branch information
goofyz committed Jan 16, 2024
1 parent db63dab commit 81b1a51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.blankj.utilcode.util.ScreenUtils
import com.blankj.utilcode.util.SizeUtils
import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayoutManager
import com.google.android.flexbox.JustifyContent
import com.osfans.trime.R
import com.osfans.trime.core.CandidateListItem
import com.osfans.trime.core.Rime
import com.osfans.trime.data.SymbolHistory
Expand Down Expand Up @@ -107,9 +107,8 @@ class LiquidKeyboard(private val context: Context) : ClipboardHelper.OnClipboard
private fun initFixData(i: Int) {
val tabTag = TabManager.getTag(i)

val itemWidth = context.resources.getDimensionPixelSize(R.dimen.simple_item_size)
val itemMargin = context.resources.getDimensionPixelSize(R.dimen.simple_key_margin_x)
val columnCount = ScreenUtils.getScreenWidth() / (itemWidth + itemMargin)
val itemWidth = SizeUtils.dp2px(theme.liquid.getFloat("single_width"))
val columnCount = ScreenUtils.getAppScreenWidth() / itemWidth
val simpleAdapter =
SimpleAdapter(theme, columnCount).apply {
// 列表适配器的点击监听事件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.osfans.trime.R;
import com.blankj.utilcode.util.SizeUtils;
import com.osfans.trime.data.theme.FontManager;
import com.osfans.trime.data.theme.Theme;
import com.osfans.trime.databinding.SimpleItemOneBinding;
Expand Down Expand Up @@ -66,7 +66,7 @@ public long getItemId(int position) {
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final SimpleItemRowBinding binding =
SimpleItemRowBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
int size = parent.getResources().getDimensionPixelSize(R.dimen.simple_item_size);
int size = SizeUtils.dp2px(theme.liquid.getFloat("single_width"));
ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(size, size);

List<SimpleItemOneBinding> bindings = new ArrayList<>();
Expand Down

0 comments on commit 81b1a51

Please sign in to comment.