Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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

Rev 16 Rev 17
Línea 3... Línea 3...
3
import android.os.Bundle;
3
import android.os.Bundle;
Línea 4... Línea 4...
4
 
4
 
5
import androidx.annotation.NonNull;
5
import androidx.annotation.NonNull;
6
import androidx.fragment.app.Fragment;
6
import androidx.fragment.app.Fragment;
-
 
7
import androidx.lifecycle.LifecycleOwner;
7
import androidx.lifecycle.LifecycleOwner;
8
import androidx.lifecycle.ViewModelProvider;
8
import androidx.recyclerview.widget.GridLayoutManager;
9
import androidx.recyclerview.widget.GridLayoutManager;
Línea 9... Línea 10...
9
import androidx.recyclerview.widget.RecyclerView;
10
import androidx.recyclerview.widget.RecyclerView;
10
 
11
 
Línea 39... Línea 40...
39
import com.cesams.twogetskills.entity.Progress;
40
import com.cesams.twogetskills.entity.Progress;
40
import com.cesams.twogetskills.entity.Slide;
41
import com.cesams.twogetskills.entity.Slide;
41
import com.cesams.twogetskills.entity.Topic;
42
import com.cesams.twogetskills.entity.Topic;
42
import com.cesams.twogetskills.library.MD5;
43
import com.cesams.twogetskills.library.MD5;
43
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
44
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
-
 
45
import com.cesams.twogetskills.viewdata.SlideRefreshUIViewData;
-
 
46
import com.cesams.twogetskills.viewmodel.SlideRefreshUIViewModel;
44
import com.google.android.material.tabs.TabLayout;
47
import com.google.android.material.tabs.TabLayout;
Línea 45... Línea 48...
45
 
48
 
46
import java.util.ArrayList;
49
import java.util.ArrayList;
47
import java.util.Calendar;
50
import java.util.Calendar;
Línea 53... Línea 56...
53
/**
56
/**
54
 * A simple {@link Fragment} subclass.
57
 * A simple {@link Fragment} subclass.
55
 * Use the {@link WelcomeFragment#newInstance} factory method to
58
 * Use the {@link WelcomeFragment#newInstance} factory method to
56
 * create an instance of this fragment.
59
 * create an instance of this fragment.
57
 */
60
 */
58
public class WelcomeFragment extends Fragment implements LifecycleOwner {
61
public class WelcomeFragment extends Fragment implements TabsCapsulesAdapter.ClickListener, LifecycleOwner {
Línea 59... Línea 62...
59
 
62
 
60
    TextView username, titulotarjeta, progresoporcentaje, empezar; ProgressBar progresotarjeta;
63
    TextView username, titulotarjeta, progresoporcentaje, empezar; ProgressBar progresotarjeta;
61
    private ITwoGetSkills iTwoGetSkills; View card;
64
    private ITwoGetSkills iTwoGetSkills; View card;
62
    ArrayList<HashMap<String, String>> capsuleList;
65
    ArrayList<HashMap<String, String>> capsuleList;
63
    ImageView imagetarjeta;
66
    ImageView imagetarjeta;
64
    TabsCapsulesAdapter adapter2;
67
    TabsCapsulesAdapter adapter2;
65
    RecyclerView categorizados;
68
    RecyclerView categorizados;
66
    EditText busqueda; TextView textowelcome; Button continuar;
69
    EditText busqueda; TextView textowelcome; Button continuar;
-
 
70
    TabLayout tabs; String tabactual="pendientes";     private SlideRefreshUIViewModel mSlideRefreshUi;
Línea 67... Línea 71...
67
    TabLayout tabs; String tabactual="pendientes";
71
 
68
 
72
 
69
    public WelcomeFragment() {
73
    public WelcomeFragment() {
Línea 94... Línea 98...
94
        textowelcome= view.findViewById(R.id.textView15);
98
        textowelcome= view.findViewById(R.id.textView15);
95
        busqueda=view.findViewById(R.id.busqueda);
99
        busqueda=view.findViewById(R.id.busqueda);
96
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.titlenotifi); tabs=view.findViewById(R.id.tabLayout);
100
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.titlenotifi); tabs=view.findViewById(R.id.tabLayout);
97
        capsuleList = new ArrayList<>();
101
        capsuleList = new ArrayList<>();
Línea -... Línea 102...
-
 
102
 
-
 
103
 
-
 
104
        mSlideRefreshUi = new ViewModelProvider(requireActivity()).get(SlideRefreshUIViewModel.class);
-
 
105
 
-
 
106
 
-
 
107
 
98
 
108
 
99
        //Tarjeta Principal
109
        //Tarjeta Principal
100
        titulotarjeta = view.findViewById(R.id.description); progresotarjeta= view.findViewById(R.id.progressBar2); imagetarjeta= view.findViewById(R.id.imagelist);
110
        titulotarjeta = view.findViewById(R.id.description); progresotarjeta= view.findViewById(R.id.progressBar2); imagetarjeta= view.findViewById(R.id.imagelist);
Línea 163... Línea 173...
163
 
173
 
Línea 164... Línea 174...
164
            }
174
            }
165
 
175
 
166
            @Override
176
            @Override
167
            public void onTextChanged(CharSequence s, int start, int before, int count) {
177
            public void onTextChanged(CharSequence s, int start, int before, int count) {
168
                Log.e("El texto","buscado: "+s);
178
            //    Log.e("El texto","buscado: "+s);
169
                capsuleList.clear();
179
                capsuleList.clear();
170
                adapter2.notifyDataSetChanged();
180
                adapter2.notifyDataSetChanged();
Línea 188... Línea 198...
188
        GridLayoutManager layoutcategoria = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
198
        GridLayoutManager layoutcategoria = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
189
        categorizados.setLayoutManager(layoutcategoria);
199
        categorizados.setLayoutManager(layoutcategoria);
190
        categorizados.setAdapter(adapter2);
200
        categorizados.setAdapter(adapter2);
Línea 191... Línea -...
191
 
-
 
-
 
201
 
Línea 192... Línea 202...
192
 
202
 
193
 
203
        adapter2.setClickListener(this);
194
 
204
 
Línea 195... Línea 205...
195
        categorizados.setOnFlingListener(new RecyclerView.OnFlingListener() {
205
        categorizados.setOnFlingListener(new RecyclerView.OnFlingListener() {
Línea 196... Línea 206...
196
            @Override
206
            @Override
197
            public boolean onFling(int velocityX, int velocityY) {
207
            public boolean onFling(int velocityX, int velocityY) {
198
 
208
 
199
                if (categorizados.canScrollVertically(-1) ) {
209
                if (categorizados.canScrollVertically(-1) ) {
200
 
210
 
201
                    Log.e("Se activa", "On fling");
211
                   // Log.e("Se activa", "On fling");
Línea 236... Línea 246...
236
    public void onResume() {
246
    public void onResume() {
237
        super.onResume();
247
        super.onResume();
238
        loadContinuecard();
248
        loadContinuecard();
239
    }
249
    }
Línea 240... Línea -...
240
 
-
 
241
 
-
 
242
 
250
 
243
    @Override
251
    @Override
244
    public void onHiddenChanged(boolean hidden) {
252
    public void onHiddenChanged(boolean hidden) {
Línea 245... Línea 253...
245
        super.onHiddenChanged(hidden);
253
        super.onHiddenChanged(hidden);
Línea 246... Línea 254...
246
 
254
 
247
        Log.e("TAG", "onHiddenChanged : " + (hidden ? "true" : "false"));
255
       // Log.e("TAG", "onHiddenChanged : " + (hidden ? "true" : "false"));
Línea 248... Línea 256...
248
 
256
 
Línea 266... Línea 274...
266
        }
274
        }
267
    }
275
    }
Línea 268... Línea 276...
268
 
276
 
Línea 269... Línea 277...
269
    private void loadContinuecard(){
277
    private void loadContinuecard(){
Línea 270... Línea 278...
270
 
278
 
271
        Log.e("Cargo datos"," en tarjeta principal");
279
      //  Log.e("Cargo datos"," en tarjeta principal");
Línea 272... Línea 280...
272
 
280
 
273
        //Capsula de primera tarjeta
281
        //Capsula de primera tarjeta
Línea -... Línea 282...
-
 
282
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
-
 
283
 
274
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
284
        Progress progress;
275
 
285
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
276
        Progress progress;
286
 
277
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
287
        Capsule capsulafinal = null;
Línea 278... Línea 288...
278
 
288
 
Línea 279... Línea 289...
279
        List<Capsule> dbCapsules= capsuleDao.selectAll();
289
        List<Capsule> dbCapsules= capsuleDao.selectAll();
280
        for(Capsule dbCapsule : dbCapsules)
290
        for(Capsule dbCapsule : dbCapsules)
Línea 281... Línea 291...
281
        {
291
        {
282
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
292
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
283
 
293
 
284
            if (progress != null) {
294
            if (progress != null) {
285
 
295
 
286
                    if (progress.getProgress() < 100) {
296
                    if (progress.getProgress() < 100) {
Línea 287... Línea 297...
287
                        Log.e("Es menor"," a 100");
297
                    //    Log.e("Es menor"," a 100");
288
 
-
 
Línea 289... Línea 298...
289
                        titulotarjeta.setText(dbCapsule.getName());
298
 
Línea 290... Línea 299...
290
                        progresotarjeta.setVisibility(View.VISIBLE);
299
                        titulotarjeta.setText(dbCapsule.getName());
291
                        progresoporcentaje.setVisibility(View.VISIBLE);
300
                        progresotarjeta.setVisibility(View.VISIBLE);
Línea 335... Línea 344...
335
 
344
 
Línea 336... Línea 345...
336
        }
345
        }
337
 
346
 
338
        if(titulotarjeta.getText().equals(""))
347
        if(titulotarjeta.getText().equals(""))
Línea 339... Línea 348...
339
        {
348
        {
340
            Log.e("Nombre","vacio");
349
           // Log.e("Nombre","vacio");
Línea 341... Línea 350...
341
 
350
 
Línea 347... Línea 356...
347
 
356
 
Línea 348... Línea 357...
348
                progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
357
                progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
Línea 349... Línea 358...
349
 
358
 
Línea 350... Línea 359...
350
                if (progress == null) {
359
                if (progress == null) {
351
 
360
 
352
                        Log.e("Es nueva","");
361
                      //  Log.e("Es nueva","");
353
 
362
 
354
                        titulotarjeta.setText(dbCapsule.getName());
363
                        titulotarjeta.setText(dbCapsule.getName());
Línea 355... Línea 364...
355
                        progresotarjeta.setVisibility(View.INVISIBLE);
364
                        progresotarjeta.setVisibility(View.INVISIBLE);
356
                        progresoporcentaje.setVisibility(View.INVISIBLE);
-
 
Línea 357... Línea 365...
357
                        empezar.setText("Nueva");
365
                        progresoporcentaje.setVisibility(View.INVISIBLE);
Línea 358... Línea 366...
358
                        continuar.setText("Ver cápsula");
366
                        empezar.setText("Nueva");
359
 
367
                        continuar.setText("Ver cápsula");
360
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
368
 
361
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
369
                        capsulafinal=dbCapsule;
Línea 457... Línea 465...
457
 
465
 
Línea -... Línea 466...
-
 
466
 
Línea 458... Línea 467...
458
 
467
        }
Línea -... Línea 468...
-
 
468
 
-
 
469
 
-
 
470
        Capsule finalCapsulafinal = capsulafinal;
-
 
471
 
459
        }
472
        continuar.setOnClickListener(v -> {
460
 
473
 
Línea 461... Línea 474...
461
 
474
            iTwoGetSkills.getPreference().setCapsuleUuidActive(finalCapsulafinal.getUuid());
Línea 522... Línea 535...
522
                    capsule.setProgress(progress.getProgress());
535
                    capsule.setProgress(progress.getProgress());
Línea 523... Línea 536...
523
 
536
 
524
                    m_li.put("view", String.valueOf(progress.getViewSlides()));
537
                    m_li.put("view", String.valueOf(progress.getViewSlides()));
525
                    m_li.put("total", String.valueOf(progress.getTotalSlides()));
538
                    m_li.put("total", String.valueOf(progress.getTotalSlides()));
-
 
539
                    m_li.put("progress", String.valueOf(progress.getProgress()));
Línea 526... Línea 540...
526
                    m_li.put("progress", String.valueOf(progress.getProgress()));
540
                    m_li.put("completado",String.valueOf(progress.getCompleted()));
Línea 527... Línea 541...
527
 
541
 
528
                }
542
                }
Línea 538... Línea 552...
538
 
552
 
Línea 539... Línea 553...
539
                List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
553
                List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
Línea 540... Línea 554...
540
 
554
 
541
                if (slides.isEmpty()) {
555
                if (slides.isEmpty()) {
542
 
556
 
Línea 543... Línea 557...
543
                    Log.e("Capsula","Es omitida, no tiene slides");
557
                  //  Log.e("Capsula","Es omitida, no tiene slides");
544
                } else {
558
                } else {
Línea 552... Línea 566...
552
                                capsuleList.add(m_li);
566
                                capsuleList.add(m_li);
553
                            }
567
                            }
Línea 554... Línea 568...
554
 
568
 
Línea 555... Línea 569...
555
                        }
569
                        }
Línea 556... Línea 570...
556
 
570
 
557
                    } else if (tabposition.equals("cursando") && progress != null && progress.getProgress() < 100) {
571
                    } else if (tabposition.equals("cursando") && progress != null && progress.getProgress() < 100 && capsule.getCompleted()==0) {
Línea 558... Línea 572...
558
 
572
 
Línea 564... Línea 578...
564
                                capsuleList.add(m_li);
578
                                capsuleList.add(m_li);
565
                            }
579
                            }
Línea 566... Línea 580...
566
 
580
 
Línea 567... Línea 581...
567
                        }
581
                        }
Línea 568... Línea 582...
568
 
582
 
-
 
583
                    } else if (tabposition.equals("finalizados") && progress != null && progress.getProgress() >= 100 && capsule.getCompleted()==1) {
569
                    } else if (tabposition.equals("finalizados") && progress != null && progress.getProgress() >= 100) {
584
 
Línea 570... Línea 585...
570
 
585
                        if (buscar.equals("")) {
571
                        if (buscar.equals("")) {
586
                            //capsule.getCompleted();
572
                            capsuleList.add(m_li);
587
                            capsuleList.add(m_li);
Línea 588... Línea 603...
588
        }
603
        }
Línea 589... Línea 604...
589
 
604
 
Línea -... Línea 605...
-
 
605
    }
-
 
606
 
-
 
607
 
-
 
608
    @Override
-
 
609
    public void onItemClick(int position, View v) {
-
 
610
 
-
 
611
        Log.e("Evento","del click"+position);
-
 
612
 
-
 
613
        //Cambio de livedata en el Slide cuando se va alla.
-
 
614
        SlideRefreshUIViewData slideRefreshUIViewData = mSlideRefreshUi.getSlideRefreshUIViewData();
-
 
615
 
-
 
616
 
-
 
617
        slideRefreshUIViewData.setCapsuleUuidActiveViewData(capsuleList.get(position).get("uuid"));
-
 
618
 
-
 
619
        iTwoGetSkills.getPreference().setCapsuleUuidActive(capsuleList.get(position).get("uuid"));
-
 
620
        iTwoGetSkills.getPreference().setTopicUuidActive(capsuleList.get(position).get("topicuuid"));
-
 
621
        iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
-
 
622
 
590
    }
623
       // Log.e("Capsula","topic active"+mDataSet.get(viewHolder.getAbsoluteAdapterPosition()).get("topicuuid"));
591
 
624