mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-07 16:06:18 +00:00
SmsBuffer: add push helper function to factorize code
This commit is contained in:
parent
d950fc73ed
commit
ebfd1ccfbf
@ -56,15 +56,7 @@ public class AndroidSmsFetcher {
|
||||
|
||||
// Mailbox ID is required by server
|
||||
entry.put("mbox", mbID.ordinal());
|
||||
|
||||
smsBuffer.push(entry.getInt("_id"),
|
||||
mbID.ordinal(),
|
||||
entry.getInt("type"),
|
||||
entry.getLong("date"),
|
||||
entry.getString("address"),
|
||||
entry.getString("body"),
|
||||
entry.getString("read"),
|
||||
entry.getString("seen"));
|
||||
smsBuffer.push(mbID, entry);
|
||||
|
||||
} catch (JSONException e) {
|
||||
Log.e(AndroidSmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
|
||||
@ -130,15 +122,7 @@ public class AndroidSmsFetcher {
|
||||
* aren't indexed in the same mean
|
||||
*/
|
||||
entry.put("mbox", (mboxId - 1));
|
||||
|
||||
results.push(entry.getInt("_id"),
|
||||
mbID.ordinal(),
|
||||
entry.getInt("type"),
|
||||
entry.getLong("date"),
|
||||
entry.getString("address"),
|
||||
entry.getString("body"),
|
||||
entry.getString("read"),
|
||||
entry.getString("seen"));
|
||||
results.push(mbID, entry);
|
||||
} catch (JSONException e) {
|
||||
Log.e(AndroidSmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package fr.unix_experience.owncloud_sms.jni;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import fr.unix_experience.owncloud_sms.enums.MailboxID;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2014-2017, Loic Blot <loic.blot@unix-experience.fr>
|
||||
*
|
||||
@ -43,6 +48,17 @@ public class SmsBuffer {
|
||||
public native void print();
|
||||
public native String asRawJsonString();
|
||||
|
||||
public void push (MailboxID mbid, JSONObject jsonObject) throws JSONException {
|
||||
push(jsonObject.getInt("_id"),
|
||||
mbid.ordinal(),
|
||||
jsonObject.getInt("type"),
|
||||
jsonObject.getLong("date"),
|
||||
jsonObject.getString("address"),
|
||||
jsonObject.getString("body"),
|
||||
jsonObject.getString("read"),
|
||||
jsonObject.getString("seen"));
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (mHandle == 0) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user