use of dz.easy.androidclient.Adapters.TeachersAdapter 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);
}
use of dz.easy.androidclient.Adapters.TeachersAdapter 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);
}
use of dz.easy.androidclient.Adapters.TeachersAdapter in project easy by MehdiBenmesa.
the class RendezVousFragment 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_RENDEZVOUS_MANAGER:
String jsonStringManager = resultData.getString("result");
JSONArray response = null;
try {
response = new JSONArray(jsonStringManager);
recyclerViewRendeVous.setAdapter(new TeachersAdapter(response, (TeachersAdapter.AdapterInterface) this));
} catch (JSONException e) {
e.printStackTrace();
}
/*
<<<<<<< HEAD
recyclerViewRendeVous.setHasFixedSize(true);
//Use this now
recyclerViewRendeVous.addItemDecoration(new MaterialViewPagerHeaderDecorator());
recyclerViewRendeVous.setAdapter(new TestRecyclerViewAdapter(response,(TestRecyclerViewAdapter.AdapterInterface) RendezVousFragment.this));
}
}, new Response.ErrorListener() {
*
@Override
public void onErrorResponse(VolleyError error) {
*/
break;
case GET_RENDEZVOUS_STUDENT:
String jsonStringStudent = resultData.getString("result");
JSONArray responseStudent = null;
try {
responseStudent = new JSONArray(jsonStringStudent);
// recyclerViewRendeVous.setAdapter(new TeachersAdapter(responseStudent));
} catch (JSONException e) {
e.printStackTrace();
}
break;
case GET_RENDEZVOUS_TEACHER:
String jsonStringTeacher = resultData.getString("result");
JSONArray responseTeacher = null;
try {
responseTeacher = new JSONArray(jsonStringTeacher);
// recyclerViewRendeVous.setAdapter(new TeachersAdapter(responseTeacher));
} 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;
}
}
Aggregations