Page 375 - 2020학년도 MDP과제발표회 자료집 (통신과) (3)
P. 375

Log.e(this.getClass().getName(),  split[1]);
                                                    JSONArray  jsonArray  =  new  JSONArray(split[0]);            //JSON  String 으로  받은
            데이터를  JSONArray    값으로  변환
                                                    for  (int  i  =  0;  i  <  jsonArray.length();  i++)  {
                                                            JSONObject  jsonObject  =  jsonArray.getJSONObject(i);          //JSONArray 의
            길이만큼  JSONObject    를  추출
                                                            String  bookname  =  jsonObject.getString(BOOK);
                                                            String  writer  =  jsonObject.getString(WRITER);
                                                            String  deadline  =  jsonObject.getString(DEADLINE);
                                                            HashMap<String,  String>  hashMap  =  new  HashMap<>();
                                                            hashMap.put(BOOK,  bookname);
                                                            hashMap.put(WRITER,  writer);
                                                            hashMap.put(DEADLINE,  deadline);


                                                            Log.e(this.getClass().getName(),  i  +  ":"  +  BOOK  +  ":"  +  bookname);
                                                            Log.e(this.getClass().getName(),  i  +  ":"  +  WRITER  +  ":"  +  writer);
                                                            Log.e(this.getClass().getName(),  i  +  ":"  +  DEADLINE  +  ":"  +  deadline);
                                                            blistArrayList.add(hashMap);
                                                    }
                                                    badapter  =  new  SimpleAdapter(getActivity(),  blistArrayList,
                                                                    R.layout.library_booklist_item,
                                                                    new  String[]{BOOK,  WRITER,  DEADLINE},
                                                                    new  int[]{R.id.jmb_TextView_booklist_bookname,
                                                                                    R.id.jmb_TextView_booklist_writer,
                                                                                    R.id.jmb_TextView_booklist_deadline});
                                                    ((SimpleAdapter)  badapter).notifyDataSetChanged();
                                                    blistListView_list.setAdapter(badapter);          //JSONObject 의  값을  추출해서  미리
            만들어둔  ListView    틀에  삽입
                                                    if  (split[1].equals("0"))  {
                          // 데이터베이스에  rentdenydate      에  이  들어있으면  대출가능  권수를  표시0
                                                            blistTextView_rentdeny.setText(" 현재  대출이  가능한  권수는  "  +  (2  -
            jsonArray.length())  +  "   입니다.");
                                                    }  else  {
                          // 데이터베이스에  날짜가  들어있으면  언제까지  대출이  불가하다를  표시
                                                            blistTextView_rentdeny.setText(" 연채가  되어  "  +  split[1]  +  " 까지  대출이  불가
            능  합니다");
                                                    }
                                            }  catch  (Exception  e){
                                                    e.printStackTrace();
                                            }
                                    }
                            };


                            final  Thread  worker  =  new  Thread()  {        //worker  를  Thread  로  생성
                                    public  void  run()  {  // 스레드  실행구문

                                                                                      인천전자마이스터고등학교
                                                         -  391  -                       정보통신기기과         391
   370   371   372   373   374   375   376   377   378   379   380