Search in sources :

Example 1 with NoteAdapter

use of dz.easy.androidclient.Adapters.NoteAdapter in project easy by MehdiBenmesa.

the class NoteFragment method onReceiveResult.

@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
    switch(resultCode) {
        case STATUS_RUNNING:
            dialogListner.showDialog();
            break;
        case STATUS_FINISHED:
            /* Hide progress & extract result from bundle */
            dialogListner.hideDialog();
            switch(resultData.getString("action")) {
                case GET_NOTE_STUDENT_MODULE:
                    String jsonString = resultData.getString("result");
                    JSONArray response = null;
                    try {
                        response = new JSONArray(jsonString);
                        mRecyclerView.setAdapter(new NoteAdapter(response));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    break;
            }
            break;
        case STATUS_ERROR:
            /* Handle the error */
            String error = resultData.getString(Intent.EXTRA_TEXT);
            Toast.makeText(getContext(), error, Toast.LENGTH_LONG).show();
            break;
    }
}
Also used : JSONArray(org.json.JSONArray) NoteAdapter(dz.easy.androidclient.Adapters.NoteAdapter) JSONException(org.json.JSONException)

Example 2 with NoteAdapter

use of dz.easy.androidclient.Adapters.NoteAdapter in project easy by MehdiBenmesa.

the class NoteFragment method getNoteByStudent.

public void getNoteByStudent() {
    try {
        System.out.println("AVANT ABSENCE 2 ");
        CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_NOTE_BY_MODULES + "/" + user.getString("_id") + "/" + moduleID, null, new Response.Listener<JSONArray>() {

            @Override
            public void onResponse(JSONArray response) {
                if (GRID_LAYOUT) {
                    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
                } else {
                    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
                }
                mRecyclerView.setHasFixedSize(true);
                // Use this now
                mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
                mRecyclerView.setAdapter(new NoteAdapter(response));
            }
        }, new Response.ErrorListener() {

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

Aggregations

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