use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class MyProfileFrag method userPic.
@OnClick(R.id.user_pic)
public void userPic() {
SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
final User user = App.getUser();
if (getSelectedValue().toString().equals(getString(R.string.frag_myprofile_facePicChoice))) {
Profile profile = Profile.getCurrentProfile();
if (profile != null) {
String faceId = profile.getId();
String profilePicUrl = "https://graph.facebook.com/" + faceId + "/picture?type=large";
// if (user.getProfilePicUrl() == null || !user.getProfilePicUrl().equals(profilePicUrl)) {
user.setProfilePicUrl(profilePicUrl);
Picasso.with(getContext()).load(profilePicUrl).error(R.drawable.auth_bg).transform(new RoundedTransformation()).into(user_pic);
saveProfilePicUrl(profilePicUrl);
// }
} else {
Util.toast(R.string.frag_myprofile_facePickChoiceNotOnFace);
}
} else {
CaronaeAPI.service(getContext()).getIntranetPhotoUrl().enqueue(new Callback<UrlForJson>() {
@Override
public void onResponse(Call<UrlForJson> call, Response<UrlForJson> response) {
if (response.isSuccessful()) {
UrlForJson urlForJson = response.body();
if (urlForJson == null)
return;
String profilePicUrl = urlForJson.getUrl();
if (profilePicUrl != null && !profilePicUrl.isEmpty()) {
user.setProfilePicUrl(profilePicUrl);
Picasso.with(getContext()).load(profilePicUrl).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(user_pic);
saveProfilePicUrl(profilePicUrl);
}
} else {
Util.treatResponseFromServer(response);
Util.toast(R.string.frag_myprofile_errorGetIntranetPhoto);
Log.e("getIntranetPhotoUrl", response.message());
}
}
@Override
public void onFailure(Call<UrlForJson> call, Throwable t) {
Util.toast(R.string.frag_myprofile_errorGetIntranetPhoto);
Log.e("getIntranetPhotoUrl", t.getMessage());
}
});
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.items(new String[] { getString(R.string.frag_myprofile_facePicChoice) }, 0).title("Usar foto do Facebook?").positiveAction(getString(R.string.ok)).negativeAction(getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
}
use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class MyProfileFrag method showOtherNeighborhoodDialog.
public void showOtherNeighborhoodDialog() {
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) {
android.widget.EditText neighborhood_et = (android.widget.EditText) fragment.getDialog().findViewById(R.id.neighborhood_et);
String neighborhood = neighborhood_et.getText().toString();
if (!neighborhood.isEmpty()) {
location_et.setText(neighborhood);
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.title(getActivity().getString(R.string.frag_ridesearch_typeNeighborhood)).positiveAction(getString(R.string.ok)).negativeAction(getString(R.string.cancel)).contentView(R.layout.other_neighborhood);
DialogFragment fragment2 = DialogFragment.newInstance(builder);
fragment2.show(getActivity().getSupportFragmentManager(), null);
}
use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class RideFilterFrag method locationEt2.
public void locationEt2(final String zone) {
this.zone = zone;
SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
CharSequence[] selectedNeighborhoods = null;
try {
selectedNeighborhoods = getSelectedValues();
} catch (Exception e) {
// do nothing
}
if (selectedNeighborhoods != null) {
String resumedField = "";
neighborhoods = "";
for (int i = 0; i < selectedNeighborhoods.length; i++) {
if (selectedNeighborhoods[i].equals(Util.getNeighborhoods("")[0]) || selectedNeighborhoods.length == Util.getNeighborhoods(zone).length) {
super.onPositiveActionClicked(fragment);
return;
}
neighborhoods += selectedNeighborhoods[i];
if (i + 1 != selectedNeighborhoods.length) {
neighborhoods += ", ";
}
}
if (selectedNeighborhoods.length > 3) {
resumeLocation = selectedNeighborhoods[0] + "... " + selectedNeighborhoods[selectedNeighborhoods.length - 1];
location_et.setText(resumeLocation);
} else {
location_et.setText(neighborhoods);
}
location = neighborhoods;
} else {
location_et.setText(zone);
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
@SuppressWarnings("ConstantConditions") ArrayList<String> neighborhoods = new ArrayList<>(Arrays.asList(Util.getNeighborhoods(zone)));
neighborhoods.add(0, Util.getNeighborhoods("")[0]);
String[] neighborhoodsArray = new String[neighborhoods.size()];
neighborhoods.toArray(neighborhoodsArray);
builder.multiChoiceItems(neighborhoodsArray, -1).title(getContext().getString(R.string.frag_rideSearch_pickNeighborhood)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
}
use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class RideFilterFrag method locationEt.
@OnClick(R.id.location_et)
public void locationEt() {
SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
String selectedZone = getSelectedValue().toString();
location_et.setText(selectedZone);
locationEt2(selectedZone);
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.items(Util.getZonesForFilter(), 0).title(getContext().getString(R.string.frag_rideSearch_pickZones)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
}
use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class RideOfferFrag method date_et.
@OnClick(R.id.date_et)
public void date_et() {
Dialog.Builder builder = new DatePickerDialog.Builder(R.style.Material_App_Dialog_DatePicker_Light) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
DatePickerDialog dialog = (DatePickerDialog) fragment.getDialog();
date_et.setText(dialog.getFormattedDate(new SimpleDateFormat("dd/MM/yyyy", Locale.US)));
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
}
Aggregations