mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-07-08 04:40:28 +03:00
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;
|
||||||
|
boolean present = true;
|
||||||
|
if (pinned == null) {
|
||||||
|
pinned = new Pinned();
|
||||||
|
pinned.pinnedTimelines = new ArrayList<>();
|
||||||
|
present = false;
|
||||||
|
} else {
|
||||||
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
||||||
if (pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.host.compareToIgnoreCase(finalInstanceName) == 0) {
|
if (pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.host.compareToIgnoreCase(finalInstanceName) == 0) {
|
||||||
alreadyPinned = true;
|
alreadyPinned = true;
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
if (nodeInfo != null) {
|
|
||||||
RemoteInstance.InstanceType instanceType;
|
RemoteInstance.InstanceType instanceType;
|
||||||
|
if (nodeInfo != null) {
|
||||||
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,6 +766,9 @@ public class ProfileActivity extends BaseActivity {
|
||||||
} else {
|
} else {
|
||||||
instanceType = RemoteInstance.InstanceType.MASTODON;
|
instanceType = RemoteInstance.InstanceType.MASTODON;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
instanceType = RemoteInstance.InstanceType.MASTODON;
|
||||||
|
}
|
||||||
RemoteInstance remoteInstance = new RemoteInstance();
|
RemoteInstance remoteInstance = new RemoteInstance();
|
||||||
remoteInstance.type = instanceType;
|
remoteInstance.type = instanceType;
|
||||||
remoteInstance.host = finalInstanceName;
|
remoteInstance.host = finalInstanceName;
|
||||||
|
@ -768,9 +778,15 @@ public class ProfileActivity extends BaseActivity {
|
||||||
pinnedTimeline.type = Timeline.TimeLineEnum.REMOTE;
|
pinnedTimeline.type = Timeline.TimeLineEnum.REMOTE;
|
||||||
pinnedTimeline.position = pinned.pinnedTimelines.size();
|
pinnedTimeline.position = pinned.pinnedTimelines.size();
|
||||||
pinned.pinnedTimelines.add(pinnedTimeline);
|
pinned.pinnedTimelines.add(pinnedTimeline);
|
||||||
|
Pinned finalPinned = pinned;
|
||||||
|
boolean finalPresent = present;
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
new Pinned(ProfileActivity.this).updatePinned(pinned);
|
if (finalPresent) {
|
||||||
|
new Pinned(ProfileActivity.this).updatePinned(finalPinned);
|
||||||
|
} else {
|
||||||
|
new Pinned(ProfileActivity.this).insertPinned(finalPinned);
|
||||||
|
}
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
|
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
|
||||||
|
@ -782,7 +798,6 @@ public class ProfileActivity extends BaseActivity {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -59,11 +59,12 @@ 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));
|
||||||
dataTrending.setColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
|
dataTrending.setColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
|
||||||
|
|
Loading…
Reference in a new issue