From edc8b0c7debc79bd5aeb185e06bd3ff3342b0bb6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 3 Nov 2022 11:50:23 +0100 Subject: [PATCH] Some fixes --- .../android/ui/drawer/ContextAdapter.java | 90 ------------------- .../ui/drawer/ConversationAdapter.java | 1 + .../timeline/FragmentMastodonTimeline.java | 9 +- 3 files changed, 8 insertions(+), 92 deletions(-) delete mode 100644 app/src/main/java/app/fedilab/android/ui/drawer/ContextAdapter.java diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ContextAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ContextAdapter.java deleted file mode 100644 index b0c7fbea9..000000000 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ContextAdapter.java +++ /dev/null @@ -1,90 +0,0 @@ -package app.fedilab.android.ui.drawer; -/* Copyright 2021 Thomas Schneider - * - * This file is a part of Fedilab - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation; either version 3 of the - * License, or (at your option) any later version. - * - * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Fedilab; if not, - * see . */ - - -import static app.fedilab.android.ui.drawer.StatusAdapter.statusManagement; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.lifecycle.ViewModelProvider; -import androidx.lifecycle.ViewModelStoreOwner; -import androidx.recyclerview.widget.RecyclerView; - -import java.util.List; - -import app.fedilab.android.client.entities.api.Status; -import app.fedilab.android.client.entities.app.Timeline; -import app.fedilab.android.databinding.DrawerStatusBinding; -import app.fedilab.android.viewmodel.mastodon.SearchVM; -import app.fedilab.android.viewmodel.mastodon.StatusesVM; - - -public class ContextAdapter extends RecyclerView.Adapter { - private final List statusList; - private final int TYPE_NORMAL = 0; - private final int TYPE_FOCUSED = 1; - private Context context; - - public ContextAdapter(List statusList) { - this.statusList = statusList; - } - - public int getCount() { - return statusList.size(); - } - - public Status getItem(int position) { - return statusList.get(position); - } - - @Override - public int getItemViewType(int position) { - return statusList.get(position).isFocused ? TYPE_FOCUSED : TYPE_NORMAL; - } - - @NonNull - @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - context = parent.getContext(); - DrawerStatusBinding itemBinding = DrawerStatusBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); - return new StatusAdapter.StatusViewHolder(itemBinding); - } - - @Override - public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { - Status status = statusList.get(position); - StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class); - SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class); - StatusAdapter.StatusViewHolder holder = (StatusAdapter.StatusViewHolder) viewHolder; - statusManagement(context, statusesVM, searchVM, holder, this, statusList, status, Timeline.TimeLineEnum.UNKNOWN, false, true, null); - //Hide/Show specific view - - } - - public long getItemId(int position) { - return position; - } - - @Override - public int getItemCount() { - return statusList.size(); - } - - -} \ No newline at end of file diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java index d3acef6c7..b266bda29 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java @@ -111,6 +111,7 @@ public class ConversationAdapter extends RecyclerView.Adapter { if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) { getCachedStatus(direction, fetchingMissing, timelineParams); } else { getLiveStatus(direction, fetchingMissing, timelineParams, status); } - }, slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0 ? 0 : 1000); + }, slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0 ? 0 : 1000);*/ + if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) { + getCachedStatus(direction, fetchingMissing, timelineParams); + } else { + getLiveStatus(direction, fetchingMissing, timelineParams, status); + } }