Use LRU to cache the Avatar shown in push notifications (#7124)

* iOS switch from file cache to memory cache and use last_picture_update to update the avatar if needed

* Android switch from file cache to memory cache and use last_picture_update to update the avatar if needed, split function to multiple files and catch potential exceptions
This commit is contained in:
Elias Nahum
2023-02-15 11:19:31 +02:00
committed by GitHub
parent ab5084ce48
commit 23cbf82353
40 changed files with 1919 additions and 1042 deletions

View File

@@ -29,6 +29,7 @@ import org.json.JSONException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
@@ -75,8 +76,8 @@ public class ShareModule extends ReactContextBaseJavaModule {
public String getCurrentActivityName() {
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
String actvName = currentActivity.getComponentName().getClassName();
String[] components = actvName.split("\\.");
String activityName = currentActivity.getComponentName().getClassName();
String[] components = activityName.split("\\.");
return components[components.length - 1];
}
@@ -115,7 +116,7 @@ public class ShareModule extends ReactContextBaseJavaModule {
if (data != null && data.hasKey("serverUrl")) {
ReadableArray files = data.getArray("files");
String serverUrl = data.getString("serverUrl");
final String token = Credentials.getCredentialsForServerSync(this.getReactApplicationContext(), serverUrl);
final String token = Credentials.getCredentialsForServerSync(mReactContext, serverUrl);
JSONObject postData = buildPostObject(data);
if (files != null && files.size() > 0) {
@@ -236,7 +237,7 @@ public class ShareModule extends ReactContextBaseJavaModule {
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
String responseData = response.body().string();
String responseData = Objects.requireNonNull(response.body()).string();
JSONObject responseJson = new JSONObject(responseData);
JSONArray fileInfoArray = responseJson.getJSONArray("file_infos");
JSONArray file_ids = new JSONArray();