Refactoring

pull/214/head
M66B 1 year ago
parent ad0c8058d0
commit b91575031d

@ -31,6 +31,8 @@ import android.text.TextUtils;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import org.json.JSONObject;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; 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, static Long insert(Context context, ICalendar icalendar, VEvent event, int status,
String selectedAccount, String selectedName, EntityMessage message) { String selectedAccount, String selectedName, EntityMessage message) {
Long existId = null; Long existId = null;

@ -71,7 +71,6 @@ import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.commonmark.parser.Parser; import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer; import org.commonmark.renderer.html.HtmlRenderer;
import org.json.JSONObject;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node; import org.jsoup.nodes.Node;
@ -4467,19 +4466,7 @@ public class MessageHelper {
return; return;
} }
String selectedAccount; CalendarHelper.insert(context, icalendar, event, status, account, message);
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);
} else } else
EntityLog.log(context, "Unknown event method=" + method.getValue()); EntityLog.log(context, "Unknown event method=" + method.getValue());
} catch (Throwable ex) { } catch (Throwable ex) {

Loading…
Cancel
Save