Subversion Repository Public Repository

Nextrek

Diff Revisions 696 vs 703 for /Android/SmartCharging/SmartCharging/app/src/main/java/it/fedeloper/smartcharging/Controller/MapActivity.java

Diff revisions: vs.
  @@ -84,7 +84,7 @@
84 84 HashMap<Marker, JSONObject> ms = new HashMap<>();
85 85 HashMap<Integer, JSONObject> mapCacheInfo = new HashMap<Integer, JSONObject>();
86 86 HashMap<Integer, JSONObject> mapCachelocals = new HashMap<Integer, JSONObject>();
87 -
87 + public static HashMap<Integer, JSONObject> mapCacheRecensioni = new HashMap<Integer, JSONObject>();
88 88 Geocoder geoCoder;
89 89 private GoogleMap map;
90 90 private LocationManager locationManager;
  @@ -518,7 +518,7 @@
518 518 }).start();
519 519 }
520 520
521 - private void getInfoById(final int id) {
521 + public void getInfoById(final int id) {
522 522 // if (id != idlocale) {
523 523 // runOnUiThread(new Runnable() {
524 524 // @Override
  @@ -530,6 +530,8 @@
530 530 if (full != null && id != idlocale) {
531 531 backPress();
532 532 }
533 +
534 +
533 535 //getting info of local
534 536 new Thread(new Runnable() {
535 537 public void run() {
  @@ -582,6 +584,71 @@
582 584 }
583 585 }).start();
584 586
587 +
588 +
589 + //getting recensione
590 +
591 + new Thread(new Runnable() {
592 + public void run() {
593 +
594 + if (mapCacheRecensioni.containsKey(id)) {
595 +
596 + runOnUiThread(new Runnable() {
597 + @Override
598 + public void run() {
599 +
600 + try {
601 + if( mapCacheRecensioni.get(id).getJSONObject("comment")!=null)
602 + reviewButton.setText(R.string.modifica_recensione);
603 + else
604 + reviewButton.setText(R.string.scrivirecensione_btn);
605 +
606 + } catch (JSONException e) {
607 + e.printStackTrace();
608 + reviewButton.setText(R.string.scrivirecensione_btn);
609 + }
610 + }
611 + });
612 + } else {
613 + try {
614 +
615 + JSONObject obj = new JSONObject();
616 + obj.put("id_local", id);
617 + obj.put("id_user", PrefsManager.getId(c));
618 +
619 +
620 + final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT +"/get_commento.php", obj);
621 +
622 + if (resp.getInt("return") == 0) {
623 +
624 + mapCacheRecensioni.put(id, resp);
625 + if (currentLoad == id) {
626 + runOnUiThread(new Runnable() {
627 + @Override
628 + public void run() {
629 + try {
630 + if( mapCacheRecensioni.get(id).getJSONObject("comment")!=null)
631 + reviewButton.setText(R.string.modifica_recensione);
632 + else
633 + reviewButton.setText(R.string.scrivirecensione_btn);
634 + } catch (JSONException e) {
635 + e.printStackTrace();
636 + reviewButton.setText(R.string.scrivirecensione_btn);
637 + }
638 + }
639 + });
640 + }
641 + }
642 + } catch (JSONException e) {
643 + e.printStackTrace();
644 + }
645 + }
646 + }
647 + }).start();
648 +
649 +
650 +
651 +
585 652 //getting avatar image
586 653 new Thread(new Runnable() {
587 654 public void run() {
  @@ -754,7 +821,8 @@
754 821 i.putExtra("nome", ((TextView) findViewById(R.id.nome_locale)).getText().toString());
755 822 i.putExtra("tipologia", ((TextView) findViewById(R.id.tipologia)).getText().toString());
756 823 i.putExtra("idlocale", idlocale);
757 -
824 + i.putExtra("json", mapCacheRecensioni.get(idlocale).toString());
825 + // mapCacheRecensioni.remove(idlocale);
758 826 startActivity(i);
759 827 }
760 828