|
@@ -140,13 +140,13 @@ |
140 |
140 |
|
public void run() { |
141 |
141 |
|
|
142 |
142 |
|
|
143 |
|
- |
if(!mapCacheRecensioni.containsKey(idlocale) && mapCacheInfo.containsKey(idlocale)) |
144 |
|
- |
{ |
145 |
|
- |
getInfoById(idlocale); |
146 |
|
- |
if (expanded) { |
147 |
|
- |
closeFullInfo(); |
148 |
|
- |
} |
|
143 |
+ |
if(!mapCacheRecensioni.containsKey(idlocale) && mapCacheInfo.containsKey(idlocale)) |
|
144 |
+ |
{ |
|
145 |
+ |
getInfoById(idlocale); |
|
146 |
+ |
if (expanded) { |
|
147 |
+ |
closeFullInfo(); |
149 |
148 |
|
} |
|
149 |
+ |
} |
150 |
150 |
|
|
151 |
151 |
|
|
152 |
152 |
|
} |
|
@@ -165,16 +165,16 @@ |
165 |
165 |
|
setContentView(R.layout.activity_map); |
166 |
166 |
|
initView(); |
167 |
167 |
|
|
168 |
|
- |
if (MyLocation.isGpsEnabled(this,false)) |
169 |
|
- |
{ |
170 |
|
- |
loadingAll.setVisibility(View.VISIBLE); |
171 |
|
- |
noLocalMsg.setText(R.string.ricerca_gps); |
172 |
|
- |
} |
173 |
|
- |
else |
174 |
|
- |
{ |
175 |
|
- |
loadingAll.setVisibility(View.GONE); |
176 |
|
- |
noLocalMsg.setText(R.string.seleziona_locale); |
177 |
|
- |
} |
|
168 |
+ |
if (MyLocation.isGpsEnabled(this,false)) |
|
169 |
+ |
{ |
|
170 |
+ |
loadingAll.setVisibility(View.VISIBLE); |
|
171 |
+ |
noLocalMsg.setText(R.string.ricerca_gps); |
|
172 |
+ |
} |
|
173 |
+ |
else |
|
174 |
+ |
{ |
|
175 |
+ |
loadingAll.setVisibility(View.GONE); |
|
176 |
+ |
noLocalMsg.setText(R.string.seleziona_locale); |
|
177 |
+ |
} |
178 |
178 |
|
|
179 |
179 |
|
|
180 |
180 |
|
|
|
@@ -184,24 +184,24 @@ |
184 |
184 |
|
setListenerToRootView(); |
185 |
185 |
|
|
186 |
186 |
|
|
187 |
|
- |
addressView.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
188 |
|
- |
@Override |
189 |
|
- |
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
190 |
|
- |
if (actionId == EditorInfo.IME_ACTION_DONE) { |
191 |
|
- |
searchAddress(v.getText().toString()); |
192 |
|
- |
View view = MapActivity.this.getCurrentFocus(); |
193 |
|
- |
|
194 |
|
- |
if (view != null) { |
195 |
|
- |
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
196 |
|
- |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
187 |
+ |
addressView.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
|
188 |
+ |
@Override |
|
189 |
+ |
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
|
190 |
+ |
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
191 |
+ |
searchAddress(v.getText().toString()); |
|
192 |
+ |
View view = MapActivity.this.getCurrentFocus(); |
|
193 |
+ |
|
|
194 |
+ |
if (view != null) { |
|
195 |
+ |
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
196 |
+ |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
197 |
197 |
|
|
198 |
|
- |
} |
199 |
|
- |
view.clearFocus(); |
200 |
|
- |
return true; |
201 |
|
- |
} |
202 |
|
- |
return false; |
203 |
198 |
|
} |
204 |
|
- |
}); |
|
199 |
+ |
view.clearFocus(); |
|
200 |
+ |
return true; |
|
201 |
+ |
} |
|
202 |
+ |
return false; |
|
203 |
+ |
} |
|
204 |
+ |
}); |
205 |
205 |
|
addressView.setOnFocusChangeListener(new View.OnFocusChangeListener() { |
206 |
206 |
|
@Override |
207 |
207 |
|
public void onFocusChange(View v, boolean hasFocus) { |
|
@@ -279,7 +279,7 @@ |
279 |
279 |
|
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(41.902285, 12.496975), 5.0f)); |
280 |
280 |
|
} |
281 |
281 |
|
boolean isOpened = false; |
282 |
|
- |
private boolean firstLocal=true; |
|
282 |
+ |
private boolean firstLocal=true; |
283 |
283 |
|
public void setListenerToRootView(){ |
284 |
284 |
|
final View activityRootView = getWindow().getDecorView().findViewById(android.R.id.content); |
285 |
285 |
|
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { |
|
@@ -562,7 +562,7 @@ |
562 |
562 |
|
|
563 |
563 |
|
private boolean animationOffEnded=false; |
564 |
564 |
|
|
565 |
|
- |
public void getInfoById(final int id) { |
|
565 |
+ |
public void getInfoById(final int id) { |
566 |
566 |
|
// if (id != idlocale) { |
567 |
567 |
|
// runOnUiThread(new Runnable() { |
568 |
568 |
|
// @Override |
|
@@ -575,386 +575,410 @@ |
575 |
575 |
|
backPress(); |
576 |
576 |
|
} |
577 |
577 |
|
|
578 |
|
- |
if ( Utils.isNetworkConnected(c)) { |
579 |
|
- |
new Thread(new Runnable() { |
580 |
|
- |
public void run() { |
581 |
|
- |
|
582 |
|
- |
if (mapCacheInfo.containsKey(id)) { |
583 |
|
- |
runOnUiThread(new Runnable() { |
584 |
|
- |
@Override |
585 |
|
- |
public void run() { |
586 |
|
- |
final JSONObject resp = mapCacheInfo.get(id); |
587 |
|
- |
final String[] tipi = getResources().getStringArray(R.array.type_array); |
588 |
|
- |
runOnUiThread(new Runnable() { |
589 |
|
- |
@Override |
590 |
|
- |
public void run() { |
591 |
|
- |
|
592 |
|
- |
localeContainer.animate() |
593 |
|
- |
.translationY(0) |
594 |
|
- |
.alpha(0.0f) |
595 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
596 |
|
- |
@Override |
597 |
|
- |
public void onAnimationEnd(Animator animation) { |
598 |
|
- |
super.onAnimationEnd(animation); |
599 |
|
- |
localeContainer.setVisibility(View.VISIBLE); |
600 |
|
- |
localeContainer.setAlpha(1.0f); |
601 |
|
- |
try { |
602 |
|
- |
((TextView) findViewById(R.id.nome_locale)).setText(resp.getString("nomelocale")); |
603 |
|
- |
((TextView) findViewById(R.id.tipologia)).setText(tipi[Integer.parseInt(resp.getString("tipologia"))]); |
604 |
|
- |
((TextView) findViewById(R.id.descrizione)).setText(resp.getString("descrizione")); |
605 |
|
- |
((TextView) findViewById(R.id.via_locale)).setText(resp.getString("indirizzo")); |
606 |
|
- |
((RatingBar) findViewById(R.id.ratingBar)).setRating(resp.getLong("stelle")); |
607 |
|
- |
|
608 |
|
- |
|
609 |
|
- |
String sito = resp.getString("sito"); |
610 |
|
- |
String em = resp.getString("email"); |
611 |
|
- |
|
612 |
|
- |
if (em.length()>0) |
613 |
|
- |
emailLocaleTextView.setVisibility(View.VISIBLE); |
614 |
|
- |
else |
615 |
|
- |
emailLocaleTextView.setVisibility(View.GONE); |
616 |
|
- |
|
617 |
|
- |
|
618 |
|
- |
if (sito.length()>0) |
619 |
|
- |
sitoLocaleTextView.setVisibility(View.VISIBLE); |
620 |
|
- |
else |
621 |
|
- |
sitoLocaleTextView.setVisibility(View.GONE); |
622 |
|
- |
|
623 |
|
- |
sitoLocaleTextView.setText(sito); |
624 |
|
- |
emailLocaleTextView.setText(em); |
625 |
|
- |
numLocaleTextView.setText(resp.getString("telefono")); |
626 |
|
- |
cariLocaleTextView.setText(getString(R.string.punti_di_ricarica) + resp.getString("n_punti_ricarica")); |
627 |
|
- |
|
628 |
|
- |
|
629 |
|
- |
} catch (JSONException e) { |
630 |
|
- |
e.printStackTrace(); |
631 |
|
- |
} |
632 |
|
- |
|
633 |
|
- |
|
634 |
|
- |
} |
635 |
|
- |
}); |
636 |
|
- |
otherInfo.animate() |
637 |
|
- |
.translationY(0) |
638 |
|
- |
.alpha(0.0f) |
639 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
640 |
|
- |
@Override |
641 |
|
- |
public void onAnimationEnd(Animator animation) { |
642 |
|
- |
super.onAnimationEnd(animation); |
643 |
|
- |
otherInfo.setVisibility(View.VISIBLE); |
644 |
|
- |
otherInfo.setAlpha(1.0f); |
645 |
|
- |
} |
646 |
|
- |
}); |
647 |
|
- |
} |
648 |
|
- |
}); |
649 |
|
- |
|
650 |
|
- |
idlocale = id; |
651 |
|
- |
} |
652 |
|
- |
}); |
653 |
|
- |
}else |
654 |
|
- |
{ |
655 |
|
- |
if (firstLocal==false) |
656 |
|
- |
{ |
657 |
|
- |
runOnUiThread(new Runnable() { |
658 |
|
- |
@Override |
659 |
|
- |
public void run() { |
660 |
|
- |
animationOffEnded=false; |
661 |
|
- |
localeContainer.animate() |
662 |
|
- |
.translationY(0) |
663 |
|
- |
.alpha(0.0f) |
664 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
665 |
|
- |
@Override |
666 |
|
- |
public void onAnimationEnd(Animator animation) { |
667 |
|
- |
super.onAnimationEnd(animation); |
668 |
|
- |
localeContainer.setVisibility(View.GONE); |
669 |
|
- |
loadingAll.setVisibility(View.VISIBLE); |
670 |
|
- |
noLocalMsg.setText(R.string.caricamento_info); |
671 |
|
- |
noLocalMsg.setVisibility(View.VISIBLE); |
672 |
|
- |
animationOffEnded=true; |
673 |
|
- |
} |
674 |
|
- |
}); |
675 |
|
- |
otherInfo.animate() |
676 |
|
- |
.translationY(0) |
677 |
|
- |
.alpha(0.0f) |
678 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
679 |
|
- |
@Override |
680 |
|
- |
public void onAnimationEnd(Animator animation) { |
681 |
|
- |
super.onAnimationEnd(animation); |
682 |
|
- |
otherInfo.setVisibility(View.INVISIBLE); |
683 |
|
- |
} |
684 |
|
- |
}); |
685 |
|
- |
} |
686 |
|
- |
}); |
687 |
|
- |
}else |
688 |
|
- |
{ |
689 |
|
- |
runOnUiThread(new Runnable() { |
690 |
|
- |
@Override |
691 |
|
- |
public void run() { |
692 |
|
- |
loadingAll.setVisibility(View.VISIBLE); |
693 |
|
- |
} |
694 |
|
- |
}); |
695 |
|
- |
|
696 |
|
- |
} |
697 |
|
- |
|
698 |
|
- |
|
699 |
|
- |
JSONObject obj = new JSONObject(); |
700 |
|
- |
if (inLoading <= 0) { |
701 |
|
- |
inLoading = 0; |
702 |
|
- |
try { |
703 |
|
- |
inLoading++; |
704 |
|
- |
currentLoad = id; |
705 |
|
- |
obj.put("id", id); |
706 |
|
- |
final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_info_full_locale.php", obj); |
707 |
|
- |
|
708 |
|
- |
if (resp == null && isInFront) { |
709 |
|
- |
getInfoById(id); |
710 |
|
- |
} else { |
711 |
|
- |
|
712 |
|
- |
mapCacheInfo.put(id, resp); |
713 |
|
- |
if (firstLocal==false) |
714 |
|
- |
{ |
715 |
|
- |
while (animationOffEnded==false) |
716 |
|
- |
{ |
717 |
|
- |
try { |
718 |
|
- |
Thread.sleep(100); |
719 |
|
- |
} catch (InterruptedException e) { |
720 |
|
- |
e.printStackTrace(); |
721 |
|
- |
} |
722 |
|
- |
} |
723 |
|
- |
}else |
724 |
|
- |
{ |
725 |
|
- |
firstLocal=false; |
726 |
|
- |
} |
727 |
|
- |
|
728 |
|
- |
runOnUiThread(new Runnable() { |
729 |
|
- |
@Override |
730 |
|
- |
public void run() { |
731 |
|
- |
try { |
732 |
|
- |
|
733 |
|
- |
loadingAll.setVisibility(View.GONE); |
734 |
|
- |
noLocalMsg.setVisibility(View.GONE); |
735 |
|
- |
String[] tipi = getResources().getStringArray(R.array.type_array); |
736 |
|
- |
((TextView) findViewById(R.id.nome_locale)).setText(resp.getString("nomelocale")); |
737 |
|
- |
((TextView) findViewById(R.id.tipologia)).setText(tipi[Integer.parseInt(resp.getString("tipologia"))]); |
738 |
|
- |
((TextView) findViewById(R.id.descrizione)).setText(resp.getString("descrizione")); |
739 |
|
- |
((TextView) findViewById(R.id.via_locale)).setText(resp.getString("indirizzo")); |
740 |
|
- |
((RatingBar) findViewById(R.id.ratingBar)).setRating(resp.getLong("stelle")); |
741 |
|
- |
|
742 |
|
- |
String sito = resp.getString("sito"); |
743 |
|
- |
String em = resp.getString("email"); |
744 |
|
- |
|
745 |
|
- |
if (em.length()>0) |
746 |
|
- |
emailLocaleTextView.setVisibility(View.VISIBLE); |
747 |
|
- |
else |
748 |
|
- |
emailLocaleTextView.setVisibility(View.GONE); |
749 |
|
- |
|
750 |
|
- |
|
751 |
|
- |
if (sito.length()>0) |
752 |
|
- |
sitoLocaleTextView.setVisibility(View.VISIBLE); |
753 |
|
- |
else |
754 |
|
- |
sitoLocaleTextView.setVisibility(View.GONE); |
755 |
|
- |
|
756 |
|
- |
sitoLocaleTextView.setText(sito); |
757 |
|
- |
emailLocaleTextView.setText(em); |
758 |
|
- |
|
759 |
|
- |
|
760 |
|
- |
|
761 |
|
- |
numLocaleTextView.setText(resp.getString("telefono")); |
762 |
|
- |
cariLocaleTextView.setText(getString(R.string.punti_di_ricarica)+resp.getString("n_punti_ricarica")); |
763 |
|
- |
idlocale = id; |
764 |
|
- |
} catch (JSONException e) { |
765 |
|
- |
e.printStackTrace(); |
766 |
|
- |
} |
767 |
|
- |
} |
768 |
|
- |
}); |
769 |
|
- |
} |
770 |
|
- |
} catch (JSONException e) { |
771 |
|
- |
e.printStackTrace(); |
772 |
|
- |
} |
773 |
|
- |
catch (NullPointerException e) { |
774 |
|
- |
Utils.toast(c, R.string.internet_problem); |
775 |
|
- |
} |
776 |
|
- |
|
777 |
|
- |
|
778 |
|
- |
runOnUiThread(new Runnable() { |
779 |
|
- |
@Override |
780 |
|
- |
public void run() { |
781 |
|
- |
|
782 |
|
- |
localeContainer.animate() |
783 |
|
- |
.translationY(0) |
784 |
|
- |
.alpha(1.0f) |
785 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
786 |
|
- |
@Override |
787 |
|
- |
public void onAnimationEnd(Animator animation) { |
788 |
|
- |
super.onAnimationEnd(animation); |
789 |
|
- |
localeContainer.setVisibility(View.VISIBLE); |
790 |
|
- |
} |
791 |
|
- |
}); |
792 |
|
- |
otherInfo.animate() |
793 |
|
- |
.translationY(0) |
794 |
|
- |
.alpha(1.0f) |
795 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
796 |
|
- |
@Override |
797 |
|
- |
public void onAnimationEnd(Animator animation) { |
798 |
|
- |
super.onAnimationEnd(animation); |
799 |
|
- |
otherInfo.setVisibility(View.VISIBLE); |
800 |
|
- |
} |
801 |
|
- |
}); |
802 |
|
- |
} |
803 |
|
- |
}); |
804 |
|
- |
|
805 |
|
- |
inLoading--; |
806 |
|
- |
if (nextToLoad != -1) |
807 |
|
- |
getInfoById(nextToLoad); |
808 |
|
- |
nextToLoad = -1; |
809 |
|
- |
} else { |
810 |
|
- |
if (nextToLoad != currentLoad) |
811 |
|
- |
nextToLoad = id; |
812 |
|
- |
} |
813 |
|
- |
} |
814 |
|
- |
|
815 |
|
- |
} |
816 |
|
- |
}).start(); |
817 |
|
- |
|
818 |
|
- |
|
819 |
|
- |
|
820 |
|
- |
//getting recensione |
821 |
|
- |
|
822 |
|
- |
new Thread(new Runnable() { |
823 |
|
- |
public void run() { |
824 |
|
- |
|
825 |
|
- |
if (mapCacheRecensioni.containsKey(id)) { |
826 |
|
- |
|
827 |
|
- |
runOnUiThread(new Runnable() { |
828 |
|
- |
@Override |
829 |
|
- |
public void run() { |
830 |
|
- |
|
831 |
|
- |
try { |
832 |
|
- |
if( mapCacheRecensioni.get(id).getJSONObject("comment")!=null) |
833 |
|
- |
reviewButton.setText(R.string.modifica_recensione); |
834 |
|
- |
else |
835 |
|
- |
reviewButton.setText(R.string.scrivirecensione_btn); |
836 |
|
- |
|
837 |
|
- |
} catch (JSONException e) { |
838 |
|
- |
e.printStackTrace(); |
839 |
|
- |
reviewButton.setText(R.string.scrivirecensione_btn); |
840 |
|
- |
} |
841 |
|
- |
} |
842 |
|
- |
}); |
843 |
|
- |
} else { |
844 |
|
- |
try { |
845 |
|
- |
|
846 |
|
- |
JSONObject obj = new JSONObject(); |
847 |
|
- |
obj.put("id_local", id); |
848 |
|
- |
obj.put("id_user", PrefsManager.getId(c)); |
849 |
|
- |
|
850 |
|
- |
|
851 |
|
- |
final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT +"/get_commento.php", obj); |
852 |
|
- |
|
853 |
|
- |
if (resp.getInt("return") == 0) { |
854 |
|
- |
|
855 |
|
- |
mapCacheRecensioni.put(id, resp); |
856 |
|
- |
if (currentLoad == id) { |
857 |
|
- |
runOnUiThread(new Runnable() { |
858 |
|
- |
@Override |
859 |
|
- |
public void run() { |
860 |
|
- |
try { |
861 |
|
- |
if( mapCacheRecensioni.get(id).getJSONObject("comment")!=null) |
862 |
|
- |
reviewButton.setText(R.string.modifica_recensione); |
863 |
|
- |
else |
864 |
|
- |
reviewButton.setText(R.string.scrivirecensione_btn); |
865 |
|
- |
} catch (JSONException e) { |
866 |
|
- |
e.printStackTrace(); |
867 |
|
- |
reviewButton.setText(R.string.scrivirecensione_btn); |
868 |
|
- |
} |
869 |
|
- |
} |
870 |
|
- |
}); |
871 |
|
- |
} |
872 |
|
- |
} |
873 |
|
- |
} catch (JSONException e) { |
874 |
|
- |
e.printStackTrace(); |
875 |
|
- |
} |
876 |
|
- |
catch (NullPointerException e) { |
877 |
|
- |
Utils.toast(c,R.string.internet_problem); |
878 |
|
- |
} |
879 |
|
- |
} |
880 |
|
- |
} |
881 |
|
- |
}).start(); |
882 |
|
- |
|
883 |
|
- |
|
884 |
|
- |
|
885 |
|
- |
|
886 |
|
- |
//getting avatar image |
887 |
|
- |
new Thread(new Runnable() { |
888 |
|
- |
public void run() { |
889 |
|
- |
|
890 |
|
- |
if (mapCacheImage.containsKey(id)) { |
891 |
|
- |
|
892 |
|
- |
runOnUiThread(new Runnable() { |
893 |
|
- |
@Override |
894 |
|
- |
public void run() { |
895 |
|
- |
|
896 |
|
- |
loadingImage.setVisibility(View.GONE); |
897 |
|
- |
findViewById(R.id.profile_image).animate() |
898 |
|
- |
.translationY(0) |
899 |
|
- |
.alpha(0.0f) |
900 |
|
- |
.setListener(new AnimatorListenerAdapter() { |
901 |
|
- |
@Override |
902 |
|
- |
public void onAnimationEnd(Animator animation) { |
903 |
|
- |
super.onAnimationEnd(animation); |
904 |
|
- |
findViewById(R.id.profile_image).setVisibility(View.VISIBLE); |
905 |
|
- |
findViewById(R.id.profile_image).setAlpha(1.0f); |
906 |
|
- |
((ImageView) findViewById(R.id.profile_image)).setImageBitmap(mapCacheImage.get(id)); |
907 |
|
- |
} |
908 |
|
- |
}); |
909 |
|
- |
|
910 |
|
- |
|
911 |
|
- |
} |
912 |
|
- |
}); |
913 |
|
- |
} else { |
914 |
|
- |
|
915 |
|
- |
runOnUiThread(new Runnable() { |
916 |
|
- |
@Override |
917 |
|
- |
public void run() { |
918 |
|
- |
|
919 |
|
- |
findViewById(R.id.profile_image).setVisibility(View.INVISIBLE); |
920 |
|
- |
loadingImage.setVisibility(View.VISIBLE); |
921 |
|
- |
} |
922 |
|
- |
}); |
923 |
|
- |
|
924 |
|
- |
try { |
925 |
|
- |
|
926 |
|
- |
JSONObject obj = new JSONObject(); |
927 |
|
- |
obj.put("user_id", mapCachelocals.get(id).getInt("id_utente_owner")); |
928 |
|
- |
|
929 |
|
- |
|
930 |
|
- |
final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT +"/get_avatar.php", obj); |
931 |
|
- |
|
932 |
|
- |
if (resp.getInt("return") == 0) { |
933 |
|
- |
String filename = resp.getString("avatar"); |
934 |
|
- |
final Bitmap bitm = Utils.getBitmapFromURL(filename); |
935 |
|
- |
mapCacheImage.put(id, bitm); |
936 |
|
- |
if (currentLoad == id) { |
937 |
|
- |
runOnUiThread(new Runnable() { |
938 |
|
- |
@Override |
939 |
|
- |
public void run() { |
940 |
|
- |
findViewById(R.id.profile_image).setVisibility(View.VISIBLE); |
941 |
|
- |
loadingImage.setVisibility(View.GONE); |
942 |
|
- |
((ImageView) findViewById(R.id.profile_image)).setImageBitmap(bitm); |
943 |
|
- |
} |
944 |
|
- |
}); |
945 |
|
- |
} |
946 |
|
- |
} |
947 |
|
- |
} catch (JSONException e) { |
948 |
|
- |
e.printStackTrace(); |
949 |
|
- |
} |
950 |
|
- |
catch (NullPointerException e) { |
951 |
|
- |
Utils.toast(c, R.string.internet_problem); |
952 |
|
- |
} |
953 |
|
- |
} |
954 |
|
- |
} |
955 |
|
- |
}).start(); |
|
578 |
+ |
if ( Utils.isNetworkConnected(c)) { |
|
579 |
+ |
new Thread(new Runnable() { |
|
580 |
+ |
public void run() { |
|
581 |
+ |
|
|
582 |
+ |
if (mapCacheInfo.containsKey(id)) { |
|
583 |
+ |
runOnUiThread(new Runnable() { |
|
584 |
+ |
@Override |
|
585 |
+ |
public void run() { |
|
586 |
+ |
final JSONObject resp = mapCacheInfo.get(id); |
|
587 |
+ |
final String[] tipi = getResources().getStringArray(R.array.type_array); |
|
588 |
+ |
runOnUiThread(new Runnable() { |
|
589 |
+ |
@Override |
|
590 |
+ |
public void run() { |
|
591 |
+ |
|
|
592 |
+ |
localeContainer.animate() |
|
593 |
+ |
.translationY(0) |
|
594 |
+ |
.alpha(0.0f) |
|
595 |
+ |
.setListener(new AnimatorListenerAdapter() { |
|
596 |
+ |
@Override |
|
597 |
+ |
public void onAnimationEnd(Animator animation) { |
|
598 |
+ |
super.onAnimationEnd(animation); |
|
599 |
+ |
localeContainer.setVisibility(View.VISIBLE); |
|
600 |
+ |
localeContainer.setAlpha(1.0f); |
|
601 |
+ |
try { |
|
602 |
+ |
((TextView) findViewById(R.id.nome_locale)).setText(resp.getString("nomelocale")); |
|
603 |
+ |
((TextView) findViewById(R.id.tipologia)).setText(tipi[Integer.parseInt(resp.getString("tipologia"))]); |
|
604 |
+ |
((TextView) findViewById(R.id.descrizione)).setText(resp.getString("descrizione")); |
|
605 |
+ |
((TextView) findViewById(R.id.via_locale)).setText(resp.getString("indirizzo")); |
|
606 |
+ |
((RatingBar) findViewById(R.id.ratingBar)).setRating(resp.getLong("stelle")); |
|
607 |
+ |
|
|
608 |
+ |
|
|
609 |
+ |
String sito = resp.getString("sito"); |
|
610 |
+ |
String em = resp.getString("email"); |
|
611 |
+ |
|
|
612 |
+ |
if (em.length()>0) |
|
613 |
+ |
emailLocaleTextView.setVisibility(View.VISIBLE); |
|
614 |
+ |
else |
|
615 |
+ |
emailLocaleTextView.setVisibility(View.GONE); |
|
616 |
+ |
|
|
617 |
+ |
|
|
618 |
+ |
if (sito.length()>0) |
|
619 |
+ |
sitoLocaleTextView.setVisibility(View.VISIBLE); |
|
620 |
+ |
else |
|
621 |
+ |
sitoLocaleTextView.setVisibility(View.GONE); |
|
622 |
+ |
|
|
623 |
+ |
sitoLocaleTextView.setText(sito); |
|
624 |
+ |
emailLocaleTextView.setText(em); |
|
625 |
+ |
numLocaleTextView.setText(resp.getString("telefono")); |
|
626 |
+ |
cariLocaleTextView.setText(getString(R.string.punti_di_ricarica) + resp.getString("n_punti_ricarica")); |
|
627 |
+ |
|
|
628 |
+ |
|
|
629 |
+ |
} catch (JSONException e) { |
|
630 |
+ |
e.printStackTrace(); |
|
631 |
+ |
} |
|
632 |
+ |
|
|
633 |
+ |
|
|
634 |
+ |
} |
|
635 |
+ |
}); |
|
636 |
+ |
otherInfo.animate() |
|
637 |
+ |
.translationY(0) |
|
638 |
+ |
.alpha(0.0f) |
|
639 |
+ |
.setListener(new AnimatorListenerAdapter() { |
|
640 |
+ |
@Override |
|
641 |
+ |
public void onAnimationEnd(Animator animation) { |
|
642 |
+ |
super.onAnimationEnd(animation); |
|
643 |
+ |
otherInfo.setVisibility(View.VISIBLE); |
|
644 |
+ |
otherInfo.setAlpha(1.0f); |
|
645 |
+ |
} |
|
646 |
+ |
}); |
|
647 |
+ |
} |
|
648 |
+ |
}); |
|
649 |
+ |
|
|
650 |
+ |
idlocale = id; |
|
651 |
+ |
} |
|
652 |
+ |
}); |
|
653 |
+ |
}else |
|
654 |
+ |
{ |
|
655 |
+ |
if (firstLocal==false) |
|
656 |
+ |
{ |
|
657 |
+ |
runOnUiThread(new Runnable() { |
|
658 |
+ |
@Override |
|
659 |
+ |
public void run() { |
|
660 |
+ |
animationOffEnded=false; |
|
661 |
+ |
localeContainer.animate() |
|
662 |
+ |
.translationY(0) |
|
663 |
+ |
.alpha(0.0f) |
|
664 |
+ |
.setListener(new AnimatorListenerAdapter() { |
|
665 |
+ |
@Override |
|
666 |
+ |
public void onAnimationEnd(Animator animation) { |
|
667 |
+ |
super.onAnimationEnd(animation); |
|
668 |
+ |
localeContainer.setVisibility(View.GONE); |
|
669 |
+ |
loadingAll.setVisibility(View.VISIBLE); |
|
670 |
+ |
noLocalMsg.setText(R.string.caricamento_info); |
|
671 |
+ |
noLocalMsg.setVisibility(View.VISIBLE); |
|
672 |
+ |
animationOffEnded=true; |
|
673 |
+ |
} |
|
674 |
+ |
}); |
|
675 |
+ |
otherInfo.animate() |
|
676 |
+ |
.translationY(0) |
|
677 |
+ |
.alpha(0.0f) |
|
678 |
+ |
.setListener(new AnimatorListenerAdapter() { |
|
679 |
+ |
@Override |
|
680 |
+ |
public void onAnimationEnd(Animator animation) { |
|
681 |
+ |
super.onAnimationEnd(animation); |
|
682 |
+ |
otherInfo.setVisibility(View.INVISIBLE); |
|
683 |
+ |
} |
|
684 |
+ |
}); |
|
685 |
+ |
} |
|
686 |
+ |
}); |
|
687 |
+ |
}else |
|
688 |
+ |
{ |
|
689 |
+ |
runOnUiThread(new Runnable() { |
|
690 |
+ |
@Override |
|
691 |
+ |
public void run() { |
|
692 |
+ |
loadingAll.setVisibility(View.VISIBLE); |
|
693 |
+ |
} |
|
694 |
+ |
}); |
|
695 |
+ |
|
|
696 |
+ |
} |
|
697 |
+ |
|
|
698 |
+ |
|
|
699 |
+ |
JSONObject obj = new JSONObject(); |
|
700 |
+ |
if (inLoading <= 0) { |
|
701 |
+ |
inLoading = 0; |
|
702 |
+ |
try { |
|
703 |
+ |
inLoading++; |
|
704 |
+ |
currentLoad = id; |
|
705 |
+ |
obj.put("id", id); |
|
706 |
+ |
final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_info_full_locale.php", obj); |
|
707 |
+ |
|
|
708 |
+ |
if (resp == null && isInFront) { |
|
709 |
+ |
getInfoById(id); |
|
710 |
+ |
} else { |
|
711 |
+ |
|
|
712 |
+ |
mapCacheInfo.put(id, resp); |
|
713 |
+ |
if (firstLocal==false) |
|
714 |
+ |
{ |
|
715 |
+ |
while (animationOffEnded==false) |
|
716 |
+ |
{ |
|
717 |
+ |
try { |
|
718 |
+ |
Thread.sleep(100); |
|
719 |
+ |
} catch (InterruptedException e) { |
|
720 |
+ |
e.printStackTrace(); |
|
721 |
+ |
} |
|
722 |
+ |
} |
|
723 |
+ |
}else |
|
724 |
+ |
{ |
|
725 |
+ |
firstLocal=false; |
|
726 |
+ |
} |
|
727 |
+ |
|
|
728 |
+ |
runOnUiThread(new Runnable() { |
|
729 |
+ |
@Override |
|
730 |
+ |
public void run() { |
|
731 |
+ |
try { |
|
732 |
+ |
|
|
733 |
+ |
loadingAll.setVisibility(View.GONE); |
|
734 |
+ |
noLocalMsg.setVisibility(View.GONE); |
|
735 |
+ |
String[] tipi = getResources().getStringArray(R.array.type_array); |
|
736 |
+ |
((TextView) findViewById(R.id.nome_locale)).setText(resp.getString("nomelocale")); |
|
737 |
+ |
((TextView) findViewById(R.id.tipologia)).setText(tipi[Integer.parseInt(resp.getString("tipologia"))]); |
|
738 |
+ |
((TextView) findViewById(R.id.descrizione)).setText(resp.getString("descrizione")); |
|
739 |
+ |
((TextView) findViewById(R.id.via_locale)).setText(resp.getString("indirizzo")); |
|
740 |
+ |
((RatingBar) findViewById(R.id.ratingBar)).setRating(resp.getLong("stelle")); |
|
741 |
+ |
|
|
742 |
+ |
String sito = resp.getString("sito"); |
|
743 |
+ |
String em = resp.getString("email"); |
|
744 |
+ |
|
|
745 |
+ |
if (em.length()>0) |
|
746 |
+ |
emailLocaleTextView.setVisibility(View.VISIBLE); |
|
747 |
+ |
else |
|
748 |
+ |
emailLocaleTextView.setVisibility(View.GONE); |
|
749 |
+ |
|
|
750 |
+ |
|
|
751 |
+ |
if (sito.length()>0) |
|
752 |
+ |
sitoLocaleTextView.setVisibility(View.VISIBLE); |
|
753 |
+ |
else |
|
754 |
+ |
sitoLocaleTextView.setVisibility(View.GONE); |
|
755 |
+ |
|
|
756 |
+ |
sitoLocaleTextView.setText(sito); |
|
757 |
+ |
emailLocaleTextView.setText(em); |
|
758 |
+ |
|
|
759 |
+ |
|
|
760 |
+ |
|
|
761 |
+ |
numLocaleTextView.setText(resp.getString("telefono")); |
|
762 |
+ |
cariLocaleTextView.setText(getString(R.string.punti_di_ricarica)+resp.getString("n_punti_ricarica")); |
|
763 |
+ |
idlocale = id; |
|
764 |
+ |
} catch (JSONException e) { |
|
765 |
+ |
e.printStackTrace(); |
|
766 |
+ |
} |
|
767 |
+ |
} |
|
768 |
+ |
}); |
|
769 |
+ |
} |
|
770 |
+ |
} catch (JSONException e) { |
|
771 |
+ |
e.printStackTrace(); |
|
772 |
+ |
} |
|
773 |
+ |
catch (NullPointerException e) { |
|
774 |
+ |
Utils.toast(c, R.string.internet_problem); |
|
775 |
+ |
} |
|
776 |
+ |
|
|
777 |
+ |
|
|
778 |
+ |
runOnUiThread(new Runnable() { |
|
779 |
+ |
@Override |
|
780 |
+ |
public void run() { |
|
781 |
+ |
|
|
782 |
+ |
localeContainer.animate() |
|
783 |
+ |
.translationY(0) |
|
784 |
+ |
.alpha(1.0f) |
|
785 |
+ |
.setListener(new AnimatorListenerAdapter() { |
|
786 |
+ |
@Override |
|
787 |
+ |
public void onAnimationEnd(Animator animation) { |
|
788 |
+ |
super.onAnimationEnd(animation); |
|
789 |
+ |
localeContainer.setVisibility(View.VISIBLE); |
|
790 |
+ |
} |
|
791 |
+ |
}); |
|
792 |
+ |
otherInfo.animate() |
|
793 |
+ |
.translationY(0) |
|
794 |
+ |
.alpha(1.0f) |
|
795 |
+ |
.setListener(new AnimatorListenerAdapter() { |
|
796 |
+ |
@Override |
|
797 |
+ |
public void onAnimationEnd(Animator animation) { |
|
798 |
+ |
super.onAnimationEnd(animation); |
|
799 |
+ |
otherInfo.setVisibility(View.VISIBLE); |
|
800 |
+ |
} |
|
801 |
+ |
}); |
|
802 |
+ |
} |
|
803 |
+ |
}); |
|
804 |
+ |
|
|
805 |
+ |
inLoading--; |
|
806 |
+ |
if (nextToLoad != -1) |
|
807 |
+ |
getInfoById(nextToLoad); |
|
808 |
+ |
nextToLoad = -1; |
|
809 |
+ |
} else { |
|
810 |
+ |
if (nextToLoad != currentLoad) |
|
811 |
+ |
nextToLoad = id; |
|
812 |
+ |
} |
|
813 |
+ |
} |
|
814 |
+ |
|
|
815 |
+ |
} |
|
816 |
+ |
}).start(); |
|
817 |
+ |
|
|
818 |
+ |
|
|
819 |
+ |
|
|
820 |
+ |
//getting recensione |
|
821 |
+ |
|
|
822 |
+ |
new Thread(new Runnable() { |
|
823 |
+ |
public void run() { |
|
824 |
+ |
|
|
825 |
+ |
if (mapCacheRecensioni.containsKey(id)) { |
|
826 |
+ |
|
|
827 |
+ |
runOnUiThread(new Runnable() { |
|
828 |
+ |
@Override |
|
829 |
+ |
public void run() { |
|
830 |
+ |
|
|
831 |
+ |
try { |
|
832 |
+ |
if( mapCacheRecensioni.get(id).getJSONObject("comment")!=null) |
|
833 |
+ |
reviewButton.setText(R.string.modifica_recensione); |
|
834 |
+ |
else |
|
835 |
+ |
reviewButton.setText(R.string.scrivirecensione_btn); |
|
836 |
+ |
|
|
837 |
+ |
} catch (JSONException e) { |
|
838 |
+ |
e.printStackTrace(); |
|
839 |
+ |
reviewButton.setText(R.string.scrivirecensione_btn); |
|
840 |
+ |
} |
|
841 |
+ |
} |
|
842 |
+ |
}); |
|
843 |
+ |
} else { |
|
844 |
+ |
try { |
|
845 |
+ |
|
|
846 |
+ |
JSONObject obj = new JSONObject(); |
|
847 |
+ |
obj.put("id_local", id); |
|
848 |
+ |
obj.put("id_user", PrefsManager.getId(c)); |
|
849 |
+ |
|
|
850 |
+ |
|
|
851 |
+ |
final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT +"/get_commento.php", obj); |
|
852 |
+ |
|
|
853 |
+ |
if (resp.getInt("return") == 0) { |
|
854 |
+ |
|
|
855 |
+ |
mapCacheRecensioni.put(id, resp); |
|
856 |
+ |
if (currentLoad == id) { |
|
857 |
+ |
runOnUiThread(new Runnable() { |
|
858 |
+ |
@Override |
|
859 |
+ |
public void run() { |
|
860 |
+ |
try { |
|
861 |
+ |
if( mapCacheRecensioni.get(id).getJSONObject("comment")!=null) |
|
862 |
+ |
reviewButton.setText(R.string.modifica_recensione); |
|
863 |
+ |
else |
|
864 |
+ |
reviewButton.setText(R.string.scrivirecensione_btn); |
|
865 |
+ |
} catch (JSONException e) { |
|
866 |
+ |
e.printStackTrace(); |
|
867 |
+ |
reviewButton.setText(R.string.scrivirecensione_btn); |
|
868 |
+ |
} |
|
869 |
+ |
} |
|
870 |
+ |
}); |
|
871 |
+ |
} |
|
872 |
+ |
} |
|
873 |
+ |
} catch (JSONException e) { |
|
874 |
+ |
e.printStackTrace(); |
|
875 |
+ |
} |
|
876 |
+ |
catch (NullPointerException e) { |
|
877 |
+ |
Utils.toast(c,R.string.internet_problem); |
|
878 |
+ |
} |
|
879 |
+ |
} |
|
880 |
+ |
} |
|
881 |
+ |
}).start(); |
|
882 |
+ |
|
956 |
883 |
|
|
957 |
|
- |
} |
|
884 |
+ |
|
|
885 |
+ |
|
|
886 |
+ |
//getting avatar image |
|
887 |
+ |
new Thread(new Runnable() { |
|
888 |
+ |
public void run() { |
|
889 |
+ |
|
|
890 |
+ |
// if (mapCacheImage.containsKey(id)) { |
|
891 |
+ |
// |
|
892 |
+ |
// runOnUiThread(new Runnable() { |
|
893 |
+ |
// @Override |
|
894 |
+ |
// public void run() { |
|
895 |
+ |
// |
|
896 |
+ |
// loadingImage.setVisibility(View.GONE); |
|
897 |
+ |
// findViewById(R.id.profile_image).animate() |
|
898 |
+ |
// .translationY(0) |
|
899 |
+ |
// .alpha(0.0f) |
|
900 |
+ |
// .setListener(new AnimatorListenerAdapter() { |
|
901 |
+ |
// @Override |
|
902 |
+ |
// public void onAnimationEnd(Animator animation) { |
|
903 |
+ |
// super.onAnimationEnd(animation); |
|
904 |
+ |
// findViewById(R.id.profile_image).setVisibility(View.VISIBLE); |
|
905 |
+ |
// findViewById(R.id.profile_image).setAlpha(1.0f); |
|
906 |
+ |
// ((ImageView) findViewById(R.id.profile_image)).setImageBitmap(mapCacheImage.get(id)); |
|
907 |
+ |
// } |
|
908 |
+ |
// }); |
|
909 |
+ |
// |
|
910 |
+ |
// |
|
911 |
+ |
// } |
|
912 |
+ |
// }); |
|
913 |
+ |
// } else { |
|
914 |
+ |
|
|
915 |
+ |
runOnUiThread(new Runnable() { |
|
916 |
+ |
@Override |
|
917 |
+ |
public void run() { |
|
918 |
+ |
|
|
919 |
+ |
findViewById(R.id.profile_image).setVisibility(View.INVISIBLE); |
|
920 |
+ |
loadingImage.setVisibility(View.VISIBLE); |
|
921 |
+ |
} |
|
922 |
+ |
}); |
|
923 |
+ |
JSONObject obj = new JSONObject(); |
|
924 |
+ |
try { |
|
925 |
+ |
obj.put("id", id); |
|
926 |
+ |
final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_immagini.php", obj); |
|
927 |
+ |
final JSONArray jArray = resp.getJSONArray("imgs"); |
|
928 |
+ |
if(jArray.length()>0){ |
|
929 |
+ |
final String filename = (String) jArray.get(0); |
|
930 |
+ |
final Bitmap imgweb = Utils.getBitmapFromURL(filename); |
|
931 |
+ |
runOnUiThread(new Runnable() { |
|
932 |
+ |
@Override |
|
933 |
+ |
public void run() { |
|
934 |
+ |
findViewById(R.id.profile_image).setVisibility(View.VISIBLE); |
|
935 |
+ |
loadingImage.setVisibility(View.GONE); |
|
936 |
+ |
((ImageView) findViewById(R.id.profile_image)).setImageBitmap(imgweb); |
|
937 |
+ |
} |
|
938 |
+ |
}); |
|
939 |
+ |
} else { |
|
940 |
+ |
runOnUiThread(new Runnable() { |
|
941 |
+ |
@Override |
|
942 |
+ |
public void run() { |
|
943 |
+ |
findViewById(R.id.profile_image).setVisibility(View.VISIBLE); |
|
944 |
+ |
loadingImage.setVisibility(View.GONE); |
|
945 |
+ |
((ImageView) findViewById(R.id.profile_image)).setImageResource(R.drawable.placeholder); |
|
946 |
+ |
} |
|
947 |
+ |
}); |
|
948 |
+ |
} |
|
949 |
+ |
|
|
950 |
+ |
|
|
951 |
+ |
// JSONObject obj = new JSONObject(); |
|
952 |
+ |
// obj.put("user_id", mapCachelocals.get(id).getInt("id_utente_owner")); |
|
953 |
+ |
|
|
954 |
+ |
|
|
955 |
+ |
// final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_avatar.php", obj); |
|
956 |
+ |
// |
|
957 |
+ |
// if (resp.getInt("return") == 0) { |
|
958 |
+ |
// String filename = resp.getString("avatar"); |
|
959 |
+ |
// final Bitmap bitm = Utils.getBitmapFromURL(filename); |
|
960 |
+ |
// mapCacheImage.put(id, bitm); |
|
961 |
+ |
// if (currentLoad == id) { |
|
962 |
+ |
// runOnUiThread(new Runnable() { |
|
963 |
+ |
// @Override |
|
964 |
+ |
// public void run() { |
|
965 |
+ |
// findViewById(R.id.profile_image).setVisibility(View.VISIBLE); |
|
966 |
+ |
// loadingImage.setVisibility(View.GONE); |
|
967 |
+ |
// ((ImageView) findViewById(R.id.profile_image)).setImageBitmap(bitm); |
|
968 |
+ |
// } |
|
969 |
+ |
// }); |
|
970 |
+ |
// } |
|
971 |
+ |
// } |
|
972 |
+ |
} catch (JSONException e) { |
|
973 |
+ |
e.printStackTrace(); |
|
974 |
+ |
} catch (NullPointerException e) { |
|
975 |
+ |
Utils.toast(c, R.string.internet_problem); |
|
976 |
+ |
} |
|
977 |
+ |
// } |
|
978 |
+ |
} |
|
979 |
+ |
}).start(); |
|
980 |
+ |
|
|
981 |
+ |
} |
958 |
982 |
|
//getting info of local |
959 |
983 |
|
|
960 |
984 |
|
} |
|
@@ -1079,7 +1103,7 @@ |
1079 |
1103 |
|
i.putExtra("tipologia", ((TextView) findViewById(R.id.tipologia)).getText().toString()); |
1080 |
1104 |
|
i.putExtra("idlocale", idlocale); |
1081 |
1105 |
|
i.putExtra("json", mapCacheRecensioni.get(idlocale).toString()); |
1082 |
|
- |
// mapCacheRecensioni.remove(idlocale); |
|
1106 |
+ |
// mapCacheRecensioni.remove(idlocale); |
1083 |
1107 |
|
startActivity(i); |
1084 |
1108 |
|
} |
1085 |
1109 |
|
|