Click on email contact pictures to select them
This commit is contained in:
@@ -24,11 +24,17 @@ import android.widget.TextView;
|
||||
public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
private final LayoutInflater mInflater;
|
||||
private SparseBooleanArray mSelectedEmails;
|
||||
private EmailSelector mSelector;
|
||||
|
||||
public EmailListAdapter(Context context) {
|
||||
public interface EmailSelector {
|
||||
public void select(int position);
|
||||
}
|
||||
|
||||
public EmailListAdapter(Context context, EmailSelector selector) {
|
||||
super(context, android.R.layout.simple_list_item_2);
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mSelectedEmails = new SparseBooleanArray();
|
||||
mSelector = selector;
|
||||
}
|
||||
|
||||
public void setData(List<Email> emails) {
|
||||
@@ -43,7 +49,7 @@ public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = mInflater.inflate(R.layout.listitem_email, parent, false);
|
||||
Email email = getItem(position);
|
||||
final Email email = getItem(position);
|
||||
|
||||
ImageView picture = (ImageView) v.findViewById(R.id.contact_picture);
|
||||
TextView subject = (TextView) v.findViewById(R.id.email_subject);
|
||||
@@ -51,6 +57,12 @@ public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
TextView content = (TextView) v.findViewById(R.id.email_content);
|
||||
TextView sent = (TextView) v.findViewById(R.id.email_sent);
|
||||
|
||||
picture.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
mSelector.select(getPosition(email));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
String fromAddress = email.getOneFromAddress();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.List;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
import i2p.bote.I2PBote;
|
||||
import i2p.bote.android.util.BetterAsyncTaskLoader;
|
||||
import i2p.bote.android.util.BoteHelper;
|
||||
@@ -43,7 +42,8 @@ import android.widget.TextView;
|
||||
|
||||
public class EmailListFragment extends ListFragment implements
|
||||
LoaderManager.LoaderCallbacks<List<Email>>,
|
||||
MoveToDialogFragment.MoveToDialogListener {
|
||||
MoveToDialogFragment.MoveToDialogListener,
|
||||
EmailListAdapter.EmailSelector {
|
||||
public static final String FOLDER_NAME = "folder_name";
|
||||
|
||||
private static final int EMAIL_LIST_LOADER = 1;
|
||||
@@ -93,7 +93,7 @@ public class EmailListFragment extends ListFragment implements
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mAdapter = new EmailListAdapter(getActivity());
|
||||
mAdapter = new EmailListAdapter(getActivity(), this);
|
||||
String folderName = getArguments().getString(FOLDER_NAME);
|
||||
mFolder = BoteHelper.getMailFolder(folderName);
|
||||
|
||||
@@ -433,4 +433,10 @@ public class EmailListFragment extends ListFragment implements
|
||||
getActivity().setTitle(
|
||||
BoteHelper.getFolderDisplayName(getActivity(), mFolder));
|
||||
}
|
||||
|
||||
// EmailListAdapter.EmailSelector
|
||||
|
||||
public void select(int position) {
|
||||
onListItemSelect(position);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user