> :
PlaceSupportMvpFragment(), IWallView, WallAdapter.ClickListener,
- NonPublishedPostActionListener, MenuProvider, BackPressCallback {
+ NonPublishedPostActionListener, MenuProvider, BackPressCallback,
+ DocsUploadAdapter.ActionListener {
private var mSwipeRefreshLayout: SwipeRefreshLayout? = null
private var mWallAdapter: WallAdapter? = null
private var mLoadMoreFooterHelper: LoadMoreFooterHelper? = null
private var mStoryAdapter: HorizontalStoryAdapter? = null
private var fabCreate: UpEditFab? = null
+
+ private var mUploadAdapter: DocsUploadAdapter? = null
+ private var mUploadRoot: View? = null
protected fun setupPaganContent(Runes: View?, paganSymbol: RLottieImageView?) {
Runes?.visibility = if (Settings.get()
.other().isRunes_show
@@ -133,6 +157,75 @@ abstract class AbsWallFragment> :
return true
}
+ private val openRequestStory =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
+ if (result.data != null && result.resultCode == Activity.RESULT_OK) {
+ val localPhotos: ArrayList? =
+ result.data?.getParcelableArrayListExtraCompat(Extra.PHOTOS)
+ val file = result.data?.getStringExtra(Extra.PATH)
+ val video: LocalVideo? = result.data?.getParcelableExtraCompat(Extra.VIDEO)
+ lazyPresenter {
+ fireStorySelected(requireActivity(), localPhotos, file, video)
+ }
+ }
+ }
+
+ private val openRequestResizeStoryPhoto =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
+ if (result.resultCode == Activity.RESULT_OK) {
+ lazyPresenter {
+ doUploadStoryFile(
+ (result.data
+ ?: return@lazyPresenter).getStringExtra(IMGEditActivity.EXTRA_IMAGE_SAVE_PATH)
+ ?: return@lazyPresenter,
+ Upload.IMAGE_SIZE_FULL,
+ false
+ )
+ }
+ }
+ }
+
+ override fun doEditStoryPhoto(uri: Uri) {
+ try {
+ openRequestResizeStoryPhoto.launch(
+ Intent(requireContext(), IMGEditActivity::class.java)
+ .putExtra(IMGEditActivity.EXTRA_IMAGE_URI, uri)
+ .putExtra(
+ IMGEditActivity.EXTRA_IMAGE_SAVE_PATH,
+ File(requireActivity().externalCacheDir.toString() + File.separator + "scale.jpg").absolutePath
+ )
+ )
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ override fun showAvatarUploadedMessage(accountId: Long, post: Post) {
+ MaterialAlertDialogBuilder(requireActivity())
+ .setTitle(R.string.success)
+ .setMessage(R.string.avatar_was_changed_successfully)
+ .setPositiveButton(R.string.button_show) { _: DialogInterface?, _: Int ->
+ PlaceFactory.getPostPreviewPlace(
+ accountId,
+ post.vkid,
+ post.ownerId,
+ post
+ ).tryOpenWith(requireActivity())
+ }
+ .setNegativeButton(R.string.button_ok, null)
+ .show()
+ }
+
+ fun requestUploadStory() {
+ val sources = Sources()
+ .with(LocalPhotosSelectableSource())
+ .with(LocalGallerySelectableSource())
+ .with(LocalVideosSelectableSource())
+ .with(FileManagerSelectableSource())
+ val intent = DualTabPhotoActivity.createIntent(requireActivity(), 1, sources)
+ openRequestStory.launch(intent)
+ }
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
requireActivity().addMenuProvider(this, viewLifecycleOwner)
@@ -142,6 +235,10 @@ abstract class AbsWallFragment> :
getNarrativesPlace(accountId, ownerId).tryOpenWith(requireActivity())
}
+ override fun goClips(accountId: Long, ownerId: Long) {
+ getShortVideoPlace(accountId, ownerId).tryOpenWith(requireActivity())
+ }
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@@ -149,6 +246,14 @@ abstract class AbsWallFragment> :
): View? {
val root = inflater.inflate(R.layout.fragment_wall, container, false)
(requireActivity() as AppCompatActivity).setSupportActionBar(root.findViewById(R.id.toolbar))
+
+ val uploadRecyclerView: RecyclerView = root.findViewById(R.id.uploads_recycler_view)
+ uploadRecyclerView.layoutManager =
+ LinearLayoutManager(requireActivity(), LinearLayoutManager.HORIZONTAL, false)
+ mUploadAdapter = DocsUploadAdapter(emptyList(), this)
+ uploadRecyclerView.adapter = mUploadAdapter
+ mUploadRoot = root.findViewById(R.id.uploads_root)
+
mSwipeRefreshLayout = root.findViewById(R.id.refresh)
mSwipeRefreshLayout?.setOnRefreshListener {
presenter?.fireRefresh()
@@ -200,13 +305,46 @@ abstract class AbsWallFragment> :
}
override fun onStoryLongClick(item: Story, pos: Int): Boolean {
- PlaceFactory.getLikesCopiesPlace(
- Settings.get().accounts().current,
- "stories_view",
- item.ownerId,
- item.id,
- null
- ).tryOpenWith(requireActivity())
+ val isMy = item.ownerId == Settings.get().accounts().current
+ val items: Array = if (isMy) {
+ arrayOf(
+ getString(R.string.delete),
+ getString(R.string.views)
+ )
+ } else {
+ arrayOf(getString(R.string.answer), getString(R.string.views))
+ }
+ MaterialAlertDialogBuilder(requireActivity()).setItems(items) { _: DialogInterface?, i: Int ->
+ when (i) {
+ 0 -> {
+ if (!isMy) {
+ presenter?.updateToStory(AbsApi.join(
+ listOf(AccessIdPair(item.id, item.ownerId, item.accessKey)),
+ ","
+ ) { AccessIdPair.format(it) })
+ requestUploadStory()
+ } else {
+ MaterialAlertDialogBuilder(
+ requireActivity()
+ ).setMessage(R.string.do_delete)
+ .setTitle(R.string.confirmation)
+ .setCancelable(true)
+ .setPositiveButton(R.string.button_yes) { _: DialogInterface?, _: Int ->
+ presenter?.fireRemoveStoryClick(item.ownerId, item.id)
+ }.setNegativeButton(R.string.button_cancel, null)
+ .show()
+ }
+ }
+
+ 1 -> {
+ PlaceFactory.getStoriesViewPlace(
+ Settings.get().accounts().current,
+ item.ownerId,
+ item.id
+ ).tryOpenWith(requireActivity())
+ }
+ }
+ }.setCancelable(true).show()
return true
}
})
@@ -573,6 +711,36 @@ abstract class AbsWallFragment> :
presenter?.fireButtonRemoveClick(post)
}
+ override fun onRemoveClick(upload: Upload) {
+ presenter?.fireRemoveClick(
+ upload
+ )
+ }
+
+ override fun setUploadDataVisible(visible: Boolean) {
+ mUploadRoot?.visibility = if (visible) View.VISIBLE else View.GONE
+ }
+
+ override fun displayUploads(data: List) {
+ mUploadAdapter?.setData(data)
+ }
+
+ override fun notifyUploadItemsAdded(position: Int, count: Int) {
+ mUploadAdapter?.notifyItemRangeInserted(position, count)
+ }
+
+ override fun notifyUploadItemChanged(position: Int) {
+ mUploadAdapter?.notifyItemChanged(position)
+ }
+
+ override fun notifyUploadItemRemoved(position: Int) {
+ mUploadAdapter?.notifyItemRemoved(position)
+ }
+
+ override fun notifyUploadProgressChanged(position: Int, progress: Int, smoothly: Boolean) {
+ mUploadAdapter?.changeUploadProgress(position, progress, smoothly)
+ }
+
protected class OptionView : IWallView.IOptionView {
var isMy = false
var isBlacklistedByMe = false
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/AbsWallPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/AbsWallPresenter.kt
index 89b031a94..bdb05ffc3 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/AbsWallPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/AbsWallPresenter.kt
@@ -13,12 +13,14 @@ import android.widget.Spinner
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.imageview.ShapeableImageView
import com.google.android.material.textfield.TextInputEditText
+import dev.ragnarok.fenrir.Includes
import dev.ragnarok.fenrir.Includes.provideMainThreadScheduler
import dev.ragnarok.fenrir.R
import dev.ragnarok.fenrir.api.model.VKApiPost
import dev.ragnarok.fenrir.api.model.VKApiProfileInfo
import dev.ragnarok.fenrir.db.model.PostUpdate
import dev.ragnarok.fenrir.domain.IOwnersRepository
+import dev.ragnarok.fenrir.domain.IStoriesShortVideosInteractor
import dev.ragnarok.fenrir.domain.IWallsRepository
import dev.ragnarok.fenrir.domain.InteractorFactory
import dev.ragnarok.fenrir.domain.Repository
@@ -30,6 +32,16 @@ import dev.ragnarok.fenrir.model.criteria.WallCriteria
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.requireNonNull
import dev.ragnarok.fenrir.settings.Settings
+import dev.ragnarok.fenrir.upload.IUploadManager
+import dev.ragnarok.fenrir.upload.MessageMethod
+import dev.ragnarok.fenrir.upload.Method
+import dev.ragnarok.fenrir.upload.Upload
+import dev.ragnarok.fenrir.upload.UploadDestination
+import dev.ragnarok.fenrir.upload.UploadIntent
+import dev.ragnarok.fenrir.upload.UploadResult
+import dev.ragnarok.fenrir.upload.UploadUtils
+import dev.ragnarok.fenrir.util.Pair
+import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.checkEditInfo
import dev.ragnarok.fenrir.util.Utils.findIndexByPredicate
import dev.ragnarok.fenrir.util.Utils.findInfoByPredicate
@@ -59,6 +71,7 @@ abstract class AbsWallPresenter internal constructor(
val stories: MutableList
private val ownersRepository: IOwnersRepository
+ private val storiesInteractor: IStoriesShortVideosInteractor
private val walls: IWallsRepository
private val cacheCompositeDisposable = CompositeDisposable()
private val netCompositeDisposable = CompositeDisposable()
@@ -69,12 +82,45 @@ abstract class AbsWallPresenter internal constructor(
private var nowRequestOffset = 0
private var nextOffset = 0
private var actualDataReady = false
-
+ private val uploadManager: IUploadManager = Includes.uploadManager
private var skipWallOffset = 0
+ private var toStory: String? = null
+ private val uploadsData: MutableList = ArrayList(0)
open fun searchStory(ByName: Boolean) {
throw IllegalArgumentException("Unknown story search")
}
+ private fun firePrepared() {
+ appendDisposable(uploadManager[accountId, listOf(Method.STORY, Method.PHOTO_TO_PROFILE)]
+ .fromIOToMain()
+ .subscribe { data -> onUploadsDataReceived(data) })
+ appendDisposable(uploadManager.observeAdding()
+ .observeOn(provideMainThreadScheduler())
+ .subscribe { added -> onUploadsAdded(added) })
+ appendDisposable(uploadManager.observeDeleting(true)
+ .observeOn(provideMainThreadScheduler())
+ .subscribe { ids -> onUploadDeleted(ids) })
+ appendDisposable(uploadManager.observeResults()
+ .filter {
+ listOf(
+ Method.STORY,
+ Method.PHOTO_TO_PROFILE
+ ).contains(it.first.destination.method)
+ }
+ .observeOn(provideMainThreadScheduler())
+ .subscribe { pair -> onUploadFinished(pair) })
+ appendDisposable(uploadManager.observeStatus()
+ .observeOn(provideMainThreadScheduler())
+ .subscribe { upload -> onUploadStatusUpdate(upload) })
+ appendDisposable(uploadManager.observeProgress()
+ .observeOn(provideMainThreadScheduler())
+ .subscribe { updates -> onProgressUpdates(updates) })
+ }
+
+ fun updateToStory(toStory: String?) {
+ this.toStory = toStory
+ }
+
fun fireRequestSkipOffset() {
view?.onRequestSkipOffset(accountId, ownerId, wallFilter, nextOffset + skipWallOffset)
}
@@ -83,6 +129,10 @@ abstract class AbsWallPresenter internal constructor(
view?.goNarratives(accountId, ownerId)
}
+ fun fireClipsClick() {
+ view?.goClips(accountId, ownerId)
+ }
+
private fun onPostInvalid(postVkid: Int) {
val index = findIndexByPredicate(
wall
@@ -133,6 +183,9 @@ abstract class AbsWallPresenter internal constructor(
viewHost.displayWallData(wall)
viewHost.updateStory(stories)
resolveLoadMoreFooterView()
+
+ viewHost.displayUploads(uploadsData)
+ resolveUploadDataVisibility()
}
internal fun onExecuteComplete() {
@@ -160,10 +213,22 @@ abstract class AbsWallPresenter internal constructor(
.subscribe({ onExecuteComplete() }) { t -> onExecuteError(t) })
}
+ fun fireRemoveStoryClick(storyOwnerId: Long, id: Int) {
+ appendDisposable(
+ storiesInteractor
+ .stories_delete(accountId, storyOwnerId, id)
+ .fromIOToMain()
+ .subscribe({ fireRefresh() }) { t -> onExecuteError(t) })
+ }
+
private fun loadWallCachedData() {
cacheCompositeDisposable.add(walls.getCachedWall(accountId, ownerId, wallFilter)
.fromIOToMain()
- .subscribe({ posts -> onCachedDataReceived(posts) }) { obj -> obj.printStackTrace() })
+ .subscribe({ posts -> onCachedDataReceived(posts) }) { obj ->
+ obj.printStackTrace()
+ actualDataReady = false
+ requestWall(0)
+ })
}
private fun onCachedDataReceived(posts: List) {
@@ -171,6 +236,7 @@ abstract class AbsWallPresenter internal constructor(
wall.addAll(posts)
actualDataReady = false
view?.notifyWallDataSetChanged()
+ requestWall(0)
}
public override fun onGuiResumed() {
@@ -406,7 +472,7 @@ abstract class AbsWallPresenter internal constructor(
cacheCompositeDisposable.clear()
requestWall(0)
if (!Settings.get().other().isDisable_history) {
- appendDisposable(ownersRepository.getStory(
+ appendDisposable(storiesInteractor.getStory(
accountId,
if (accountId == ownerId) null else ownerId
)
@@ -629,16 +695,216 @@ abstract class AbsWallPresenter internal constructor(
}
}
+ private fun doUploadStoryFile(context: Context, file: String) {
+ for (i in Settings.get().other().photoExt()) {
+ if (file.endsWith(i, true)) {
+ Uri.fromFile(
+ File(
+ file
+ )
+ )
+ return
+ }
+ }
+ for (i in Settings.get().other().videoExt()) {
+ if (file.endsWith(i, true)) {
+ doUploadStoryFile(
+ file,
+ 0,
+ true
+ )
+ return
+ }
+ }
+ MaterialAlertDialogBuilder(context)
+ .setTitle(R.string.select)
+ .setNegativeButton(R.string.video) { _: DialogInterface?, _: Int ->
+ doUploadStoryFile(
+ file,
+ 0,
+ true
+ )
+ }
+ .setPositiveButton(R.string.photo) { _: DialogInterface?, _: Int ->
+ view?.doEditStoryPhoto(
+ Uri.fromFile(
+ File(
+ file
+ )
+ )
+ )
+ }
+ .create().show()
+ }
+
+ fun doUploadStoryFile(file: String, size: Int, isVideo: Boolean) {
+ val intents: List = if (isVideo) {
+ UploadUtils.createIntents(
+ accountId,
+ UploadDestination.forStory(MessageMethod.VIDEO, toStory),
+ file,
+ size,
+ true
+ )
+ } else {
+ UploadUtils.createIntents(
+ accountId,
+ UploadDestination.forStory(MessageMethod.PHOTO, toStory),
+ file,
+ size,
+ true
+ )
+ }
+ toStory = null
+ uploadManager.enqueue(intents)
+ }
+
+ fun fireRemoveClick(upload: Upload) {
+ uploadManager.cancel(upload.getObjectId())
+ }
+
+ private fun doUploadStoryVideo(file: String) {
+ val intents = UploadUtils.createVideoIntents(
+ accountId,
+ UploadDestination.forStory(MessageMethod.VIDEO, toStory),
+ file,
+ true
+ )
+ toStory = null
+ uploadManager.enqueue(intents)
+ }
+
+ private fun doUploadStoryPhotos(photos: List) {
+ if (photos.size == 1) {
+ var to_up = photos[0].getFullImageUri() ?: return
+ if (to_up.path?.let { File(it).isFile } == true) {
+ to_up = Uri.fromFile(to_up.path?.let { File(it) })
+ }
+ view?.doEditStoryPhoto(to_up)
+ return
+ }
+ val intents = UploadUtils.createIntents(
+ accountId,
+ UploadDestination.forStory(MessageMethod.PHOTO, toStory),
+ photos,
+ Upload.IMAGE_SIZE_FULL,
+ true
+ )
+ toStory = null
+ uploadManager.enqueue(intents)
+ }
+
+ fun fireStorySelected(
+ context: Context,
+ localPhotos: ArrayList?,
+ file: String?,
+ video: LocalVideo?
+ ) {
+ when {
+ file.nonNullNoEmpty() -> doUploadStoryFile(context, file)
+ localPhotos.nonNullNoEmpty() -> {
+ doUploadStoryPhotos(localPhotos)
+ }
+
+ video != null -> {
+ doUploadStoryVideo(video.getData().toString())
+ }
+ }
+ }
+
+ fun fireNewAvatarPhotoSelected(file: String?) {
+ val intent = UploadIntent(accountId, UploadDestination.forProfilePhoto(ownerId))
+ .setAutoCommit(true)
+ .setFileUri(Uri.parse(file))
+ .setSize(Upload.IMAGE_SIZE_FULL)
+ uploadManager.enqueue(listOf(intent))
+ }
+
+ private fun onUploadFinished(pair: Pair>) {
+ val destination = pair.first.destination
+ if (destination.method == Method.PHOTO_TO_PROFILE && destination.ownerId == ownerId) {
+ onRefresh()
+ val post = pair.second.result as Post
+ resumedView?.showAvatarUploadedMessage(
+ accountId,
+ post
+ )
+ } else if (destination.method == Method.STORY && Settings.get()
+ .accounts().current == ownerId
+ ) {
+ fireRefresh()
+ }
+ }
+
+ private fun resolveUploadDataVisibility() {
+ view?.setUploadDataVisible(uploadsData.isNotEmpty())
+ }
+
+ private fun onUploadsDataReceived(data: List) {
+ uploadsData.clear()
+ uploadsData.addAll(data)
+ resolveUploadDataVisibility()
+ }
+
+ private fun onProgressUpdates(updates: List) {
+ for (update in updates) {
+ val index = Utils.findIndexById(uploadsData, update.id)
+ if (index != -1) {
+ view?.notifyUploadProgressChanged(
+ index,
+ update.progress,
+ true
+ )
+ }
+ }
+ }
+
+ private fun onUploadStatusUpdate(upload: Upload) {
+ val index = Utils.findIndexById(uploadsData, upload.getObjectId())
+ if (index != -1) {
+ view?.notifyUploadItemChanged(
+ index
+ )
+ }
+ }
+
+ private fun onUploadsAdded(added: List) {
+ for (u in added) {
+ if (listOf(Method.STORY, Method.PHOTO_TO_PROFILE).contains(u.destination.method)) {
+ val index = uploadsData.size
+ uploadsData.add(u)
+ view?.notifyUploadItemsAdded(
+ index,
+ 1
+ )
+ }
+ }
+ resolveUploadDataVisibility()
+ }
+
+ private fun onUploadDeleted(ids: IntArray) {
+ for (id in ids) {
+ val index = Utils.findIndexById(uploadsData, id)
+ if (index != -1) {
+ uploadsData.removeAt(index)
+ view?.notifyUploadItemRemoved(
+ index
+ )
+ }
+ }
+ resolveUploadDataVisibility()
+ }
+
init {
wall = ArrayList()
stories = ArrayList()
wallFilter = WallCriteria.MODE_ALL
walls = Repository.walls
ownersRepository = owners
+ storiesInteractor = InteractorFactory.createStoriesInteractor()
loadWallCachedData()
- requestWall(0)
if (!Settings.get().other().isDisable_history) {
- appendDisposable(ownersRepository.getStory(
+ appendDisposable(storiesInteractor.getStory(
accountId,
if (accountId == ownerId) null else ownerId
)
@@ -666,5 +932,6 @@ abstract class AbsWallPresenter internal constructor(
.filter { it.ownerId == ownerId }
.observeOn(provideMainThreadScheduler())
.subscribe { onPostInvalid(it.id) })
+ firePrepared()
}
}
\ No newline at end of file
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/IWallView.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/IWallView.kt
index 851d19c00..a0855dda3 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/IWallView.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/abswall/IWallView.kt
@@ -1,5 +1,6 @@
package dev.ragnarok.fenrir.fragment.abswall
+import android.net.Uri
import dev.ragnarok.fenrir.fragment.base.IAttachmentsPlacesView
import dev.ragnarok.fenrir.fragment.base.core.IErrorView
import dev.ragnarok.fenrir.fragment.base.core.IMvpView
@@ -11,6 +12,7 @@ import dev.ragnarok.fenrir.model.Owner
import dev.ragnarok.fenrir.model.Photo
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.model.Story
+import dev.ragnarok.fenrir.upload.Upload
interface IWallView : IAttachmentsPlacesView, IMvpView, ISnackbarView,
IErrorView, IToastView {
@@ -37,9 +39,11 @@ interface IWallView : IAttachmentsPlacesView, IMvpView, ISnackbarView,
fun goToWallSearch(accountId: Long, ownerId: Long)
fun openPostEditor(accountId: Long, post: Post)
+ fun showAvatarUploadedMessage(accountId: Long, post: Post)
fun notifyWallItemRemoved(index: Int)
fun goToConversationAttachments(accountId: Long, ownerId: Long)
fun goNarratives(accountId: Long, ownerId: Long)
+ fun goClips(accountId: Long, ownerId: Long)
interface IOptionView {
fun typeOwnerId(id: Long)
fun setIsMy(my: Boolean)
@@ -48,5 +52,14 @@ interface IWallView : IAttachmentsPlacesView, IMvpView, ISnackbarView,
fun setIsSubscribed(subscribed: Boolean)
}
+ fun doEditStoryPhoto(uri: Uri)
+
fun onRequestSkipOffset(accountId: Long, ownerId: Long, wallFilter: Int, currentPos: Int)
+
+ fun notifyUploadItemsAdded(position: Int, count: Int)
+ fun notifyUploadItemRemoved(position: Int)
+ fun notifyUploadItemChanged(position: Int)
+ fun notifyUploadProgressChanged(position: Int, progress: Int, smoothly: Boolean)
+ fun setUploadDataVisible(visible: Boolean)
+ fun displayUploads(data: List)
}
\ No newline at end of file
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt
index cfc73ef87..7e4d70b98 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt
@@ -50,7 +50,6 @@ import dev.ragnarok.fenrir.util.serializeble.json.*
import dev.ragnarok.fenrir.util.toast.CustomSnackbars
import dev.ragnarok.fenrir.util.toast.CustomToast.Companion.createCustomToast
import okhttp3.*
-import java.util.*
class AccountsFragment : BaseMvpFragment(), IAccountsView,
View.OnClickListener, AccountAdapter.Callback,
@@ -250,7 +249,7 @@ class AccountsFragment : BaseMvpFragment(), IA
}
}).attachToRecyclerView(mRecyclerView)
root.findViewById(R.id.fab).setOnClickListener(this)
- mAdapter = AccountAdapter(requireActivity(), Collections.emptyList(), this)
+ mAdapter = AccountAdapter(requireActivity(), emptyList(), this)
mRecyclerView?.adapter = mAdapter
return root
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt
index 07fe91ba7..545e6719d 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt
@@ -46,7 +46,7 @@ import dev.ragnarok.fenrir.view.WeakRunnable
import dev.ragnarok.fenrir.view.YoutubeButton
import me.minetsh.imaging.IMGEditActivity
import java.io.File
-import java.util.*
+import java.util.Locale
abstract class AbsAttachmentsEditFragment, V : IBaseAttachmentsEditView> :
BaseMvpFragment
(), IBaseAttachmentsEditView, AttchmentsEditorAdapter.Callback,
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentcreate/CommentCreatePresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentcreate/CommentCreatePresenter.kt
index 552cf217a..a00faeca0 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentcreate/CommentCreatePresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentcreate/CommentCreatePresenter.kt
@@ -169,7 +169,7 @@ class CommentCreatePresenter(
appendDisposable(uploadManager.observeAdding()
.observeOn(provideMainThreadScheduler())
.subscribe { it -> onUploadQueueUpdates(it) { destination.compareTo(it.destination) } })
- appendDisposable(uploadManager.obseveStatus()
+ appendDisposable(uploadManager.observeStatus()
.observeOn(provideMainThreadScheduler())
.subscribe {
onUploadStatusUpdate(
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentedit/CommentEditPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentedit/CommentEditPresenter.kt
index 355bb0205..f84f9070b 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentedit/CommentEditPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/commentedit/CommentEditPresenter.kt
@@ -207,7 +207,7 @@ class CommentEditPresenter(
it
)
})
- appendDisposable(uploadManager.obseveStatus()
+ appendDisposable(uploadManager.observeStatus()
.observeOn(provideMainThreadScheduler())
.subscribe {
onUploadStatusUpdate(
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postcreate/PostCreatePresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postcreate/PostCreatePresenter.kt
index 51e2e95a3..c3bd33b3d 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postcreate/PostCreatePresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postcreate/PostCreatePresenter.kt
@@ -210,7 +210,7 @@ class PostCreatePresenter(
appendDisposable(uploadManager.observeProgress()
.observeOn(provideMainThreadScheduler())
.subscribe { onUploadProgressUpdate(it) })
- appendDisposable(uploadManager.obseveStatus()
+ appendDisposable(uploadManager.observeStatus()
.observeOn(provideMainThreadScheduler())
.subscribe {
onUploadStatusUpdate(
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postedit/PostEditPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postedit/PostEditPresenter.kt
index 6d95031f7..ae39f58a7 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postedit/PostEditPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/postedit/PostEditPresenter.kt
@@ -437,7 +437,7 @@ class PostEditPresenter(
appendDisposable(uploadManager.observeProgress()
.observeOn(provideMainThreadScheduler())
.subscribe { onUploadProgressUpdate(it) })
- appendDisposable(uploadManager.obseveStatus()
+ appendDisposable(uploadManager.observeStatus()
.observeOn(provideMainThreadScheduler())
.subscribe {
onUploadStatusUpdate(
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt
index 1360c53f6..c489b0d56 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt
@@ -67,7 +67,7 @@ class AudiosLocalPresenter(accountId: Long, savedInstanceState: Bundle?) :
}
.observeOn(provideMainThreadScheduler())
.subscribe { pair -> onUploadResults(pair) })
- appendDisposable(uploadManager.obseveStatus()
+ appendDisposable(uploadManager.observeStatus()
.observeOn(provideMainThreadScheduler())
.subscribe { upload -> onUploadStatusUpdate(upload) })
appendDisposable(uploadManager.observeProgress()
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/base/AttachmentsViewBinder.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/base/AttachmentsViewBinder.kt
index 24ff2e2a6..005bca2cb 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/base/AttachmentsViewBinder.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/base/AttachmentsViewBinder.kt
@@ -42,7 +42,6 @@ import dev.ragnarok.fenrir.view.WaveFormView
import dev.ragnarok.fenrir.view.emoji.EmojiconTextView
import dev.ragnarok.fenrir.view.natives.rlottie.RLottieImageView
import java.lang.ref.WeakReference
-import java.util.*
import kotlin.math.abs
class AttachmentsViewBinder(
@@ -1007,7 +1006,7 @@ class AttachmentsViewBinder(
}
}
- interface VoiceActionListener : EventListener {
+ interface VoiceActionListener {
fun onVoiceHolderBinded(voiceMessageId: Int, voiceHolderId: Int)
fun onVoicePlayButtonClick(
voiceHolderId: Int,
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/comments/CommentsPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/comments/CommentsPresenter.kt
index 779edb234..89fe154af 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/comments/CommentsPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/comments/CommentsPresenter.kt
@@ -1058,7 +1058,9 @@ class CommentsPresenter(
cacheLoadingDisposable.add(
interactor.getAllCachedData(accountId, commented)
.fromIOToMain()
- .subscribe({ onCachedDataReceived(it) }, ignore())
+ .subscribe({ onCachedDataReceived(it) }, {
+ requestInitialData()
+ })
)
}
@@ -1099,6 +1101,7 @@ class CommentsPresenter(
if (!directionDesc) {
view?.scrollToPosition(data.size - 1)
}
+ requestInitialData()
}
@SuppressLint("CheckResult")
@@ -1167,10 +1170,6 @@ class CommentsPresenter(
directionDesc = Settings.get().other().isCommentsDesc
this.CommentThread = CommentThread
data = ArrayList()
- if (focusToComment == null && CommentThread == null) {
- // если надо сфокусироваться на каком-то комментарии - не грузим из кэша
- loadCachedData()
- }
val attachmentsRepository = attachmentsRepository
appendDisposable(attachmentsRepository
.observeAdding()
@@ -1189,7 +1188,12 @@ class CommentsPresenter(
.observeOn(provideMainThreadScheduler())
.subscribe({ update -> onCommentMinorUpdate(update) }) { it.printStackTrace() })
restoreDraftCommentSync()
- requestInitialData()
loadAuthorData()
+ if (focusToComment == null && CommentThread == null) {
+ // если надо сфокусироваться на каком-то комментарии - не грузим из кэша
+ loadCachedData()
+ } else {
+ requestInitialData()
+ }
}
}
\ No newline at end of file
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAdapter.kt
index 54feb7f9e..ef9ee0b57 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAdapter.kt
@@ -13,7 +13,6 @@ import dev.ragnarok.fenrir.model.PhotoSize
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.picasso.PicassoInstance.Companion.with
import dev.ragnarok.fenrir.util.AppTextUtils
-import java.util.EventListener
import java.util.Locale
class DocsAdapter(data: MutableList) :
@@ -61,7 +60,7 @@ class DocsAdapter(data: MutableList) :
return R.layout.item_document_big
}
- interface ActionListener : EventListener {
+ interface ActionListener {
fun onDocClick(index: Int, doc: Document)
fun onDocLongClick(index: Int, doc: Document): Boolean
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAsImagesAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAsImagesAdapter.kt
index a05903f11..4c69a3efd 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAsImagesAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsAsImagesAdapter.kt
@@ -11,7 +11,6 @@ import dev.ragnarok.fenrir.model.Document
import dev.ragnarok.fenrir.model.PhotoSize
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.picasso.PicassoInstance.Companion.with
-import java.util.EventListener
class DocsAsImagesAdapter(data: MutableList) :
RecyclerBindableAdapter(data) {
@@ -54,7 +53,7 @@ class DocsAsImagesAdapter(data: MutableList) :
return R.layout.item_doc_as_image
}
- interface ActionListener : EventListener {
+ interface ActionListener {
fun onDocClick(index: Int, doc: Document)
fun onDocLongClick(index: Int, doc: Document): Boolean
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt
index de661e650..eb56304e5 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt
@@ -518,7 +518,7 @@ class DocsListPresenter(
}
.observeOn(provideMainThreadScheduler())
.subscribe { onUploadResults(it) })
- appendDisposable(uploadManager.obseveStatus()
+ appendDisposable(uploadManager.observeStatus()
.observeOn(provideMainThreadScheduler())
.subscribe { onUploadStatusUpdate(it) })
appendDisposable(uploadManager.observeProgress()
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/feedback/FeedbackAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/feedback/FeedbackAdapter.kt
index 726560a61..167e5d5ea 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/feedback/FeedbackAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/feedback/FeedbackAdapter.kt
@@ -24,7 +24,6 @@ import dev.ragnarok.fenrir.model.feedback.ReplyCommentFeedback
import dev.ragnarok.fenrir.model.feedback.UsersFeedback
import dev.ragnarok.fenrir.view.OnlineView
import java.util.Calendar
-import java.util.EventListener
class FeedbackAdapter(
context: Activity,
@@ -281,7 +280,7 @@ class FeedbackAdapter(
}
}
- interface ClickListener : EventListener {
+ interface ClickListener {
fun onNotificationClick(notification: Feedback)
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/filemanagerselect/FileManagerSelectFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/filemanagerselect/FileManagerSelectFragment.kt
index 11f46141c..8d50b35fb 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/filemanagerselect/FileManagerSelectFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/filemanagerselect/FileManagerSelectFragment.kt
@@ -37,7 +37,6 @@ import dev.ragnarok.fenrir.view.natives.rlottie.RLottieImageView
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.Disposable
import java.io.File
-import java.util.Collections
import java.util.concurrent.TimeUnit
class FileManagerSelectFragment :
@@ -140,7 +139,7 @@ class FileManagerSelectFragment :
mHeader?.visibility =
if (arguments?.getBoolean(Extra.HIDE_TITLE, false) == true) View.GONE else View.VISIBLE
- mAdapter = FileManagerSelectAdapter(Collections.emptyList())
+ mAdapter = FileManagerSelectAdapter(emptyList())
mAdapter?.setClickListener(this)
mRecyclerView?.adapter = mAdapter
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesPresenter.kt
index e0c177176..ae67ed79a 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesPresenter.kt
@@ -20,7 +20,7 @@ import kotlinx.serialization.builtins.ListSerializer
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
-import java.util.*
+import java.util.Locale
class FriendsByPhonesPresenter(accountId: Long, context: Context, savedInstanceState: Bundle?) :
AccountDependencyPresenter(accountId, savedInstanceState) {
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupchats/GroupChatsAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupchats/GroupChatsAdapter.kt
index 9acaf444f..bf931793f 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupchats/GroupChatsAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupchats/GroupChatsAdapter.kt
@@ -18,7 +18,6 @@ import dev.ragnarok.fenrir.settings.CurrentTheme
import dev.ragnarok.fenrir.util.AppTextUtils
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.toast.CustomToast.Companion.createCustomToast
-import java.util.EventListener
class GroupChatsAdapter(
context: Context,
@@ -89,7 +88,7 @@ class GroupChatsAdapter(
return R.layout.item_group_chat
}
- interface ActionListener : EventListener {
+ interface ActionListener {
fun onGroupChatsClick(chat: GroupChats)
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallFragment.kt
index b1e91e728..62a0fcb3e 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallFragment.kt
@@ -514,7 +514,8 @@ class GroupWallFragment : AbsWallFragment(),
products: Int,
chats: Int,
products_services: Int,
- narratives: Int
+ narratives: Int,
+ clips: Int
) {
if (mHeaderHolder == null) return
setupCounter(mHeaderHolder?.bTopics, topics)
@@ -527,6 +528,7 @@ class GroupWallFragment : AbsWallFragment(),
setupCounter(mHeaderHolder?.bProducts, products)
setupCounter(mHeaderHolder?.bProductServices, products_services)
setupCounter(mHeaderHolder?.bNarratives, narratives)
+ setupCounter(mHeaderHolder?.bClips, clips)
setupCounterFlow(mHeaderHolder?.bChats, mHeaderHolder?.bChatsContainer, chats)
}
@@ -581,6 +583,7 @@ class GroupWallFragment : AbsWallFragment(),
val bProducts: TextView = root.findViewById(R.id.header_group_bproducts)
val bProductServices: TextView = root.findViewById(R.id.header_group_bservices_products)
val bNarratives: TextView = root.findViewById(R.id.header_group_bnarratives)
+ val bClips: TextView = root.findViewById(R.id.header_group_bclips)
val bMembers: TextView = root.findViewById(R.id.header_group_bmembers)
val bDocuments: TextView = root.findViewById(R.id.header_group_bdocuments)
val bPhotos: TextView = root.findViewById(R.id.header_group_bphotos)
@@ -692,6 +695,12 @@ class GroupWallFragment : AbsWallFragment(),
.setOnClickListener {
presenter?.fireNarrativesClick()
}
+ root.findViewById(R.id.header_group_clips_container).let {
+ it.setOnClickListener {
+ presenter?.fireClipsClick()
+ }
+ it.visibility = if (Utils.isOfficialVKCurrent) View.VISIBLE else View.GONE
+ }
bChatsContainer.setOnClickListener {
presenter?.fireGroupChatsClick()
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallPresenter.kt
index e49bb33ef..d92f8b9c8 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/GroupWallPresenter.kt
@@ -9,6 +9,7 @@ import dev.ragnarok.fenrir.api.model.VKApiCommunity
import dev.ragnarok.fenrir.domain.ICommunitiesInteractor
import dev.ragnarok.fenrir.domain.IFaveInteractor
import dev.ragnarok.fenrir.domain.IOwnersRepository
+import dev.ragnarok.fenrir.domain.IStoriesShortVideosInteractor
import dev.ragnarok.fenrir.domain.IWallsRepository
import dev.ragnarok.fenrir.domain.InteractorFactory
import dev.ragnarok.fenrir.domain.Repository.owners
@@ -46,6 +47,7 @@ class GroupWallPresenter(
private val faveInteractor: IFaveInteractor
private val ownersRepository: IOwnersRepository
private val communitiesInteractor: ICommunitiesInteractor
+ private val storiesInteractor: IStoriesShortVideosInteractor
private val wallsRepository: IWallsRepository
private val filters: MutableList
private val menus: MutableList
@@ -72,7 +74,8 @@ class GroupWallPresenter(
details.getProductsCount(),
details.getChatsCount(),
details.getProductServicesCount(),
- details.getNarrativesCount()
+ details.getNarrativesCount(),
+ details.getClipsCount()
)
}
@@ -570,7 +573,7 @@ class GroupWallPresenter(
}
override fun searchStory(ByName: Boolean) {
- appendDisposable(ownersRepository.searchStory(
+ appendDisposable(storiesInteractor.searchStory(
accountId,
if (ByName) community.fullName else null,
if (ByName) null else ownerId
@@ -595,6 +598,7 @@ class GroupWallPresenter(
community = pCommunity ?: Community(abs(ownerId))
details = CommunityDetails()
ownersRepository = owners
+ storiesInteractor = InteractorFactory.createStoriesInteractor()
faveInteractor = InteractorFactory.createFaveInteractor()
communitiesInteractor = InteractorFactory.createCommunitiesInteractor()
settings = Includes.settings.accounts()
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/IGroupWallView.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/IGroupWallView.kt
index a19a988cf..64f84dae1 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/IGroupWallView.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/groupwall/IGroupWallView.kt
@@ -37,7 +37,8 @@ interface IGroupWallView : IWallView {
products: Int,
chats: Int,
products_services: Int,
- narratives: Int
+ narratives: Int,
+ clips: Int
)
fun invalidateOptionsMenu()
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/LikesFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/LikesFragment.kt
index c88a694bb..f8714aee3 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/LikesFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/LikesFragment.kt
@@ -14,11 +14,7 @@ class LikesFragment : AbsOwnersListFragment
- onDataReceived(
- offset,
- owners
- )
- }) { t -> onDataGetError(t) })
- } else {
- netDisposable.add(likesInteractor.getLikes(
- accountId,
- type,
- ownerId,
- itemId,
- filter,
- 50,
- offset
- )
- .fromIOToMain()
- .subscribe({ owners ->
- onDataReceived(
- offset,
- owners
- )
- }) { t -> onDataGetError(t) })
- }
+ netDisposable.add(likesInteractor.getLikes(
+ accountId,
+ type,
+ ownerId,
+ itemId,
+ filter,
+ 50,
+ offset
+ )
+ .fromIOToMain()
+ .subscribe({ owners ->
+ onDataReceived(
+ offset,
+ owners
+ )
+ }) { t -> onDataGetError(t) })
}
private fun onDataGetError(t: Throwable) {
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/IStoriesViewView.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/IStoriesViewView.kt
new file mode 100644
index 000000000..bc835ef37
--- /dev/null
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/IStoriesViewView.kt
@@ -0,0 +1,16 @@
+package dev.ragnarok.fenrir.fragment.likes.storiesview
+
+import androidx.annotation.StringRes
+import dev.ragnarok.fenrir.fragment.base.core.IErrorView
+import dev.ragnarok.fenrir.fragment.base.core.IMvpView
+import dev.ragnarok.fenrir.model.Owner
+
+interface IStoriesViewView : IMvpView, IErrorView {
+ fun displayOwnerList(owners: List>)
+ fun notifyDataSetChanged()
+ fun notifyDataAdded(position: Int, count: Int)
+ fun notifyDataRemoved(position: Int, count: Int)
+ fun displayRefreshing(refreshing: Boolean)
+ fun showOwnerWall(accountId: Long, owner: Owner)
+ fun updateTitle(@StringRes res: Int)
+}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewAdapter.kt
new file mode 100644
index 000000000..16581edeb
--- /dev/null
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewAdapter.kt
@@ -0,0 +1,180 @@
+package dev.ragnarok.fenrir.fragment.likes.storiesview
+
+import android.content.Context
+import android.graphics.Color
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.squareup.picasso3.Transformation
+import dev.ragnarok.fenrir.Constants
+import dev.ragnarok.fenrir.R
+import dev.ragnarok.fenrir.activity.SelectionUtils.addSelectionProfileSupport
+import dev.ragnarok.fenrir.fragment.communities.CommunitiesAdapter.Companion.getCommunityType
+import dev.ragnarok.fenrir.model.Community
+import dev.ragnarok.fenrir.model.Owner
+import dev.ragnarok.fenrir.model.User
+import dev.ragnarok.fenrir.picasso.PicassoInstance.Companion.with
+import dev.ragnarok.fenrir.settings.CurrentTheme
+import dev.ragnarok.fenrir.util.AppTextUtils
+import dev.ragnarok.fenrir.util.UserInfoResolveUtil
+import dev.ragnarok.fenrir.util.Utils
+import dev.ragnarok.fenrir.util.ViewUtils
+import dev.ragnarok.fenrir.util.ViewUtils.displayAvatar
+import dev.ragnarok.fenrir.view.OnlineView
+
+class StoriesViewAdapter(
+ private val mContext: Context,
+ private var mData: List>
+) :
+ RecyclerView.Adapter() {
+ private val transformation: Transformation = CurrentTheme.createTransformationForAvatar()
+ private val transformationWithStory: Transformation =
+ CurrentTheme.createTransformationStrokeForAvatar()
+ private var mClickListener: ClickListener? = null
+ private var longClickListener: LongClickListener? = null
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
+ when (viewType) {
+ TYPE_USER -> return PeopleHolder(
+ LayoutInflater.from(mContext).inflate(R.layout.item_people_with_like, parent, false)
+ )
+
+ TYPE_COMMUNITY -> return CommunityHolder(
+ LayoutInflater.from(mContext).inflate(R.layout.item_group_with_like, parent, false)
+ )
+ }
+ throw RuntimeException("StoriesViewAdapter.onCreateViewHolder")
+ }
+
+ override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
+ when (getItemViewType(position)) {
+ TYPE_USER -> bindUserHolder(
+ holder as PeopleHolder,
+ mData[position].first as User,
+ mData[position].second
+ )
+
+ TYPE_COMMUNITY -> bindCommunityHolder(
+ holder as CommunityHolder,
+ mData[position].first as Community,
+ mData[position].second
+ )
+ }
+ }
+
+ private fun bindCommunityHolder(holder: CommunityHolder, community: Community, liked: Boolean) {
+ holder.tvName.text = community.fullName
+ holder.tvName.setTextColor(Utils.getVerifiedColor(mContext, community.isVerified))
+ holder.ivVerified.visibility = if (community.isVerified) View.VISIBLE else View.GONE
+ holder.liked.visibility = if (liked) View.VISIBLE else View.GONE
+ holder.tvType.text = getCommunityType(mContext, community)
+ holder.tvMembersCount.text = mContext.getString(
+ R.string.members_count,
+ if (community.membersCount > 0) AppTextUtils.getCounterWithK(community.membersCount) else "-"
+ )
+ with()
+ .load(community.maxSquareAvatar)
+ .tag(Constants.PICASSO_TAG)
+ .transform(if (community.hasUnseenStories) transformationWithStory else transformation)
+ .into(holder.ivAvatar)
+ holder.itemView.setOnClickListener {
+ mClickListener?.onOwnerClick(community)
+ }
+ holder.itemView.setOnLongClickListener {
+ longClickListener?.onOwnerLongClick(
+ community
+ ) == true
+ }
+ }
+
+ private fun bindUserHolder(holder: PeopleHolder, user: User, liked: Boolean) {
+ holder.name.text = user.fullName
+ holder.name.setTextColor(Utils.getVerifiedColor(mContext, user.isVerified))
+ holder.ivVerified.visibility = if (user.isVerified) View.VISIBLE else View.GONE
+ holder.blacklisted.visibility = if (user.blacklisted) View.VISIBLE else View.GONE
+ holder.subtitle.text = UserInfoResolveUtil.getUserActivityLine(mContext, user, true)
+ holder.subtitle.setTextColor(if (user.isOnline) CurrentTheme.getColorPrimary(mContext) else STATUS_COLOR_OFFLINE)
+ holder.liked.visibility = if (liked) View.VISIBLE else View.GONE
+ holder.online.visibility = if (user.isOnline) View.VISIBLE else View.GONE
+ val onlineIcon =
+ ViewUtils.getOnlineIcon(
+ user.isOnline,
+ user.isOnlineMobile,
+ user.platform,
+ user.onlineApp
+ )
+ holder.online.setIcon(onlineIcon ?: 0)
+ val avaUrl = user.maxSquareAvatar
+ displayAvatar(
+ holder.avatar,
+ if (user.hasUnseenStories) transformationWithStory else transformation,
+ avaUrl,
+ Constants.PICASSO_TAG,
+ monochrome = user.blacklisted
+ )
+ holder.itemView.setOnClickListener {
+ mClickListener?.onOwnerClick(user)
+ }
+ holder.itemView.setOnLongClickListener {
+ longClickListener?.onOwnerLongClick(
+ user
+ ) == true
+ }
+ addSelectionProfileSupport(mContext, holder.avatarRoot, user)
+ }
+
+ override fun getItemCount(): Int {
+ return mData.size
+ }
+
+ fun setItems(data: List>) {
+ mData = data
+ notifyDataSetChanged()
+ }
+
+ override fun getItemViewType(position: Int): Int {
+ return if (mData[position].first is User) TYPE_USER else TYPE_COMMUNITY
+ }
+
+ fun setClickListener(clickListener: ClickListener?) {
+ mClickListener = clickListener
+ }
+
+ interface ClickListener {
+ fun onOwnerClick(owner: Owner)
+ }
+
+ interface LongClickListener {
+ fun onOwnerLongClick(owner: Owner): Boolean
+ }
+
+ private class CommunityHolder(root: View) : RecyclerView.ViewHolder(root) {
+ val tvName: TextView = root.findViewById(R.id.item_group_name)
+ val tvType: TextView = root.findViewById(R.id.item_group_type)
+ val tvMembersCount: TextView = root.findViewById(R.id.item_group_members)
+ val ivAvatar: ImageView = root.findViewById(R.id.item_group_avatar)
+ val ivVerified: ImageView = itemView.findViewById(R.id.item_verified)
+ val liked: ImageView = itemView.findViewById(R.id.item_group_liked)
+ }
+
+ private class PeopleHolder(itemView: View) :
+ RecyclerView.ViewHolder(itemView) {
+ val name: TextView = itemView.findViewById(R.id.item_people_name)
+ val subtitle: TextView = itemView.findViewById(R.id.item_people_subtitle)
+ val avatar: ImageView = itemView.findViewById(R.id.item_people_avatar)
+ val liked: ImageView = itemView.findViewById(R.id.item_people_liked)
+ val ivVerified: ImageView = itemView.findViewById(R.id.item_verified)
+ val avatarRoot: ViewGroup = itemView.findViewById(R.id.avatar_root)
+ val blacklisted: ImageView = itemView.findViewById(R.id.item_blacklisted)
+ val online: OnlineView = itemView.findViewById(R.id.item_people_online)
+ }
+
+ companion object {
+ private val STATUS_COLOR_OFFLINE = Color.parseColor("#999999")
+ private const val TYPE_USER = 0
+ private const val TYPE_COMMUNITY = 1
+ }
+
+}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewFragment.kt
new file mode 100644
index 000000000..49760fb73
--- /dev/null
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewFragment.kt
@@ -0,0 +1,160 @@
+package dev.ragnarok.fenrir.fragment.likes.storiesview
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.annotation.StringRes
+import androidx.appcompat.app.AppCompatActivity
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+import com.google.android.material.textview.MaterialTextView
+import dev.ragnarok.fenrir.Constants
+import dev.ragnarok.fenrir.Extra
+import dev.ragnarok.fenrir.R
+import dev.ragnarok.fenrir.activity.ActivityFeatures
+import dev.ragnarok.fenrir.activity.ActivityUtils.supportToolbarFor
+import dev.ragnarok.fenrir.fragment.base.BaseMvpFragment
+import dev.ragnarok.fenrir.fragment.base.core.IPresenterFactory
+import dev.ragnarok.fenrir.listener.EndlessRecyclerOnScrollListener
+import dev.ragnarok.fenrir.listener.PicassoPauseOnScrollListener
+import dev.ragnarok.fenrir.model.Owner
+import dev.ragnarok.fenrir.place.PlaceFactory
+import dev.ragnarok.fenrir.util.ViewUtils
+
+class StoriesViewFragment : BaseMvpFragment(),
+ IStoriesViewView {
+ private var mRecyclerView: RecyclerView? = null
+ private var mSwipeRefreshLayout: SwipeRefreshLayout? = null
+
+ private var mOwnersAdapter: StoriesViewAdapter? = null
+ private var mLinearLayoutManager: LinearLayoutManager? = null
+ private var mCount: MaterialTextView? = null
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ val root = inflater.inflate(
+ R.layout.fragment_abs_friends_with_toolbar,
+ container,
+ false
+ )
+ (requireActivity() as AppCompatActivity).setSupportActionBar(root.findViewById(R.id.toolbar))
+ mRecyclerView = root.findViewById(R.id.list)
+ mSwipeRefreshLayout = root.findViewById(R.id.refresh)
+ mCount = root.findViewById(R.id.count_data)
+ mCount?.visibility = View.VISIBLE
+ mSwipeRefreshLayout?.setOnRefreshListener {
+ presenter?.fireRefresh()
+ }
+ ViewUtils.setupSwipeRefreshLayoutWithCurrentTheme(requireActivity(), mSwipeRefreshLayout)
+ mLinearLayoutManager =
+ LinearLayoutManager(requireActivity(), LinearLayoutManager.VERTICAL, false)
+ mRecyclerView?.layoutManager = mLinearLayoutManager
+ mRecyclerView?.addOnScrollListener(PicassoPauseOnScrollListener(Constants.PICASSO_TAG))
+ mRecyclerView?.addOnScrollListener(object : EndlessRecyclerOnScrollListener() {
+ override fun onScrollToLastElement() {
+ presenter?.fireScrollToEnd()
+ }
+ })
+ mOwnersAdapter = StoriesViewAdapter(requireActivity(), emptyList())
+ mOwnersAdapter?.setClickListener(object : StoriesViewAdapter.ClickListener {
+ override fun onOwnerClick(owner: Owner) {
+ presenter?.fireOwnerClick(owner)
+ }
+ })
+ mRecyclerView?.adapter = mOwnersAdapter
+ return root
+ }
+
+ override fun displayOwnerList(owners: List>) {
+ if (mOwnersAdapter != null) {
+ mOwnersAdapter?.setItems(owners)
+ mCount?.text = getString(R.string.people_count, owners.size)
+ }
+ }
+
+ override fun updateTitle(@StringRes res: Int) {
+ val actionBar = supportToolbarFor(this)
+ actionBar?.setTitle(res)
+ }
+
+ override fun notifyDataSetChanged() {
+ if (mOwnersAdapter != null) {
+ mOwnersAdapter?.notifyDataSetChanged()
+ mCount?.text = getString(R.string.people_count, mOwnersAdapter?.itemCount ?: 0)
+ }
+ }
+
+ override fun notifyDataAdded(position: Int, count: Int) {
+ if (mOwnersAdapter != null) {
+ mOwnersAdapter?.notifyItemRangeInserted(position, count)
+ mCount?.text = getString(R.string.people_count, mOwnersAdapter?.itemCount ?: 0)
+ }
+ }
+
+ override fun notifyDataRemoved(position: Int, count: Int) {
+ if (mOwnersAdapter != null) {
+ mOwnersAdapter?.notifyItemRangeRemoved(position, count)
+ mCount?.text = getString(R.string.people_count, mOwnersAdapter?.itemCount ?: 0)
+ }
+ }
+
+ override fun displayRefreshing(refreshing: Boolean) {
+ mSwipeRefreshLayout?.isRefreshing = refreshing
+ }
+
+ override fun showOwnerWall(accountId: Long, owner: Owner) {
+ PlaceFactory.getOwnerWallPlace(accountId, owner).tryOpenWith(requireActivity())
+ }
+
+ override fun onResume() {
+ super.onResume()
+ val actionBar = supportToolbarFor(this)
+ if (actionBar != null) {
+ actionBar.setTitle(R.string.views)
+ actionBar.subtitle = null
+ }
+ ActivityFeatures.Builder()
+ .begin()
+ .setHideNavigationMenu(false)
+ .setBarsColored(requireActivity(), true)
+ .build()
+ .apply(requireActivity())
+ }
+
+ override fun getPresenterFactory(saveInstanceState: Bundle?): IPresenterFactory {
+ return object : IPresenterFactory {
+ override fun create(): StoriesViewPresenter {
+ return StoriesViewPresenter(
+ requireArguments().getLong(Extra.ACCOUNT_ID),
+ requireArguments().getLong(Extra.OWNER_ID),
+ requireArguments().getInt(Extra.ITEM_ID),
+ saveInstanceState
+ )
+ }
+ }
+ }
+
+ companion object {
+ fun buildArgs(
+ accountId: Long,
+ ownerId: Long,
+ itemId: Int
+ ): Bundle {
+ val args = Bundle()
+ args.putLong(Extra.ACCOUNT_ID, accountId)
+ args.putLong(Extra.OWNER_ID, ownerId)
+ args.putInt(Extra.ITEM_ID, itemId)
+ return args
+ }
+
+ fun newInstance(args: Bundle): StoriesViewFragment {
+ val fragment = StoriesViewFragment()
+ fragment.arguments = args
+ return fragment
+ }
+ }
+}
\ No newline at end of file
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewPresenter.kt
new file mode 100644
index 000000000..c860d5650
--- /dev/null
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/likes/storiesview/StoriesViewPresenter.kt
@@ -0,0 +1,118 @@
+package dev.ragnarok.fenrir.fragment.likes.storiesview
+
+import android.os.Bundle
+import dev.ragnarok.fenrir.domain.IStoriesShortVideosInteractor
+import dev.ragnarok.fenrir.domain.InteractorFactory
+import dev.ragnarok.fenrir.fragment.base.AccountDependencyPresenter
+import dev.ragnarok.fenrir.fromIOToMain
+import dev.ragnarok.fenrir.model.Owner
+import dev.ragnarok.fenrir.nonNullNoEmpty
+import dev.ragnarok.fenrir.util.Utils.getCauseIfRuntime
+import io.reactivex.rxjava3.disposables.CompositeDisposable
+
+class StoriesViewPresenter(
+ accountId: Long,
+ private val ownerId: Long,
+ private val itemId: Int,
+ savedInstanceState: Bundle?
+) : AccountDependencyPresenter(accountId, savedInstanceState) {
+ val data: MutableList> = ArrayList()
+ private val storiesInteractor: IStoriesShortVideosInteractor =
+ InteractorFactory.createStoriesInteractor()
+ private val netDisposable = CompositeDisposable()
+ private var endOfContent = false
+ private var loadingNow = false
+
+ override fun onGuiCreated(viewHost: IStoriesViewView) {
+ super.onGuiCreated(viewHost)
+ viewHost.displayOwnerList(data)
+ }
+
+ fun fireRefresh() {
+ onUserRefreshed()
+ }
+
+ fun fireScrollToEnd() {
+ onUserScrolledToEnd()
+ }
+
+ fun fireOwnerClick(owner: Owner) {
+ view?.showOwnerWall(accountId, owner)
+ }
+
+ //private int loadingOffset;
+ private fun requestData(offset: Int) {
+ loadingNow = true
+ //this.loadingOffset = offset;
+ resolveRefreshingView()
+ netDisposable.add(storiesInteractor.getStoriesViewers(
+ accountId,
+ ownerId,
+ itemId,
+ 50,
+ offset
+ )
+ .fromIOToMain()
+ .subscribe({ owners ->
+ onDataReceived(
+ offset,
+ owners
+ )
+ }) { t -> onDataGetError(t) })
+ }
+
+ private fun onDataGetError(t: Throwable) {
+ showError(getCauseIfRuntime(t))
+ loadingNow = false
+ resolveRefreshingView()
+ }
+
+ private fun onDataReceived(offset: Int, owners: List>) {
+ loadingNow = false
+ endOfContent = owners.isEmpty()
+ if (offset == 0) {
+ data.clear()
+ data.addAll(owners)
+ view?.notifyDataSetChanged()
+ } else {
+ val sizeBefore = data.size
+ data.addAll(owners)
+ view?.notifyDataAdded(
+ sizeBefore,
+ owners.size
+ )
+ }
+ resolveRefreshingView()
+ }
+
+ public override fun onGuiResumed() {
+ super.onGuiResumed()
+ resolveRefreshingView()
+ }
+
+ private fun resolveRefreshingView() {
+ resumedView?.displayRefreshing(
+ loadingNow
+ )
+ }
+
+ override fun onDestroyed() {
+ netDisposable.dispose()
+ super.onDestroyed()
+ }
+
+ private fun onUserRefreshed() {
+ netDisposable.clear()
+ requestData(0)
+ }
+
+ private fun onUserScrolledToEnd() {
+ if (!loadingNow && !endOfContent && data.nonNullNoEmpty()) {
+ requestData(data.size)
+ }
+ }
+
+ init {
+ requestData(0)
+ }
+}
\ No newline at end of file
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/localserver/filemanagerremote/FileManagerRemoteFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/localserver/filemanagerremote/FileManagerRemoteFragment.kt
index 27b1f0dd5..dcb72622d 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/localserver/filemanagerremote/FileManagerRemoteFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/localserver/filemanagerremote/FileManagerRemoteFragment.kt
@@ -50,7 +50,6 @@ import dev.ragnarok.fenrir.view.MySearchView
import dev.ragnarok.fenrir.view.natives.rlottie.RLottieImageView
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.Disposable
-import java.util.Collections
import java.util.concurrent.TimeUnit
class FileManagerRemoteFragment :
@@ -154,7 +153,7 @@ class FileManagerRemoteFragment :
}
ViewUtils.setupSwipeRefreshLayoutWithCurrentTheme(requireActivity(), mSwipeRefreshLayout)
- mAdapter = FileManagerRemoteAdapter(requireActivity(), Collections.emptyList())
+ mAdapter = FileManagerRemoteAdapter(requireActivity(), emptyList())
mAdapter?.setClickListener(this)
mRecyclerView?.adapter = mAdapter
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/logs/LogsAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/logs/LogsAdapter.kt
index ffc48e9cc..6867e787c 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/logs/LogsAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/logs/LogsAdapter.kt
@@ -9,7 +9,6 @@ import dev.ragnarok.fenrir.model.LogEventWrapper
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.util.AppTextUtils
import dev.ragnarok.fenrir.util.Utils
-import java.util.EventListener
class LogsAdapter(data: MutableList, private val actionListener: ActionListener) :
RecyclerBindableAdapter(data) {
@@ -56,7 +55,7 @@ class LogsAdapter(data: MutableList, private val actionListener
return R.layout.item_log
}
- interface ActionListener : EventListener {
+ interface ActionListener {
fun onShareClick(wrapper: LogEventWrapper)
fun onCopyClick(wrapper: LogEventWrapper)
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatFragment.kt
index b17c1a663..a683391fb 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatFragment.kt
@@ -78,7 +78,6 @@ import dev.ragnarok.fenrir.view.natives.rlottie.RLottieImageView
import me.minetsh.imaging.IMGEditActivity
import java.io.File
import java.lang.ref.WeakReference
-import java.util.*
class ChatFragment : PlaceSupportMvpFragment(), IChatView,
InputViewController.OnInputActionCallback,
@@ -237,7 +236,7 @@ class ChatFragment : PlaceSupportMvpFragment(), IChatV
}
stickersKeywordsView = root.findViewById(R.id.stickers)
- stickersAdapter = StickersKeyWordsAdapter(requireActivity(), Collections.emptyList())
+ stickersAdapter = StickersKeyWordsAdapter(requireActivity(), emptyList())
stickersAdapter?.setStickerClickedListener(object :
EmojiconsPopup.OnStickerClickedListener {
override fun onStickerClick(sticker: Sticker) {
@@ -1092,10 +1091,10 @@ class ChatFragment : PlaceSupportMvpFragment(), IChatV
if (result.data != null && result.resultCode == RESULT_OK) {
val vkphotos: List =
result.data?.getParcelableArrayListExtraCompat(Extra.ATTACHMENTS)
- ?: Collections.emptyList()
+ ?: emptyList()
val localPhotos: List =
result.data?.getParcelableArrayListExtraCompat(Extra.PHOTOS)
- ?: Collections.emptyList()
+ ?: emptyList()
val vid: LocalVideo? = result.data?.getParcelableExtraCompat(Extra.VIDEO)
@@ -1130,7 +1129,7 @@ class ChatFragment : PlaceSupportMvpFragment(), IChatV
if (result.data != null && result.resultCode == RESULT_OK) {
val attachments: List =
result.data?.getParcelableArrayListExtraCompat(Extra.ATTACHMENTS)
- ?: Collections.emptyList()
+ ?: emptyList()
presenter?.fireEditAttachmentsSelected(attachments)
}
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatPresenter.kt
index 376c22b35..a09ac8285 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/ChatPresenter.kt
@@ -46,7 +46,6 @@ import dev.ragnarok.fenrir.settings.ISettings
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.upload.*
import dev.ragnarok.fenrir.util.*
-import dev.ragnarok.fenrir.util.Optional
import dev.ragnarok.fenrir.util.PersistentLogger.logThrowable
import dev.ragnarok.fenrir.util.Utils.addElementToList
import dev.ragnarok.fenrir.util.Utils.countOfSelection
@@ -67,7 +66,6 @@ import io.reactivex.rxjava3.functions.Consumer
import io.reactivex.rxjava3.functions.Predicate
import java.io.*
import java.lang.ref.WeakReference
-import java.util.*
import java.util.concurrent.TimeUnit
class ChatPresenter(
@@ -239,7 +237,7 @@ class ChatPresenter(
)
appendDisposable(
- uploadManager.obseveStatus()
+ uploadManager.observeStatus()
.toMainThread()
.subscribe({ onUploadStatusChange(it) }, ignore())
)
@@ -332,7 +330,7 @@ class ChatPresenter(
}
}
- fireForwardToHereClick(ArrayList(Collections.singleton(data[position])))
+ fireForwardToHereClick(arrayListOf(data[position]))
}
fun fireTranscript(voiceMessageId: String, messageId: Int) {
@@ -445,8 +443,9 @@ class ChatPresenter(
if (!refresh) {
loadAllCachedData()
+ } else {
+ requestAtStart()
}
- requestAtStart()
}
private fun onUploadProgressUpdate(data: List) {
@@ -631,12 +630,13 @@ class ChatPresenter(
.fromIOToMain()
.subscribe(
{ onCachedDataReceived(it) },
- { onCachedDataReceived(Collections.emptyList()) })
+ { onCachedDataReceived(emptyList()) })
}
private fun onCachedDataReceived(data: List) {
setCacheLoadingNow(false)
onAllDataLoaded(data, appendToList = false, isCache = true)
+ requestAtStart()
}
private fun onNetDataReceived(messages: List, startMessageId: Int?) {
@@ -838,7 +838,7 @@ class ChatPresenter(
}
stickersWordsDisplayDisposable.dispose()
if (s.isNullOrEmpty()) {
- view?.updateStickers(Collections.emptyList())
+ view?.updateStickers(emptyList())
return
}
stickersWordsDisplayDisposable =
@@ -1853,7 +1853,7 @@ class ChatPresenter(
appendDisposable(
messagesRepository.edit(
messagesOwnerId, message, "Ragnarök",
- Collections.emptyList(), false
+ emptyList(), false
)
.fromIOToMain()
.subscribe({
@@ -2524,7 +2524,7 @@ class ChatPresenter(
pFileUri = Uri.parse(video.getData().toString())
}
- uploadManager.enqueue(Collections.singletonList(intents))
+ uploadManager.enqueue(listOf(intents))
}
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsAdapter.kt
index 4f3ab62bb..05adeaccb 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsAdapter.kt
@@ -29,7 +29,7 @@ import dev.ragnarok.fenrir.util.ViewUtils.displayAvatar
import dev.ragnarok.fenrir.util.ViewUtils.getOnlineIcon
import dev.ragnarok.fenrir.view.OnlineView
import java.text.SimpleDateFormat
-import java.util.*
+import java.util.Date
class DialogsAdapter(private val mContext: Context, private var mDialogs: List