This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forkJoin(samples.map(sample => this.save(sample))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forkJoin(samples.map(this.save)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {HttpClient} from "@angular/common/http"; | |
import {forkJoin, Observable} from "rxjs"; | |
import {map} from "rxjs/operators"; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class SampleService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: https://pt.slideshare.net/haimyadid/building-microservices-with-kotlin | |
interface DBEnum { | |
val id: Int | |
val dbName: String | |
companion object { | |
inline fun <reified T> fromId(id: Int): T where T : Enum<T>, T : DBEnum = | |
enumValues<T>().first { it.id == id } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AlertDialog.Builder(thisActivity).apply { | |
setMessage(R.string.never_ask_again_message) | |
setTitle(R.string.never_ask_again_title) | |
setPositiveButton(R.string.go_to_settings) { d, i -> | |
// Cria intent para a tela de detalhes do app onde é possível o usuário conceder permissão à funcionalidade | |
val appSettings = Intent().apply { | |
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS | |
data = Uri.fromParts("package", thisActivity.packageName, null) | |
} | |
startActivity(appSettings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
when (requestCode) { | |
CALL_PHONE_RESULT_CODE -> { | |
if (grantResults.isNotEmpty() && grantResults.first() == PackageManager.PERMISSION_GRANTED) { | |
// Permissão foi concedida, já é possível usufruir da funcionalidade | |
} else if (!shouldShowRequestPermissionRationale(Manifest.permission.CALL_PHONE)) { | |
// Usuário marcou a caixa "não perguntar novamente" | |
// Mostrar uma dialog explicando a importância do app ter acesso a funcionalidade | |
} else { | |
// Usuário negou acesso à permissão |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
when (requestCode) { | |
CALL_PHONE_RESULT_CODE -> { | |
if (grantResults.isNotEmpty() && grantResults.first() == PackageManager.PERMISSION_GRANTED) { | |
// Permissão foi concedida, já é possível usufruir da funcionalidade | |
} else { | |
// Usuário negou acesso à permissão | |
// Bloquear trecho que utilizava a funcionalidade ou informar o usuário da necessidade de ter acesso à funcionalidade | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val CALL_PHONE_RESULT_CODE = 111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActivityCompat.requestPermissions( | |
thisActivity, | |
arrayOf(Manifest.permission.CALL_PHONE), | |
CALL_PHONE_RESULT_CODE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
when (requestCode) { | |
CALL_PHONE_RESULT_CODE -> { | |
// Gerenciar o resultado da requisição | |
} | |
} | |
} |
NewerOlder