1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00

Simplify null and empty check

This commit is contained in:
Ammar Githam 2020-08-16 05:33:04 +09:00
parent 87a7c400d7
commit 0a8b7020b5

View File

@ -121,29 +121,31 @@ public final class Utils {
public static void setupCookies(final String cookieRaw) { public static void setupCookies(final String cookieRaw) {
final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore(); final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore();
if (cookieRaw == "LOGOUT") { if (cookieStore == null || isEmpty(cookieRaw)) {
cookieStore.removeAll(); return;
} }
else if (cookieRaw != null && !isEmpty(cookieRaw)) { if (cookieRaw.equals("LOGOUT")) {
try { cookieStore.removeAll();
final URI uri1 = new URI("https://instagram.com"); return;
final URI uri2 = new URI("https://instagram.com/"); }
final URI uri3 = new URI("https://i.instagram.com/"); try {
for (final String cookie : cookieRaw.split(";")) { final URI uri1 = new URI("https://instagram.com");
final String[] strings = cookie.split("=", 2); final URI uri2 = new URI("https://instagram.com/");
final HttpCookie httpCookie = new HttpCookie(strings[0].trim(), strings[1].trim()); final URI uri3 = new URI("https://i.instagram.com/");
httpCookie.setDomain("instagram.com"); for (final String cookie : cookieRaw.split(";")) {
httpCookie.setPath("/"); final String[] strings = cookie.split("=", 2);
httpCookie.setVersion(0); final HttpCookie httpCookie = new HttpCookie(strings[0].trim(), strings[1].trim());
cookieStore.add(uri1, httpCookie); httpCookie.setDomain("instagram.com");
cookieStore.add(uri2, httpCookie); httpCookie.setPath("/");
cookieStore.add(uri3, httpCookie); httpCookie.setVersion(0);
} cookieStore.add(uri1, httpCookie);
} catch (final URISyntaxException e) { cookieStore.add(uri2, httpCookie);
if (logCollector != null) cookieStore.add(uri3, httpCookie);
logCollector.appendException(e, LogCollector.LogFile.UTILS, "setupCookies");
if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e);
} }
} catch (final URISyntaxException e) {
if (logCollector != null)
logCollector.appendException(e, LogCollector.LogFile.UTILS, "setupCookies");
if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e);
} }
} }