chnage LocationMessageViewHolder to kotlin

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-05-27 23:30:35 +02:00 committed by Andy Scherzinger
parent 4d29a4b638
commit ba7bfe3150
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 54 additions and 78 deletions

View File

@ -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");
}
}

View File

@ -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")
}
}
}
}