Select identify from to address, several fixes and improvements

This commit is contained in:
M66B
2018-08-06 11:05:14 +00:00
parent 7052639d48
commit 7b6364b3a2
9 changed files with 113 additions and 50 deletions

View File

@@ -31,6 +31,9 @@ import android.util.Log;
import org.json.JSONArray;
import java.util.ArrayList;
import java.util.List;
import static android.arch.persistence.room.ForeignKey.CASCADE;
@Entity(
@@ -60,6 +63,8 @@ public class EntityOperation {
public static final String SEND = "send";
public static final String ATTACHMENT = "attachment";
private static List<Intent> queue = new ArrayList<>();
static void queue(Context context, EntityMessage message, String name) {
JSONArray jsonArray = new JSONArray();
queue(context, message, name, jsonArray);
@@ -92,16 +97,26 @@ public class EntityOperation {
operation.args = jsonArray.toString();
operation.id = dao.insertOperation(operation);
synchronized (queue) {
queue.add(new Intent(SEND.equals(name)
? ServiceSynchronize.ACTION_PROCESS_OUTBOX
: ServiceSynchronize.ACTION_PROCESS_FOLDER)
.putExtra("folder", message.folder));
}
Log.i(Helper.TAG, "Queued op=" + operation.id + "/" + name +
" args=" + operation.args +
" msg=" + message.folder + "/" + message.id + " uid=" + message.uid +
" purged=" + purged);
}
public static void process(Context context) {
// Processing needs to be done after committing to the database
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(SEND.equals(name)
? ServiceSynchronize.ACTION_PROCESS_OUTBOX
: ServiceSynchronize.ACTION_PROCESS_FOLDER)
.putExtra("folder", message.folder));
synchronized (queue) {
for (Intent intent : queue)
lbm.sendBroadcast(intent);
queue.clear();
}
}
}