use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class MyProfileFrag 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();
if (selectedZone.equals("Outros")) {
showOtherNeighborhoodDialog();
} else {
locationEt2(selectedZone);
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.items(Util.getZones(), 0).title("Escolha sua zona").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 RideFilterFrag method centerEt.
@OnClick(R.id.center_et)
public void centerEt() {
final ArrayList<String> selectedItems = new ArrayList<>();
String[] selectedCenters = center_et.getText().toString().split(", ");
boolean[] ifCentersAreSelected = new boolean[Util.getFundaoCenters().length];
for (int centers = 0; centers < Util.getFundaoCenters().length; centers++) {
ifCentersAreSelected[centers] = false;
for (int selecteds = 0; selecteds < selectedCenters.length; selecteds++) {
if (Util.getFundaoCenters()[centers].equals(selectedCenters[selecteds])) {
ifCentersAreSelected[centers] = true;
selectedItems.add(Util.getFundaoCenters()[centers]);
}
}
}
final AlertDialog builder = new AlertDialog.Builder(getContext()).setTitle(getContext().getString(R.string.frag_rideSearch_hintPickCenter)).setMultiChoiceItems(Util.getFundaoCenters(), ifCentersAreSelected, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (isChecked) {
// If the user checked the item, add it to the selected items
selectedItems.add(Util.getFundaoCenters()[which]);
} else if (selectedItems.contains(Util.getFundaoCenters()[which])) {
// Else, if the item is already in the array, remove it
for (int item = 0; item < selectedItems.size(); item++) {
if (Util.getFundaoCenters()[which].equals(selectedItems.get(item)))
selectedItems.remove(item);
}
}
}
}).setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String centers = "";
for (int selectedValues = 0; selectedValues < selectedItems.size(); selectedValues++) {
if (selectedItems.get(selectedValues).equals(Util.getFundaoCenters()[0]) || selectedItems.size() == Util.getFundaoCenters().length - 1) {
selectedItems.clear();
// selectedItems.add(Util.getFundaoCenters()[0]);
selectedItems.add("Cidade Universitária");
campi = "Cidade Universitária";
centers = selectedItems.get(0) + ", ";
break;
}
centers = centers + selectedItems.get(selectedValues) + ", ";
}
if (!centers.equals("")) {
centers = centers.substring(0, centers.length() - 2);
}
center_et.setText(centers);
center = centers;
}
}).setNegativeButton(getContext().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create();
SimpleDialog.Builder campiBuilder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
if (getSelectedValue().toString().equals("Praia Vermelha")) {
center_et.setText(getSelectedValue());
campi = getSelectedValue().toString();
} else {
// centerBuilder.items(Util.getCentersByCampi(getSelectedValue().toString()), 0)
// .title(getContext().getString(R.string.frag_rideOffer_pickCenter))
// .positiveAction(getContext().getString(R.string.ok))
// .negativeAction(getContext().getString(R.string.cancel));
// DialogFragment centerFragment = DialogFragment.newInstance(centerBuilder);
// centerFragment.show(getFragmentManager(), null);
builder.show();
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
campiBuilder.items(Util.getCampiWithoutAllCampi(), 0).title(getContext().getString(R.string.frag_rideOffer_pickCenter)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(campiBuilder);
fragment.show(getFragmentManager(), null);
}
use of com.rey.material.app.DialogFragment in project caronae-android by caronae.
the class RideFilterFrag 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) {
EditText neighborhood_et = (EditText) fragment.getDialog().findViewById(R.id.neighborhood_et);
String neighborhood = neighborhood_et.getText().toString();
if (!neighborhood.isEmpty()) {
location_et.setText(neighborhood);
location = neighborhood;
resumeLocation = 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 RideOfferFrag method showCenterListDialog.
public void showCenterListDialog(String campus) {
SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
center_et.setText(getSelectedValue());
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
if (going) {
builder.items(Util.getCentersWithoutAllCenters(), 0).title(getContext().getString(R.string.frag_rideOffer_pickCenter)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
} else {
builder.items(Util.getHubsByCampi(campus), 0).title(getContext().getString(R.string.frag_rideOffer_pickHub)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
// if (campi_et.getText().toString().equals("")){
// campi_et.setError("Escolher o campus");
// } else {
// if (campi_et.getText().toString().equals(Util.getCampus()[1])) {
// builder.items(Util.getFundaoHubs(), 0);
// }
// if (campi_et.getText().toString().equals(Util.getCampus()[2])) {
// builder.items(Util.getPraiaVermelhaHubs(), 0);
// }
// 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 neighborhoodEt.
@OnClick(R.id.neighborhood_et)
public void neighborhoodEt() {
SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
String selectedZone = getSelectedValue().toString();
zone = selectedZone;
if (selectedZone.equals("Outros")) {
showOtherNeighborhoodDialog();
} else {
locationEt2(selectedZone);
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.items(Util.getZones(), 0).title(getContext().getString(R.string.frag_rideOffer_pickZone)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
}
Aggregations