Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
package it.fedeloper.smartcharging.Controller;


import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.ScrollView;
import android.widget.TextView;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import it.fedeloper.smartcharging.*;
import it.fedeloper.smartcharging.Manager.MyLocation;
import it.fedeloper.smartcharging.Manager.Utils;
import it.fedeloper.smartcharging.Service.EndPoint;
import it.fedeloper.smartcharging.Service.HttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;

public class MapActivity extends FragmentActivity {
    private static final long MIN_TIME = 400;
    private static final float MIN_DISTANCE = 1000;
    public static HashMap<Integer, Bitmap> mapCacheImage = new HashMap<Integer, Bitmap>();
    public static int listLoading = 0;
    static Context c;
    static Activity a;
    static ViewGroup.LayoutParams old;
    public int inLoading = 0;
    public int nextToLoad = -1;
    public int currentLoad = -1;
    public Boolean toReDone = false;
    public Marker nearest = null;
    HashMap<Marker, JSONObject> ms = new HashMap<>();
    HashMap<Integer, JSONObject> mapCacheInfo = new HashMap<Integer, JSONObject>();
    HashMap<Integer, Fragment> mapCacheFragment = new HashMap<Integer, Fragment>();
    Geocoder geoCoder;
    private GoogleMap map;
    private LocationManager locationManager;
    private Double lat;
    private Double lon;
    private TextView txt;
    private LatLng mylocation;
    private Paint paint = new Paint();
    private Rect bounds = new Rect();
    private int idlocale = -1;
    private Fragment full;
    private int typelocale = -1;
    private boolean isInFront;
    private LinearLayout localeContainer;

    @Override
    public void onResume() {
        super.onResume();
        isInFront = true;
    }

    @Override
    public void onPause() {
        super.onPause();
        isInFront = false;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        localeContainer = (LinearLayout) findViewById(R.id.locale_container);
        localeContainer.setVisibility(View.GONE);

        findViewById(R.id.smallinfo).setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, getWindowManager().getDefaultDisplay().getHeight() - 100));
        findViewById(R.id.map).setLayoutParams(new android.widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (getWindowManager().getDefaultDisplay().getHeight() - 100 - findViewById(R.id.button12).getHeight()) / 2));

        final EditText addressView = (EditText) findViewById(R.id.editText6);
        addressView.setImeOptions(EditorInfo.IME_ACTION_DONE);
        addressView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                String input;
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    new Thread(new Runnable() {
                        public void run() {
                            JSONObject obj = new JSONObject();
                            try {

                                try {
                                    URL url = new URL("http://maps.googleapis.com/maps/api/geocode/json?address=" + addressView.getText().toString() + "&sensor=true");
                                    String nullFragment = null;
                                    URI uri = new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), nullFragment);
                                    System.out.println("URI " + uri.toString() + " is OK");


                                    JSONObject resp = HttpClient.SendHttpPostAsync(uri.toString(), obj);

                                    Log.e("0", resp.getJSONArray("results").getJSONObject(0).toString());
                                    Log.e("0", resp.getJSONArray("results").getJSONObject(0).getJSONObject("geometry").toString());
                                    Log.e("0", resp.getJSONArray("results").getJSONObject(0).getJSONObject("geometry").getJSONObject("location").toString());

                                    JSONObject o = resp.getJSONArray("results").getJSONObject(0).getJSONObject("geometry").getJSONObject("location");
                                    Double lat = o.getDouble("lat");
                                    Double lng = o.getDouble("lng");

                                    final LatLng latLng = new LatLng(lat, lng);
                                    if (latLng != null) {

                                        final CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 13);
                                        runOnUiThread(new Runnable() {
                                            public void run() {
                                                map.animateCamera(cameraUpdate);
                                                map.addMarker(new MarkerOptions().title("me").position(latLng));
                                            }
                                        });


                                        mylocation = latLng;


                                        putLocalsOnMap();
                                        runOnUiThread(new Runnable() {
                                            public void run() {
                                                map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

                                                    @Override
                                                    public boolean onMarkerClick(Marker arg0) {
                                                        markerClick(arg0);
                                                        return true;
                                                    }

                                                });
                                            }
                                        });


                                    } else {
                                        AlertDialog.Builder adb = new AlertDialog.Builder(c);
                                        adb.setTitle("Google Map");
                                        adb.setMessage("Inserisci un indirizzo corretto");
                                        adb.setPositiveButton("chiudi", null);
                                        adb.show();
                                    }

                                } catch (MalformedURLException e) {
                                    System.out.println("URL " + txt.getText().toString() + " is a malformed URL");
                                } catch (URISyntaxException e) {
                                    System.out.println("URI " + txt.getText().toString() + " is a malformed URL");
                                }


                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }
                    }).start();


                    return true;
                }
                return false;
            }
        });


        Bundle b = new Bundle();
        b = getIntent().getExtras();
        if (b.getBoolean("fast") == false) {
            typelocale = b.getInt("tipologia");
        }

        geoCoder = new Geocoder(this);
        a = this;
        txt = ((TextView) findViewById(R.id.editText9));
        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        final ScrollView scroll = (ScrollView) findViewById(R.id.scrollView);
        ((ScrollMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).setListener(new ScrollMapFragment.OnTouchListener() {
            @Override
            public void onTouch() {
                scroll.requestDisallowInterceptTouchEvent(true);
            }
        });
        c = getApplicationContext();
        MyLocation.LocationResult locationResult = new MyLocation.LocationResult() {
            @Override
            public void gotLocation(Location location) {
                Log.e("sdsdsdsdsdsds", "update");
                if(location==null)
                    return;

                final LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

                lat = location.getLatitude();
                lon = location.getLongitude();
                final CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 13);
                runOnUiThread(new Runnable() {
                    public void run() {
                        map.animateCamera(cameraUpdate);
                        map.addMarker(new MarkerOptions().title("me").position(latLng));
                    }
                });

                mylocation = latLng;

                putLocalsOnMap();
                runOnUiThread(new Runnable() {
                    public void run() {
                        map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

                            @Override
                            public boolean onMarkerClick(Marker arg0) {
                                markerClick(arg0);
                                return true;
                            }

                        });
                    }
                });

            }
        };

        MyLocation.getLocation(this, locationResult);
        Log.e("sdsdsdsdsdsds", "end");
    }

    public static void expand(final LinearLayout v) {

        v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);


        final int targetHeight = v.getMeasuredHeight() + a.findViewById(R.id.map).getHeight() - 88;

        a.findViewById(R.id.map).setLayoutParams(new android.widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, a.findViewById(R.id.map).getHeight()));

        v.setVisibility(View.VISIBLE);
        Animation a = new Animation() {
            float h = 0;

            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                if (h == 0) {
                    h = v.getLayoutParams().height;
                }
                float sottrae = (h - targetHeight) * interpolatedTime;
                v.getLayoutParams().height = (int) (h - sottrae);
                if (interpolatedTime == 1f) {
                    v.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
                }
                v.requestLayout();
                Log.e("h", String.valueOf(v.getHeight()));
            }

            @Override
            public boolean willChangeBounds() {
                return true;
            }
        };

        // 1dp/ms
        a.setDuration((int) ((v.getLayoutParams().height - targetHeight) / v.getContext().getResources().getDisplayMetrics().density) * 4);
        v.startAnimation(a);
    }

    public static void collapse(final View v) {


        final int targetHeight = a.getWindowManager().getDefaultDisplay().getHeight() - 100;
        final int h = v.getHeight();
        final float coef = targetHeight - h;

        v.setVisibility(View.VISIBLE);
        Animation a1 = new Animation() {

            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {

                v.getLayoutParams().height = (int) (h + (coef * interpolatedTime));
                if (interpolatedTime == 1f) {
                    v.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, a.getWindowManager().getDefaultDisplay().getHeight() - 100));
                }
                v.requestLayout();

            }

            @Override
            public boolean willChangeBounds() {
                return true;
            }
        };

        // 1dp/ms
        a1.setDuration((int) ((targetHeight - h) / v.getContext().getResources().getDisplayMetrics().density) * 4);
        v.startAnimation(a1);
    }

    public static float distFrom(double lat1, double lng1, double lat2, double lng2) {
        double earthRadius = 3958.75;
        double dLat = Math.toRadians(lat2 - lat1);
        double dLng = Math.toRadians(lng2 - lng1);
        double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
                Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
                        Math.sin(dLng / 2) * Math.sin(dLng / 2);
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        double dist = earthRadius * c;

        int meterConversion = 1609;

        return new Float(dist * meterConversion).floatValue();
    }

    private void putLocalsOnMap() {
        new Thread(new Runnable() {

            public void run() {

                JSONObject obj = new JSONObject();
                try {

                    obj.put("tipologia", typelocale);
                    obj.put("lat", lat);
                    obj.put("lon", lon);
                    obj.put("distance", 1000000);

                    JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_list_locali.php", obj);

                    JSONArray arr = resp.getJSONArray("locals");


                    for (int i = 0; i < arr.length(); i++) {

                        JSONObject jdata = arr.getJSONObject(i);
                        LatLng latLng = new LatLng(jdata.getDouble("lat"), jdata.getDouble("lon"));

                        String nome = jdata.getString("nomelocale");
                        addMarkerAsync(latLng, nome, jdata);

                    }
                    Thread.sleep(100);

                    if (arr.length() > 0) {
                        boolean a = false;
                        while (a == false) {
                            try {
                                Log.e("qua ci sto", "-1");
                                markerClick(nearest);
                                a = true;
                            } catch (Exception e) {
                                Log.e("erroreeeee", nearest.toString());

                            }
                        }
                    } else {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                AlertDialog.Builder dlgAlert = new AlertDialog.Builder(MapActivity.this);
                                dlgAlert.setMessage(R.string.no_locals);
                                dlgAlert.setTitle(getString(R.string.errore_msg));
                                dlgAlert.setPositiveButton("OK", null);
                                dlgAlert.setCancelable(true);
                                dlgAlert.setPositiveButton("Ok",
                                        new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog, int which) {
                                                finish();
                                            }
                                        });
                                dlgAlert.create().show();
                            }
                        });
                    }


                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (NullPointerException e) {
                    if (isInFront)
                        putLocalsOnMap();
                }

            }


        }).start();
    }

    private void getInfoById(final int id) {
        if (id != idlocale) {

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ((ImageView) findViewById(R.id.imageView4)).setVisibility(View.INVISIBLE);
                }
            });


        }
        if (full != null && id != idlocale) {
            try {
                collapse((LinearLayout) findViewById(R.id.smallinfo));
            } catch (Exception e) {
                Log.e("dghdsfksgfg", e.getMessage());
            }

            a.findViewById(R.id.button11).setVisibility(View.VISIBLE);
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

            fragmentTransaction.remove(full);
            fragmentTransaction.commit();
        }
        if (mapCacheInfo.containsKey(id)) {

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        JSONObject resp = mapCacheInfo.get(id);
                        String[] tipi = getResources().getStringArray(R.array.type_array);

                        ((TextView) findViewById(R.id.textView12)).setText(tipi[Integer.parseInt(resp.getString("tipologia"))]);
                        ((TextView) findViewById(R.id.textView13)).setText(resp.getString("descrizione"));
                        ((TextView) findViewById(R.id.textView22)).setText(resp.getString("indirizzo"));
                        ((RatingBar) findViewById(R.id.ratingBar)).setRating(resp.getLong("stelle"));

                        idlocale = id;


                    } catch (JSONException e) {
                        e.printStackTrace();
                    }


                }
            });
        } else {

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ((TextView) findViewById(R.id.textView12)).setText("-");
                    ((TextView) findViewById(R.id.textView13)).setText("-");
                    ((TextView) findViewById(R.id.textView22)).setText("-");
                    ((RatingBar) findViewById(R.id.ratingBar)).setRating(5);
                }
            });
            //getting info of local
            new Thread(new Runnable() {
                public void run() {
                    JSONObject obj = new JSONObject();
                    if (inLoading <= 0) {
                        inLoading = 0;


                        try {
                            inLoading++;
                            currentLoad = id;
                            obj.put("id", id);


                            final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_info_small_locale.php", obj);

                            if (resp == null) {

                                if (isInFront) {
                                    getInfoById(id);
                                }
                            } else {

                                mapCacheInfo.put(id, resp);
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {

                                            String[] tipi = getResources().getStringArray(R.array.type_array);

                                            ((TextView) findViewById(R.id.textView12)).setText(tipi[Integer.parseInt(resp.getString("tipologia"))]);
                                            ((TextView) findViewById(R.id.textView13)).setText(resp.getString("descrizione"));
                                            ((TextView) findViewById(R.id.textView22)).setText(resp.getString("indirizzo"));
                                            ((RatingBar) findViewById(R.id.ratingBar)).setRating(resp.getLong("stelle"));

                                            idlocale = id;


                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }


                                    }
                                });
                            }


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        inLoading--;
                        if (nextToLoad != -1)
                            getInfoById(nextToLoad);
                        nextToLoad = -1;
                    } else {
                        if (nextToLoad != currentLoad)
                            nextToLoad = id;
                    }

                }
            }).start();

        }

        //getting avatar image

        new Thread(new Runnable() {
            public void run() {

                if (mapCacheImage.containsKey(id)) {

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            ((ImageView) findViewById(R.id.imageView4)).setVisibility(View.VISIBLE);

                            ((ImageView) findViewById(R.id.imageView4)).setImageBitmap(mapCacheImage.get(id));
                        }
                    });


                } else {

                    try {

                        JSONObject obj = new JSONObject();
                        obj.put("user_id", id);


                        final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT +"/get_avatar.php", obj);

                        if (resp.getInt("return") == 0) {
                            String filename = resp.getString("avatar");
                            Log.e("imgeeeeee","http://svm19842.vps.tagadab.it:8084" + filename);
                            final Bitmap bitm = Utils.getBitmapFromURL("http://svm19842.vps.tagadab.it:8084" + filename);
                            mapCacheImage.put(id, bitm);
                            if (currentLoad == id) {
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        ((ImageView) findViewById(R.id.imageView4)).setVisibility(View.VISIBLE);

                                        ((ImageView) findViewById(R.id.imageView4)).setImageBitmap(bitm);
                                    }
                                });

                            }
                        }


                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }


            }
        }).start();


    }

    public void markerClick(final Marker arg0) {

        final JSONObject j = ms.get(arg0);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {

                ((TextView) findViewById(R.id.textView11)).setText(arg0.getTitle());


            }
        });
        try {

            getInfoById(j.getInt("id"));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private BitmapDescriptor GetCustomBitmapDescriptor(String text) {
        Bitmap baseBitmap = BitmapFactory.decodeResource(c.getResources(), R.drawable.base);
        Bitmap bitmap = baseBitmap.copy(Bitmap.Config.ARGB_8888, true);
        paint.setAntiAlias(true);

        paint.getTextBounds(text, 0, text.length(), bounds);

        float x = bitmap.getWidth() / 2.0f;
        float y = (bitmap.getHeight() - bounds.height()) / 2.0f - bounds.top;

        Canvas canvas = new Canvas(bitmap);

        canvas.drawText(text, x, y, paint);

        BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bitmap);

        return (icon);
    }

    public void addMarkerAsync(LatLng l, String n, JSONObject j) {


        Runnable addMarker = new AddMarker(map, new MarkerOptions()
                .position(l)
                .title(n)
                .icon(GetCustomBitmapDescriptor(n)), j);
        a.runOnUiThread(addMarker);

    }

    public void clickshow(View v) {
        if (mapCacheFragment.containsKey(idlocale) && mapCacheFragment.get(idlocale) != full) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

            fragmentTransaction.add(R.id.fullInfo, mapCacheFragment.get(idlocale), "HELLO");
            fragmentTransaction.commit();
            full = mapCacheFragment.get(idlocale);

        } else {
            Bundle b = new Bundle();
            b.putInt("idlocale", idlocale);
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            FullInfoFragment hello = new FullInfoFragment();
            hello.setArguments(b);
            fragmentTransaction.add(R.id.fullInfo, hello, "HELLO");
            fragmentTransaction.commit();
            full = hello;
            mapCacheFragment.put(idlocale, hello);
        }
        v.setVisibility(View.INVISIBLE);
        expand((LinearLayout) findViewById(R.id.smallinfo));


/*
        Intent i = new Intent(MapActivity.this, FullInfoActivity.class);
        i.putExtra("nome", ((TextView) findViewById(R.id.textView11)).getText().toString());
        i.putExtra("tipologia", ((TextView) findViewById(R.id.textView12)).getText().toString());
        i.putExtra("descrizione", ((TextView) findViewById(R.id.textView13)).getText().toString());
        i.putExtra("indirizzo", ((TextView) findViewById(R.id.textView22)).getText().toString());
        i.putExtra("stelle", ((RatingBar) findViewById(R.id.ratingBar)).getRating());
        i.putExtra("idlocale",idlocale);

        startActivity(i);
        overridePendingTransition(R.anim.slideup,R.anim.slidedown);

*/

    }

    public void clickRecensione(View v) {
        Intent i = new Intent(MapActivity.this, RecensioneActivity.class);
        i.putExtra("nome", ((TextView) findViewById(R.id.textView11)).getText().toString());
        i.putExtra("tipologia", ((TextView) findViewById(R.id.textView12)).getText().toString());
        i.putExtra("idlocale", idlocale);

        startActivity(i);
    }

    private class AddMarker implements Runnable {

        JSONObject j;
        private GoogleMap map;
        private MarkerOptions options;

        public AddMarker(GoogleMap map, MarkerOptions options, JSONObject jo) {
            this.j = jo;
            this.map = map;
            this.options = options;
        }

        @Override
        public void run() {
            Marker m = map.addMarker(options);
            if (nearest == null) {
                nearest = m;
            } else if (distFrom(nearest.getPosition().latitude, nearest.getPosition().longitude, mylocation.latitude, mylocation.longitude) > distFrom(m.getPosition().latitude, m.getPosition().longitude, mylocation.latitude, mylocation.longitude)) {
                nearest = m;
            }
            ms.put(m, j);
        }
    }
}

Commits for Nextrek/Android/SmartCharging/SmartCharging/app/src/main/java/it/fedeloper/smartcharging/Controller/MapActivity.java

Diff revisions: vs.
Revision Author Commited Message
532 Diff Diff MStefanelli picture MStefanelli Mon 24 Aug, 2015 12:22:55 +0000

WE

529 Diff Diff MStefanelli picture MStefanelli Mon 24 Aug, 2015 10:44:00 +0000
525 Diff Diff FFontana picture FFontana Sat 22 Aug, 2015 11:08:25 +0000
524 Diff Diff FFontana picture FFontana Sat 22 Aug, 2015 10:47:42 +0000
523 Diff Diff MStefanelli picture MStefanelli Fri 21 Aug, 2015 16:43:01 +0000
522 Diff Diff MStefanelli picture MStefanelli Fri 21 Aug, 2015 16:02:26 +0000
521 Diff Diff MStefanelli picture MStefanelli Fri 21 Aug, 2015 12:38:59 +0000
518 Diff Diff FFontana picture FFontana Thu 20 Aug, 2015 14:36:46 +0000
506 Diff Diff FFontana picture FFontana Wed 19 Aug, 2015 17:39:12 +0000
505 FFontana picture FFontana Wed 19 Aug, 2015 08:54:46 +0000