Messaging: Further code improvements
* Remove redundant casts * getParcelable(ArrayList|Exra) without class argument is deprecated * ViewPager.setOnPageChangeListener -> addOnPageChangeListener * RecyclerView.setOnScrollListener -> addOnScrollListener * Remove unused initializations * Remove unused code Change-Id: I21beb6c90c675a4f2cfd7e3d5ebbd18b745f5911
This commit is contained in:
@@ -433,7 +433,7 @@ public class BugleDatabaseOperations {
|
||||
Assert.isNotMainThread();
|
||||
dbWrapper.beginTransaction();
|
||||
boolean conversationDeleted = false;
|
||||
boolean conversationMessagesDeleted = false;
|
||||
boolean conversationMessagesDeleted;
|
||||
try {
|
||||
// Delete existing messages
|
||||
if (cutoffTimestamp == Long.MAX_VALUE) {
|
||||
@@ -1558,7 +1558,7 @@ public class BugleDatabaseOperations {
|
||||
public static ParticipantData getOrCreateSelf(final DatabaseWrapper dbWrapper,
|
||||
final int subId) {
|
||||
Assert.isNotMainThread();
|
||||
ParticipantData participant = null;
|
||||
ParticipantData participant;
|
||||
dbWrapper.beginTransaction();
|
||||
try {
|
||||
final ParticipantData shell = ParticipantData.getSelfParticipant(subId);
|
||||
@@ -1583,8 +1583,8 @@ public class BugleDatabaseOperations {
|
||||
Assert.isNotMainThread();
|
||||
Assert.isTrue(dbWrapper.getDatabase().inTransaction());
|
||||
int subId = ParticipantData.OTHER_THAN_SELF_SUB_ID;
|
||||
String participantId = null;
|
||||
String canonicalRecipient = null;
|
||||
String participantId;
|
||||
String canonicalRecipient;
|
||||
if (participant.isSelf()) {
|
||||
subId = participant.getSubId();
|
||||
canonicalRecipient = getCanonicalRecipientFromSubId(subId);
|
||||
|
||||
@@ -377,7 +377,7 @@ public abstract class MessageNotificationState extends NotificationState {
|
||||
@Override
|
||||
protected NotificationCompat.Style build(final Builder builder) {
|
||||
builder.setContentTitle(mTitle);
|
||||
NotificationCompat.InboxStyle inboxStyle = null;
|
||||
NotificationCompat.InboxStyle inboxStyle;
|
||||
inboxStyle = new NotificationCompat.InboxStyle(builder);
|
||||
|
||||
final Context context = Factory.get().getApplicationContext();
|
||||
@@ -507,7 +507,7 @@ public abstract class MessageNotificationState extends NotificationState {
|
||||
builder.setContentTitle(mTitle)
|
||||
.setTicker(getTicker());
|
||||
|
||||
NotificationCompat.Style notifStyle = null;
|
||||
NotificationCompat.Style notifStyle;
|
||||
final ConversationLineInfo convInfo = mConvList.mConvInfos.get(0);
|
||||
final List<NotificationLineInfo> lineInfos = convInfo.mLineInfos;
|
||||
final int messageCount = lineInfos.size();
|
||||
|
||||
@@ -446,7 +446,7 @@ public class MessagingContentProvider extends ContentProvider {
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
// This is going to wind up calling into createDatabase() below.
|
||||
mDatabaseHelper = (DatabaseHelper) getDatabase();
|
||||
mDatabaseHelper = getDatabase();
|
||||
// We cannot initialize mDatabaseWrapper yet as the Factory may not be initialized
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class NoConfirmationSmsSendService extends IntentService {
|
||||
if (TextUtils.isEmpty(conversationId)) {
|
||||
InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject);
|
||||
} else {
|
||||
MessageData messageData = null;
|
||||
MessageData messageData;
|
||||
if (requiresMms) {
|
||||
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
||||
LogUtil.v(TAG, "Auto-sending MMS message in conversation: " +
|
||||
|
||||
@@ -243,7 +243,7 @@ public abstract class Action implements Parcelable {
|
||||
* Helper method to generate a unique operation index
|
||||
*/
|
||||
protected static long getActionIdx() {
|
||||
long idx = 0;
|
||||
long idx;
|
||||
synchronized (sLock) {
|
||||
idx = ++sActionIdx;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ActionMonitor {
|
||||
* Return flag to indicate if action is complete
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
boolean complete = false;
|
||||
boolean complete;
|
||||
synchronized (mLock) {
|
||||
complete = (mState == STATE_COMPLETE);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ public class ActionMonitor {
|
||||
*/
|
||||
private void complete(final Action action, final int expectedOldState, final Object result,
|
||||
final boolean succeeded) {
|
||||
ActionCompletedListener completedListener = null;
|
||||
ActionCompletedListener completedListener;
|
||||
synchronized (mLock) {
|
||||
setState(action, expectedOldState, STATE_COMPLETE);
|
||||
completedListener = mCompletedListener;
|
||||
@@ -357,7 +357,7 @@ public class ActionMonitor {
|
||||
*/
|
||||
final void executed(final Action action,
|
||||
final int expectedOldState, final boolean hasBackgroundActions, final Object result) {
|
||||
ActionExecutedListener executedListener = null;
|
||||
ActionExecutedListener executedListener;
|
||||
synchronized (mLock) {
|
||||
if (hasBackgroundActions) {
|
||||
setState(action, expectedOldState, STATE_BACKGROUND_ACTIONS_QUEUED);
|
||||
@@ -432,7 +432,7 @@ public class ActionMonitor {
|
||||
* Find monitor associated with particular action
|
||||
*/
|
||||
private static ActionMonitor lookupActionMonitor(final String actionKey) {
|
||||
ActionMonitor monitor = null;
|
||||
ActionMonitor monitor;
|
||||
synchronized (sActionMonitors) {
|
||||
monitor = sActionMonitors.get(actionKey);
|
||||
}
|
||||
|
||||
@@ -228,11 +228,6 @@ public class ActionServiceImpl extends JobIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onHandleWork(@NonNull final Intent intent) {
|
||||
if (intent == null) {
|
||||
// Shouldn't happen but sometimes does following another crash.
|
||||
LogUtil.w(TAG, "ActionService.onHandleIntent: Called with null intent");
|
||||
return;
|
||||
}
|
||||
final int opcode = intent.getIntExtra(EXTRA_OP_CODE, 0);
|
||||
|
||||
Action action;
|
||||
@@ -240,20 +235,20 @@ public class ActionServiceImpl extends JobIntentService {
|
||||
actionBundle.setClassLoader(getClassLoader());
|
||||
switch(opcode) {
|
||||
case OP_START_ACTION: {
|
||||
action = (Action) actionBundle.getParcelable(BUNDLE_ACTION);
|
||||
action = actionBundle.getParcelable(BUNDLE_ACTION, Action.class);
|
||||
executeAction(action);
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_RECEIVE_BACKGROUND_RESPONSE: {
|
||||
action = (Action) actionBundle.getParcelable(BUNDLE_ACTION);
|
||||
action = actionBundle.getParcelable(BUNDLE_ACTION, Action.class);
|
||||
final Bundle response = intent.getBundleExtra(EXTRA_WORKER_RESPONSE);
|
||||
processBackgroundResponse(action, response);
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_RECEIVE_BACKGROUND_FAILURE: {
|
||||
action = (Action) actionBundle.getParcelable(BUNDLE_ACTION);
|
||||
action = actionBundle.getParcelable(BUNDLE_ACTION, Action.class);
|
||||
processBackgroundFailure(action);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class BackgroundWorkerService extends JobIntentService {
|
||||
*/
|
||||
private void doBackgroundWork(final Action action, final int attempt) {
|
||||
action.markBackgroundWorkStarting();
|
||||
Bundle response = null;
|
||||
Bundle response;
|
||||
try {
|
||||
final LoggingTimer timer = new LoggingTimer(
|
||||
TAG, action.getClass().getSimpleName() + "#doBackgroundWork");
|
||||
|
||||
@@ -237,7 +237,7 @@ public class DownloadMmsAction extends Action implements Parcelable {
|
||||
final Context context = Factory.get().getApplicationContext();
|
||||
final int subId = actionParameters.getInt(KEY_SUB_ID);
|
||||
final String messageId = actionParameters.getString(KEY_MESSAGE_ID);
|
||||
final Uri notificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI);
|
||||
final Uri notificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI, Uri.class);
|
||||
final String subPhoneNumber = actionParameters.getString(KEY_SUB_PHONE_NUMBER);
|
||||
final String transactionId = actionParameters.getString(KEY_TRANSACTION_ID);
|
||||
final String contentLocation = actionParameters.getString(KEY_CONTENT_LOCATION);
|
||||
|
||||
@@ -49,8 +49,8 @@ public class FixupMessageStatusOnStartupAction extends Action implements Parcela
|
||||
// Now mark any messages in active sending or downloading state as inactive
|
||||
final DatabaseWrapper db = DataModel.get().getDatabase();
|
||||
db.beginTransaction();
|
||||
int downloadFailedCnt = 0;
|
||||
int sendFailedCnt = 0;
|
||||
int downloadFailedCnt;
|
||||
int sendFailedCnt;
|
||||
try {
|
||||
// For both sending and downloading messages, let's assume they failed.
|
||||
// For MMS sent/downloaded via platform, the sent/downloaded pending intent
|
||||
|
||||
@@ -97,7 +97,8 @@ public class GetOrCreateConversationAction extends Action implements Parcelable
|
||||
|
||||
// First find the thread id for this list of participants.
|
||||
final ArrayList<ParticipantData> participants =
|
||||
actionParameters.getParcelableArrayList(KEY_PARTICIPANTS_LIST);
|
||||
actionParameters.getParcelableArrayList(KEY_PARTICIPANTS_LIST,
|
||||
ParticipantData.class);
|
||||
BugleDatabaseOperations.sanitizeConversationParticipants(participants);
|
||||
final ArrayList<String> recipients =
|
||||
BugleDatabaseOperations.getRecipientsFromConversationParticipants(participants);
|
||||
|
||||
@@ -120,7 +120,7 @@ public class InsertNewMessageAction extends Action implements Parcelable {
|
||||
*/
|
||||
@Override
|
||||
protected Object executeAction() {
|
||||
MessageData message = actionParameters.getParcelable(KEY_MESSAGE);
|
||||
MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class);
|
||||
if (message == null) {
|
||||
LogUtil.i(TAG, "InsertNewMessageAction: Creating MessageData with provided data");
|
||||
message = createMessage();
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ProcessDeliveryReportAction extends Action implements Parcelable {
|
||||
|
||||
@Override
|
||||
protected Object executeAction() {
|
||||
final Uri smsMessageUri = actionParameters.getParcelable(KEY_URI);
|
||||
final Uri smsMessageUri = actionParameters.getParcelable(KEY_URI, Uri.class);
|
||||
final int status = actionParameters.getInt(KEY_STATUS);
|
||||
|
||||
final DatabaseWrapper db = DataModel.get().getDatabase();
|
||||
|
||||
@@ -98,8 +98,9 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
// This is called when MMS lib API returns via PendingIntent
|
||||
public static void processMessageDownloaded(final int resultCode, final Bundle extras) {
|
||||
final String messageId = extras.getString(DownloadMmsAction.EXTRA_MESSAGE_ID);
|
||||
final Uri contentUri = extras.getParcelable(DownloadMmsAction.EXTRA_CONTENT_URI);
|
||||
final Uri notificationUri = extras.getParcelable(DownloadMmsAction.EXTRA_NOTIFICATION_URI);
|
||||
final Uri contentUri = extras.getParcelable(DownloadMmsAction.EXTRA_CONTENT_URI, Uri.class);
|
||||
final Uri notificationUri = extras.getParcelable(DownloadMmsAction.EXTRA_NOTIFICATION_URI,
|
||||
Uri.class);
|
||||
final String conversationId = extras.getString(DownloadMmsAction.EXTRA_CONVERSATION_ID);
|
||||
final String participantId = extras.getString(DownloadMmsAction.EXTRA_PARTICIPANT_ID);
|
||||
Assert.notNull(messageId);
|
||||
@@ -245,7 +246,7 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
if (downloadedByPlatform) {
|
||||
final int resultCode = actionParameters.getInt(KEY_RESULT_CODE);
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI);
|
||||
final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI, Uri.class);
|
||||
final File downloadedFile = MmsFileProvider.getFile(contentUri);
|
||||
byte[] downloadedData = null;
|
||||
try {
|
||||
@@ -273,7 +274,7 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
if (retrieveConf != null) {
|
||||
// Insert the downloaded MMS into telephony
|
||||
final Uri notificationUri = actionParameters.getParcelable(
|
||||
KEY_NOTIFICATION_URI);
|
||||
KEY_NOTIFICATION_URI, Uri.class);
|
||||
final String subPhoneNumber = actionParameters.getString(
|
||||
KEY_SUB_PHONE_NUMBER);
|
||||
final boolean autoDownload = actionParameters.getBoolean(
|
||||
@@ -313,7 +314,7 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
// In either case, we just need to copy the status to the response bundle.
|
||||
status = actionParameters.getInt(KEY_STATUS);
|
||||
rawStatus = actionParameters.getInt(KEY_RAW_STATUS);
|
||||
mmsUri = actionParameters.getParcelable(KEY_MMS_URI);
|
||||
mmsUri = actionParameters.getParcelable(KEY_MMS_URI, Uri.class);
|
||||
}
|
||||
|
||||
final Bundle response = new Bundle();
|
||||
@@ -335,7 +336,7 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
|
||||
final int status = response.getInt(BUNDLE_REQUEST_STATUS);
|
||||
final int rawStatus = response.getInt(BUNDLE_RAW_TELEPHONY_STATUS);
|
||||
final Uri messageUri = response.getParcelable(BUNDLE_MMS_URI);
|
||||
final Uri messageUri = response.getParcelable(BUNDLE_MMS_URI, Uri.class);
|
||||
final boolean autoDownload = actionParameters.getBoolean(KEY_AUTO_DOWNLOAD);
|
||||
final String messageId = actionParameters.getString(KEY_MESSAGE_ID);
|
||||
|
||||
@@ -411,7 +412,8 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
private MessageData processResult(final int status, final int rawStatus, final Uri mmsUri) {
|
||||
final Context context = Factory.get().getApplicationContext();
|
||||
final String messageId = actionParameters.getString(KEY_MESSAGE_ID);
|
||||
final Uri mmsNotificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI);
|
||||
final Uri mmsNotificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI,
|
||||
Uri.class);
|
||||
final String notificationConversationId = actionParameters.getString(KEY_CONVERSATION_ID);
|
||||
final String notificationParticipantId = actionParameters.getString(KEY_PARTICIPANT_ID);
|
||||
final int statusIfFailed = actionParameters.getInt(KEY_STATUS_IF_FAILED);
|
||||
@@ -432,8 +434,8 @@ public class ProcessDownloadedMmsAction extends Action {
|
||||
mms = MmsUtils.loadMms(mmsUri);
|
||||
}
|
||||
|
||||
boolean messageInFocusedConversation = false;
|
||||
boolean messageInObservableConversation = false;
|
||||
boolean messageInFocusedConversation;
|
||||
boolean messageInObservableConversation;
|
||||
String conversationId = null;
|
||||
MessageData message = null;
|
||||
final DatabaseWrapper db = DataModel.get().getDatabase();
|
||||
|
||||
@@ -306,8 +306,8 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
|
||||
final String selfId) {
|
||||
String toSendMessageId = null;
|
||||
Cursor cursor = null;
|
||||
int sendingCnt = 0;
|
||||
int pendingCnt = 0;
|
||||
int sendingCnt;
|
||||
int pendingCnt;
|
||||
int failedCnt = 0;
|
||||
db.beginTransaction();
|
||||
try {
|
||||
@@ -390,8 +390,8 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
|
||||
final String selfId) {
|
||||
String toDownloadMessageId = null;
|
||||
Cursor cursor = null;
|
||||
int downloadingCnt = 0;
|
||||
int pendingCnt = 0;
|
||||
int downloadingCnt;
|
||||
int pendingCnt;
|
||||
db.beginTransaction();
|
||||
try {
|
||||
// First check if we have any messages already downloading
|
||||
|
||||
@@ -86,13 +86,13 @@ public class ProcessSentMessageAction extends Action {
|
||||
params.putString(KEY_MESSAGE_ID, extras.getString(SendMessageAction.EXTRA_MESSAGE_ID));
|
||||
params.putParcelable(KEY_MESSAGE_URI, messageUri);
|
||||
params.putParcelable(KEY_UPDATED_MESSAGE_URI,
|
||||
extras.getParcelable(SendMessageAction.EXTRA_UPDATED_MESSAGE_URI));
|
||||
extras.getParcelable(SendMessageAction.EXTRA_UPDATED_MESSAGE_URI, Uri.class));
|
||||
params.putInt(KEY_SUB_ID,
|
||||
extras.getInt(SendMessageAction.KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID));
|
||||
params.putInt(KEY_RESULT_CODE, resultCode);
|
||||
params.putInt(KEY_HTTP_STATUS_CODE, extras.getInt(SmsManager.EXTRA_MMS_HTTP_STATUS, 0));
|
||||
params.putParcelable(KEY_CONTENT_URI,
|
||||
extras.getParcelable(SendMessageAction.EXTRA_CONTENT_URI));
|
||||
extras.getParcelable(SendMessageAction.EXTRA_CONTENT_URI, Uri.class));
|
||||
params.putByteArray(KEY_RESPONSE, extras.getByteArray(SmsManager.EXTRA_MMS_DATA));
|
||||
params.putBoolean(KEY_RESPONSE_IMPORTANT,
|
||||
extras.getBoolean(SendMessageAction.EXTRA_RESPONSE_IMPORTANT));
|
||||
@@ -128,8 +128,9 @@ public class ProcessSentMessageAction extends Action {
|
||||
protected Object executeAction() {
|
||||
final Context context = Factory.get().getApplicationContext();
|
||||
final String messageId = actionParameters.getString(KEY_MESSAGE_ID);
|
||||
final Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI);
|
||||
final Uri updatedMessageUri = actionParameters.getParcelable(KEY_UPDATED_MESSAGE_URI);
|
||||
final Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI, Uri.class);
|
||||
final Uri updatedMessageUri = actionParameters.getParcelable(KEY_UPDATED_MESSAGE_URI,
|
||||
Uri.class);
|
||||
final boolean isSms = actionParameters.getBoolean(KEY_SMS);
|
||||
final boolean sentByPlatform = actionParameters.getBoolean(KEY_SENT_BY_PLATFORM);
|
||||
|
||||
@@ -140,7 +141,7 @@ public class ProcessSentMessageAction extends Action {
|
||||
|
||||
if (sentByPlatform) {
|
||||
// Delete temporary file backing the contentUri passed to MMS service
|
||||
final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI);
|
||||
final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI, Uri.class);
|
||||
Assert.isTrue(contentUri != null);
|
||||
final File tempFile = MmsFileProvider.getFile(contentUri);
|
||||
long messageSize = 0;
|
||||
|
||||
@@ -84,7 +84,8 @@ public class ReadDraftDataAction extends Action implements Parcelable {
|
||||
protected Object executeAction() {
|
||||
final DatabaseWrapper db = DataModel.get().getDatabase();
|
||||
final String conversationId = actionParameters.getString(KEY_CONVERSATION_ID);
|
||||
final MessageData incomingDraft = actionParameters.getParcelable(KEY_INCOMING_DRAFT);
|
||||
final MessageData incomingDraft = actionParameters.getParcelable(KEY_INCOMING_DRAFT,
|
||||
MessageData.class);
|
||||
final ConversationListItemData conversation =
|
||||
ConversationListItemData.getExistingConversation(db, conversationId);
|
||||
MessageData message = null;
|
||||
|
||||
@@ -59,7 +59,8 @@ public class ReceiveSmsMessageAction extends Action implements Parcelable {
|
||||
@Override
|
||||
protected Object executeAction() {
|
||||
final Context context = Factory.get().getApplicationContext();
|
||||
final ContentValues messageValues = actionParameters.getParcelable(KEY_MESSAGE_VALUES);
|
||||
final ContentValues messageValues = actionParameters.getParcelable(KEY_MESSAGE_VALUES,
|
||||
ContentValues.class);
|
||||
final DatabaseWrapper db = DataModel.get().getDatabase();
|
||||
|
||||
// Get the SIM subscription ID
|
||||
|
||||
@@ -193,9 +193,9 @@ public class SendMessageAction extends Action implements Parcelable {
|
||||
*/
|
||||
@Override
|
||||
protected Bundle doBackgroundWork() {
|
||||
final MessageData message = actionParameters.getParcelable(KEY_MESSAGE);
|
||||
final MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class);
|
||||
final String messageId = actionParameters.getString(KEY_MESSAGE_ID);
|
||||
Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI);
|
||||
Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI, Uri.class);
|
||||
Uri updatedMessageUri = null;
|
||||
final boolean isSms = message.getProtocol() == MessageData.PROTOCOL_SMS;
|
||||
final int subId = actionParameters.getInt(KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID);
|
||||
@@ -294,7 +294,7 @@ public class SendMessageAction extends Action implements Parcelable {
|
||||
@Override
|
||||
protected Object processBackgroundFailure() {
|
||||
final String messageId = actionParameters.getString(KEY_MESSAGE_ID);
|
||||
final MessageData message = actionParameters.getParcelable(KEY_MESSAGE);
|
||||
final MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class);
|
||||
final boolean isSms = message.getProtocol() == MessageData.PROTOCOL_SMS;
|
||||
final int subId = actionParameters.getInt(KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID);
|
||||
final int resultCode = actionParameters.getInt(ProcessSentMessageAction.KEY_RESULT_CODE);
|
||||
|
||||
@@ -489,7 +489,7 @@ class SyncCursorPair {
|
||||
|
||||
@Override
|
||||
public DatabaseMessage next() {
|
||||
DatabaseMessage result = null;
|
||||
DatabaseMessage result;
|
||||
if (mNextSms != null && mNextMms != null) {
|
||||
if (mNextSms.getTimestampInMillis() >= mNextMms.getTimestampInMillis()) {
|
||||
result = mNextSms;
|
||||
|
||||
@@ -197,7 +197,7 @@ class SyncMessageBatch {
|
||||
|
||||
public static int bugleStatusForSms(final boolean isOutgoing, final int type,
|
||||
final int status) {
|
||||
int bugleStatus = MessageData.BUGLE_STATUS_UNKNOWN;
|
||||
int bugleStatus;
|
||||
// For a message we sync either
|
||||
if (isOutgoing) {
|
||||
// Outgoing message not yet been sent
|
||||
|
||||
@@ -272,10 +272,10 @@ public class SyncMessagesAction extends Action implements Parcelable {
|
||||
final long startTimeMillis = SystemClock.elapsedRealtime();
|
||||
|
||||
// Number of messages scanned local and remote
|
||||
int localPos = 0;
|
||||
int remotePos = 0;
|
||||
int localTotal = 0;
|
||||
int remoteTotal = 0;
|
||||
int localPos;
|
||||
int remotePos;
|
||||
int localTotal;
|
||||
int remoteTotal;
|
||||
// Scan through the messages on both sides and prepare messages for local message table
|
||||
// changes (including adding and deleting)
|
||||
try {
|
||||
@@ -383,11 +383,12 @@ public class SyncMessagesAction extends Action implements Parcelable {
|
||||
} else {
|
||||
// Succeeded
|
||||
final ArrayList<SmsMessage> smsToAdd =
|
||||
response.getParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES);
|
||||
response.getParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES, SmsMessage.class);
|
||||
final ArrayList<MmsMessage> mmsToAdd =
|
||||
response.getParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES);
|
||||
response.getParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES, MmsMessage.class);
|
||||
final ArrayList<LocalDatabaseMessage> messagesToDelete =
|
||||
response.getParcelableArrayList(BUNDLE_KEY_MESSAGES_TO_DELETE);
|
||||
response.getParcelableArrayList(BUNDLE_KEY_MESSAGES_TO_DELETE,
|
||||
LocalDatabaseMessage.class);
|
||||
|
||||
final int messagesUpdated = smsToAdd.size() + mmsToAdd.size()
|
||||
+ messagesToDelete.size();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class WriteDraftMessageAction extends Action implements Parcelable {
|
||||
protected Object executeAction() {
|
||||
final DatabaseWrapper db = DataModel.get().getDatabase();
|
||||
final String conversationId = actionParameters.getString(KEY_CONVERSATION_ID);
|
||||
final MessageData message = actionParameters.getParcelable(KEY_MESSAGE);
|
||||
final MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class);
|
||||
if (message.getSelfId() == null || message.getParticipantId() == null) {
|
||||
// This could happen when this occurs before the draft message is loaded
|
||||
// In this case, we just use the conversation's current self id as draft's
|
||||
|
||||
@@ -185,7 +185,7 @@ public class DraftMessageData extends BindableData implements ReadDraftDataActio
|
||||
* @return the MessageData for the draft, null if self id is not set
|
||||
*/
|
||||
public MessageData createMessageWithCurrentAttachments(final boolean clearLocalCopy) {
|
||||
MessageData message = null;
|
||||
MessageData message;
|
||||
if (getIsMms()) {
|
||||
message = MessageData.createDraftMmsMessage(mConversationId, mSelfId,
|
||||
mMessageText, mMessageSubject);
|
||||
|
||||
@@ -837,7 +837,8 @@ public class MessageData implements Parcelable {
|
||||
mParts = new ArrayList<>();
|
||||
final int partCount = in.readInt();
|
||||
for (int i = 0; i < partCount; i++) {
|
||||
mParts.add((MessagePartData) in.readParcelable(MessagePartData.class.getClassLoader()));
|
||||
mParts.add(in.readParcelable(MessagePartData.class.getClassLoader(),
|
||||
MessagePartData.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,6 @@ public class DecodedImageResource extends ImageResource {
|
||||
} finally {
|
||||
if (scaledBitmap != null && scaledBitmap != getBitmap()) {
|
||||
scaledBitmap.recycle();
|
||||
scaledBitmap = null;
|
||||
}
|
||||
releaseLock();
|
||||
release();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GifImageResource extends ImageResource {
|
||||
@Override
|
||||
public Drawable getDrawable(Resources resources) {
|
||||
try {
|
||||
return (AnimatedImageDrawable) ImageDecoder.decodeDrawable(mImageDecoderSource);
|
||||
return ImageDecoder.decodeDrawable(mImageDecoderSource);
|
||||
} catch (final Throwable t) {
|
||||
// Malicious gif images can make the platform throw different kind of throwables, such
|
||||
// as OutOfMemoryError and NullPointerException. Catch them all.
|
||||
|
||||
@@ -157,7 +157,7 @@ public class MediaResourceManager {
|
||||
final MediaRequest<T> mediaRequest)
|
||||
throws Exception {
|
||||
final List<MediaRequest<T>> chainedRequests = new ArrayList<>();
|
||||
T loadedResource = null;
|
||||
T loadedResource;
|
||||
// Try fetching from cache first.
|
||||
final T cachedResource = loadMediaFromCache(mediaRequest);
|
||||
if (cachedResource != null) {
|
||||
|
||||
@@ -222,7 +222,7 @@ public class VCardResourceEntry {
|
||||
|
||||
if (vcard.getOrganizationList() != null) {
|
||||
for (final OrganizationData organtization : vcard.getOrganizationList()) {
|
||||
String type = null;
|
||||
String type;
|
||||
try {
|
||||
type = resources.getString(Organization.getTypeLabelResource(
|
||||
organtization.getType()));
|
||||
|
||||
@@ -48,7 +48,7 @@ public class VideoThumbnailRequest extends ImageRequest<UriImageRequestDescripto
|
||||
|
||||
@Override
|
||||
protected Bitmap getBitmapForResource() throws IOException {
|
||||
Bitmap bitmap = null;
|
||||
Bitmap bitmap;
|
||||
// Get a thumbnail through MediaMetadataRetriever to get a representative frame at any time
|
||||
// position instead.
|
||||
final MediaMetadataRetrieverWrapper retriever = new MediaMetadataRetrieverWrapper();
|
||||
|
||||
Reference in New Issue
Block a user