1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 04:35:57 +00:00

Refactoring

This commit is contained in:
M66B 2023-10-26 12:19:53 +02:00
parent ad0c8058d0
commit b91575031d
2 changed files with 20 additions and 14 deletions

View file

@ -31,6 +31,8 @@ import android.text.TextUtils;
import androidx.preference.PreferenceManager;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@ -104,6 +106,23 @@ public class CalendarHelper {
}
}
static Long insert(Context context, ICalendar icalendar, VEvent event, int status,
EntityAccount account, EntityMessage message) {
String selectedAccount;
String selectedName;
try {
JSONObject jselected = new JSONObject(account.calendar);
selectedAccount = jselected.getString("account");
selectedName = jselected.optString("name", null);
} catch (Throwable ex) {
Log.i(ex);
selectedAccount = account.calendar;
selectedName = null;
}
return insert(context, icalendar, event, status, selectedAccount, selectedName, message);
}
static Long insert(Context context, ICalendar icalendar, VEvent event, int status,
String selectedAccount, String selectedName, EntityMessage message) {
Long existId = null;

View file

@ -71,7 +71,6 @@ import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.json.JSONObject;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
@ -4467,19 +4466,7 @@ public class MessageHelper {
return;
}
String selectedAccount;
String selectedName;
try {
JSONObject jselected = new JSONObject(account.calendar);
selectedAccount = jselected.getString("account");
selectedName = jselected.optString("name", null);
} catch (Throwable ex) {
Log.i(ex);
selectedAccount = account.calendar;
selectedName = null;
}
CalendarHelper.insert(context, icalendar, event, status, selectedAccount, selectedName, message);
CalendarHelper.insert(context, icalendar, event, status, account, message);
} else
EntityLog.log(context, "Unknown event method=" + method.getValue());
} catch (Throwable ex) {