Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
275b9f8a
Unverified
Commit
275b9f8a
authored
Aug 23, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Aug 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into patch-1
parents
7c5b4974
7301cde4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
147 additions
and
11 deletions
+147
-11
AuthenticationActivity.kt
...ocket/android/authentication/ui/AuthenticationActivity.kt
+1
-1
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+1
-1
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+1
-1
DirectReplyReceiver.kt
...main/java/chat/rocket/android/push/DirectReplyReceiver.kt
+1
-2
Fragment.kt
...main/java/chat/rocket/android/util/extensions/Fragment.kt
+1
-1
TransformedLiveData.kt
.../chat/rocket/android/util/livedata/TransformedLiveData.kt
+1
-2
build.gradle
emoji/build.gradle
+2
-0
EmojiPagerAdapter.kt
...a/chat/rocket/android/emoji/internal/EmojiPagerAdapter.kt
+1
-2
Coroutines.kt
...ain/java/chat/rocket/android/util/extension/Coroutines.kt
+1
-1
HandlerContext.kt
...main/java/chat/rocket/android/util/temp/HandlerContext.kt
+137
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/ui/AuthenticationActivity.kt
View file @
275b9f8a
...
...
@@ -16,7 +16,7 @@ import dagger.android.AndroidInjector
import
dagger.android.DispatchingAndroidInjector
import
dagger.android.support.HasSupportFragmentInjector
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.launch
import
javax.inject.Inject
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
275b9f8a
...
...
@@ -70,7 +70,7 @@ import chat.rocket.core.model.Command
import
chat.rocket.core.model.Message
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.DefaultDispatcher
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.channels.Channel
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.withContext
...
...
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
275b9f8a
...
...
@@ -17,7 +17,7 @@ import chat.rocket.common.util.ifNull
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.internal.rest.spotlight
import
chat.rocket.core.model.SpotlightResult
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.delay
import
kotlinx.coroutines.experimental.isActive
import
kotlinx.coroutines.experimental.launch
...
...
app/src/main/java/chat/rocket/android/push/DirectReplyReceiver.kt
View file @
275b9f8a
...
...
@@ -4,7 +4,6 @@ import android.app.NotificationManager
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
androidx.core.app.NotificationManagerCompat
import
androidx.core.app.RemoteInput
import
android.widget.Toast
import
chat.rocket.android.R
...
...
@@ -12,7 +11,7 @@ import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.common.RocketChatException
import
chat.rocket.core.internal.rest.sendMessage
import
dagger.android.AndroidInjection
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
java.util.*
...
...
app/src/main/java/chat/rocket/android/util/extensions/Fragment.kt
View file @
275b9f8a
...
...
@@ -4,7 +4,7 @@ import android.os.Looper
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentActivity
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.launch
inline
fun
Fragment
.
ui
(
crossinline
block
:
(
activity
:
FragmentActivity
)
->
Unit
):
Job
?
{
...
...
app/src/main/java/chat/rocket/android/util/livedata/TransformedLiveData.kt
View file @
275b9f8a
...
...
@@ -4,12 +4,11 @@ import androidx.lifecycle.LiveData
import
androidx.lifecycle.Observer
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.withContext
import
kotlin.coroutines.experimental.CoroutineContext
class
TransformedLiveData
<
Source
,
Output
>(
private
val
runContext
:
CoroutineContext
=
CommonPool
,
private
val
source
:
LiveData
<
Source
>,
...
...
emoji/build.gradle
View file @
275b9f8a
...
...
@@ -26,6 +26,8 @@ android {
}
dependencies
{
implementation
project
(
':util'
)
implementation
libraries
.
androidKtx
implementation
libraries
.
appCompat
implementation
libraries
.
kotlin
...
...
emoji/src/main/java/chat/rocket/android/emoji/internal/EmojiPagerAdapter.kt
View file @
275b9f8a
...
...
@@ -17,11 +17,10 @@ import chat.rocket.android.emoji.R
import
kotlinx.android.synthetic.main.emoji_category_layout.view.*
import
kotlinx.android.synthetic.main.emoji_row_item.view.*
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.android
.UI
import
chat.rocket.android.util.temp
.UI
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.withContext
internal
class
EmojiPagerAdapter
(
private
val
listener
:
EmojiKeyboardListener
)
:
PagerAdapter
()
{
private
val
adapters
=
hashMapOf
<
EmojiCategory
,
EmojiAdapter
>()
...
...
util/src/main/java/chat/rocket/android/util/extension/Coroutines.kt
View file @
275b9f8a
package
chat.rocket.android.util.extension
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.util.temp.UI
import
kotlinx.coroutines.experimental.CoroutineScope
import
kotlinx.coroutines.experimental.Job
import
kotlinx.coroutines.experimental.android.UI
import
kotlinx.coroutines.experimental.launch
/**
...
...
util/src/main/java/chat/rocket/android/util/temp/HandlerContext.kt
0 → 100644
View file @
275b9f8a
/*
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
/**
* Workaround for https://github.com/Kotlin/kotlinx.coroutines/issues/367#issuecomment-414185769
*
* TODO: Remove after issue is resolved.
*/
package
chat.rocket.android.util.temp
import
android.os.Handler
import
android.os.Looper
import
android.view.Choreographer
import
androidx.annotation.Keep
import
kotlinx.coroutines.experimental.BlockingChecker
import
kotlinx.coroutines.experimental.CancellableContinuation
import
kotlinx.coroutines.experimental.CoroutineDispatcher
import
kotlinx.coroutines.experimental.Delay
import
kotlinx.coroutines.experimental.DisposableHandle
import
kotlinx.coroutines.experimental.suspendCancellableCoroutine
import
java.util.concurrent.TimeUnit
import
kotlin.coroutines.experimental.CoroutineContext
/**
* Dispatches execution onto Android main UI thread and provides native [delay][Delay.delay] support.
*/
val
UI
=
HandlerContext
(
Handler
(
Looper
.
getMainLooper
()),
"UI"
)
/**
* Represents an arbitrary [Handler] as a implementation of [CoroutineDispatcher].
*/
fun
Handler
.
asCoroutineDispatcher
()
=
HandlerContext
(
this
)
private
const
val
MAX_DELAY
=
Long
.
MAX_VALUE
/
2
// cannot delay for too long on Android
/**
* Implements [CoroutineDispatcher] on top of an arbitrary Android [Handler].
*/
public
class
HandlerContext
private
constructor
(
private
val
handler
:
Handler
,
private
val
name
:
String
?,
private
val
invokeImmediately
:
Boolean
)
:
CoroutineDispatcher
(),
Delay
{
/**
* Creates [CoroutineDispatcher] for the given Android [handler].
*
* @param handler a handler.
* @param name an optional name for debugging.
*/
public
constructor
(
handler
:
Handler
,
name
:
String
?
=
null
)
:
this
(
handler
,
name
,
false
)
@Volatile
private
var
_immediate
:
HandlerContext
?
=
if
(
invokeImmediately
)
this
else
null
/**
* Returns dispatcher that executes coroutines immediately when it is already in the right handler context
* (current looper is the same as [handler] looper). See [isDispatchNeeded] documentation on
* why this should not be done by default.
*/
public
val
immediate
:
HandlerContext
=
_immediate
?:
HandlerContext
(
handler
,
name
,
true
).
also
{
_immediate
=
it
}
@Volatile
private
var
_choreographer
:
Choreographer
?
=
null
override
fun
isDispatchNeeded
(
context
:
CoroutineContext
):
Boolean
{
return
!
invokeImmediately
||
Looper
.
myLooper
()
!=
handler
.
looper
}
override
fun
dispatch
(
context
:
CoroutineContext
,
block
:
Runnable
)
{
handler
.
post
(
block
)
}
override
fun
scheduleResumeAfterDelay
(
time
:
Long
,
unit
:
TimeUnit
,
continuation
:
CancellableContinuation
<
Unit
>)
{
handler
.
postDelayed
({
with
(
continuation
)
{
resumeUndispatched
(
Unit
)
}
},
unit
.
toMillis
(
time
).
coerceAtMost
(
MAX_DELAY
))
}
override
fun
invokeOnTimeout
(
time
:
Long
,
unit
:
TimeUnit
,
block
:
Runnable
):
DisposableHandle
{
handler
.
postDelayed
(
block
,
unit
.
toMillis
(
time
).
coerceAtMost
(
MAX_DELAY
))
return
object
:
DisposableHandle
{
override
fun
dispose
()
{
handler
.
removeCallbacks
(
block
)
}
}
}
/**
* Awaits the next animation frame and returns frame time in nanoseconds.
*/
public
suspend
fun
awaitFrame
():
Long
{
// fast path when choreographer is already known
val
choreographer
=
_choreographer
if
(
choreographer
!=
null
)
{
return
suspendCancellableCoroutine
{
cont
->
postFrameCallback
(
choreographer
,
cont
)
}
}
// post into looper thread thread to figure it out
return
suspendCancellableCoroutine
{
cont
->
handler
.
post
{
updateChoreographerAndPostFrameCallback
(
cont
)
}
}
}
private
fun
updateChoreographerAndPostFrameCallback
(
cont
:
CancellableContinuation
<
Long
>)
{
val
choreographer
=
_choreographer
?:
Choreographer
.
getInstance
()
!!
.
also
{
_choreographer
=
it
}
postFrameCallback
(
choreographer
,
cont
)
}
private
fun
postFrameCallback
(
choreographer
:
Choreographer
,
cont
:
CancellableContinuation
<
Long
>)
{
choreographer
.
postFrameCallback
{
nanos
->
with
(
cont
)
{
resumeUndispatched
(
nanos
)
}
}
}
override
fun
toString
()
=
name
?:
handler
.
toString
()
override
fun
equals
(
other
:
Any
?):
Boolean
=
other
is
HandlerContext
&&
other
.
handler
===
handler
override
fun
hashCode
():
Int
=
System
.
identityHashCode
(
handler
)
}
/**
* @suppress This is an internal impl class.
*/
@Keep
class
MainLooperChecker
:
BlockingChecker
{
override
fun
checkRunBlocking
()
=
check
(
Looper
.
myLooper
()
!=
Looper
.
getMainLooper
())
{
"runBlocking is not allowed in Android main looper thread"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment