mirror of
https://github.com/pachli/pachli-android.git
synced 2025-02-05 11:47:47 +01:00
refactor: Convert StatusActionListener to Kotlin (#73)
This commit is contained in:
parent
0bf459d385
commit
5193f31ad8
@ -339,7 +339,7 @@ class ConversationsFragment :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVoteInPoll(position: Int, choices: MutableList<Int>) {
|
||||
override fun onVoteInPoll(position: Int, choices: List<Int>) {
|
||||
adapter.peek(position)?.let { conversation ->
|
||||
viewModel.voteInPoll(choices, conversation)
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class SearchViewModel @Inject constructor(
|
||||
updateStatusViewData(statusViewData.copy(isCollapsed = collapsed))
|
||||
}
|
||||
|
||||
fun voteInPoll(statusViewData: StatusViewData, choices: MutableList<Int>) {
|
||||
fun voteInPoll(statusViewData: StatusViewData, choices: List<Int>) {
|
||||
val votedPoll = statusViewData.status.actionableStatus.poll!!.votedCopy(choices)
|
||||
updateStatus(statusViewData.status.copy(poll = votedPoll))
|
||||
viewModelScope.launch {
|
||||
|
@ -185,7 +185,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData>(), StatusActionLis
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVoteInPoll(position: Int, choices: MutableList<Int>) {
|
||||
override fun onVoteInPoll(position: Int, choices: List<Int>) {
|
||||
searchAdapter.peek(position)?.let {
|
||||
viewModel.voteInPoll(it, choices)
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
/* Copyright 2017 Andrew Dawson
|
||||
*
|
||||
* This file is a part of Pachli.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Pachli 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 Tusky; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package app.pachli.interfaces;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StatusActionListener extends LinkListener {
|
||||
void onReply(int position);
|
||||
void onReblog(final boolean reblog, final int position);
|
||||
void onFavourite(final boolean favourite, final int position);
|
||||
void onBookmark(final boolean bookmark, final int position);
|
||||
void onMore(@NonNull View view, final int position);
|
||||
void onViewMedia(int position, int attachmentIndex, @Nullable View view);
|
||||
void onViewThread(int position);
|
||||
|
||||
/**
|
||||
* Open reblog author for the status.
|
||||
* @param position At which position in the list status is located
|
||||
*/
|
||||
void onOpenReblog(int position);
|
||||
void onExpandedChange(boolean expanded, int position);
|
||||
void onContentHiddenChange(boolean isShowing, int position);
|
||||
|
||||
/**
|
||||
* Called when the status {@link android.widget.ToggleButton} responsible for collapsing long
|
||||
* status content is interacted with.
|
||||
*
|
||||
* @param isCollapsed Whether the status content is shown in a collapsed state or fully.
|
||||
* @param position The position of the status in the list.
|
||||
*/
|
||||
void onContentCollapsedChange(boolean isCollapsed, int position);
|
||||
|
||||
/**
|
||||
* called when the reblog count has been clicked
|
||||
* @param position The position of the status in the list.
|
||||
*/
|
||||
default void onShowReblogs(int position) {}
|
||||
|
||||
/**
|
||||
* called when the favourite count has been clicked
|
||||
* @param position The position of the status in the list.
|
||||
*/
|
||||
default void onShowFavs(int position) {}
|
||||
|
||||
void onVoteInPoll(int position, @NonNull List<Integer> choices);
|
||||
|
||||
default void onShowEdits(int position) {}
|
||||
|
||||
void clearWarningAction(int position);
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2023 Pachli Association
|
||||
*
|
||||
* This file is a part of Pachli.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Pachli 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 Pachli; if not,
|
||||
* see <http://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
package app.pachli.interfaces
|
||||
|
||||
import android.view.View
|
||||
|
||||
interface StatusActionListener : LinkListener {
|
||||
fun onReply(position: Int)
|
||||
fun onReblog(reblog: Boolean, position: Int)
|
||||
fun onFavourite(favourite: Boolean, position: Int)
|
||||
fun onBookmark(bookmark: Boolean, position: Int)
|
||||
fun onMore(view: View, position: Int)
|
||||
fun onViewMedia(position: Int, attachmentIndex: Int, view: View?)
|
||||
fun onViewThread(position: Int)
|
||||
|
||||
/**
|
||||
* Open reblog author for the status.
|
||||
* @param position At which position in the list status is located
|
||||
*/
|
||||
fun onOpenReblog(position: Int)
|
||||
fun onExpandedChange(expanded: Boolean, position: Int)
|
||||
fun onContentHiddenChange(isShowing: Boolean, position: Int)
|
||||
|
||||
/**
|
||||
* Called when the status [android.widget.ToggleButton] responsible for collapsing long
|
||||
* status content is interacted with.
|
||||
*
|
||||
* @param isCollapsed Whether the status content is shown in a collapsed state or fully.
|
||||
* @param position The position of the status in the list.
|
||||
*/
|
||||
fun onContentCollapsedChange(isCollapsed: Boolean, position: Int)
|
||||
|
||||
/**
|
||||
* called when the reblog count has been clicked
|
||||
* @param position The position of the status in the list.
|
||||
*/
|
||||
fun onShowReblogs(position: Int) {}
|
||||
|
||||
/**
|
||||
* called when the favourite count has been clicked
|
||||
* @param position The position of the status in the list.
|
||||
*/
|
||||
fun onShowFavs(position: Int) {}
|
||||
fun onVoteInPoll(position: Int, choices: List<Int>)
|
||||
fun onShowEdits(position: Int) {}
|
||||
fun clearWarningAction(position: Int)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user