Fix crashes
This commit is contained in:
parent
d80193545d
commit
4dcb2cc3d9
|
@ -19,6 +19,7 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
@ -4776,6 +4777,7 @@ public class API {
|
||||||
public static Status parseNotes(Context context, String instance, JSONObject resobj){
|
public static Status parseNotes(Context context, String instance, JSONObject resobj){
|
||||||
Status status = new Status();
|
Status status = new Status();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
status.setId(resobj.get("id").toString());
|
status.setId(resobj.get("id").toString());
|
||||||
status.setUri("https://" + instance + "/notes/" + resobj.get("id").toString());
|
status.setUri("https://" + instance + "/notes/" + resobj.get("id").toString());
|
||||||
status.setCreated_at(Helper.mstStringToDate(context, resobj.get("createdAt").toString()));
|
status.setCreated_at(Helper.mstStringToDate(context, resobj.get("createdAt").toString()));
|
||||||
|
@ -4787,40 +4789,49 @@ public class API {
|
||||||
status.setVisibility(resobj.get("visibility").toString());
|
status.setVisibility(resobj.get("visibility").toString());
|
||||||
}catch (Exception e){status.setVisibility("public"); e.printStackTrace();}
|
}catch (Exception e){status.setVisibility("public"); e.printStackTrace();}
|
||||||
status.setUrl("https://" + instance + "/notes/" + resobj.get("id").toString());
|
status.setUrl("https://" + instance + "/notes/" + resobj.get("id").toString());
|
||||||
|
Log.v(Helper.TAG,"ici: " + resobj);
|
||||||
//Retrieves attachments
|
//Retrieves attachments
|
||||||
JSONArray arrayAttachement = resobj.getJSONArray("media");
|
if( resobj.has("media")) {
|
||||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
JSONArray arrayAttachement = resobj.getJSONArray("media");
|
||||||
if( arrayAttachement != null){
|
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||||
for(int j = 0 ; j < arrayAttachement.length() ; j++){
|
if (arrayAttachement != null) {
|
||||||
JSONObject attObj = arrayAttachement.getJSONObject(j);
|
for (int j = 0; j < arrayAttachement.length(); j++) {
|
||||||
Attachment attachment = new Attachment();
|
JSONObject attObj = arrayAttachement.getJSONObject(j);
|
||||||
attachment.setId(attObj.get("id").toString());
|
Attachment attachment = new Attachment();
|
||||||
attachment.setPreview_url(attObj.get("thumbnailUrl").toString());
|
attachment.setId(attObj.get("id").toString());
|
||||||
attachment.setRemote_url(attObj.get("url").toString());
|
attachment.setPreview_url(attObj.get("thumbnailUrl").toString());
|
||||||
if( attObj.get("type").toString().contains("/")){
|
attachment.setRemote_url(attObj.get("url").toString());
|
||||||
attachment.setType(attObj.get("type").toString().split("/")[0]);
|
if (attObj.get("type").toString().contains("/")) {
|
||||||
}else
|
attachment.setType(attObj.get("type").toString().split("/")[0]);
|
||||||
attachment.setType(attObj.get("type").toString());
|
} else
|
||||||
attachment.setText_url(attObj.get("url").toString());
|
attachment.setType(attObj.get("type").toString());
|
||||||
attachment.setUrl(attObj.get("url").toString());
|
attachment.setText_url(attObj.get("url").toString());
|
||||||
if(attObj.get("isSensitive").toString().equals("true")){
|
attachment.setUrl(attObj.get("url").toString());
|
||||||
status.setSensitive(true);
|
if (attObj.get("isSensitive").toString().equals("true")) {
|
||||||
|
status.setSensitive(true);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
attachment.setDescription(attObj.get("comment").toString());
|
||||||
|
} catch (JSONException ignore) {
|
||||||
|
ignore.printStackTrace();
|
||||||
|
}
|
||||||
|
attachments.add(attachment);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
attachment.setDescription(attObj.get("comment").toString());
|
|
||||||
}catch (JSONException ignore){ignore.printStackTrace();}
|
|
||||||
attachments.add(attachment);
|
|
||||||
}
|
}
|
||||||
|
status.setMedia_attachments(attachments);
|
||||||
|
}else{
|
||||||
|
status.setMedia_attachments(new ArrayList<>());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
status.setCard(parseCardResponse(resobj.getJSONObject("card")));
|
status.setCard(parseCardResponse(resobj.getJSONObject("card")));
|
||||||
}catch (Exception e){status.setCard(null);}
|
}catch (Exception e){status.setCard(null);}
|
||||||
|
|
||||||
status.setMedia_attachments(attachments);
|
|
||||||
//Retrieves mentions
|
//Retrieves mentions
|
||||||
List<Mention> mentions = new ArrayList<>();
|
List<Mention> mentions = new ArrayList<>();
|
||||||
|
|
||||||
status.setAccount(parseMisskeyAccountResponse(context, instance, resobj.getJSONObject("user")));
|
status.setAccount(parseMisskeyAccountResponse(context, instance, resobj.getJSONObject("user")));
|
||||||
|
|
||||||
status.setContent(resobj.get("text").toString());
|
status.setContent(resobj.get("text").toString());
|
||||||
try{
|
try{
|
||||||
status.setReplies_count(Integer.valueOf(resobj.get("repliesCount").toString()));
|
status.setReplies_count(Integer.valueOf(resobj.get("repliesCount").toString()));
|
||||||
|
@ -4840,34 +4851,34 @@ public class API {
|
||||||
status.setMentions(mentions);
|
status.setMentions(mentions);
|
||||||
//Retrieves tags
|
//Retrieves tags
|
||||||
List<Tag> tags = new ArrayList<>();
|
List<Tag> tags = new ArrayList<>();
|
||||||
JSONArray arrayTag = resobj.getJSONArray("tags");
|
if( resobj.has("tags")) {
|
||||||
if( arrayTag != null){
|
JSONArray arrayTag = resobj.getJSONArray("tags");
|
||||||
for(int j = 0 ; j < arrayTag.length() ; j++){
|
if (arrayTag != null) {
|
||||||
JSONObject tagObj = arrayTag.getJSONObject(j);
|
for (int j = 0; j < arrayTag.length(); j++) {
|
||||||
Tag tag = new Tag();
|
JSONObject tagObj = arrayTag.getJSONObject(j);
|
||||||
tag.setName(tagObj.get("name").toString());
|
Tag tag = new Tag();
|
||||||
tag.setUrl(tagObj.get("url").toString());
|
tag.setName(tagObj.get("name").toString());
|
||||||
tags.add(tag);
|
tag.setUrl(tagObj.get("url").toString());
|
||||||
|
tags.add(tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status.setTags(tags);
|
status.setTags(tags);
|
||||||
|
|
||||||
//Retrieves emjis
|
//Retrieves emjis
|
||||||
List<Emojis> emojiList = new ArrayList<>();
|
List<Emojis> emojiList = new ArrayList<>();
|
||||||
try {
|
if( resobj.has("emojis")) {
|
||||||
JSONArray emojisTag = resobj.getJSONArray("emojis");
|
JSONArray emojisTag = resobj.getJSONArray("emojis");
|
||||||
if( emojisTag != null){
|
if (emojisTag != null) {
|
||||||
for(int j = 0 ; j < emojisTag.length() ; j++){
|
for (int j = 0; j < emojisTag.length(); j++) {
|
||||||
JSONObject emojisObj = emojisTag.getJSONObject(j);
|
JSONObject emojisObj = emojisTag.getJSONObject(j);
|
||||||
Emojis emojis = parseMisskeyEmojis(emojisObj);
|
Emojis emojis = parseMisskeyEmojis(emojisObj);
|
||||||
emojiList.add(emojis);
|
emojiList.add(emojis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status.setEmojis(emojiList);
|
status.setEmojis(emojiList);
|
||||||
}catch (Exception e){
|
|
||||||
status.setEmojis(new ArrayList<>());
|
|
||||||
}
|
}
|
||||||
|
status.setEmojis(emojiList);
|
||||||
//Retrieve Application
|
//Retrieve Application
|
||||||
Application application = new Application();
|
Application application = new Application();
|
||||||
try {
|
try {
|
||||||
|
@ -5631,15 +5642,18 @@ public class API {
|
||||||
private static Account parseMisskeyAccountResponse(Context context, String instance, JSONObject resobj){
|
private static Account parseMisskeyAccountResponse(Context context, String instance, JSONObject resobj){
|
||||||
|
|
||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
|
Log.v(Helper.TAG,"account: " + resobj);
|
||||||
try {
|
try {
|
||||||
account.setId(resobj.get("id").toString());
|
account.setId(resobj.get("id").toString());
|
||||||
account.setUsername(resobj.get("username").toString());
|
account.setUsername(resobj.get("username").toString());
|
||||||
String host = resobj.get("host").toString();
|
String host = null;
|
||||||
String acct;
|
String acct;
|
||||||
if( host == null || host.equals("null"))
|
if( resobj.isNull("host")) {
|
||||||
acct = resobj.get("username").toString();
|
acct = resobj.get("username").toString();
|
||||||
else
|
}else{
|
||||||
|
host = resobj.get("host").toString();
|
||||||
acct = resobj.get("username").toString() + "@" + host;
|
acct = resobj.get("username").toString() + "@" + host;
|
||||||
|
}
|
||||||
account.setAcct(acct);
|
account.setAcct(acct);
|
||||||
account.setDisplay_name(resobj.get("name").toString());
|
account.setDisplay_name(resobj.get("name").toString());
|
||||||
account.setCreated_at(new Date());
|
account.setCreated_at(new Date());
|
||||||
|
@ -5654,7 +5668,7 @@ public class API {
|
||||||
}
|
}
|
||||||
//Retrieves emjis
|
//Retrieves emjis
|
||||||
List<Emojis> emojiList = new ArrayList<>();
|
List<Emojis> emojiList = new ArrayList<>();
|
||||||
try {
|
if( resobj.has("emojis")){
|
||||||
JSONArray emojisTag = resobj.getJSONArray("emojis");
|
JSONArray emojisTag = resobj.getJSONArray("emojis");
|
||||||
if( emojisTag != null){
|
if( emojisTag != null){
|
||||||
for(int j = 0 ; j < emojisTag.length() ; j++){
|
for(int j = 0 ; j < emojisTag.length() ; j++){
|
||||||
|
@ -5663,11 +5677,10 @@ public class API {
|
||||||
emojiList.add(emojis);
|
emojiList.add(emojis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
account.setEmojis(emojiList);
|
|
||||||
}catch (Exception e){
|
|
||||||
account.setEmojis(new ArrayList<>());
|
|
||||||
}
|
}
|
||||||
} catch (JSONException ignored) {}
|
account.setEmojis(emojiList);
|
||||||
|
Log.v(Helper.TAG,"accountxx: " + account);
|
||||||
|
} catch (JSONException ignored) {ignored.printStackTrace();}
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
private boolean isOnWifi;
|
private boolean isOnWifi;
|
||||||
private NotificationsListAdapter.ViewHolder holder;
|
private NotificationsListAdapter.ViewHolder holder;
|
||||||
private int style;
|
private int style;
|
||||||
|
private Timer timer;
|
||||||
|
|
||||||
public NotificationsListAdapter(Context context, boolean isOnWifi, int behaviorWithAttachments, List<Notification> notifications){
|
public NotificationsListAdapter(Context context, boolean isOnWifi, int behaviorWithAttachments, List<Notification> notifications){
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -387,19 +388,22 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
}
|
}
|
||||||
}, 0, 130, TimeUnit.MILLISECONDS);
|
}, 0, 130, TimeUnit.MILLISECONDS);
|
||||||
}catch (Exception ignored){}*/
|
}catch (Exception ignored){}*/
|
||||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
if( timer == null) {
|
||||||
@Override
|
timer = new Timer();
|
||||||
public void run() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
((Activity)context).runOnUiThread(new Runnable() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
((Activity) context).runOnUiThread(new Runnable() {
|
||||||
holder.notification_account_username.invalidate();
|
@Override
|
||||||
holder.notification_status_content.invalidate();
|
public void run() {
|
||||||
}
|
holder.notification_account_username.invalidate();
|
||||||
});
|
holder.notification_status_content.invalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 0, 130);
|
}, 0, 130);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( !status.isClickable())
|
if( !status.isClickable())
|
||||||
Status.transform(context, status);
|
Status.transform(context, status);
|
||||||
|
|
|
@ -52,6 +52,7 @@ import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -215,7 +216,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
private TextView warning_message;
|
private TextView warning_message;
|
||||||
private Status tootReply;
|
private Status tootReply;
|
||||||
private long currentToId = -1;
|
private long currentToId = -1;
|
||||||
|
private Timer timer;
|
||||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -1182,19 +1183,22 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
}
|
}
|
||||||
}, 0, 130, TimeUnit.MILLISECONDS);
|
}, 0, 130, TimeUnit.MILLISECONDS);
|
||||||
}catch (Exception ignored){}*/
|
}catch (Exception ignored){}*/
|
||||||
|
if( timer == null) {
|
||||||
|
timer = new Timer();
|
||||||
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
((Activity) context).runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
holder.status_account_displayname.invalidate();
|
||||||
|
holder.status_content.invalidate();
|
||||||
|
|
||||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
}
|
||||||
@Override
|
});
|
||||||
public void run() {
|
}
|
||||||
((Activity)context).runOnUiThread(new Runnable() {
|
}, 0, 130);
|
||||||
@Override
|
}
|
||||||
public void run() {
|
|
||||||
holder.status_account_displayname.invalidate();
|
|
||||||
holder.status_content.invalidate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 0, 130);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14 * textSizePercent / 100);
|
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14 * textSizePercent / 100);
|
||||||
|
|
Loading…
Reference in New Issue