From 5eeff2f08dab0fedee2133571c249e3b021551e8 Mon Sep 17 00:00:00 2001 From: spiky-s <49979126+spiky-s@users.noreply.github.com> Date: Thu, 18 Aug 2022 20:24:03 +0300 Subject: [PATCH] Add files via upload --- .../java/ru/vtosters/lite/foaf/FoafBase.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java b/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java index 1161d73c6..8aac7cd94 100644 --- a/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java +++ b/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java @@ -18,6 +18,9 @@ import androidx.exifinterface.media.ExifInterface; import com.vk.core.dialogs.alert.VkAlertDialog; import com.vk.core.network.Network; +import org.json.JSONException; +import org.json.JSONObject; + import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -32,11 +35,13 @@ import java.util.regex.Pattern; import okhttp3.Headers; import okhttp3.OkHttpClient; import ru.vtosters.lite.net.Request; +import ru.vtosters.lite.utils.AccountManagerUtils; public class FoafBase { private static final Pattern FOAF_REGEX = Pattern.compile(""); private static final Pattern FOAF_REGEX_LAST_SEEN = Pattern.compile(""); private static final Pattern FOAF_REGEX_LOGIN = Pattern.compile(""); + private static final String API_VKNEXT = "https://api.vknext.net/v1/getBypassedOnlineInfo?json=1&ids="; private static final OkHttpClient client = new OkHttpClient(); public static long getLastSeen(long origtime, int id) throws ParseException, IOException { @@ -65,6 +70,48 @@ public class FoafBase { return sdf.parse(sdf.format(date)).getTime() / 1000; } + + public static JSONObject getBypassedOnlineInfo(int id) throws JSONException { + var request = new okhttp3.Request.a() + .b(API_VKNEXT + Integer.toString(id)) + .a(); + + String response = null; + + var dummy = new JSONObject(); + dummy.put("last_seen", 0); + + try { + response = client.a(request).execute().a().g(); + var online_info = new JSONObject(response).optJSONObject("response").optJSONObject(Integer.toString(id)); + return online_info == null ? dummy : online_info; + } catch (Exception e) { + Log.e("GetBypassedOnlineInfo", e.getMessage()); + return dummy; + } + } + + public static JSONObject getBypassedOnlineInfo(String ids) throws JSONException { + + + var request = new okhttp3.Request.a() + .b(API_VKNEXT + ids) + .a(); + + String response = null; + + var dummy = new JSONObject(); + + try { + response = client.a(request).execute().a().g(); + var online_info = new JSONObject(response).optJSONObject("response"); + return online_info == null ? dummy : online_info; + } catch (Exception e) { + Log.e("GetBypassedOnlineInfo1", e.getMessage()); + return dummy; + } + } + private static String getLink(int i) { String str; StringBuilder sb;