mirror of https://github.com/M66B/FairEmail.git
parent
5483c25c9c
commit
81f9547402
@ -0,0 +1,52 @@
|
||||
package eu.faircode.email;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AdapterIdentitySelect extends ArrayAdapter<TupleIdentityEx> {
|
||||
private Context context;
|
||||
private List<TupleIdentityEx> identities;
|
||||
|
||||
AdapterIdentitySelect(@NonNull Context context, List<TupleIdentityEx> identities) {
|
||||
super(context, 0, identities);
|
||||
this.context = context;
|
||||
this.identities = identities;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
return getLayout(position, convertView, parent, R.layout.spinner_item2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getLayout(position, convertView, parent, R.layout.spinner_item2_dropdown);
|
||||
}
|
||||
|
||||
View getLayout(int position, View convertView, ViewGroup parent, int resid) {
|
||||
View view = LayoutInflater.from(context).inflate(resid, parent, false);
|
||||
|
||||
TupleIdentityEx identity = identities.get(position);
|
||||
|
||||
View vwColor = view.findViewById(R.id.vwColor);
|
||||
TextView text1 = view.findViewById(android.R.id.text1);
|
||||
TextView text2 = view.findViewById(android.R.id.text2);
|
||||
|
||||
vwColor.setBackgroundColor(identity.color == null ? Color.TRANSPARENT : identity.color);
|
||||
text1.setText(identity.accountName + "/" + identity.getDisplayName() + (identity.primary ? " ★" : ""));
|
||||
text2.setText(identity.email);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue