Last active
August 29, 2015 14:06
-
-
Save leonardocordeiro/59107ec5582a38064dbe to your computer and use it in GitHub Desktop.
InfoWeek
This file contains hidden or 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
public class Infoweek { | |
private static AlertUtils alertUtils = new AlertUtils(); | |
private static Context ctx; | |
private Infoweek(){} | |
public static void init(Context ctx) { | |
Infoweek.ctx = ctx; | |
} | |
public static double somar(CharSequence primeiroValor, CharSequence segundoValor) { | |
if(primeiroValor.toString().isEmpty() || segundoValor.toString().isEmpty()) { | |
alertUtils.show(ctx, "Erro!", "Preencha corretamente os valores!"); | |
return 0; | |
} | |
try { | |
double primeiroValorNumerico = Double.valueOf(primeiroValor.toString()); | |
double segundoValorNumerico = Double.valueOf(segundoValor.toString()); | |
double resultado = primeiroValorNumerico + segundoValorNumerico; | |
Toast.makeText(ctx, "O resultado é: " + (int) resultado, Toast.LENGTH_LONG).show(); | |
return resultado; | |
} catch(NumberFormatException e) { | |
alertUtils.show(ctx, "Erro!", "Preencha corretamente os valores!"); | |
} | |
return 0; | |
} | |
public static Intent getTextToSpeechIntent() { | |
Intent stt = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); | |
stt.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); | |
stt.putExtra(RecognizerIntent.EXTRA_PROMPT, "Diga um número."); | |
stt.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "pt-BR"); | |
stt.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10); | |
return stt; | |
} | |
public static void enviarSms(String mensagem, String numero) { | |
Intent sms = new Intent(Intent.ACTION_VIEW); | |
sms.setData(Uri.parse("sms:" + numero)); | |
sms.putExtra("sms_body", mensagem); | |
ctx.startActivity(sms); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment