mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
chnage LocationMessageViewHolder to kotlin
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4d29a4b638
commit
ba7bfe3150
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Marcel Hibbe
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.stfalcon.chatkit.messages.MessageHolders;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import autodagger.AutoInjector;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class LocationMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder<ChatMessage> {
|
||||
|
||||
private static String TAG = "LocationMessageViewHolder";
|
||||
|
||||
@BindView(R.id.locationText)
|
||||
TextView messageText;
|
||||
|
||||
View progressBar;
|
||||
|
||||
@Inject
|
||||
Context context;
|
||||
|
||||
@Inject
|
||||
OkHttpClient okHttpClient;
|
||||
|
||||
public LocationMessageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
progressBar = itemView.findViewById(R.id.progress_bar);
|
||||
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBind(ChatMessage message) {
|
||||
super.onBind(message);
|
||||
|
||||
if (message.getMessageType() == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) {
|
||||
Log.d(TAG, "handle geolocation here");
|
||||
messageText.setText("geolocation...");
|
||||
}
|
||||
|
||||
// text.setText("bbbbbb");
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.nextcloud.talk.adapters.messages
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import autodagger.AutoInjector
|
||||
import butterknife.BindView
|
||||
import butterknife.ButterKnife
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.stfalcon.chatkit.messages.MessageHolders
|
||||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class LocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
.IncomingTextMessageViewHolder<ChatMessage>(incomingView) {
|
||||
|
||||
private val TAG = "LocationMessageViewHolder"
|
||||
|
||||
@JvmField
|
||||
@BindView(R.id.locationText)
|
||||
var messageText: TextView? = null
|
||||
|
||||
@JvmField
|
||||
@Inject
|
||||
var context: Context? = null
|
||||
|
||||
init {
|
||||
ButterKnife.bind(
|
||||
this,
|
||||
itemView
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBind(message: ChatMessage) {
|
||||
super.onBind(message)
|
||||
if (message.messageType == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) {
|
||||
Log.d(TAG, "handle geolocation here")
|
||||
messageText!!.text = "geolocation..."
|
||||
}
|
||||
if (message.messageParameters != null && message.messageParameters.size > 0) {
|
||||
for (key in message.messageParameters.keys) {
|
||||
val individualHashMap: Map<String, String> = message.messageParameters[key]!!
|
||||
val lon = individualHashMap["longitude"]
|
||||
val lat = individualHashMap["latitude"]
|
||||
Log.d(TAG, "lon $lon lat $lat")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user