Search in sources :

Example 1 with LovelyCustomDialog

use of com.yarolegovich.lovelydialog.LovelyCustomDialog in project easy by MehdiBenmesa.

the class StudentsFragmentAbsence method startDialog.

public void startDialog(final JSONArray response, final JSONArray pseances, List<String> modules) {
    /*   List<String> modules = new ArrayList<String>();
        final JSONArray seances = new JSONArray();
        try{
            for (int i =0;i<response.length();i++) {
                JSONObject seance = response.getJSONObject(i);
                JSONObject idmodule = seance.getJSONObject("module");
                if(idmodule.getString("_id").equals(module.getString("_id"))){
                    String type = "";
                    try{
                        type = seance.getString("type") + " de : ";
                    }catch (Exception e){
                        e.printStackTrace();
                        type = "heur de : ";
                    }
                    String seanceSpinner = type + seance.getString("starts") + " à "+seance.getString("ends");
                    modules.add(seanceSpinner);
                    seances.put(seance);
                }
            }} catch (JSONException e){
            e.printStackTrace();
        }*/
    addDialog = getActivity().getLayoutInflater().inflate(R.layout.absence_dialog, null);
    final TextView nom = (TextView) addDialog.findViewById(R.id.nomdialog);
    final Spinner etat = (Spinner) addDialog.findViewById(R.id.okdialog);
    ArrayAdapter<String> adap = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, modules);
    adap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    etat.setAdapter(adap);
    nom.setText("");
    dialog = new LovelyCustomDialog(getContext(), R.style.EditTextTintTheme).setTopColorRes(R.color.darkRed).setView(addDialog).setTitle(R.string.text_input_title).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
    dialog.show();
    Button ok = (Button) addDialog.findViewById(R.id.ok);
    Button annuler = (Button) addDialog.findViewById(R.id.cancel);
    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            try {
                String module = etat.getSelectedItem().toString();
            } catch (Exception e) {
                System.out.println("NO MODULE ");
            }
            try {
                int position = etat.getSelectedItemPosition();
                AbsenceService.getAbsneceBySeance(getContext(), mReceiver, new JSONObject().put("idSeance", pseances.getJSONObject(position).getString("_id")).put("date", newDate));
            } catch (JSONException e) {
                e.printStackTrace();
            }
            dialog.dismiss();
        }
    });
    annuler.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
}
Also used : Spinner(android.widget.Spinner) JSONException(org.json.JSONException) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) Button(android.widget.Button) LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog) TextView(android.widget.TextView) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with LovelyCustomDialog

use of com.yarolegovich.lovelydialog.LovelyCustomDialog in project easy by MehdiBenmesa.

the class RendezVousActivity method buttonPressed.

@Override
public void buttonPressed(final JSONObject module) {
    addDialog = getLayoutInflater().inflate(R.layout.rdv_dialog, null);
    final TextView nom = (TextView) addDialog.findViewById(R.id.nomdialog);
    final TextView date = (TextView) addDialog.findViewById(R.id.date);
    final EditText heur = (EditText) addDialog.findViewById(R.id.heur);
    final EditText value = (EditText) addDialog.findViewById(R.id.value);
    dialog = new LovelyCustomDialog(this, R.style.EditTextTintTheme).setTopColorRes(R.color.darkRed).setView(addDialog).setTitle(R.string.text_input_title).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
    dialog.show();
    Button ok = (Button) addDialog.findViewById(R.id.ok);
    Button annuler = (Button) addDialog.findViewById(R.id.cancel);
    date.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showDatePicker();
        }
    });
    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            try {
                ajouterRdv(module.getString("_id"), date.getText().toString(), value.getText().toString());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            dialog.dismiss();
        }
    });
    annuler.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
    ondate = new DatePickerDialog.OnDateSetListener() {

        @RequiresApi(api = Build.VERSION_CODES.N)
        @Override
        public void onDateSet(android.widget.DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            monthOfYear = monthOfYear + 1;
            date.setText(year + "-" + monthOfYear + 1 + "-" + dayOfMonth);
            calender.set(year, monthOfYear, dayOfMonth);
            int dayOfWeek = 0;
            dayOfWeek = calender.get(Calendar.DAY_OF_WEEK);
            System.out.println("DAY_OF_WEEK : +======== " + dayOfWeek);
        // studentsListAdapter.notifyDataSetChanged();
        }
    };
}
Also used : EditText(android.widget.EditText) DatePickerDialog(android.app.DatePickerDialog) JSONException(org.json.JSONException) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Button(android.widget.Button) LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog) RequiresApi(android.support.annotation.RequiresApi) TextView(android.widget.TextView)

Example 3 with LovelyCustomDialog

use of com.yarolegovich.lovelydialog.LovelyCustomDialog in project easy by MehdiBenmesa.

the class RendezVousFragment method buttonPressed.

@Override
public void buttonPressed(final JSONObject rdv) {
    addDialog = getActivity().getLayoutInflater().inflate(R.layout.rdv_dialog, null);
    final TextView nom = (TextView) addDialog.findViewById(R.id.nomdialog);
    final TextView date = (TextView) addDialog.findViewById(R.id.date);
    final EditText heur = (EditText) addDialog.findViewById(R.id.heur);
    final EditText value = (EditText) addDialog.findViewById(R.id.value);
    dialog = new LovelyCustomDialog(getContext(), R.style.EditTextTintTheme).setTopColorRes(R.color.darkRed).setView(addDialog).setTitle(R.string.text_input_title).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
    dialog.show();
    Button ok = (Button) addDialog.findViewById(R.id.ok);
    Button annuler = (Button) addDialog.findViewById(R.id.cancel);
    date.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showDatePicker();
        }
    });
    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            accept(rdv, date.getText().toString(), heur.getText().toString(), value.getText().toString());
            dialog.dismiss();
        }
    });
    annuler.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            refuse(rdv, value.getText().toString());
            dialog.dismiss();
        }
    });
    ondate = new DatePickerDialog.OnDateSetListener() {

        @RequiresApi(api = Build.VERSION_CODES.N)
        @Override
        public void onDateSet(android.widget.DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            monthOfYear = monthOfYear + 1;
            date.setText(year + "-" + monthOfYear + 1 + "-" + dayOfMonth);
            calender.set(year, monthOfYear, dayOfMonth);
            int dayOfWeek = 0;
            dayOfWeek = calender.get(Calendar.DAY_OF_WEEK);
            System.out.println("DAY_OF_WEEK : +======== " + dayOfWeek);
        // studentsListAdapter.notifyDataSetChanged();
        }
    };
}
Also used : EditText(android.widget.EditText) DatePickerDialog(android.app.DatePickerDialog) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Button(android.widget.Button) LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog) RequiresApi(android.support.annotation.RequiresApi) TextView(android.widget.TextView)

Example 4 with LovelyCustomDialog

use of com.yarolegovich.lovelydialog.LovelyCustomDialog in project easy by MehdiBenmesa.

the class BaseActivity method showAlertDialog.

private void showAlertDialog(String message) {
    LovelyCustomDialog dialog = new LovelyCustomDialog(this, R.style.EditTextTintTheme).setTopColorRes(R.color.colorPrimaryDark).setTitle("Message Received !").setMessage(message).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
    dialog.show();
}
Also used : LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog)

Example 5 with LovelyCustomDialog

use of com.yarolegovich.lovelydialog.LovelyCustomDialog in project easy by MehdiBenmesa.

the class StudentsFragmentNote method buttonPressed.

@Override
public void buttonPressed(final JSONObject student, final JSONArray notes) throws JSONException {
    addDialog = getActivity().getLayoutInflater().inflate(R.layout.adddialog, null);
    final TextView nom = (TextView) addDialog.findViewById(R.id.nomdialog);
    final Spinner etat = (Spinner) addDialog.findViewById(R.id.okdialog);
    final EditText value = (EditText) addDialog.findViewById(R.id.value);
    ArrayAdapter adap = ArrayAdapter.createFromResource(getContext(), R.array.snipperdialog, R.layout.item_spinner);
    etat.setAdapter(adap);
    nom.setText(student.getString("name") + " " + student.getString("lastname"));
    dialog = new LovelyCustomDialog(getContext(), R.style.EditTextTintTheme).setTopColorRes(R.color.darkRed).setView(addDialog).setTitle(R.string.text_input_title).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
    dialog.show();
    Button ok = (Button) addDialog.findViewById(R.id.ok);
    Button annuler = (Button) addDialog.findViewById(R.id.cancel);
    etat.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            String item = adapterView.getItemAtPosition(position).toString();
            value.setText("");
            try {
                for (int i = 0; i < notes.length(); i++) {
                    JSONObject note = notes.getJSONObject(i);
                    if (note.getString("module").equals(module.getString("_id")))
                        if (note.getString("reason").equals(item)) {
                            value.setText(note.getString("value"));
                        }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String valeur = value.getText().toString();
            String reason = etat.getSelectedItem().toString();
            try {
                // putNoteStudent(valeur, student.getString("_id"), reason);
                JSONObject dataToSend = new JSONObject();
                dataToSend.put("reason", reason);
                dataToSend.put("student", student.getString("_id"));
                dataToSend.put("value", valeur);
                dataToSend.put("module", module.getString("_id"));
                dataToSend.put("modulename", module.getString("_name"));
                NoteService.putNoteStudent(getContext(), mReceiver, dataToSend);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            dialog.dismiss();
        }
    });
    annuler.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
}
Also used : EditText(android.widget.EditText) MaterialSpinner(com.jaredrummler.materialspinner.MaterialSpinner) Spinner(android.widget.Spinner) JSONException(org.json.JSONException) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) JSONObject(org.json.JSONObject) Button(android.widget.Button) LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

LovelyCustomDialog (com.yarolegovich.lovelydialog.LovelyCustomDialog)5 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 Button (android.widget.Button)4 TextView (android.widget.TextView)4 EditText (android.widget.EditText)3 BindView (butterknife.BindView)3 JSONException (org.json.JSONException)3 DatePickerDialog (android.app.DatePickerDialog)2 RequiresApi (android.support.annotation.RequiresApi)2 AdapterView (android.widget.AdapterView)2 ArrayAdapter (android.widget.ArrayAdapter)2 Spinner (android.widget.Spinner)2 JSONObject (org.json.JSONObject)2 MaterialSpinner (com.jaredrummler.materialspinner.MaterialSpinner)1 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)1