Code simplifcation
This commit is contained in:
parent
6190c47524
commit
95783c14b6
@ -272,6 +272,33 @@ public class MultiSmsSender extends Activity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long createMessageId(String messageName, int messageNbPart) {
|
||||||
|
ContentValues values = new ContentValues(2);
|
||||||
|
|
||||||
|
values.put(DeliveryDbAdapter.KEY_MESSAGE_NAME, messageName);
|
||||||
|
values.put(DeliveryDbAdapter.KEY_MESSAGE_DATE, DateFormat
|
||||||
|
.getDateInstance().format(new Date()));
|
||||||
|
values.put(DeliveryDbAdapter.KEY_MESSAGE_NB_PART, messageNbPart);
|
||||||
|
|
||||||
|
return Long.parseLong(getContentResolver()
|
||||||
|
.insert(DeliveryDbAdapter.CONTENT_MESSAGE_URI, values)
|
||||||
|
.getPathSegments().get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public long createEntryId(String number, long messageId) {
|
||||||
|
ContentValues values = new ContentValues(3);
|
||||||
|
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME,
|
||||||
|
nameFromNumber(getContentResolver(), number));
|
||||||
|
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER,
|
||||||
|
number);
|
||||||
|
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_MESSAGE_ID,
|
||||||
|
messageId);
|
||||||
|
|
||||||
|
return Long.parseLong(getContentResolver()
|
||||||
|
.insert(DeliveryDbAdapter.CONTENT_DELIVERY_URI,
|
||||||
|
values).getPathSegments().get(1));
|
||||||
|
}
|
||||||
|
|
||||||
public void sendMessage(Handler handler) {
|
public void sendMessage(Handler handler) {
|
||||||
|
|
||||||
SmsManager manager = SmsManager.getDefault();
|
SmsManager manager = SmsManager.getDefault();
|
||||||
@ -295,17 +322,10 @@ public class MultiSmsSender extends Activity {
|
|||||||
int messageCount = messages.size();
|
int messageCount = messages.size();
|
||||||
|
|
||||||
if (haveDeliveryReports) {
|
if (haveDeliveryReports) {
|
||||||
ContentValues values = new ContentValues(2);
|
messageId = createMessageId(
|
||||||
|
|
||||||
values.put(DeliveryDbAdapter.KEY_MESSAGE_NAME,
|
|
||||||
message.substring(0, Math.min(30, message.length()))
|
message.substring(0, Math.min(30, message.length()))
|
||||||
.replace('\n', ' '));
|
.replace('\n', ' ')
|
||||||
values.put(DeliveryDbAdapter.KEY_MESSAGE_DATE, DateFormat
|
, messageCount);
|
||||||
.getDateInstance().format(new Date()));
|
|
||||||
|
|
||||||
messageId = Long.parseLong(getContentResolver()
|
|
||||||
.insert(DeliveryDbAdapter.CONTENT_MESSAGE_URI, values)
|
|
||||||
.getPathSegments().get(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if numbers are correct and prepare deliveryId
|
// Check if numbers are correct and prepare deliveryId
|
||||||
@ -317,19 +337,8 @@ public class MultiSmsSender extends Activity {
|
|||||||
&& !phoneNumberConform.contains(newN)) {
|
&& !phoneNumberConform.contains(newN)) {
|
||||||
phoneNumberConform.add(newN);
|
phoneNumberConform.add(newN);
|
||||||
if (haveDeliveryReports) {
|
if (haveDeliveryReports) {
|
||||||
ContentValues values = new ContentValues(3);
|
long entryId = createEntryId(newN, messageId);
|
||||||
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME,
|
|
||||||
nameFromNumber(getContentResolver(), newN));
|
|
||||||
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER,
|
|
||||||
newN);
|
|
||||||
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_MESSAGE_ID,
|
|
||||||
messageId);
|
|
||||||
|
|
||||||
long entryId = Long.parseLong(getContentResolver()
|
|
||||||
.insert(DeliveryDbAdapter.CONTENT_DELIVERY_URI,
|
|
||||||
values).getPathSegments().get(1));
|
|
||||||
deliveryIdMap.put(newN, entryId);
|
deliveryIdMap.put(newN, entryId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user