mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-01-09 09:03:52 +01:00
Applying changes of LabelWidthCalculator to LabelsAdapter. (#398)
Trying to find a compromise. make them great again ;) Applying changes of LabelWidthCalculator to LabelsAdapter. Co-authored-by: opyale <example@example.com> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/398 Reviewed-by: 6543 <6543@noreply.gitea.io> Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
parent
3a524c9f5d
commit
4123e03f7d
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -109,7 +110,6 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Labels currentItem = labelsList.get(position);
|
||||
int width = 33;
|
||||
|
||||
holder.labelTitle.setText(currentItem.getName());
|
||||
holder.labelId.setText(String.valueOf(currentItem.getId()));
|
||||
@ -117,35 +117,24 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
String labelName = currentItem.getName();
|
||||
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
//.useFont(Typeface.DEFAULT)
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.bold()
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(40)
|
||||
.width(LabelWidthCalculator.customWidth(getMaxLabelLength()))
|
||||
.height(65)
|
||||
.fontSize(35)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, 40, 20))
|
||||
.height(55)
|
||||
.endConfig()
|
||||
.buildRoundRect(labelName, color, 10);
|
||||
|
||||
holder.labelsView.setImageDrawable(drawable);
|
||||
|
||||
}
|
||||
|
||||
private int getMaxLabelLength() {
|
||||
|
||||
for(int i = 0; i < labelsList.size(); i++) {
|
||||
|
||||
Labels labelItem = labelsList.get(i);
|
||||
labelsArray.add(labelItem.getName().length());
|
||||
|
||||
}
|
||||
|
||||
return Collections.max(labelsArray);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return labelsList.size();
|
||||
|
Loading…
Reference in New Issue
Block a user