mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
Extend CI workflows (-> https://codeberg.org/gitnex/GitNex/issues/1099) 1. pull translations and push them again on every pull @mmarif this needs the secrets and `BOT_TOKEN` the code for this comes from tea4j-autodeploy 2. add a **template** for a check workflow which only does some static checks right now. It is disabled because it requires some investigation and discussion on how we should deal with these issues. The checks are currently (if we would enable it): 1. check code style and formatting according to the project file in `.idea/` 2. make sure every Java file has an `@author` annotation I would wait until you reviewed with enabling them because we have to reformat all the files which results in changes with a few thousand changed lines (tried this once). Closes https://codeberg.org/gitnex/GitNex/issues/141 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1155 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
142 lines
4 KiB
Java
142 lines
4 KiB
Java
package org.mian.gitnex.adapters;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.text.Html;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.CheckBox;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import org.gitnex.tea4j.v2.models.User;
|
|
import org.mian.gitnex.R;
|
|
import org.mian.gitnex.clients.PicassoService;
|
|
import org.mian.gitnex.helpers.AppUtil;
|
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
|
import java.util.ArrayList;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author M M Arif
|
|
*/
|
|
|
|
public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> {
|
|
|
|
private final Context context;
|
|
private final List<User> assigneesList;
|
|
private List<String> assigneesStrings = new ArrayList<>();
|
|
private List<String> currentAssignees;
|
|
|
|
private final AssigneesListAdapterListener assigneesListener;
|
|
|
|
public interface AssigneesListAdapterListener {
|
|
|
|
void assigneesInterface(List<String> data);
|
|
}
|
|
|
|
public AssigneesListAdapter(Context ctx, List<User> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
|
|
|
this.context = ctx;
|
|
this.assigneesList = dataMain;
|
|
this.assigneesListener = assigneesListener;
|
|
this.currentAssignees = currentAssignees;
|
|
}
|
|
|
|
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
private final CheckBox assigneesSelection;
|
|
private final TextView assigneesName;
|
|
private final ImageView assigneesAvatar;
|
|
|
|
private AssigneesViewHolder(View itemView) {
|
|
|
|
super(itemView);
|
|
this.setIsRecyclable(false);
|
|
|
|
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
|
assigneesName = itemView.findViewById(R.id.assigneesName);
|
|
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
|
}
|
|
}
|
|
|
|
@NonNull
|
|
@Override
|
|
public AssigneesListAdapter.AssigneesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_assignees_list, parent, false);
|
|
return new AssigneesListAdapter.AssigneesViewHolder(v);
|
|
}
|
|
|
|
@Override
|
|
public void onBindViewHolder(@NonNull AssigneesListAdapter.AssigneesViewHolder holder, int position) {
|
|
|
|
User currentItem = assigneesList.get(position);
|
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
|
|
|
if(currentItem.getFullName().equals("")) {
|
|
|
|
holder.assigneesName.setText(currentItem.getLogin());
|
|
}
|
|
else {
|
|
|
|
holder.assigneesName.setText(Html.fromHtml(currentItem.getFullName()));
|
|
}
|
|
PicassoService
|
|
.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
|
|
|
for(int i = 0; i < assigneesList.size(); i++) {
|
|
|
|
if(assigneesStrings.contains(currentItem.getLogin())) {
|
|
|
|
holder.assigneesSelection.setChecked(true);
|
|
}
|
|
}
|
|
|
|
currentAssignees = new ArrayList<>(new LinkedHashSet<>(currentAssignees));
|
|
|
|
for(int i = 0; i < currentAssignees.size(); i++) {
|
|
|
|
if(currentAssignees.contains(currentItem.getLogin())) {
|
|
|
|
holder.assigneesSelection.setChecked(true);
|
|
assigneesStrings.add(currentAssignees.get(i));
|
|
}
|
|
}
|
|
|
|
assigneesListener.assigneesInterface(assigneesStrings);
|
|
|
|
holder.assigneesSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
|
|
if(isChecked) {
|
|
|
|
assigneesStrings.add(currentItem.getLogin());
|
|
}
|
|
else {
|
|
|
|
assigneesStrings.remove(currentItem.getLogin());
|
|
}
|
|
|
|
assigneesListener.assigneesInterface(assigneesStrings);
|
|
});
|
|
|
|
assigneesStrings = new ArrayList<>(new LinkedHashSet<>(assigneesStrings));
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
|
|
return assigneesList.size();
|
|
}
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
public void updateList(List<String> list) {
|
|
|
|
currentAssignees = list;
|
|
notifyDataSetChanged();
|
|
}
|
|
}
|