Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 9 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 9 Rev 10
Línea 56... Línea 56...
56
 * Use the {@link WelcomeFragment#newInstance} factory method to
56
 * Use the {@link WelcomeFragment#newInstance} factory method to
57
 * create an instance of this fragment.
57
 * create an instance of this fragment.
58
 */
58
 */
59
public class WelcomeFragment extends Fragment implements CapsuleListViewAdapter.ItemClickListener, LifecycleOwner {
59
public class WelcomeFragment extends Fragment implements CapsuleListViewAdapter.ItemClickListener, LifecycleOwner {
Línea 60... Línea 60...
60
 
60
 
61
    TextView username, titulotarjeta, progresoporcentaje; ProgressBar progresotarjeta;
61
    TextView username, titulotarjeta, progresoporcentaje, empezar; ProgressBar progresotarjeta;
62
    private ITwoGetSkills iTwoGetSkills; View card;
62
    private ITwoGetSkills iTwoGetSkills; View card;
63
    ArrayList<HashMap<String, String>> capsuleList;
63
    ArrayList<HashMap<String, String>> capsuleList;
64
    private CardViewAdapter adapter; ImageView imagetarjeta;
64
    private CardViewAdapter adapter; ImageView imagetarjeta;
65
    private TabsCapsulesAdapter adapter2;
65
    private TabsCapsulesAdapter adapter2;
Línea 91... Línea 91...
91
        View view= inflater.inflate(R.layout.fragment_welcome, container, false);
91
        View view= inflater.inflate(R.layout.fragment_welcome, container, false);
Línea 92... Línea 92...
92
 
92
 
93
        username=view.findViewById(R.id.textView14);
93
        username=view.findViewById(R.id.textView14);
94
        textowelcome= view.findViewById(R.id.textView15);
94
        textowelcome= view.findViewById(R.id.textView15);
95
        busqueda=view.findViewById(R.id.busqueda);
95
        busqueda=view.findViewById(R.id.busqueda);
96
        card= view.findViewById(R.id.include);
96
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.textView17);
Línea 97... Línea 97...
97
        capsuleList = new ArrayList<>();
97
        capsuleList = new ArrayList<>();
98
 
98
 
99
        //Tarjeta Principal
99
        //Tarjeta Principal
Línea 206... Línea 206...
206
        {
206
        {
207
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
207
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
Línea 208... Línea 208...
208
 
208
 
Línea 209... Línea -...
209
            if (progress != null) {
-
 
210
 
-
 
211
                    Log.e("Progreso", ": " + progress.getProgress());
209
            if (progress != null) {
-
 
210
 
-
 
211
                    if (progress.getProgress() < 100) {
212
 
212
                        Log.e("Es menor"," a 100");
-
 
213
 
-
 
214
                        titulotarjeta.setText(dbCapsule.getName());
213
                    if (progress.getProgress() < 100) {
215
                        progresotarjeta.setVisibility(View.VISIBLE);
214
                        titulotarjeta.setText(dbCapsule.getName());
216
                        progresoporcentaje.setVisibility(View.VISIBLE);
-
 
217
                        progresotarjeta.setProgress((int) progress.getProgress());
-
 
218
                        progresoporcentaje.setText("" + progress.getProgress() + " %");
-
 
219
                        empezar.setText("En curso");
-
 
220
 
-
 
221
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
-
 
222
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
-
 
223
 
-
 
224
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
-
 
225
 
-
 
226
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
-
 
227
                            Calendar calendar = Calendar.getInstance(timeZone);
-
 
228
                            TimeZone tz = calendar.getTimeZone();
-
 
229
                            int created = (int) (calendar.getTimeInMillis() / 1000);
-
 
230
 
-
 
231
                            Random random = new Random(created);
-
 
232
                            int rand = 1000 + random.nextInt(8999);
-
 
233
 
-
 
234
 
-
 
235
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
-
 
236
                            String password = iTwoGetSkills.getPreference().getPassword();
-
 
237
 
-
 
238
 
-
 
239
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
-
 
240
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
-
 
241
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
-
 
242
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
-
 
243
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
-
 
244
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
-
 
245
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
-
 
246
                                    .build());
-
 
247
 
-
 
248
                            RequestOptions options = new RequestOptions()
-
 
249
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
-
 
250
 
-
 
251
                            Glide.with(getContext()).load(url)
-
 
252
                                    .thumbnail()
-
 
253
                                    .apply(options)
-
 
254
                                    .into(imagetarjeta);
-
 
255
                        }
-
 
256
                    }
-
 
257
 
-
 
258
            }
-
 
259
 
-
 
260
 
-
 
261
        }
-
 
262
 
-
 
263
        if(titulotarjeta.getText().equals(""))
-
 
264
        {
-
 
265
            Log.e("Nombre","vacio");
-
 
266
 
-
 
267
            //Despues del recorrido no se encontro progreso en ninguna capsula, por lo cual la tarjeta queda vacia
-
 
268
            // vamos a llenarla con la ultima capsula, que debe ser nueva al no tener progreso
-
 
269
 
-
 
270
            for(Capsule dbCapsule : dbCapsules)
-
 
271
            {
-
 
272
 
-
 
273
                progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
-
 
274
 
-
 
275
                if (progress == null) {
-
 
276
 
-
 
277
                        Log.e("Es nueva","");
-
 
278
 
-
 
279
                        titulotarjeta.setText(dbCapsule.getName());
-
 
280
                        progresotarjeta.setVisibility(View.INVISIBLE);
-
 
281
                        progresoporcentaje.setVisibility(View.INVISIBLE);
Línea 215... Línea 282...
215
                        progresotarjeta.setProgress((int) progress.getProgress());
282
                        empezar.setText("Nueva");
216
                        progresoporcentaje.setText("" + progress.getProgress() + " %");
283
                        continuar.setText("Ver cápsula");
Línea 217... Línea 284...
217
 
284
 
Línea 248... Línea 315...
248
                            Glide.with(getContext()).load(url)
315
                            Glide.with(getContext()).load(url)
249
                                    .thumbnail()
316
                                    .thumbnail()
250
                                    .apply(options)
317
                                    .apply(options)
251
                                    .into(imagetarjeta);
318
                                    .into(imagetarjeta);
252
                        }
319
                        }
-
 
320
 
253
                    }
321
                    }
Línea -... Línea 322...
-
 
322
 
-
 
323
                /*
-
 
324
                if (progress != null) {
-
 
325
 
-
 
326
                    double progre = progress.getProgress();
-
 
327
 
-
 
328
                    if (progre >= 100) {
-
 
329
                        Log.e("Es mayor"," a 100");
-
 
330
 
-
 
331
                    } else {
-
 
332
 
-
 
333
                        Log.e("Es nueva","");
-
 
334
 
-
 
335
                        titulotarjeta.setText(dbCapsule.getName());
-
 
336
                        progresotarjeta.setVisibility(View.INVISIBLE);
-
 
337
                        progresoporcentaje.setVisibility(View.INVISIBLE);
-
 
338
                        empezar.setText("Nueva");
-
 
339
                        continuar.setText("Ver cápsula");
-
 
340
 
-
 
341
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
-
 
342
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
-
 
343
 
-
 
344
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
-
 
345
 
-
 
346
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
-
 
347
                            Calendar calendar = Calendar.getInstance(timeZone);
-
 
348
                            TimeZone tz = calendar.getTimeZone();
-
 
349
                            int created = (int) (calendar.getTimeInMillis() / 1000);
-
 
350
 
-
 
351
                            Random random = new Random(created);
-
 
352
                            int rand = 1000 + random.nextInt(8999);
-
 
353
 
-
 
354
 
-
 
355
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
-
 
356
                            String password = iTwoGetSkills.getPreference().getPassword();
-
 
357
 
-
 
358
 
-
 
359
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
-
 
360
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
-
 
361
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
-
 
362
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
-
 
363
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
-
 
364
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
-
 
365
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
-
 
366
                                    .build());
-
 
367
 
-
 
368
                            RequestOptions options = new RequestOptions()
-
 
369
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
-
 
370
 
-
 
371
                            Glide.with(getContext()).load(url)
-
 
372
                                    .thumbnail()
-
 
373
                                    .apply(options)
-
 
374
                                    .into(imagetarjeta);
-
 
375
                        }
-
 
376
 
254
 
377
                    }
-
 
378
                }
-
 
379
*/
-
 
380
            }
-
 
381
 
Línea 255... Línea 382...
255
                }
382
 
Línea -... Línea 383...
-
 
383
 
-
 
384
        }
256
 
385
 
Línea 257... Línea 386...
257
        }
386
 
258
 
387