ソースを参照

Fixed Codacy Static and ktlint errors

Smarshal21 1 年間 前
コミット
25e2cabbdf

+ 1 - 1
app/src/main/java/com/nextcloud/talk/adapters/GeocodingAdapter.kt

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

+ 6 - 5
app/src/main/java/com/nextcloud/talk/location/GeocodingActivity.kt

@@ -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

+ 4 - 2
app/src/main/java/com/nextcloud/talk/viewmodels/GeoCodingViewModel.kt

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