Fixed Codacy Static and ktlint errors

This commit is contained in:
Smarshal21 2023-09-28 11:21:33 +05:30
parent 4d4eb2149c
commit 25e2cabbdf
3 changed files with 11 additions and 8 deletions

View file

@ -36,7 +36,7 @@ class GeocodingAdapter(private val context: Context, private var dataSource: Lis
fun onItemClick(position: Int)
}
fun updateData(data: List<Address>) {
this.dataSource = data
this.dataSource = data
notifyDataSetChanged()
}

View file

@ -103,10 +103,11 @@ class GeocodingActivity :
viewModel = ViewModelProvider(this).get(GeoCodingViewModel::class.java)
// Observe geocoding results LiveData
viewModel.getGeocodingResultsLiveData().observe(this, Observer { results ->
// Update the adapter with the new results
adapter.updateData(results)
})
viewModel.getGeocodingResultsLiveData().observe(
this,
Observer { results -> // Update the adapter with the new results
adapter.updateData(results)
})
val baseUrl = getString(R.string.osm_geocoder_url)
val email = context.getString(R.string.osm_geocoder_contact)
nominatimClient = TalkJsonNominatimClient(baseUrl, okHttpClient, email)
@ -200,7 +201,7 @@ class GeocodingActivity :
searchView?.maxWidth = Int.MAX_VALUE
searchView?.inputType = InputType.TYPE_TEXT_VARIATION_FILTER
var imeOptions = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences!!.isKeyboardIncognito) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.isKeyboardIncognito) {
imeOptions = imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
}
searchView?.imeOptions = imeOptions

View file

@ -17,6 +17,7 @@
* 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.viewmodels
import android.util.Log
@ -30,6 +31,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import okhttp3.OkHttpClient
import java.io.IOException
class GeoCodingViewModel : ViewModel() {
private val geocodingResultsLiveData = MutableLiveData<List<Address>>()
@ -53,9 +55,9 @@ class GeoCodingViewModel : ViewModel() {
try {
val results = nominatimClient.search(query) as ArrayList<Address>
geocodingResultsLiveData.postValue(results)
} catch (e: Exception) {
} catch (e: IOException) {
Log.e(TAG, "Failed to get geocoded addresses", e)
}
}
}
}
}