use of br.ufrj.caronae.models.modelsforjson.FalaeMsgForJson in project caronae-android by caronae.
the class FalaeFrag method sendBt.
@OnClick(R.id.send_bt)
public void sendBt() {
String message = message_et.getText().toString();
if (message.isEmpty()) {
Util.toast(getActivity().getString(R.string.frag_falae_msgblank));
return;
}
message = message + "\n\n--------------------------------\n" + "Device: " + android.os.Build.MODEL + " (Android " + android.os.Build.VERSION.RELEASE + ")\n" + "Versão do app: " + Util.getAppVersionName(getContext());
int checkedId = radioGroup.getCheckedRadioButtonId();
String subject = "";
switch(checkedId) {
case R.id.suggestion_rb:
subject = getActivity().getString(R.string.frag_falae_suggestionRb);
break;
case R.id.question_rb:
subject = getActivity().getString(R.string.frag_falae_questionRb);
break;
case R.id.report_rb:
subject = getActivity().getString(R.string.frag_falae_reportRb);
break;
}
subject = subject.concat(subject_et.getText().toString());
final ProgressDialog pd = ProgressDialog.show(getContext(), "", getString(R.string.wait), true, true);
CaronaeAPI.service(getContext()).falaeSendMessage(new FalaeMsgForJson(subject, message)).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
pd.dismiss();
Util.toast(getActivity().getString(R.string.frag_falae_thanksSent));
subject_et.setText("");
message_et.setText("");
Log.i("falaeSendMessage", "falae message sent succesfully");
} else {
Util.treatResponseFromServer(response);
pd.dismiss();
Util.toast(getActivity().getString(R.string.frag_falae_errorSent));
Log.e("falaeSendMessage", response.message());
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
pd.dismiss();
Util.toast(getActivity().getString(R.string.frag_falae_errorSent));
Log.e("falaeSendMessage", t.getMessage());
}
});
}
use of br.ufrj.caronae.models.modelsforjson.FalaeMsgForJson in project caronae-android by caronae.
the class ProfileAct method reportBt.
@OnClick(R.id.report_bt)
public void reportBt() {
Dialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
protected void onBuildDone(Dialog dialog) {
dialog.layoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
EditText msg_et = (EditText) fragment.getDialog().findViewById(R.id.msg_et);
String msg = msg_et.getText().toString();
if (msg.isEmpty()) {
Util.toast(getString(R.string.frag_falae_msgblank));
return;
}
msg = msg + "\n\n--------------------------------\n" + "Device: " + android.os.Build.MODEL + " (Android " + android.os.Build.VERSION.RELEASE + ")\n" + "Versão do app: " + Util.getAppVersionName(getBaseContext());
CaronaeAPI.service(getApplicationContext()).falaeSendMessage(new FalaeMsgForJson(getString(R.string.frag_falae_reportRb) + user.getName() + " - ID:" + user.getDbId(), msg)).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
Util.toast(getString(R.string.act_profile_reportOk));
Log.i("falaeSendMessage", "falae message sent succesfully");
} else {
Util.treatResponseFromServer(response);
Util.toast(getString(R.string.frag_falae_errorSent));
Log.e("falaeSendMessage", response.message());
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Util.toast(getString(R.string.frag_falae_errorSent));
Log.e("falaeSendMessage", t.getMessage());
}
});
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
String name = user.getName().split(" ")[0];
builder.title("Reportar " + name).positiveAction(getString(R.string.send_bt)).negativeAction(getString(R.string.cancel)).contentView(R.layout.report_dialog);
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getSupportFragmentManager(), null);
}
Aggregations