Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. `String url="http://27.147.169.230/UpSkillService/UpSkillsService.svc/"+"GetCNCCourseDefByorg/"+1+"/"+1;
  2. Ion.with(getApplicationContext())
  3. .load("GET",url)
  4. .setBodyParameter("","")
  5. .asString()
  6. .setCallback(new FutureCallback<String>() {
  7. @Override
  8. public void onCompleted(Exception e, String result) {
  9. Log.d("Result",result);
  10. try {
  11. JSONObject obj =new JSONObject(result);
  12. JSONArray jsonArray = obj.getJSONArray("GetCNCCourseDefByorgResult");
  13. //Arrays.sort(new JSONArray[]{jsonArray});
  14.  
  15.  
  16. if(obj.isNull("GetCNCCourseDefByorgResult"))
  17. {
  18. Toast.makeText(getApplicationContext(),"No Course Found",Toast.LENGTH_SHORT).show();
  19. }
  20. else if (!obj.equals(null)) {
  21. String cata="";
  22. Log.d("Resul3", jsonArray.toString());
  23. for (int i = 0; i < jsonArray.length(); i++) {
  24. final CourseCatagory catagoryModel = new CourseCatagory();
  25. JSONObject course = jsonArray.getJSONObject(i);
  26. CourseList courselist = new CourseList();
  27. if(cata!=course.getString("CategoryName"))
  28. {
  29. Log.d("Catagory",cata);
  30. catagoryModel.setCategoryName(course.getString("CategoryName"));
  31.  
  32.  
  33.  
  34. arrayListcatagory.add(catagoryModel);
  35.  
  36. for (int j=0;j<jsonArray.length();j++)
  37. {
  38. JSONObject cat1 = jsonArray.getJSONObject(j);
  39. cata=cat1.getString("CategoryName");
  40. Log.d("cat",cata);
  41. if(cat1.getString("CategoryName")==course.getString("CategoryName"))
  42. {
  43. courselist.setCourseName(cat1.getString("CourseName"));
  44. courselist.setCourseCode(cat1.getString("CourseCode"));
  45. courselist.setWishFlag(cat1.getInt("WishFlag"));
  46. Log.d("Course",cat1.getString("CourseName"));
  47. arrayListcourse.add(courselist);
  48.  
  49. }
  50. else {
  51.  
  52. }
  53.  
  54. }
  55.  
  56. }
  57. catagoryModel.setCourseList(arrayListcourse);
  58.  
  59. }
  60.  
  61. adapter.notifyDataSetChanged();
  62. }
  63.  
  64. } catch (JSONException e1) {
  65. e1.printStackTrace();
  66. }
  67. }
  68. });
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement