Fix #145 #146 #147 - Issue with Pleroma

pull/254/head
Thomas 2 years ago
parent aa35bb2bcd
commit fa100ab277

@ -736,18 +736,25 @@ public class ProfileActivity extends BaseActivity {
//Get pinned instances
reorderVM.getPinned().observe(ProfileActivity.this, pinned -> {
boolean alreadyPinned = false;
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
if (pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.host.compareToIgnoreCase(finalInstanceName) == 0) {
alreadyPinned = true;
break;
boolean present = true;
if (pinned == null) {
pinned = new Pinned();
pinned.pinnedTimelines = new ArrayList<>();
present = false;
} else {
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
if (pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.host.compareToIgnoreCase(finalInstanceName) == 0) {
alreadyPinned = true;
break;
}
}
}
if (alreadyPinned) {
Toasty.info(ProfileActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
return;
}
RemoteInstance.InstanceType instanceType;
if (nodeInfo != null) {
RemoteInstance.InstanceType instanceType;
if (nodeInfo.software.name.compareToIgnoreCase("peertube") == 0) {
instanceType = RemoteInstance.InstanceType.PEERTUBE;
} else if (nodeInfo.software.name.compareToIgnoreCase("pixelfed") == 0) {
@ -759,30 +766,38 @@ public class ProfileActivity extends BaseActivity {
} else {
instanceType = RemoteInstance.InstanceType.MASTODON;
}
RemoteInstance remoteInstance = new RemoteInstance();
remoteInstance.type = instanceType;
remoteInstance.host = finalInstanceName;
PinnedTimeline pinnedTimeline = new PinnedTimeline();
pinnedTimeline.remoteInstance = remoteInstance;
pinnedTimeline.displayed = true;
pinnedTimeline.type = Timeline.TimeLineEnum.REMOTE;
pinnedTimeline.position = pinned.pinnedTimelines.size();
pinned.pinnedTimelines.add(pinnedTimeline);
new Thread(() -> {
try {
new Pinned(ProfileActivity.this).updatePinned(pinned);
runOnUiThread(() -> {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
LocalBroadcastManager.getInstance(ProfileActivity.this).sendBroadcast(intentBD);
});
} catch (DBException e) {
e.printStackTrace();
}
}).start();
} else {
instanceType = RemoteInstance.InstanceType.MASTODON;
}
RemoteInstance remoteInstance = new RemoteInstance();
remoteInstance.type = instanceType;
remoteInstance.host = finalInstanceName;
PinnedTimeline pinnedTimeline = new PinnedTimeline();
pinnedTimeline.remoteInstance = remoteInstance;
pinnedTimeline.displayed = true;
pinnedTimeline.type = Timeline.TimeLineEnum.REMOTE;
pinnedTimeline.position = pinned.pinnedTimelines.size();
pinned.pinnedTimelines.add(pinnedTimeline);
Pinned finalPinned = pinned;
boolean finalPresent = present;
new Thread(() -> {
try {
if (finalPresent) {
new Pinned(ProfileActivity.this).updatePinned(finalPinned);
} else {
new Pinned(ProfileActivity.this).insertPinned(finalPinned);
}
runOnUiThread(() -> {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
LocalBroadcastManager.getInstance(ProfileActivity.this).sendBroadcast(intentBD);
});
} catch (DBException e) {
e.printStackTrace();
}
}).start();
});
return true;

@ -59,10 +59,11 @@ public class TagAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
int stat = 0;
for (History history : historyList) {
trendsEntry.add(0, new Entry(Float.parseFloat(history.day), Float.parseFloat(history.uses)));
stat += Integer.parseInt(history.accounts);
if (historyList != null) {
for (History history : historyList) {
trendsEntry.add(0, new Entry(Float.parseFloat(history.day), Float.parseFloat(history.uses)));
stat += Integer.parseInt(history.accounts);
}
}
tagViewHolder.binding.tagStats.setText(context.getString(R.string.talking_about, stat));
LineDataSet dataTrending = new LineDataSet(trendsEntry, context.getString(R.string.trending));

Loading…
Cancel
Save