Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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

Rev 23 Rev 24
Línea 43... Línea 43...
43
import com.cesams.twogetskills.library.MD5;
43
import com.cesams.twogetskills.library.MD5;
44
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
44
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
45
import com.cesams.twogetskills.viewmodel.SlideRefreshUIViewModel;
45
import com.cesams.twogetskills.viewmodel.SlideRefreshUIViewModel;
46
import com.google.android.material.tabs.TabLayout;
46
import com.google.android.material.tabs.TabLayout;
Línea -... Línea 47...
-
 
47
 
47
 
48
import java.text.DateFormat;
-
 
49
import java.text.Normalizer;
48
import java.text.Normalizer;
50
import java.text.SimpleDateFormat;
49
import java.util.ArrayList;
51
import java.util.ArrayList;
50
import java.util.Calendar;
52
import java.util.Calendar;
51
import java.util.HashMap;
53
import java.util.HashMap;
52
import java.util.List;
54
import java.util.List;
Línea 500... Línea 502...
500
        ArrayList<Topic> dbTopics = (ArrayList<Topic>) topicDao.selectAll();
502
        ArrayList<Topic> dbTopics = (ArrayList<Topic>) topicDao.selectAll();
Línea 501... Línea 503...
501
 
503
 
502
        List<Capsule> dbCapsules;
504
        List<Capsule> dbCapsules;
Línea -... Línea 505...
-
 
505
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
-
 
506
 
Línea -... Línea 507...
-
 
507
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
-
 
508
        SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
-
 
509
 
Línea 503... Línea 510...
503
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
510
 
Línea 504... Línea 511...
504
 
511
        if (tabposition.equals("pendientes"))
-
 
512
        {
Línea -... Línea 513...
-
 
513
            for (Topic dbTopic : dbTopics) {
Línea 505... Línea -...
505
 
-
 
506
 
-
 
507
 
-
 
508
        for (Topic dbTopic : dbTopics) {
-
 
Línea 509... Línea -...
509
 
-
 
Línea -... Línea 514...
-
 
514
 
-
 
515
                dbCapsules = capsuleDao.selectAllByTopicUuidandOrder(dbTopic.getUuid());
-
 
516
 
-
 
517
                Capsule capsule;
-
 
518
                Progress progress;
-
 
519
 
-
 
520
                HashMap<String, String> m_li;
-
 
521
 
-
 
522
 
Línea -... Línea 523...
-
 
523
 
Línea 510... Línea -...
510
            dbCapsules = capsuleDao.selectAllByTopicUuidandOrder(dbTopic.getUuid());
-
 
511
 
-
 
512
 
-
 
513
            Capsule capsule;
-
 
514
            Progress progress;
-
 
515
            ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
-
 
516
            SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
-
 
517
 
-
 
518
            HashMap<String, String> m_li;
-
 
519
 
-
 
Línea 520... Línea 524...
520
 
524
                for(Capsule dbCapsule : dbCapsules) {
Línea -... Línea 525...
-
 
525
                    capsule = new Capsule();
Línea 521... Línea 526...
521
 
526
                    capsule.setTopicUuid(dbCapsule.getTopicUuid());
-
 
527
                    capsule.setUuid(dbCapsule.getUuid());
-
 
528
                    capsule.setName(dbCapsule.getName());
Línea -... Línea 529...
-
 
529
                    capsule.setDescription(dbCapsule.getDescription());
-
 
530
                    capsule.setImage(dbCapsule.getImage());
-
 
531
                    capsule.setPosition(dbCapsule.getPosition());
Línea 522... Línea 532...
522
            for(Capsule dbCapsule : dbCapsules) {
532
                    capsule.setUpdatedOn(dbCapsule.getUpdatedOn());
523
                capsule = new Capsule();
533
 
-
 
534
                    m_li = new HashMap<>();
-
 
535
 
-
 
536
 
524
                capsule.setTopicUuid(dbCapsule.getTopicUuid());
537
                    //m_li.put("copyright",copy);
525
                capsule.setUuid(dbCapsule.getUuid());
538
 
Línea 526... Línea -...
526
                capsule.setName(dbCapsule.getName());
-
 
527
                capsule.setDescription(dbCapsule.getDescription());
539
                    progress = progressDao.selectByCapsuleUuid(capsule.getUuid());
Línea 528... Línea 540...
528
                capsule.setImage(dbCapsule.getImage());
540
 
529
                capsule.setPosition(dbCapsule.getPosition());
541
                    if (progress != null) {
530
                capsule.setAddedOn(dbCapsule.getAddedOn());
542
                        capsule.setCompleted(progress.getCompleted());
531
                capsule.setUpdatedOn(dbCapsule.getUpdatedOn());
543
                        capsule.setViewSlides(progress.getViewSlides());
532
 
544
 
533
                m_li = new HashMap<>();
-
 
Línea 534... Línea 545...
534
 
545
                        capsule.setTotalSlides(progress.getTotalSlides());
Línea 535... Línea -...
535
 
-
 
536
                //m_li.put("copyright",copy);
-
 
537
 
-
 
538
 
-
 
539
                progress = progressDao.selectByCapsuleUuid(capsule.getUuid());
-
 
540
                if (progress != null) {
546
                        capsule.setProgress(progress.getProgress());
Línea 541... Línea 547...
541
                    capsule.setCompleted(progress.getCompleted());
547
                        capsule.setAddedOn(progress.getAddedOn());
Línea 542... Línea 548...
542
                    capsule.setViewSlides(progress.getViewSlides());
548
 
-
 
549
                        // Log.e("Agregado en"," "+progress.getAddedOn());
Línea 543... Línea -...
543
 
-
 
Línea 544... Línea -...
544
                    capsule.setTotalSlides(progress.getTotalSlides());
-
 
545
                    capsule.setProgress(progress.getProgress());
550
                        // m_li.put("addedon",progress.getAddedOn());
Línea -... Línea 551...
-
 
551
                        m_li.put("view", String.valueOf(progress.getViewSlides()));
Línea 546... Línea 552...
546
 
552
                        m_li.put("total", String.valueOf(progress.getTotalSlides()));
Línea 547... Línea -...
547
                   // Log.e("Agregado en"," "+progress.getAddedOn());
-
 
548
                   // m_li.put("addedon",progress.getAddedOn());
-
 
Línea -... Línea 553...
-
 
553
                        m_li.put("progress", String.valueOf(progress.getProgress()));
-
 
554
                        m_li.put("completado",String.valueOf(progress.getCompleted()));
-
 
555
                        m_li.put("agregado",progress.getAddedOn());
-
 
556
 
-
 
557
                    }
-
 
558
 
-
 
559
                    m_li.put("imagen", capsule.getImage());
Línea 549... Línea -...
549
                    m_li.put("view", String.valueOf(progress.getViewSlides()));
-
 
550
                    m_li.put("total", String.valueOf(progress.getTotalSlides()));
-
 
551
                    m_li.put("progress", String.valueOf(progress.getProgress()));
-
 
552
                    m_li.put("completado",String.valueOf(progress.getCompleted()));
-
 
553
 
-
 
554
 
-
 
555
                }
560
                    m_li.put("nombre", capsule.getName());
Línea 556... Línea 561...
556
 
561
                    m_li.put("uuid", capsule.getUuid());
Línea 557... Línea 562...
557
                m_li.put("imagen", capsule.getImage());
562
                    m_li.put("topicuuid", capsule.getTopicUuid());
-
 
563
                    m_li.put("description", capsule.getDescription());
-
 
564
 
Línea 558... Línea -...
558
                m_li.put("nombre", capsule.getName());
-
 
559
                m_li.put("uuid", capsule.getUuid());
-
 
Línea 560... Línea -...
560
                m_li.put("topicuuid", capsule.getTopicUuid());
-
 
561
                m_li.put("description", capsule.getDescription());
-
 
562
                Log.e("Capsula recuperada",""+capsule.getAddedOn());
-
 
563
 
-
 
564
                //Lleno la lista segun el requerimiento de filtro accionado por el usuario
-
 
565
 
-
 
566
                List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
-
 
Línea 567... Línea 565...
567
 
565
 
Línea -... Línea 566...
-
 
566
                    //Lleno la lista segun el requerimiento de filtro accionado por el usuario
568
                if (slides.isEmpty()) {
567
 
-
 
568
                    List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
Línea 569... Línea -...
569
 
-
 
570
                  //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
571
                } else {
569
 
572
 
-
 
573
 
570
                    if (slides.isEmpty()) {
574
                    if (tabposition.equals("pendientes") && progress == null) {
-
 
575
 
-
 
576
                        if (buscar.equals("")) {
-
 
577
                            capsuleList.add(m_li);
-
 
578
 
-
 
579
 
571
 
Línea 580... Línea -...
580
                        } else {
-
 
Línea 581... Línea -...
581
                            String nombre= capsule.getName();
-
 
Línea -... Línea 572...
-
 
572
                        //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
573
                    } else {
-
 
574
 
-
 
575
 
-
 
576
                        if (progress == null) {
-
 
577
 
-
 
578
                            if (buscar.equals("")) {
-
 
579
 
-
 
580
                                capsuleList.add(m_li);
-
 
581
 
-
 
582
 
-
 
583
                            } else {
-
 
584
                                String nombre= capsule.getName();
-
 
585
                                String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
-
 
586
                                normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
-
 
587
                                if (normalizada.matches("(?i).*" + buscar + ".*")) {
-
 
588
                                    capsuleList.add(m_li);
-
 
589
                                }
-
 
590
 
-
 
591
                            }
-
 
592
 
-
 
593
                        }
-
 
594
 
-
 
595
                    }
-
 
596
 
-
 
597
                }
-
 
598
 
-
 
599
 
-
 
600
 
-
 
601
            }
-
 
602
 
-
 
603
        }
-
 
604
        else if (tabposition.equals("cursando"))
-
 
605
        {
-
 
606
 
-
 
607
                HashMap<String, String> m_li;
-
 
608
                List<Progress> progress;
-
 
609
                Capsule capsule;
-
 
610
 
-
 
611
 
-
 
612
 
-
 
613
            progress = progressDao.selectAllCapsulesProgress();
582
                            String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
614
 
Línea 583... Línea 615...
583
                            normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
615
                for(Progress dbProgress : progress) {
-
 
616
                    m_li = new HashMap<>();
-
 
617
 
Línea -... Línea 618...
-
 
618
                    capsule = capsuleDao.selectByUuid(dbProgress.getCapsuleUuid());
Línea -... Línea 619...
-
 
619
 
-
 
620
                    m_li.put("view", String.valueOf(dbProgress.getViewSlides()));
-
 
621
                    m_li.put("total", String.valueOf(dbProgress.getTotalSlides()));
-
 
622
                    m_li.put("progress", String.valueOf(dbProgress.getProgress()));
-
 
623
                    m_li.put("completado",String.valueOf(dbProgress.getCompleted()));
-
 
624
                    m_li.put("agregado",dbProgress.getAddedOn());
-
 
625
 
-
 
626
 
-
 
627
                    m_li.put("imagen", capsule.getImage());
-
 
628
                    m_li.put("nombre", capsule.getName());
-
 
629
                    m_li.put("uuid", capsule.getUuid());
-
 
630
                    m_li.put("topicuuid", capsule.getTopicUuid());
-
 
631
                    m_li.put("description", capsule.getDescription());
-
 
632
 
-
 
633
 
-
 
634
                    //Log.e("Lista",""+m_li);
-
 
635
                    //Lleno la lista segun el requerimiento de filtro accionado por el usuario
-
 
636
 
-
 
637
                    List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
-
 
638
 
-
 
639
                    if (slides.isEmpty()) {
-
 
640
 
-
 
641
                        //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
642
                    } else {
-
 
643
 
-
 
644
            if(dbProgress.getProgress() <= 100 && dbProgress.getCompleted()==0)
-
 
645
            {
-
 
646
            if (buscar.equals("")) {
-
 
647
                capsuleList.add(m_li);
-
 
648
 
-
 
649
            } else {
-
 
650
                String nombre= capsule.getName();
-
 
651
                String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
-
 
652
                normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
-
 
653
                if (normalizada.matches("(?i).*" + buscar + ".*")) {
-
 
654
                    capsuleList.add(m_li);
-
 
655
                }
-
 
656
 
-
 
657
            }
-
 
658
        }}
-
 
659
                }}
-
 
660
 
-
 
661
       else if (tabposition.equals("finalizados")){
-
 
662
 
-
 
663
            HashMap<String, String> m_li;
-
 
664
            List<Progress> progress;
-
 
665
            Capsule capsule;
-
 
666
 
-
 
667
 
584
                            if (normalizada.matches("(?i).*" + buscar + ".*")) {
668
 
-
 
669
            progress = progressDao.selectAllCapsulesProgress();
-
 
670
 
Línea 585... Línea 671...
585
                                capsuleList.add(m_li);
671
            for(Progress dbProgress : progress) {
Línea 586... Línea 672...
586
                            }
672
                m_li = new HashMap<>();
587
 
673
 
Línea 588... Línea 674...
588
                        }
674
                capsule = capsuleDao.selectByUuid(dbProgress.getCapsuleUuid());
589
 
-
 
Línea 590... Línea 675...
590
                    } else if (tabposition.equals("cursando") && progress != null && progress.getProgress() <= 100 && progress.getCompleted()==0) {
675
 
591
 
676
                m_li.put("view", String.valueOf(dbProgress.getViewSlides()));
592
                        if (buscar.equals("")) {
677
                m_li.put("total", String.valueOf(dbProgress.getTotalSlides()));
Línea 593... Línea 678...
593
                            capsuleList.add(m_li);
678
                m_li.put("progress", String.valueOf(dbProgress.getProgress()));
594
 
679
                m_li.put("completado",String.valueOf(dbProgress.getCompleted()));
Línea 595... Línea 680...
595
                        } else {
680
                m_li.put("agregado",dbProgress.getAddedOn());
Línea 596... Línea 681...
596
                            String nombre= capsule.getName();
681
 
597
                            String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
682
 
598
                            normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
683
                m_li.put("imagen", capsule.getImage());