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
package it.fedeloper.smartcharging.Controller;

import android.animation.ObjectAnimator;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.*;

import com.rey.material.widget.ProgressView;

import it.fedeloper.smartcharging.Manager.Utils;
import it.fedeloper.smartcharging.R;
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.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;


public class FullInfoFragment extends Fragment {
    ViewGroup v;
    int idlocale = -1;
    Context c;
    private ProgressView loadingAll;
    Bundle b;
    boolean haveScrolled = false;
    LayoutInflater li;
    private LinearLayout mainLayout;

    public FullInfoFragment(){}

    public float convertDpToPixel(float dp) {
        Resources resources = c.getResources();
        DisplayMetrics metrics = resources.getDisplayMetrics();
        float px = dp * (metrics.densityDpi / 160f);
        return px;
    }




    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState) {
        b = getArguments();

        super.onCreate(savedInstanceState);
        container = (ViewGroup) inflater.inflate(R.layout.activity_full_info, null);
        v = container;
        li = inflater;

        c = getActivity();

        idlocale = b.getInt("idlocale");
loadingAll =(ProgressView) container.findViewById(R.id.loadingAll);
        mainLayout = (LinearLayout) container.findViewById(R.id.main_layout);

        new Thread(new Runnable() {
            public void run() {
                JSONObject obj = new JSONObject();
                try {

                    obj.put("id", idlocale);

                    final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_immagini.php", obj);
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {


                            loadingAll.setVisibility(View.GONE);
                        }
                    });
                    Log.e("errore", resp.toString());
                    final JSONArray jArray = resp.getJSONArray("imgs");
                    Log.e("errore", "1111imggggg");
                    for (int i = 0; i < jArray.length(); i++) {

                        final String filename = (String) jArray.get(i);

                        new Thread(new Runnable() {
                            public void run() {
                                final ImageButton image = new ImageButton(c);
                                getActivity().runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {

                                        image.setBackgroundColor(getResources().getColor(R.color.btn_background));
                                        image.setScaleType(ImageView.ScaleType.FIT_CENTER);

                                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int) convertDpToPixel(130), (int) convertDpToPixel(130));
                                        lp.setMargins(10, 0, 10, 0);
                                        image.setLayoutParams(lp);
                                        ((LinearLayout) v.findViewById(R.id.images)).addView(image);
                                        Animation aAnimation = (Animation) AnimationUtils.loadAnimation(c, R.anim.zoom);

                                        image.startAnimation(aAnimation);

                                        if (haveScrolled == false) {

                                            ObjectAnimator objectAnimator = ObjectAnimator.ofInt(((ScrollView) getActivity().findViewById(R.id.scrollView)), "scrollY", 0, ((ScrollView) getActivity().findViewById(R.id.scrollView)).getBottom()).setDuration(500);
                                            objectAnimator.start();
                                            //   ((ScrollView)getActivity().findViewById(R.id.scrollView)).fullScroll(ScrollView.FOCUS_DOWN);
                                            haveScrolled = true;
                                        }
                                    }
                                });
                                Log.e("wwwwwwwwwwwwwwwwwww", filename);
                                final Bitmap imgweb = Utils.getBitmapFromURL(filename);
                                if (imgweb != null) {
                                    if (getActivity()!=null)
                                    getActivity().runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            image.clearAnimation();

                                            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int) (convertDpToPixel(130) * imgweb.getWidth() / imgweb.getHeight()), (int) convertDpToPixel(130));
                                            lp.setMargins(10, 0, 10, 0);
                                            image.setLayoutParams(lp);

                                            image.setImageBitmap(imgweb);

                                            image.setOnClickListener(new View.OnClickListener() {
                                                @Override
                                                public void onClick(View view) {

                                                    startActivity(new Intent(Intent.ACTION_VIEW, Utils.getImageUri(c, imgweb)));
                                                }
                                            });
                                        }
                                    });
                                }
                            }
                        }).start();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }).start();


        new Thread(new Runnable() {
            public void run() {
                JSONObject obj = new JSONObject();
                try {

                    obj.put("id", idlocale);
                    obj.put("startIndex", "0");
                    obj.put("length", "10");

                    final JSONObject resp = HttpClient.SendHttpPostAsync(EndPoint.MAIN_END_POINT + "/get_commenti.php", obj);
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {


                            loadingAll.setVisibility(View.GONE);
                        }
                    });
                    if(resp.getString("count").equals("0")){
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                TextView noCommentTextView = (TextView) v.findViewById(R.id.no_comment);
                                noCommentTextView.setVisibility(View.VISIBLE);
                            }
                        });
                    }

                    final JSONArray jArray = resp.getJSONArray("comments");

                    for (int i = 0; i < jArray.length(); i++) {
                        final JSONObject jdata = jArray.getJSONObject(i);
                        Log.e("errore i", jdata.toString());

//                        final Bitmap bitm = Utils.getBitmapFromURL(jdata.getString("user_avatar"));

                        if(getActivity()!=null)
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {

                                try {
                                    Log.e("errore", "1111");
                                    final View child = li.inflate(R.layout.commento_layout, null);

//                                    ((ImageView) child.findViewById(R.id.user_image)).setImageBitmap(bitm);
                                    if ( jdata.getString("username").contains("$"))
                                    ((TextView) child.findViewById(R.id.nameText)).setText(jdata.getString("username").substring(0, jdata.getString("username").indexOf("$")));
                                   else
                                        ((TextView) child.findViewById(R.id.nameText)).setText(jdata.getString("username"));


                                    ((TextView) child.findViewById(R.id.DescText)).setText(jdata.getString("descrizione"));
                                    ((TextView) child.findViewById(R.id.textView18)).setText(jdata.getString("data"));
                                    ((RatingBar) child.findViewById(R.id.ratingBar3)).setRating(jdata.getLong("voto"));
                                    ((LinearLayout) v.findViewById(R.id.commentiView)).addView(child);

                                /*    final JSONArray jArray1 = jdata.getJSONArray("imgs");
                                  for (int i = 0; i < jArray1.length(); i++) {

                                        final String filename = (String) jArray1.get(i);
                                       new Thread(new Runnable() {
                                            public void run() {

                                                final ImageButton image = new ImageButton(c);
                                                if (getActivity() != null) {
                                                    getActivity().runOnUiThread(new Runnable() {
                                                        @Override
                                                        public void run() {

                                                            image.setScaleType(ImageView.ScaleType.FIT_CENTER);
                                                           image.setLayoutParams(new LinearLayout.LayoutParams((int) convertDpToPixel(80), (int) convertDpToPixel(80)));
                                                           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int) convertDpToPixel(80), (int) convertDpToPixel(80));


                                                            image.setBackgroundColor(getResources().getColor(R.color.btn_background));
                                                            ((LinearLayout) child.findViewById(R.id.image)).addView(image);
                                                            Animation aAnimation = (Animation) AnimationUtils.loadAnimation(c, R.anim.zoom);

                                                            image.startAnimation(aAnimation);
                                                            if (haveScrolled == false) {
                                                                ObjectAnimator objectAnimator = ObjectAnimator.ofInt(((ScrollView) getActivity().findViewById(R.id.scrollView)), "scrollY", 0, ((ScrollView) getActivity().findViewById(R.id.scrollView)).getBottom()).setDuration(500);
                                                                objectAnimator.start();
                                                               //   ((ScrollView)getActivity().findViewById(R.id.scrollView)).fullScroll(ScrollView.FOCUS_DOWN);
                                                                haveScrolled = true;
                                                            }
                                                        }
                                                    });


                                                Log.e("ciaooooo", filename);
                                                final Bitmap imgweb = Utils.getBitmapFromURL( filename);
                                                if (imgweb != null) {
                                                   if (getActivity() != null) {
                                                        getActivity().runOnUiThread(new Runnable() {
                                                            @Override
                                                            public void run() {
                                                                image.clearAnimation();
                                                                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int) (convertDpToPixel(80) * imgweb.getWidth() / imgweb.getHeight()), (int) convertDpToPixel(80));
                                                                params.setMargins(6, 3, 0, 3);
                                                                image.setLayoutParams(params);
                                                                image.setImageBitmap(imgweb);

                                                                image.setOnClickListener(new View.OnClickListener() {
                                                                    @Override
                                                                    public void onClick(View view) {

                                                                        startActivity(new Intent(Intent.ACTION_VIEW, Utils.getImageUri(c, imgweb)));
                                                                   }
                                                                });
                                                            }
                                                        });
                                                    }
                                                }
                                            }

                                            }
                                        }).start();
                                    }*/
                                } catch (JSONException e) {
                                    Log.e("errore", "1111" + e.getMessage());
                                }
                            }
                        });
                    }
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            if (haveScrolled == false) {
                                loadingAll.setVisibility(View.GONE);
                                ObjectAnimator objectAnimator = ObjectAnimator.ofInt(((ScrollView) getActivity().findViewById(R.id.scrollView)), "scrollY", 0, ((ScrollView) getActivity().findViewById(R.id.scrollView)).getBottom()).setDuration(500);
                                objectAnimator.start();
                                //   ((ScrollView)getActivity().findViewById(R.id.scrollView)).fullScroll(ScrollView.FOCUS_DOWN);
                                haveScrolled = true;
                            }
                        }});

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        return v;
    }

   /* public void clickhide(View v) {
        finish();
        overridePendingTransition(R.anim.slideup,R.anim.slidedown);
    }*/
/*
    public void clickRecensione(View v) {
        Intent i = new Intent(FullInfoActivity.this, RecensioneActivity.class);
        i.putExtra("nome", ((TextView) findViewById(R.id.textView16)).getText().toString());
        i.putExtra("tipologia", ((TextView) findViewById(R.id.textView17)).getText().toString());
        i.putExtra("idlocale", idlocale);
        startActivity(i);
    }*/
}

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

Diff revisions: vs.
Revision Author Commited Message
785 Diff Diff FFontana picture FFontana Sat 26 Sep, 2015 14:15:20 +0000
762 Diff Diff FFontana picture FFontana Fri 18 Sep, 2015 16:18:57 +0000
748 Diff Diff FFontana picture FFontana Wed 16 Sep, 2015 15:31:34 +0000
708 Diff Diff FFontana picture FFontana Mon 07 Sep, 2015 16:01:43 +0000
703 Diff Diff FFontana picture FFontana Mon 07 Sep, 2015 15:22:49 +0000
697 Diff Diff FFontana picture FFontana Mon 07 Sep, 2015 12:37:18 +0000
686 Diff Diff FFontana picture FFontana Fri 04 Sep, 2015 14:59:51 +0000
666 Diff Diff MStefanelli picture MStefanelli Fri 04 Sep, 2015 09:55:54 +0000

me

658 Diff Diff MStefanelli picture MStefanelli Thu 03 Sep, 2015 07:07:48 +0000

Fix

647 MStefanelli picture MStefanelli Wed 02 Sep, 2015 08:00:13 +0000

me