Add clearLayer and rename methods
This commit is contained in:
parent
34928a01d6
commit
31e0f4fc38
5 changed files with 27 additions and 15 deletions
|
@ -9,7 +9,7 @@ import android.os.Build
|
|||
import android.os.Handler
|
||||
import net.osmand.telegram.helpers.*
|
||||
import net.osmand.telegram.helpers.OsmandAidlHelper.OsmandHelperListener
|
||||
import net.osmand.telegram.helpers.OsmandAidlHelper.RegisterUpdatesCallbackListener
|
||||
import net.osmand.telegram.helpers.OsmandAidlHelper.UpdatesListener
|
||||
import net.osmand.telegram.notifications.NotificationHelper
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import net.osmand.telegram.utils.UiUtils
|
||||
|
@ -57,10 +57,10 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
osmandAidlHelper.setRegisterUpdatesCallbackListener(object :
|
||||
RegisterUpdatesCallbackListener {
|
||||
osmandAidlHelper.setUpdatesListener(object : UpdatesListener {
|
||||
override fun update() {
|
||||
showLocationHelper.updateLocationsOnMap()
|
||||
showLocationHelper.clearLayer()
|
||||
showLocationHelper.startUpdateMessagesTask()
|
||||
}
|
||||
})
|
||||
shareLocationHelper = ShareLocationHelper(this)
|
||||
|
|
|
@ -253,11 +253,11 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
|||
}
|
||||
|
||||
override fun onDeleteChatLocationMessages(chatId: Long, messages: List<TdApi.Message>) {
|
||||
app().showLocationHelper.deleteMessagesTask(chatId, messages)
|
||||
app().showLocationHelper.startDeleteMessagesTask(chatId, messages)
|
||||
}
|
||||
|
||||
override fun updateLocationMessages() {
|
||||
app().showLocationHelper.updateLocationMessages()
|
||||
app().showLocationHelper.startUpdateMessagesTask()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -82,8 +82,8 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
|
|||
|
||||
@Throws(RemoteException::class)
|
||||
override fun update() {
|
||||
if (mRegisterUpdatesCallbackListener != null) {
|
||||
mRegisterUpdatesCallbackListener!!.update()
|
||||
if (mUpdatesListener != null) {
|
||||
mUpdatesListener!!.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,14 +92,14 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
|
|||
this.mSearchCompleteListener = mSearchCompleteListener
|
||||
}
|
||||
|
||||
private var mRegisterUpdatesCallbackListener: RegisterUpdatesCallbackListener? = null
|
||||
private var mUpdatesListener: UpdatesListener? = null
|
||||
|
||||
interface RegisterUpdatesCallbackListener {
|
||||
interface UpdatesListener {
|
||||
fun update()
|
||||
}
|
||||
|
||||
fun setRegisterUpdatesCallbackListener(mRegisterUpdatesCallbackListener: RegisterUpdatesCallbackListener) {
|
||||
this.mRegisterUpdatesCallbackListener = mRegisterUpdatesCallbackListener
|
||||
fun setUpdatesListener(mUpdatesListener: UpdatesListener) {
|
||||
this.mUpdatesListener = mUpdatesListener
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,6 +54,12 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
}
|
||||
}
|
||||
|
||||
fun clearLayer() {
|
||||
execOsmandApi {
|
||||
osmandAidlHelper.updateMapLayer(MAP_LAYER_ID, "Telegram", 5.5f, null)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateLocationsOnMap() {
|
||||
execOsmandApi {
|
||||
val messages = telegramHelper.getMessages()
|
||||
|
@ -164,13 +170,13 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
}
|
||||
}
|
||||
|
||||
fun deleteMessagesTask(chatId: Long, messages: List<TdApi.Message>) {
|
||||
fun startDeleteMessagesTask(chatId: Long, messages: List<TdApi.Message>) {
|
||||
if (app.settings.isShowingChatOnMap(chatId)) {
|
||||
DeleteMessagesTask(app).executeOnExecutor(executor, messages)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateLocationMessages() {
|
||||
fun startUpdateMessagesTask() {
|
||||
UpdateMessagesTask(app).executeOnExecutor(executor)
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ public class OsmandAidlService extends Service {
|
|||
private ServiceHandler mHandler = null;
|
||||
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread");
|
||||
|
||||
private boolean updatesStarted = false;
|
||||
|
||||
OsmandApplication getApp() {
|
||||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
@ -582,7 +584,11 @@ public class OsmandAidlService extends Service {
|
|||
public boolean registerCallback(IOsmAndAidlCallback callback) throws RemoteException {
|
||||
if (callback != null) {
|
||||
callbacks.add(callback);
|
||||
startRemoteUpdates();
|
||||
if (!updatesStarted) {
|
||||
startRemoteUpdates();
|
||||
updatesStarted = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue