Proyectos de Subversion Android Microlearning - Inconcert

Rev

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

Rev 8 Rev 14
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
import android.os.Bundle;
3
import android.os.Bundle;
4
 
4
 
5
import androidx.fragment.app.Fragment;
-
 
-
 
5
import androidx.fragment.app.Fragment;
6
import androidx.lifecycle.LifecycleOwner;
6
import androidx.lifecycle.LifecycleOwner;
7
import androidx.lifecycle.ViewModelProvider;
7
 
Línea 8... Línea 8...
8
import androidx.recyclerview.widget.GridLayoutManager;
8
import androidx.recyclerview.widget.GridLayoutManager;
9
import androidx.recyclerview.widget.RecyclerView;
9
import androidx.recyclerview.widget.RecyclerView;
Línea 55... Línea 55...
55
 * Use the {@link WelcomeFragment#newInstance} factory method to
55
 * Use the {@link WelcomeFragment#newInstance} factory method to
56
 * create an instance of this fragment.
56
 * create an instance of this fragment.
57
 */
57
 */
58
public class WelcomeFragment extends Fragment implements TabsCapsulesAdapter.ClickListener, LifecycleOwner {
58
public class WelcomeFragment extends Fragment implements TabsCapsulesAdapter.ClickListener, LifecycleOwner {
Línea 59... Línea 59...
59
 
59
 
60
    TextView username, titulotarjeta, progresoporcentaje, empezar; ProgressBar progresotarjeta;
60
    TextView username, titulotarjeta, progresoporcentaje, empezar, ningunelemento; ProgressBar progresotarjeta;
61
    private ITwoGetSkills iTwoGetSkills; View card;
61
    private ITwoGetSkills iTwoGetSkills; View card;
62
    ArrayList<HashMap<String, String>> capsuleList;
62
    ArrayList<HashMap<String, String>> capsuleList;
63
    ImageView imagetarjeta;
63
    ImageView imagetarjeta;
64
    TabsCapsulesAdapter adapter2;
64
    TabsCapsulesAdapter adapter2;
Línea 88... Línea 88...
88
 
88
 
Línea 89... Línea 89...
89
        iTwoGetSkills = (ITwoGetSkills) getActivity();
89
        iTwoGetSkills = (ITwoGetSkills) getActivity();
Línea 90... Línea 90...
90
 
90
 
91
        View view= inflater.inflate(R.layout.fragment_welcome, container, false);
91
        View view= inflater.inflate(R.layout.fragment_welcome, container, false);
92
 
92
 
93
        username=view.findViewById(R.id.textView14);
93
        username=view.findViewById(R.id.textView14); ningunelemento=view.findViewById(R.id.textView25);
94
        textowelcome= view.findViewById(R.id.textView15);
94
        textowelcome= view.findViewById(R.id.textView15);
Línea 95... Línea -...
95
        busqueda=view.findViewById(R.id.busqueda);
-
 
-
 
95
        busqueda=view.findViewById(R.id.busqueda);
Línea 96... Línea 96...
96
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.titlenotifi); tabs=view.findViewById(R.id.tabLayout);
96
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.titlenotifi); tabs=view.findViewById(R.id.tabLayout);
Línea 274... Línea 274...
274
                capsuleList.clear();
274
                capsuleList.clear();
Línea 275... Línea 275...
275
 
275
 
276
                loadContinuecard();
276
                loadContinuecard();
Línea -... Línea 277...
-
 
277
                loadData("pendientes","");
-
 
278
 
-
 
279
                if (capsuleList.size() == 0) //Si no tenemos capsulas pendientes nos vamos a en curso
-
 
280
                {
-
 
281
                    capsuleList.clear();
-
 
282
                    loadData("cursando","");
-
 
283
 
-
 
284
                    tabs.selectTab(tabs.getTabAt(1),true);
-
 
285
 
-
 
286
                }
-
 
287
                else
-
 
288
                {
-
 
289
                    tabs.selectTab(tabs.getTabAt(0),true);
277
                loadData("pendientes","");
290
 
Línea 278... Línea -...
278
 
-
 
-
 
291
                }
Línea 279... Línea 292...
279
                adapter2.notifyDataSetChanged();
292
                adapter2.notifyDataSetChanged();
Línea 280... Línea 293...
280
 
293
 
Línea 302... Línea 315...
302
        {
315
        {
303
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
316
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
Línea 304... Línea 317...
304
 
317
 
Línea -... Línea 318...
-
 
318
            if (progress != null) {
-
 
319
 
-
 
320
            if (progress.getProgress() <=100 && progress.getCompleted()==0)
-
 
321
                {
-
 
322
                    titulotarjeta.setText(dbCapsule.getName());
-
 
323
                    if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
-
 
324
 
-
 
325
                        TimeZone timeZone = TimeZone.getTimeZone("UTC");
-
 
326
                        Calendar calendar = Calendar.getInstance(timeZone);
-
 
327
                        TimeZone tz = calendar.getTimeZone();
-
 
328
                        int created = (int) (calendar.getTimeInMillis() / 1000);
-
 
329
 
-
 
330
                        Random random = new Random(created);
-
 
331
                        int rand = 1000 + random.nextInt(8999);
-
 
332
 
-
 
333
 
-
 
334
                        String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
-
 
335
                        String password = iTwoGetSkills.getPreference().getPassword();
-
 
336
 
-
 
337
 
-
 
338
                        String secret = MD5.generar(password + ':' + created + ':' + rand);
-
 
339
                        GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
-
 
340
                                .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
-
 
341
                                .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
-
 
342
                                .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
-
 
343
                                .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
-
 
344
                                .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
-
 
345
                                .build());
-
 
346
 
-
 
347
                        RequestOptions options = new RequestOptions()
-
 
348
                                .diskCacheStrategy(DiskCacheStrategy.ALL);
-
 
349
 
-
 
350
                        Glide.with(getContext()).load(url)
-
 
351
                                .thumbnail()
-
 
352
                                .apply(options)
-
 
353
                                .into(imagetarjeta);
-
 
354
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
305
            if (progress != null) {
355
                    }
306
 
356
                }
307
                    if (progress.getProgress() < 100) {
357
                    if (progress.getProgress() < 100 && progress.getCompleted()==0) {
308
                       // Log.e("Es menor"," a 100");
358
                       // Log.e("Es menor"," a 100");
309
                        continues=true;
359
                        continues=true;
310
                        titulotarjeta.setText(dbCapsule.getName());
360
                        titulotarjeta.setText(dbCapsule.getName());
Línea 320... Línea 370...
320
 
370
 
321
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
371
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
322
                        ) {
372
                        ) {
323
                            return;
373
                            return;
324
                        }
374
                        }
325
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
375
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
Línea 326... Línea 376...
326
                     //   Log.e("La capsula","activa en loadcurso"+dbCapsule.getUuid());
376
                     //   Log.e("La capsula","activa en loadcurso"+dbCapsule.getUuid());
Línea 327... Línea 377...
327
 
377
 
Línea 402... Línea 452...
402
 
452
 
403
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
453
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
404
                        ) {
454
                        ) {
405
                            return;
455
                            return;
406
                        }
456
                        }
407
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
457
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
408
                      //  Log.e("La capsula","activa en load"+dbCapsule.getUuid());
458
                      //  Log.e("La capsula","activa en load"+dbCapsule.getUuid());
Línea 409... Línea 459...
409
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
459
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
Línea 487... Línea 537...
487
 
537
 
488
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
538
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
489
                        ) {
539
                        ) {
490
                            return;
540
                            return;
491
                        }
541
                        }
492
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
542
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
493
                       // Log.e("La capsula","activa en load"+dbCapsule.getUuid());
543
                       // Log.e("La capsula","activa en load"+dbCapsule.getUuid());
Línea 494... Línea 544...
494
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
544
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
Línea 534... Línea 584...
534
 
584
 
Línea 535... Línea 585...
535
        continuar.setOnClickListener(v -> {
585
        continuar.setOnClickListener(v -> {
536
 
586
 
-
 
587
 
-
 
588
           // Log.e("Guardo",""+iTwoGetSkills.getPreference().getOrigenNavigation());
-
 
589
           // Log.e("Capsule","active"+iTwoGetSkills.getPreference().getCapsuleUuidActive());
-
 
590
 
-
 
591
            Progress progresscontinue; ProgressDao progressDaocontinue = iTwoGetSkills.getDatabase().getProgressDao();
-
 
592
            progresscontinue = progressDaocontinue.selectByCapsuleUuid(iTwoGetSkills.getCapsuleUuidActive());
-
 
593
            if (progresscontinue != null) {
-
 
594
                if (progresscontinue.getProgress() >= 100 && progresscontinue.getCompleted() == 1) {
-
 
595
                    iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_DETAIL_CAPSULE);
-
 
596
                } else {
-
 
597
                    iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
-
 
598
                }
-
 
599
 
-
 
600
                iTwoGetSkills.getPreference().setOrigennavigation("welcome");
-
 
601
                iTwoGetSkills.hideKeyboard(v); //Ocultamos el teclado
537
 
602
            }
-
 
603
            else
-
 
604
            {
538
           // Log.e("Guardo",""+iTwoGetSkills.getPreference().getOrigenNavigation());
605
                iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
Línea 539... Línea 606...
539
            Log.e("Capsule","active"+iTwoGetSkills.getPreference().getCapsuleUuidActive());
606
 
Línea 540... Línea 607...
540
            iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
607
            }
Línea 773... Línea 840...
773
           }
840
           }
774
    }
841
    }
775
                }}}
842
                }}}
Línea -... Línea 843...
-
 
843
 
-
 
844
 
-
 
845
       if(capsuleList.size() == 0)
-
 
846
       {
-
 
847
           ningunelemento.setVisibility(View.VISIBLE);
-
 
848
       }
-
 
849
       else
-
 
850
       {
-
 
851
           ningunelemento.setVisibility(View.GONE);
776
 
852
       }
Línea 777... Línea 853...
777
 
853
 
778
    }
854
    }
Línea 779... Línea -...
779
 
-
 
780
 
-
 
781
    @Override
-
 
782
    public void onItemClick(int position, View v) {
855
 
783
 
856
 
784
       // Log.e("Evento","del click"+position);
-
 
Línea -... Línea 857...
-
 
857
    @Override
-
 
858
    public void onItemClick(int position, View v) {
-
 
859
 
-
 
860
        iTwoGetSkills.setCapsulaActiva(capsuleList.get(position).get("uuid"));
785
 
861
        iTwoGetSkills.getPreference().setTopicUuidActive(capsuleList.get(position).get("topicuuid"));
786
 
862
 
-
 
863
        Progress progress; ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
787
        iTwoGetSkills.getPreference().setCapsuleUuidActive(capsuleList.get(position).get("uuid"));
864
        progress = progressDao.selectByCapsuleUuid(capsuleList.get(position).get("uuid"));
-
 
865
 
Línea 788... Línea 866...
788
        iTwoGetSkills.getPreference().setTopicUuidActive(capsuleList.get(position).get("topicuuid"));
866
        if (progress != null) {
-
 
867
            if (progress.getProgress() >= 100 && progress.getCompleted() == 1) {
-
 
868
                iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_DETAIL_CAPSULE);
-
 
869
            } else {
-
 
870
                iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
-
 
871
            }
Línea -... Línea 872...
-
 
872
 
789
        iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
873
            iTwoGetSkills.getPreference().setOrigennavigation("welcome");
790
 
-
 
791
        iTwoGetSkills.getPreference().setOrigennavigation("welcome");
874
            iTwoGetSkills.hideKeyboard(v); //Ocultamos el teclado
-
 
875
        }