Skip to content

Commit 2ea44e8

Browse files
committed
Minor fixes
1 parent 2081909 commit 2ea44e8

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

app/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ android {
9595

9696
dependencies {
9797

98-
def final SUPPORT_VERSION = '28.0.0-rc01'
98+
def final SUPPORT_VERSION = '28.0.0-rc02'
9999
def final ROOM_VERSION = '1.1.1'
100100
def final LIFECYCLE_VERSION = '1.1.1'
101101
def final LEAK_CANARY_VERSION = '1.6.1'
@@ -105,10 +105,9 @@ dependencies {
105105
implementation fileTree(dir: 'libs', include: ['*.jar'])
106106

107107
implementation "com.android.support:appcompat-v7:$SUPPORT_VERSION"
108-
implementation "com.android.support:design:$SUPPORT_VERSION"
109108
implementation "com.android.support:recyclerview-v7:$SUPPORT_VERSION"
110109
implementation "com.android.support:cardview-v7:$SUPPORT_VERSION"
111-
110+
implementation 'com.android.support:design:28.0.0-rc01'
112111
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
113112

114113
implementation "android.arch.persistence.room:runtime:$ROOM_VERSION"
@@ -118,12 +117,12 @@ dependencies {
118117
implementation "android.arch.lifecycle:extensions:$LIFECYCLE_VERSION"
119118
kapt "android.arch.lifecycle:compiler:$LIFECYCLE_VERSION"
120119

120+
implementation 'io.github.kobakei:ratethisapp:1.2.0'
121121
implementation 'com.squareup.picasso:picasso:2.71828'
122122
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
123-
implementation 'com.github.jkwiecien:EasyImage:2.0.4'
124123
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
124+
implementation 'com.github.jkwiecien:EasyImage:2.0.4'
125125
implementation 'me.priyesh:chroma:1.0.2'
126-
implementation 'io.github.kobakei:ratethisapp:1.2.0'
127126

128127
implementation 'org.koin:koin-android:1.0.0-RC-1'
129128

app/src/main/kotlin/com/glodanif/bluetoothchat/data/service/connection/TransferEventStrategy.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class TransferEventStrategy : DataTransferThread.EventsStrategy {
1616
val messageBody = "6#" + message.substringAfter("6#")
1717

1818
val info = fileStartRegex.replace(messageBody, "")
19-
val uid = messageBody.substring(2).substringBefore("#").toLong()
19+
val uid = messageBody.substring(2).substringBefore("#")
2020

21-
if (info.isEmpty()) {
21+
if (info.isEmpty() || !uid.isNumber()) {
2222
null
2323
} else {
2424
val size = info.substringAfter("#").substringBefore("#")
2525
if (size.isNumber()) {
2626
DataTransferThread.FileInfo(
27-
uid,
27+
uid.toLong(),
2828
info.substringBefore("#"),
2929
size.toLong()
3030
)

app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ChatActivity.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class ChatActivity : SkeletonActivity(), ChatView {
5151
parametersOf(deviceAddress ?: "", this)
5252
}
5353

54-
private val layoutManager = LinearLayoutManager(this)
55-
5654
private val chatContainer: ConstraintLayout by bind(R.id.cl_chat_container)
5755
private val actions: ActionView by bind(R.id.av_actions)
5856
private val chatList: RecyclerView by bind(R.id.rv_chat)
@@ -69,6 +67,10 @@ class ChatActivity : SkeletonActivity(), ChatView {
6967
private val presharingImage: ImageView by bind(R.id.iv_presharing_image)
7068
private val goDownButton: GoDownButton by bind(R.id.gdb_go_down)
7169

70+
private val chatLayoutManager = LinearLayoutManager(this).apply {
71+
reverseLayout = true
72+
}
73+
7274
private lateinit var scrollBehavior: ScrollAwareBehavior
7375
private lateinit var chatAdapter: ChatAdapter
7476

@@ -136,7 +138,7 @@ class ChatActivity : SkeletonActivity(), ChatView {
136138
}
137139

138140
goDownButton.setOnClickListener {
139-
layoutManager.scrollToPosition(0)
141+
chatLayoutManager.scrollToPosition(0)
140142
scrollBehavior.hideChild()
141143
goDownButton.setUnreadMessageNumber(0)
142144
}
@@ -157,9 +159,7 @@ class ChatActivity : SkeletonActivity(), ChatView {
157159

158160
chatList.apply {
159161

160-
val manager = this@ChatActivity.layoutManager
161-
manager.reverseLayout = true
162-
layoutManager = manager
162+
layoutManager = chatLayoutManager
163163
adapter = chatAdapter
164164

165165
addOnScrollListener(object : RecyclerView.OnScrollListener() {
@@ -277,7 +277,7 @@ class ChatActivity : SkeletonActivity(), ChatView {
277277
chatAdapter.messages.addFirst(message)
278278
chatAdapter.notifyItemInserted(0)
279279
if (!scrollBehavior.isChildShown()) {
280-
layoutManager.scrollToPosition(0)
280+
chatLayoutManager.scrollToPosition(0)
281281
} else {
282282
goDownButton.setUnreadMessageNumber(goDownButton.getUnreadMessageNumber() + 1)
283283
}
@@ -286,7 +286,7 @@ class ChatActivity : SkeletonActivity(), ChatView {
286286
override fun showSentMessage(message: ChatMessageViewModel) {
287287
chatAdapter.messages.addFirst(message)
288288
chatAdapter.notifyItemInserted(0)
289-
layoutManager.scrollToPosition(0)
289+
chatLayoutManager.scrollToPosition(0)
290290
}
291291

292292
override fun showRejectedConnection() = doIfStarted {

app/src/main/kotlin/com/glodanif/bluetoothchat/ui/util/ClickableMovementMethod.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.glodanif.bluetoothchat.ui.util
22

3+
import android.content.ActivityNotFoundException
34
import android.text.Spannable
45
import android.text.method.ArrowKeyMovementMethod
56
import android.text.style.ClickableSpan
@@ -24,8 +25,12 @@ object ClickableMovementMethod : ArrowKeyMovementMethod() {
2425
val off = layout.getOffsetForHorizontal(line, x)
2526
val link = buffer?.getSpans(off, off, ClickableSpan::class.java)
2627
if (link != null && link.isNotEmpty()) {
27-
link[0].onClick(widget)
28-
return true
28+
try {
29+
link[0].onClick(widget)
30+
return true
31+
} catch (e: ActivityNotFoundException) {
32+
e.printStackTrace()
33+
}
2934
}
3035
}
3136
return super.onTouchEvent(widget, buffer, event)

0 commit comments

Comments
 (0)