decrease spotbugs warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-06-07 13:54:53 +02:00 committed by Andy Scherzinger
parent 60827afe5c
commit fdf6b04fb8
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
6 changed files with 49 additions and 39 deletions

View file

@ -36,5 +36,3 @@ class GeocodingAdapter(context: Context, val dataSource: List<Address>) : BaseAd
return rowView
}
}

View file

@ -182,7 +182,9 @@ class IncomingLocationMessageViewHolder(incomingView: View) : MessageHolders
for (key in messageParameters.keys) {
val individualHashMap = message.messageParameters[key]
if (individualHashMap != null) {
if (individualHashMap["type"] == "user" || individualHashMap["type"] == "guest" || individualHashMap["type"] == "call") {
if (individualHashMap["type"] == "user"
|| individualHashMap["type"] == "guest"
|| individualHashMap["type"] == "call") {
if (individualHashMap["id"] == message.activeUser!!.userId) {
messageString = DisplayUtils.searchAndReplaceWithMentionSpan(
messageText!!.context,
@ -318,4 +320,4 @@ class IncomingLocationMessageViewHolder(incomingView: View) : MessageHolders
private fun addMarkerToGeoLink(locationGeoLink: String): String {
return locationGeoLink.replace("geo:", "geo:0,0?q=")
}
}
}

View file

@ -107,8 +107,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
val individualHashMap: HashMap<String, String>? = message.messageParameters[key]
if (individualHashMap != null) {
if (individualHashMap["type"] == "user" || (
individualHashMap["type"] == "guest"
) || individualHashMap["type"] == "call"
individualHashMap["type"] == "guest") || individualHashMap["type"] == "call"
) {
messageString = DisplayUtils.searchAndReplaceWithMentionSpan(
messageText!!.context,
@ -242,8 +241,14 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
val urlStringBuffer = StringBuffer("file:///android_asset/leafletMapMessagePreview.html")
urlStringBuffer.append("?mapProviderUrl=" + URLEncoder.encode(context!!.getString(R.string.osm_tile_server_url)))
urlStringBuffer.append("&mapProviderAttribution=" + URLEncoder.encode(context!!.getString(R.string
.osm_tile_server_attributation)))
urlStringBuffer.append(
"&mapProviderAttribution=" + URLEncoder.encode(
context!!.getString(
R.string
.osm_tile_server_attributation
)
)
)
urlStringBuffer.append("&locationLat=" + URLEncoder.encode(locationLat))
urlStringBuffer.append("&locationLon=" + URLEncoder.encode(locationLon))
urlStringBuffer.append("&locationName=" + URLEncoder.encode(locationName))
@ -282,4 +287,4 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
ButterKnife.bind(this, itemView)
this.realView = itemView
}
}
}

View file

@ -69,7 +69,9 @@ import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class LocationPickerController(args: Bundle) : BaseController(args), SearchView.OnQueryTextListener,
class LocationPickerController(args: Bundle) :
BaseController(args),
SearchView.OnQueryTextListener,
GeocodingController.GeocodingResultListener {
@Inject
@ -257,27 +259,30 @@ class LocationPickerController(args: Bundle) : BaseController(args), SearchView.
moveToCurrentLocationWasClicked = true
}
map?.addMapListener(DelayedMapListener(object : MapListener {
override fun onScroll(paramScrollEvent: ScrollEvent): Boolean {
if (moveToCurrentLocationWasClicked) {
setLocationDescription(true, false)
moveToCurrentLocationWasClicked = false
} else if (receivedChosenGeocodingResult) {
shareLocation?.isClickable = true
setLocationDescription(false, true)
receivedChosenGeocodingResult = false
} else {
shareLocation?.isClickable = true
setLocationDescription(false, false)
}
readyToShareLocation = true
return true
}
map?.addMapListener(
DelayedMapListener(
object : MapListener {
override fun onScroll(paramScrollEvent: ScrollEvent): Boolean {
if (moveToCurrentLocationWasClicked) {
setLocationDescription(true, false)
moveToCurrentLocationWasClicked = false
} else if (receivedChosenGeocodingResult) {
shareLocation?.isClickable = true
setLocationDescription(false, true)
receivedChosenGeocodingResult = false
} else {
shareLocation?.isClickable = true
setLocationDescription(false, false)
}
readyToShareLocation = true
return true
}
override fun onZoom(event: ZoomEvent): Boolean {
return false
}
}))
override fun onZoom(event: ZoomEvent): Boolean {
return false
}
})
)
}
private fun setLocationDescription(isGpsLocation: Boolean, isGeocodedResult: Boolean) {
@ -376,7 +381,8 @@ class LocationPickerController(args: Bundle) : BaseController(args), SearchView.
if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && grantResults.size > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
initMap()
} else {
Toast.makeText(context, context!!.getString(R.string.nc_location_permission_required), Toast.LENGTH_LONG).show()
Toast.makeText(context, context!!.getString(R.string.nc_location_permission_required), Toast.LENGTH_LONG)
.show()
}
}

View file

@ -4,8 +4,6 @@ import com.stfalcon.chatkit.commons.models.IMessage
interface ExtendedIMessage : IMessage {
// var isLocationMessage: Boolean
fun isLocationMessage() : Boolean
}

View file

@ -45,6 +45,7 @@ import java.util.Map;
import java.util.Objects;
import androidx.annotation.Nullable;
import kotlin.text.Charsets;
@Parcel
@JsonObject
@ -104,8 +105,8 @@ public class ChatMessage implements ExtendedIMessage, MessageContentType, Messag
for (HashMap.Entry<String, HashMap<String, String>> entry : messageParameters.entrySet()) {
Map<String, String> individualHashMap = entry.getValue();
if(MessageDigest.isEqual(
Objects.requireNonNull(individualHashMap.get("type")).getBytes(),
("file").getBytes())) {
Objects.requireNonNull(individualHashMap.get("type")).getBytes(Charsets.UTF_8),
("file").getBytes(Charsets.UTF_8))) {
return true;
}
}
@ -119,8 +120,8 @@ public class ChatMessage implements ExtendedIMessage, MessageContentType, Messag
Map<String, String> individualHashMap = entry.getValue();
if(MessageDigest.isEqual(
Objects.requireNonNull(individualHashMap.get("type")).getBytes(),
("geo-location").getBytes())) {
Objects.requireNonNull(individualHashMap.get("type")).getBytes(Charsets.UTF_8),
("geo-location").getBytes(Charsets.UTF_8))) {
return true;
}
}
@ -136,8 +137,8 @@ public class ChatMessage implements ExtendedIMessage, MessageContentType, Messag
for (HashMap.Entry<String, HashMap<String, String>> entry : messageParameters.entrySet()) {
Map<String, String> individualHashMap = entry.getValue();
if(MessageDigest.isEqual(
Objects.requireNonNull(individualHashMap.get("type")).getBytes(),
("file").getBytes())) {
Objects.requireNonNull(individualHashMap.get("type")).getBytes(Charsets.UTF_8),
("file").getBytes(Charsets.UTF_8))) {
selectedIndividualHashMap = individualHashMap;
return (ApiUtils.getUrlForFilePreviewWithFileId(getActiveUser().getBaseUrl(),
individualHashMap.get("id"), NextcloudTalkApplication.Companion.getSharedApplication().getResources().getDimensionPixelSize(R.dimen.maximum_file_preview_size)));