|
|
@ -33,6 +33,7 @@ import android.view.ViewGroup; |
|
|
|
|
|
|
|
|
|
|
|
import com.keylesspalace.tusky.entity.Status; |
|
|
|
import com.keylesspalace.tusky.entity.Status; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import retrofit2.Call; |
|
|
|
import retrofit2.Call; |
|
|
@ -61,6 +62,9 @@ public class TimelineFragment extends SFragment implements |
|
|
|
private LinearLayoutManager layoutManager; |
|
|
|
private LinearLayoutManager layoutManager; |
|
|
|
private EndlessOnScrollListener scrollListener; |
|
|
|
private EndlessOnScrollListener scrollListener; |
|
|
|
private TabLayout.OnTabSelectedListener onTabSelectedListener; |
|
|
|
private TabLayout.OnTabSelectedListener onTabSelectedListener; |
|
|
|
|
|
|
|
private SharedPreferences preferences; |
|
|
|
|
|
|
|
private boolean filterRemoveReplies; |
|
|
|
|
|
|
|
private boolean filterRemoveReblogs; |
|
|
|
|
|
|
|
|
|
|
|
public static TimelineFragment newInstance(Kind kind) { |
|
|
|
public static TimelineFragment newInstance(Kind kind) { |
|
|
|
TimelineFragment fragment = new TimelineFragment(); |
|
|
|
TimelineFragment fragment = new TimelineFragment(); |
|
|
@ -181,6 +185,8 @@ public class TimelineFragment extends SFragment implements |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
recyclerView.addOnScrollListener(scrollListener); |
|
|
|
recyclerView.addOnScrollListener(scrollListener); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -274,7 +280,36 @@ public class TimelineFragment extends SFragment implements |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void filterStatuses(List<Status> statuses) { |
|
|
|
|
|
|
|
Iterator<Status> it = statuses.iterator(); |
|
|
|
|
|
|
|
while (it.hasNext()) { |
|
|
|
|
|
|
|
Status status = it.next(); |
|
|
|
|
|
|
|
if ((status.inReplyToId != null && filterRemoveReplies) || (status.reblog != null && filterRemoveReblogs)) { |
|
|
|
|
|
|
|
it.remove(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void setFiltersFromSettings() { |
|
|
|
|
|
|
|
boolean oldRemoveReplies = filterRemoveReplies; |
|
|
|
|
|
|
|
boolean oldRemoveReblogs = filterRemoveReblogs; |
|
|
|
|
|
|
|
filterRemoveReplies = (kind == Kind.HOME && !preferences.getBoolean("tabFilterHomeReplies", true)); |
|
|
|
|
|
|
|
filterRemoveReblogs = (kind == Kind.HOME && !preferences.getBoolean("tabFilterHomeBoosts", true)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (adapter.getItemCount() > 1 && (oldRemoveReblogs != filterRemoveReblogs || oldRemoveReplies != filterRemoveReplies)) { |
|
|
|
|
|
|
|
adapter.clear(); |
|
|
|
|
|
|
|
sendFetchTimelineRequest(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onResume() { |
|
|
|
|
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
setFiltersFromSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void onFetchTimelineSuccess(List<Status> statuses, String fromId) { |
|
|
|
public void onFetchTimelineSuccess(List<Status> statuses, String fromId) { |
|
|
|
|
|
|
|
filterStatuses(statuses); |
|
|
|
if (fromId != null) { |
|
|
|
if (fromId != null) { |
|
|
|
if (statuses.size() > 0 && !findStatus(statuses, fromId)) { |
|
|
|
if (statuses.size() > 0 && !findStatus(statuses, fromId)) { |
|
|
|
adapter.addItems(statuses); |
|
|
|
adapter.addItems(statuses); |
|
|
|