mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Add methods for later
This commit is contained in:
parent
5abe3e63f9
commit
c95dfda3df
1 changed files with 40 additions and 0 deletions
|
@ -32,6 +32,7 @@ import androidx.lifecycle.LifecycleOwner;
|
|||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.work.Data;
|
||||
import androidx.work.OneTimeWorkRequest;
|
||||
|
||||
|
@ -42,6 +43,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -440,6 +442,44 @@ public class MastodonHelper {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single message depending of its publication date
|
||||
*
|
||||
* @param adapter - RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
* @param currentStatusList - Current list of messages List<Status>
|
||||
* @param statusToInsert - status to insert - Status
|
||||
*/
|
||||
public static void insertStatus(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter, List<Status> currentStatusList, Status statusToInsert) {
|
||||
if (adapter == null || currentStatusList == null || statusToInsert == null) {
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < currentStatusList.size() && statusToInsert.created_at.before(currentStatusList.get(i).created_at)) {
|
||||
i++;
|
||||
}
|
||||
currentStatusList.add(i, statusToInsert);
|
||||
adapter.notifyItemInserted(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a list of messages depending of its publication date
|
||||
*
|
||||
* @param adapter - RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
* @param currentStatusList - Current list of messages List<Status>
|
||||
* @param statusesToInsert - statuses to insert - List<Status>
|
||||
*/
|
||||
public static void insertStatuses(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter, List<Status> currentStatusList, List<Status> statusesToInsert) {
|
||||
if (adapter == null || currentStatusList == null || statusesToInsert == null || statusesToInsert.size() == 0) {
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < currentStatusList.size() && statusesToInsert.get(statusesToInsert.size() - 1).created_at.before(currentStatusList.get(i).created_at)) {
|
||||
i++;
|
||||
}
|
||||
currentStatusList.addAll(i, statusesToInsert);
|
||||
adapter.notifyItemRangeInserted(i, statusesToInsert.size());
|
||||
}
|
||||
|
||||
public enum ScheduleType {
|
||||
BOOST,
|
||||
TIMED_MUTED
|
||||
|
|
Loading…
Reference in a new issue