Search in sources :

Example 1 with DialogFragment

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);
}
Also used : UrlForJson(br.ufrj.caronae.models.modelsforjson.UrlForJson) User(br.ufrj.caronae.models.User) DialogFragment(com.rey.material.app.DialogFragment) CaretString(com.redmadrobot.inputmask.model.CaretString) Profile(com.facebook.Profile) SimpleDialog(com.rey.material.app.SimpleDialog) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) OnClick(butterknife.OnClick)

Example 2 with DialogFragment

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);
}
Also used : Dialog(com.rey.material.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) SimpleDialog(com.rey.material.app.SimpleDialog) DialogFragment(com.rey.material.app.DialogFragment) CaretString(com.redmadrobot.inputmask.model.CaretString)

Example 3 with DialogFragment

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);
}
Also used : DialogFragment(com.rey.material.app.DialogFragment) ArrayList(java.util.ArrayList) SimpleDialog(com.rey.material.app.SimpleDialog)

Example 4 with DialogFragment

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);
}
Also used : SimpleDialog(com.rey.material.app.SimpleDialog) DialogFragment(com.rey.material.app.DialogFragment) OnClick(butterknife.OnClick)

Example 5 with DialogFragment

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);
}
Also used : DatePickerDialog(com.rey.material.app.DatePickerDialog) TimePickerDialog(com.rey.material.app.TimePickerDialog) ProgressDialog(android.app.ProgressDialog) AlertDialog(android.support.v7.app.AlertDialog) DatePickerDialog(com.rey.material.app.DatePickerDialog) SimpleDialog(com.rey.material.app.SimpleDialog) Dialog(com.rey.material.app.Dialog) DialogFragment(com.rey.material.app.DialogFragment) SimpleDateFormat(java.text.SimpleDateFormat) OnClick(butterknife.OnClick)

Aggregations

DialogFragment (com.rey.material.app.DialogFragment)27 SimpleDialog (com.rey.material.app.SimpleDialog)27 OnClick (butterknife.OnClick)13 Dialog (com.rey.material.app.Dialog)12 AlertDialog (android.support.v7.app.AlertDialog)11 ProgressDialog (android.app.ProgressDialog)9 DatePickerDialog (com.rey.material.app.DatePickerDialog)7 TimePickerDialog (com.rey.material.app.TimePickerDialog)7 EditText (android.widget.EditText)4 ArrayList (java.util.ArrayList)4 User (br.ufrj.caronae.models.User)3 CaretString (com.redmadrobot.inputmask.model.CaretString)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 RoundedTransformation (br.ufrj.caronae.RoundedTransformation)2 Ride (br.ufrj.caronae.models.Ride)2