Skip to content

Commit

Permalink
build: bump compileSdk to 31 to support newer androidx libraries
Browse files Browse the repository at this point in the history
fix: type errors with new deps
  • Loading branch information
VaiTon committed Dec 18, 2021
1 parent e10bbd7 commit d8f8a30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Expand Up @@ -194,7 +194,7 @@ dependencies {
}

android {
compileSdk = 30
compileSdk = 31

testBuildType = obtainTestBuildType()

Expand Down
Expand Up @@ -343,7 +343,7 @@ class ProductListActivity : BaseActivity(), SwipeController.Actions {

@RequiresApi(Build.VERSION_CODES.KITKAT)
val fileWriterLauncher = registerForActivityResult(CreateCSVContract())
{ writeListToFile(this, productList, it) }
{ uri -> uri?.let { writeListToFile(this, productList, it) } }

private fun exportAsCSV() {
Toast.makeText(this, R.string.txt_exporting_your_listed_products, Toast.LENGTH_LONG).show()
Expand Down
Expand Up @@ -5,22 +5,24 @@ import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract

/**
* Returns a string containing the product barcode.
*/
class SimpleScanActivityContract : ActivityResultContract<Unit, String?>() {

companion object {
const val KEY_SCANNED_BARCODE = "scanned_barcode"
}

override fun createIntent(context: Context, input: Unit?): Intent {
override fun createIntent(context: Context, input: Unit): Intent {
return Intent(context, SimpleScanActivity::class.java)
}

override fun parseResult(resultCode: Int, intent: Intent?): String? {
val bundle = intent?.extras ?: return null
return if (resultCode == Activity.RESULT_OK && bundle.containsKey(KEY_SCANNED_BARCODE)) {
bundle.getString(KEY_SCANNED_BARCODE, null)
} else {
null
if (resultCode == Activity.RESULT_OK && bundle.containsKey(KEY_SCANNED_BARCODE)) {
return bundle.getString(KEY_SCANNED_BARCODE, null)
}
return null
}
}

0 comments on commit d8f8a30

Please sign in to comment.