Skip to content

Commit

Permalink
Merge pull request #16 from QuickBlox/rc-0.10.1
Browse files Browse the repository at this point in the history
0.10.1
  • Loading branch information
vdovbnya-qb authored Jan 14, 2025
2 parents 0ef856d + 202a0be commit d9c268f
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Then need to add implementation of QuickBlox UIKit and QuickBlox SDK to dependen

```
dependencies {
implementation "com.quickblox:android-ui-kit:0.10.0"
implementation "com.quickblox:android-ui-kit:0.10.1"
implementation 'com.quickblox:quickblox-android-sdk-messages:4.2.2'
implementation 'com.quickblox:quickblox-android-sdk-chat:4.2.2'
Expand Down
2 changes: 1 addition & 1 deletion ui-kit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ext {
qbSdkVersion = '4.2.2'

uiKitVersionCode = 1
uiKitVersionName = "0.10.0"
uiKitVersionName = "0.10.1"
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.quickblox.chat.JIDHelper
import com.quickblox.chat.QBAbstractChat
import com.quickblox.chat.QBChatService
import com.quickblox.chat.QBGroupChat
import com.quickblox.chat.QBGroupChatManager
import com.quickblox.chat.QBRestChatService
import com.quickblox.chat.model.QBChatDialog
import com.quickblox.chat.model.QBChatMessage
Expand Down Expand Up @@ -1052,20 +1053,32 @@ open class RemoteDataSourceImpl : RemoteDataSource {
val groupChatManager = QBChatService.getInstance().groupChatManager
val fields = groupChatManager.javaClass.declaredFields

val dialogsField: Field = fields[1]
dialogsField.isAccessible = true
for (field in fields) {
if (isGroupChatField(groupChatManager, field)) {
field.isAccessible = true

val dialogsFieldValue = dialogsField.get(groupChatManager)
val dialogsFieldValue = field.get(groupChatManager)

if (dialogsFieldValue is Map<*, *>) {
val dialogs = dialogsFieldValue as Map<String, QBGroupChat>
for ((jid, groupChat) in dialogs) {
joinGroupDialog(groupChat)
val dialogs = dialogsFieldValue as Map<String, QBGroupChat>
for ((jid, groupChat) in dialogs) {
joinGroupDialog(groupChat)
}
break
}
}
}
}

private fun isGroupChatField(groupChatManager: QBGroupChatManager, field: Field): Boolean {
try {
val dialogsFieldValue = field.get(groupChatManager) as Map<String, QBChatDialog>
val isFirstKeyString = dialogsFieldValue.keys.toList().get(0) is String
return isFirstKeyString
} catch (e: Exception) {
return false
}
}

private fun joinGroupDialog(groupChat: QBGroupChat) {
// TODO: Need to add Exception handling
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DialogsComponentImpl : LinearLayoutCompat, DialogsComponent {
binding?.rvDialogs?.background = ColorDrawable(theme.getMainBackgroundColor())
binding?.rvDialogs?.itemAnimator = null
binding?.rvDialogs?.adapter = adapter as Adapter<*>
binding?.rvDialogs?.layoutManager = LinearLayoutManagerWrapper(context)

adapter?.setTheme(theme)
adapter?.setDialogAdapterListener(DialogAdapterListenerImpl())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Created by Injoit on 9.1.2025.
* Copyright © 2025 Quickblox. All rights reserved.
*/

package com.quickblox.android_ui_kit.presentation.components.dialogs

import android.content.Context
import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.quickblox.android_ui_kit.BuildConfig

class LinearLayoutManagerWrapper(
context: Context, orientation: Int = RecyclerView.VERTICAL, reverseLayout: Boolean = false,
) : LinearLayoutManager(context, orientation, reverseLayout) {

override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) {
try {
super.onLayoutChildren(recycler, state)
} catch (e: IndexOutOfBoundsException) {
if (BuildConfig.DEBUG) {
Log.d("LinearLayoutManager", "IndexOutOfBoundsException in onLayoutChildren", e)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,22 @@ open class DialogsFragment : BaseFragment() {
DialogsViewModel.DialogChangeType.UPDATED_RANGE -> {
adapter.notifyItemRangeChanged(0, index)
}

DialogsViewModel.DialogChangeType.UPDATED -> {
adapter.notifyItemChanged(index)
}

DialogsViewModel.DialogChangeType.ADDED -> {
adapter.notifyItemInserted(index)
}

DialogsViewModel.DialogChangeType.DELETED -> {
adapter.notifyItemRemoved(index)
}

DialogsViewModel.DialogChangeType.CLEARED -> {
adapter.notifyItemRangeRemoved(0, index)
}
}
}
}
Expand Down Expand Up @@ -209,9 +216,11 @@ open class DialogsFragment : BaseFragment() {
DialogEntity.Types.GROUP -> {
startGroupChatActivity(dialogEntity)
}

DialogEntity.Types.PRIVATE -> {
startPrivateChatActivity(dialogEntity)
}

else -> {
showToast(getString(R.string.wrong_dialog_type))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DialogsViewModel : BaseViewModel() {
private val TAG: String = DialogsViewModel::class.java.simpleName

enum class DialogChangeType {
ADDED, UPDATED, UPDATED_RANGE, DELETED
ADDED, UPDATED, UPDATED_RANGE, DELETED, CLEARED
}

private var connectionRepository = QuickBloxUiKit.getDependency().getConnectionRepository()
Expand Down Expand Up @@ -117,7 +117,9 @@ class DialogsViewModel : BaseViewModel() {
getDialogsJob?.cancel()

foundDialogs?.let {
val lastIndex = dialogs.lastIndex
dialogs.clear()
_updatedDialogs.postValue(Pair(DialogChangeType.CLEARED, lastIndex))

for (dialog in it) {
dialogs.add(dialog)
Expand Down
1 change: 0 additions & 1 deletion ui-kit/src/main/res/layout/dialogs_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
android:clipToPadding="false"
android:orientation="vertical"
android:paddingBottom="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listitem="@layout/dialog_group_item" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Expand Down

0 comments on commit d9c268f

Please sign in to comment.