forked from mirrors/Fedilab
parent
aa35bb2bcd
commit
fa100ab277
2 changed files with 48 additions and 32 deletions
|
@ -736,18 +736,25 @@ public class ProfileActivity extends BaseActivity {
|
||||||
//Get pinned instances
|
//Get pinned instances
|
||||||
reorderVM.getPinned().observe(ProfileActivity.this, pinned -> {
|
reorderVM.getPinned().observe(ProfileActivity.this, pinned -> {
|
||||||
boolean alreadyPinned = false;
|
boolean alreadyPinned = false;
|
||||||
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
boolean present = true;
|
||||||
if (pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.host.compareToIgnoreCase(finalInstanceName) == 0) {
|
if (pinned == null) {
|
||||||
alreadyPinned = true;
|
pinned = new Pinned();
|
||||||
break;
|
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) {
|
if (alreadyPinned) {
|
||||||
Toasty.info(ProfileActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
|
Toasty.info(ProfileActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RemoteInstance.InstanceType instanceType;
|
||||||
if (nodeInfo != null) {
|
if (nodeInfo != null) {
|
||||||
RemoteInstance.InstanceType instanceType;
|
|
||||||
if (nodeInfo.software.name.compareToIgnoreCase("peertube") == 0) {
|
if (nodeInfo.software.name.compareToIgnoreCase("peertube") == 0) {
|
||||||
instanceType = RemoteInstance.InstanceType.PEERTUBE;
|
instanceType = RemoteInstance.InstanceType.PEERTUBE;
|
||||||
} else if (nodeInfo.software.name.compareToIgnoreCase("pixelfed") == 0) {
|
} else if (nodeInfo.software.name.compareToIgnoreCase("pixelfed") == 0) {
|
||||||
|
@ -759,30 +766,38 @@ public class ProfileActivity extends BaseActivity {
|
||||||
} else {
|
} else {
|
||||||
instanceType = RemoteInstance.InstanceType.MASTODON;
|
instanceType = RemoteInstance.InstanceType.MASTODON;
|
||||||
}
|
}
|
||||||
RemoteInstance remoteInstance = new RemoteInstance();
|
} else {
|
||||||
remoteInstance.type = instanceType;
|
instanceType = RemoteInstance.InstanceType.MASTODON;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
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;
|
return true;
|
||||||
|
|
|
@ -59,10 +59,11 @@ public class TagAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
|
|
||||||
|
if (historyList != null) {
|
||||||
for (History history : historyList) {
|
for (History history : historyList) {
|
||||||
trendsEntry.add(0, new Entry(Float.parseFloat(history.day), Float.parseFloat(history.uses)));
|
trendsEntry.add(0, new Entry(Float.parseFloat(history.day), Float.parseFloat(history.uses)));
|
||||||
stat += Integer.parseInt(history.accounts);
|
stat += Integer.parseInt(history.accounts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tagViewHolder.binding.tagStats.setText(context.getString(R.string.talking_about, stat));
|
tagViewHolder.binding.tagStats.setText(context.getString(R.string.talking_about, stat));
|
||||||
LineDataSet dataTrending = new LineDataSet(trendsEntry, context.getString(R.string.trending));
|
LineDataSet dataTrending = new LineDataSet(trendsEntry, context.getString(R.string.trending));
|
||||||
|
|
Loading…
Reference in a new issue