protected void onPostExecute(String result) { if (TabName.equals("Review_Tab1")) { rvComment.setText(""); } else if (TabName.equals("Review_Tab2")) { ReviewAdapter reviewAdapter = new ReviewAdapter(Review_Tab2_Context, reviewArr); Review_Tab2_ListView.setAdapter(reviewAdapter); } else if (TabName.equals("MapActivity")) { // Log.i("mytag", "markReview"); ReviewAdapter reviewAdapter = new ReviewAdapter(MapActivity_Context, reviewArr); MapActivity_ListView.setAdapter(reviewAdapter); // MapActivity_ListView2.setAdapter(reviewAdapter); // MapActivity ma = new MapActivity(); // ma.markReviews(reviewArr); } else if (TabName.equals("ReviewViewDelete")) { ((ReviewView) ReviewView.ReviewView_Context).finish(); Review_Tab2 rvTab2 = new Review_Tab2(); rvTab2.refreshReview(); } else if (TabName.equals("Join")) { if (isDuplicated == false) { Message msg; msg = joinPopup_MessageHandler.obtainMessage(); msg.arg1 = 1; joinPopup_MessageHandler.sendMessage(msg); } else if (isDuplicated == true) { Message msg; msg = joinPopup_MessageHandler.obtainMessage(); msg.arg1 = 2; joinPopup_MessageHandler.sendMessage(msg); } } else if (TabName.equals("Cluster")) { Cluster cc = new Cluster(); cc.setMarkArray(); Log.i("mytag", "ReviewAsyncTask"); // MapActivity map = new MapActivity(); // map.setMarkClustered(); Message msg; msg = MapActivity_MessageHandler.obtainMessage(); msg.arg1 = 2; MapActivity_MessageHandler.sendMessage(msg); } }
protected String doInBackground(String... params) { // policeArr = new ArrayList<Emergency>(); reviewArr = new ArrayList<Review>(); if (this.isCancelled()) { this.cancel(true); } try { while (conn == null) { if (conn != null) break; else { Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance(); Log.i("Connection", "**MSSQL driver load"); conn = DriverManager.getConnection( "jdbc:jtds:sqlserver://192.168.43.154:1433/SAFEMAP;encrypt=fasle;instance=SQLEXPRESS;", "sa", "74128526"); Log.i("Connection", "**MSSQL open"); stmt = conn.createStatement(); } } } catch (Exception e) { Log.w("***Error connection", "" + e.getMessage()); } if (TabName.equals("Review_Tab1")) { try { Review_Tab1 rvTab1 = new Review_Tab1(); currentDateTime = getDateTime(); stmt.executeUpdate( "insert into review (nickname, date, location, comment, icon, lat, lng) " + "values (\'" + rvTab1.getName() + "\',\'" + currentDateTime + "\',\'" + rvTab1.getLocation() + "\',\'" + rvTab1.getComment() + "\'," + rvTab1.getIcon() + "," + rvTab1.getLat() + "," + rvTab1.getLng() + ")"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Message msg; msg = Review_Tab1_MessageHandler.obtainMessage(); msg.arg1 = 1; Review_Tab1_MessageHandler.sendMessage(msg); } else if (TabName.equals("Review_Tab2")) { try { ResultSet reset = stmt.executeQuery( "select * from review where nickname = \'" + UserNickName + "\' order by reviewID desc"); while (reset.next()) { int icon = R.drawable.ic_launcher; if (reset.getInt(6) == 0) { icon = R.drawable.yellow; } else if (reset.getInt(6) == 1) { icon = R.drawable.orange; } else if (reset.getInt(6) == 2) { icon = R.drawable.red; } reviewArr.add( new Review( reset.getInt(1), icon, reset.getString(2), reset.getString(4), reset.getString(5), reset.getString(3), reset.getDouble(7), reset.getDouble(8))); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Message msg; msg = Review_Tab2_MessageHandler.obtainMessage(); msg.arg1 = 1; Review_Tab2_MessageHandler.sendMessage(msg); } else if (TabName.equals("MapActivity")) { try { ResultSet reset = stmt.executeQuery("select * from review order by reviewID desc"); while (reset.next()) { int icon = R.drawable.ic_launcher; if (reset.getInt(6) == 0) { icon = R.drawable.yellow; } else if (reset.getInt(6) == 1) { icon = R.drawable.orange; } else if (reset.getInt(6) == 2) { icon = R.drawable.red; } reviewArr.add( new Review( reset.getInt(1), icon, reset.getString(2), reset.getString(4), reset.getString(5), reset.getString(3), reset.getDouble(7), reset.getDouble(8))); } ResultSet reset2 = stmt.executeQuery("select * from police"); while (reset2.next()) { policeArr.add( new Emergency( reset2.getString(1), reset2.getString(2), reset2.getDouble(3), reset2.getDouble(4))); // Log.i("mytag", "police"); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Message msg; msg = MapActivity_MessageHandler.obtainMessage(); msg.arg1 = 1; MapActivity_MessageHandler.sendMessage(msg); } else if (TabName.equals("ReviewViewDelete")) { try { stmt.executeUpdate("delete from review where reviewID=" + ReviewID); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (TabName.equals("loading")) { Message msg; msg = loading_MessageHandler.obtainMessage(); msg.arg1 = 1; loading_MessageHandler.sendMessage(msg); } else if (TabName.equals("Join")) { try { ResultSet reset = stmt.executeQuery("select * from [user]"); while (reset.next()) { if (reset.getString(2).equals(strNickName)) { isDuplicated = true; } } if (isDuplicated == false) { stmt.executeUpdate( "insert into [user] (email, nickname) " + "values (\'" + strEmail + "\',\'" + strNickName + "\')"); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (TabName.equals("Cluster")) { Log.i("mytag", "cluster!!!"); try { ResultSet reset = stmt.executeQuery("select * from review order by reviewID desc"); while (reset.next()) { int icon = R.drawable.ic_launcher; if (reset.getInt(6) == 0) { icon = R.drawable.yellow; } else if (reset.getInt(6) == 1) { icon = R.drawable.orange; } else if (reset.getInt(6) == 2) { icon = R.drawable.red; } reviewArr.add( new Review( reset.getInt(1), icon, reset.getString(2), reset.getString(4), reset.getString(5), reset.getString(3), reset.getDouble(7), reset.getDouble(8))); } Log.i("mytag", String.valueOf(reviewArr.size())); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }