Minimal-diff change to fix NPE.

Fixes #2623

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-03-08 11:37:18 -07:00
parent db2c7fabe1
commit c05aca19ae
3 changed files with 24 additions and 7 deletions

View File

@ -52,7 +52,7 @@ public class ConversationFragment extends ListFragment
private static final String TAG = ConversationFragment.class.getSimpleName();
private final ActionModeCallback actionModeCallback = new ActionModeCallback();
private final SelectionClickListener selectionClickListener = new SelectionClickListener();
private final SelectionClickListener selectionClickListener = new ConversationFragmentSelectionClickListener();
private ConversationFragmentListener listener;
@ -289,8 +289,11 @@ public class ConversationFragment extends ListFragment
public void setComposeText(String text);
}
public class SelectionClickListener
implements AdapterView.OnItemLongClickListener, AdapterView.OnItemClickListener
public interface SelectionClickListener extends
AdapterView.OnItemLongClickListener, AdapterView.OnItemClickListener {}
private class ConversationFragmentSelectionClickListener
implements SelectionClickListener
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

View File

@ -29,6 +29,7 @@ import android.os.Handler;
import android.os.Message;
import android.provider.ContactsContract;
import android.provider.ContactsContract.QuickContact;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@ -162,8 +163,10 @@ public class ConversationItem extends LinearLayout {
if (mmsThumbnail != null) mmsThumbnail.setOnLongClickListener(new MultiSelectLongClickListener());
}
public void set(MasterSecret masterSecret, MessageRecord messageRecord,
Set<MessageRecord> batchSelected, SelectionClickListener selectionClickListener,
public void set(@NonNull MasterSecret masterSecret,
@NonNull MessageRecord messageRecord,
@NonNull Set<MessageRecord> batchSelected,
@NonNull SelectionClickListener selectionClickListener,
boolean groupThread, boolean pushDestination)
{
this.masterSecret = masterSecret;

View File

@ -18,7 +18,6 @@ package org.thoughtcrime.securesms;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Paint;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
@ -28,6 +27,7 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
@ -52,6 +52,9 @@ import java.text.SimpleDateFormat;
import java.util.HashSet;
import java.util.LinkedList;
/**
* @author Jake McGinty
*/
public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity implements LoaderCallbacks<Cursor> {
private final static String TAG = MessageDetailsActivity.class.getSimpleName();
@ -148,7 +151,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
toFromRes = R.string.message_details_header__from;
}
toFrom.setText(toFromRes);
conversationItem.set(masterSecret, messageRecord, new HashSet<MessageRecord>(), null,
conversationItem.set(masterSecret, messageRecord, new HashSet<MessageRecord>(), new NullSelectionListener(),
recipients != messageRecord.getRecipients(),
DirectoryHelper.isPushDestination(this, recipients));
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, masterSecret, messageRecord,
@ -278,6 +281,14 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
metadataContainer.setVisibility(View.VISIBLE);
}
}
}
private static class NullSelectionListener implements ConversationFragment.SelectionClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {}
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
return false;
}
}
}