Search in sources :

Example 16 with CustomRequestArray

use of dz.easy.androidclient.Util.CustomRequestArray in project easy by MehdiBenmesa.

the class RendezVousService method getRendezvousByManager.

private void getRendezvousByManager(final IRendezVous callBack) {
    CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_RDV_BY_TEACHER, null, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {
            //setup materialviewpager
            callBack.onDataRecieved(response);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });
    App.getInstance().addToRequestQueue(jsonReq);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) JSONArray(org.json.JSONArray)

Example 17 with CustomRequestArray

use of dz.easy.androidclient.Util.CustomRequestArray in project easy by MehdiBenmesa.

the class RendezVousActivity method getTeachersSearcheed.

private void getTeachersSearcheed(final String newTextS) {
    CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_TEACHERS, null, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {
            JSONArray teachers = response;
            if (GRID_LAYOUT) {
                lstView.setLayoutManager(new GridLayoutManager(RendezVousActivity.this, 2));
            } else {
                lstView.setLayoutManager(new LinearLayoutManager(RendezVousActivity.this));
            }
            lstView.setHasFixedSize(true);
            //Use this now
            lstView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
            //Search action
            JSONArray lstFound = new JSONArray();
            JSONObject item = null;
            for (int i = 0; i < teachers.length(); i++) {
                try {
                    item = teachers.getJSONObject(i);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                try {
                    if (item.getString("name").contains(newTextS) || item.getString("lastname").contains(newTextS)) {
                        lstFound.put(item);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            /*ArrayAdapter adapter = new ArrayAdapter(RendeVous.this, android.R.layout.simple_list_item_1, lstFound);
          lstView.setAdapter(adapter);*/
            lstView.setAdapter(new TeachersAdapter(lstFound, (TeachersAdapter.AdapterInterface) RendezVousActivity.this));
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });
    App.getInstance().addToRequestQueue(jsonReq);
}
Also used : VolleyError(com.android.volley.VolleyError) TeachersAdapter(dz.easy.androidclient.Adapters.TeachersAdapter) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Response(com.android.volley.Response) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) GridLayoutManager(android.support.v7.widget.GridLayoutManager) JSONObject(org.json.JSONObject) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Example 18 with CustomRequestArray

use of dz.easy.androidclient.Util.CustomRequestArray in project easy by MehdiBenmesa.

the class RendezVousActivity method getTeachers.

private void getTeachers() {
    CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_TEACHERS, null, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {
            JSONArray teachers = response;
            if (GRID_LAYOUT) {
                lstView.setLayoutManager(new GridLayoutManager(RendezVousActivity.this, 2));
            } else {
                lstView.setLayoutManager(new LinearLayoutManager(RendezVousActivity.this));
            }
            lstView.setHasFixedSize(true);
            //Use this now
            lstView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
            lstView.setAdapter(new TeachersAdapter(teachers, (TeachersAdapter.AdapterInterface) RendezVousActivity.this));
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });
    App.getInstance().addToRequestQueue(jsonReq);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) TeachersAdapter(dz.easy.androidclient.Adapters.TeachersAdapter) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) GridLayoutManager(android.support.v7.widget.GridLayoutManager) JSONArray(org.json.JSONArray) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Aggregations

Response (com.android.volley.Response)18 VolleyError (com.android.volley.VolleyError)18 CustomRequestArray (dz.easy.androidclient.Util.CustomRequestArray)18 JSONArray (org.json.JSONArray)18 GridLayoutManager (android.support.v7.widget.GridLayoutManager)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)6 JSONException (org.json.JSONException)5 TeachersAdapter (dz.easy.androidclient.Adapters.TeachersAdapter)2 JSONObject (org.json.JSONObject)2 NoteAdapter (dz.easy.androidclient.Adapters.NoteAdapter)1