Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2 gabriel 1
package com.cesams.twogetskills.fragment;
2
 
3
import android.os.Bundle;
4
 
11 gabriel 5
import androidx.annotation.NonNull;
2 gabriel 6
import androidx.fragment.app.Fragment;
7
import androidx.lifecycle.LifecycleOwner;
17 gabriel 8
import androidx.lifecycle.ViewModelProvider;
2 gabriel 9
import androidx.recyclerview.widget.GridLayoutManager;
10
import androidx.recyclerview.widget.RecyclerView;
11
 
13 gabriel 12
import android.text.Editable;
13
import android.text.TextWatcher;
2 gabriel 14
import android.util.Log;
15
import android.view.LayoutInflater;
11 gabriel 16
import android.view.MotionEvent;
2 gabriel 17
import android.view.View;
18
import android.view.ViewGroup;
11 gabriel 19
import android.widget.AdapterView;
9 gabriel 20
import android.widget.Button;
8 gabriel 21
import android.widget.EditText;
9 gabriel 22
import android.widget.ImageView;
23
import android.widget.ProgressBar;
2 gabriel 24
import android.widget.TextView;
25
 
9 gabriel 26
import com.bumptech.glide.Glide;
27
import com.bumptech.glide.load.engine.DiskCacheStrategy;
28
import com.bumptech.glide.load.model.GlideUrl;
29
import com.bumptech.glide.load.model.LazyHeaders;
30
import com.bumptech.glide.request.RequestOptions;
31
import com.cesams.twogetskills.Constants;
2 gabriel 32
import com.cesams.twogetskills.R;
33
import com.cesams.twogetskills.adapter.CapsuleListViewAdapter;
4 gabriel 34
import com.cesams.twogetskills.adapter.TabsCapsulesAdapter;
2 gabriel 35
import com.cesams.twogetskills.dao.CapsuleDao;
36
import com.cesams.twogetskills.dao.ProgressDao;
16 gabriel 37
import com.cesams.twogetskills.dao.SlideDao;
2 gabriel 38
import com.cesams.twogetskills.dao.TopicDao;
39
import com.cesams.twogetskills.entity.Capsule;
40
import com.cesams.twogetskills.entity.Progress;
16 gabriel 41
import com.cesams.twogetskills.entity.Slide;
2 gabriel 42
import com.cesams.twogetskills.entity.Topic;
9 gabriel 43
import com.cesams.twogetskills.library.MD5;
21 gabriel 44
import com.cesams.twogetskills.room.ResultCount;
2 gabriel 45
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
17 gabriel 46
import com.cesams.twogetskills.viewdata.SlideRefreshUIViewData;
47
import com.cesams.twogetskills.viewmodel.SlideRefreshUIViewModel;
12 gabriel 48
import com.google.android.material.tabs.TabLayout;
2 gabriel 49
 
21 gabriel 50
import java.text.Normalizer;
2 gabriel 51
import java.util.ArrayList;
9 gabriel 52
import java.util.Calendar;
21 gabriel 53
import java.util.Collections;
2 gabriel 54
import java.util.HashMap;
55
import java.util.List;
9 gabriel 56
import java.util.Random;
57
import java.util.TimeZone;
2 gabriel 58
 
59
/**
60
 * A simple {@link Fragment} subclass.
61
 * Use the {@link WelcomeFragment#newInstance} factory method to
62
 * create an instance of this fragment.
63
 */
17 gabriel 64
public class WelcomeFragment extends Fragment implements TabsCapsulesAdapter.ClickListener, LifecycleOwner {
2 gabriel 65
 
10 gabriel 66
    TextView username, titulotarjeta, progresoporcentaje, empezar; ProgressBar progresotarjeta;
9 gabriel 67
    private ITwoGetSkills iTwoGetSkills; View card;
2 gabriel 68
    ArrayList<HashMap<String, String>> capsuleList;
11 gabriel 69
    ImageView imagetarjeta;
70
    TabsCapsulesAdapter adapter2;
71
    RecyclerView categorizados;
9 gabriel 72
    EditText busqueda; TextView textowelcome; Button continuar;
17 gabriel 73
    TabLayout tabs; String tabactual="pendientes";     private SlideRefreshUIViewModel mSlideRefreshUi;
2 gabriel 74
 
17 gabriel 75
 
2 gabriel 76
    public WelcomeFragment() {
77
        // Required empty public constructor
78
    }
79
 
80
    public static WelcomeFragment newInstance() {
81
        WelcomeFragment fragment = new WelcomeFragment();
82
        return fragment;
83
    }
84
 
85
    @Override
86
    public void onCreate(Bundle savedInstanceState) {
87
        super.onCreate(savedInstanceState);
88
          }
89
 
90
    @Override
91
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
92
                             Bundle savedInstanceState) {
93
 
8 gabriel 94
 
2 gabriel 95
        iTwoGetSkills = (ITwoGetSkills) getActivity();
8 gabriel 96
        iTwoGetSkills.showNavigationAndToolbar();
2 gabriel 97
 
98
        View view= inflater.inflate(R.layout.fragment_welcome, container, false);
99
 
100
        username=view.findViewById(R.id.textView14);
8 gabriel 101
        textowelcome= view.findViewById(R.id.textView15);
102
        busqueda=view.findViewById(R.id.busqueda);
12 gabriel 103
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.titlenotifi); tabs=view.findViewById(R.id.tabLayout);
8 gabriel 104
        capsuleList = new ArrayList<>();
2 gabriel 105
 
17 gabriel 106
 
107
        mSlideRefreshUi = new ViewModelProvider(requireActivity()).get(SlideRefreshUIViewModel.class);
108
 
109
 
110
 
111
 
9 gabriel 112
        //Tarjeta Principal
11 gabriel 113
        titulotarjeta = view.findViewById(R.id.description); progresotarjeta= view.findViewById(R.id.progressBar2); imagetarjeta= view.findViewById(R.id.imagelist);
9 gabriel 114
        continuar = view.findViewById(R.id.button); progresoporcentaje = view.findViewById(R.id.textView16);
115
 
116
 
2 gabriel 117
        username.setText("¡Hola, "+(iTwoGetSkills.getPreference().getFirstName() +"!"));
118
 
12 gabriel 119
        tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
120
            @Override
121
            public void onTabSelected(TabLayout.Tab tab) {
122
                int position=tab.getPosition();
2 gabriel 123
 
12 gabriel 124
                capsuleList.clear();
125
                adapter2.notifyDataSetChanged();
2 gabriel 126
 
12 gabriel 127
                if(position==0)
128
                {
13 gabriel 129
                    tabactual="pendientes";
130
                    loadData(tabactual,"");
12 gabriel 131
                    adapter2.notifyDataSetChanged();
132
                }
133
                else if(position==1)
134
                {
13 gabriel 135
                    tabactual="cursando";
136
                    loadData("cursando","");
12 gabriel 137
                    adapter2.notifyDataSetChanged();
138
                }
139
                else if(position==2)
140
                {
13 gabriel 141
                    tabactual="finalizados";
142
                    loadData("finalizados","");
12 gabriel 143
                    adapter2.notifyDataSetChanged();
144
                }
145
            }
146
 
147
            @Override
148
            public void onTabUnselected(TabLayout.Tab tab) {
149
 
150
            }
151
 
152
            @Override
153
            public void onTabReselected(TabLayout.Tab tab) {
154
 
155
            }
156
        });
157
 
13 gabriel 158
        loadData("pendientes","");
12 gabriel 159
 
8 gabriel 160
        busqueda.setOnFocusChangeListener(new View.OnFocusChangeListener() {
161
            @Override
162
            public void onFocusChange(View v, boolean hasFocus) {
163
                if(hasFocus)
164
                {
9 gabriel 165
                        card.setVisibility(View.GONE);
8 gabriel 166
                        username.setVisibility(View.GONE);
167
                        textowelcome.setVisibility(View.GONE);
168
                }
169
 
170
            }
171
        });
172
 
13 gabriel 173
        busqueda.addTextChangedListener(new TextWatcher() {
174
            @Override
175
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
8 gabriel 176
 
13 gabriel 177
            }
178
 
179
            @Override
180
            public void onTextChanged(CharSequence s, int start, int before, int count) {
17 gabriel 181
            //    Log.e("El texto","buscado: "+s);
13 gabriel 182
                capsuleList.clear();
183
                adapter2.notifyDataSetChanged();
184
                loadData(tabactual, s.toString());
185
            }
186
 
187
            @Override
188
            public void afterTextChanged(Editable s) {
189
 
190
 
191
 
192
            }
193
        });
194
 
195
 
4 gabriel 196
        adapter2 = new TabsCapsulesAdapter(getContext(),capsuleList);
2 gabriel 197
 
198
 
199
 
4 gabriel 200
        categorizados = view.findViewById(R.id.categorizados);
201
        GridLayoutManager layoutcategoria = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
202
        categorizados.setLayoutManager(layoutcategoria);
203
        categorizados.setAdapter(adapter2);
204
 
11 gabriel 205
 
17 gabriel 206
        adapter2.setClickListener(this);
11 gabriel 207
 
8 gabriel 208
        categorizados.setOnFlingListener(new RecyclerView.OnFlingListener() {
209
            @Override
210
            public boolean onFling(int velocityX, int velocityY) {
211
 
212
                if (categorizados.canScrollVertically(-1) ) {
213
 
17 gabriel 214
                   // Log.e("Se activa", "On fling");
9 gabriel 215
                    card.setVisibility(View.GONE);
8 gabriel 216
                    username.setVisibility(View.GONE);
217
                    textowelcome.setVisibility(View.GONE);
218
                }else
219
                {
9 gabriel 220
                    card.setVisibility(View.VISIBLE);
8 gabriel 221
                    username.setVisibility(View.VISIBLE);
222
                    textowelcome.setVisibility(View.VISIBLE);
223
                }
224
 
225
                return false;
226
            }
227
        });
228
 
11 gabriel 229
 
8 gabriel 230
     /*   categorizados.setOnScrollChangeListener(new View.OnScrollChangeListener() {
231
            @Override
232
            public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
233
 
234
                if (!categorizados.canScrollVertically(-1)) {
235
                 //   Toast.makeText(getActivity(), "Last", Toast.LENGTH_LONG).show();
236
                    capsulas.setVisibility(View.VISIBLE);
237
                    username.setVisibility(View.VISIBLE);
238
                    textowelcome.setVisibility(View.VISIBLE);
239
                    Log.e("On scroll"," se activa");
240
                }
241
 
242
            }
243
        });
244
*/
21 gabriel 245
 
246
        getActivity().runOnUiThread(() -> {
247
            String message = capsuleList.size() == 1
248
                    ? "Hay 1 cápsula nueva disponible"
249
                    : "Tiene " + capsuleList.size() + " cápsulas pendientes para ver";
250
 
251
            iTwoGetSkills.showMessageSnackBarWithClose(message);
252
 
253
        });
2 gabriel 254
        return view;
255
    }
256
 
9 gabriel 257
    @Override
258
    public void onResume() {
259
        super.onResume();
260
        loadContinuecard();
261
    }
2 gabriel 262
 
9 gabriel 263
    @Override
264
    public void onHiddenChanged(boolean hidden) {
265
        super.onHiddenChanged(hidden);
266
 
17 gabriel 267
       // Log.e("TAG", "onHiddenChanged : " + (hidden ? "true" : "false"));
9 gabriel 268
 
269
        if(!hidden) {
16 gabriel 270
            Log.e("Esta oculto", "el fragmento");
271
 
272
            getActivity().runOnUiThread(() -> {
273
 
274
                capsuleList.clear();
275
 
276
                loadContinuecard();
277
                loadData("pendientes","");
278
 
279
                adapter2.notifyDataSetChanged();
280
 
281
                tabs.getTabAt(0).select();
282
 
283
            });
284
 
285
 
9 gabriel 286
        }
287
    }
288
 
289
    private void loadContinuecard(){
290
 
17 gabriel 291
      //  Log.e("Cargo datos"," en tarjeta principal");
9 gabriel 292
 
293
        //Capsula de primera tarjeta
294
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
295
 
296
        Progress progress;
297
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
298
 
17 gabriel 299
        Capsule capsulafinal = null;
300
 
9 gabriel 301
        List<Capsule> dbCapsules= capsuleDao.selectAll();
302
        for(Capsule dbCapsule : dbCapsules)
303
        {
304
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
305
 
306
            if (progress != null) {
307
 
10 gabriel 308
                    if (progress.getProgress() < 100) {
17 gabriel 309
                    //    Log.e("Es menor"," a 100");
9 gabriel 310
 
311
                        titulotarjeta.setText(dbCapsule.getName());
10 gabriel 312
                        progresotarjeta.setVisibility(View.VISIBLE);
313
                        progresoporcentaje.setVisibility(View.VISIBLE);
9 gabriel 314
                        progresotarjeta.setProgress((int) progress.getProgress());
315
                        progresoporcentaje.setText("" + progress.getProgress() + " %");
10 gabriel 316
                        empezar.setText("En curso");
9 gabriel 317
 
17 gabriel 318
                        capsulafinal=dbCapsule;
9 gabriel 319
 
320
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
321
 
322
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
323
                            Calendar calendar = Calendar.getInstance(timeZone);
324
                            TimeZone tz = calendar.getTimeZone();
325
                            int created = (int) (calendar.getTimeInMillis() / 1000);
326
 
327
                            Random random = new Random(created);
328
                            int rand = 1000 + random.nextInt(8999);
329
 
330
 
331
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
332
                            String password = iTwoGetSkills.getPreference().getPassword();
333
 
334
 
335
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
336
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
337
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
338
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
339
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
340
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
341
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
342
                                    .build());
343
 
344
                            RequestOptions options = new RequestOptions()
345
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
346
 
347
                            Glide.with(getContext()).load(url)
348
                                    .thumbnail()
349
                                    .apply(options)
350
                                    .into(imagetarjeta);
351
                        }
352
                    }
353
 
10 gabriel 354
            }
355
 
356
 
357
        }
358
 
359
        if(titulotarjeta.getText().equals(""))
360
        {
17 gabriel 361
           // Log.e("Nombre","vacio");
10 gabriel 362
 
363
            //Despues del recorrido no se encontro progreso en ninguna capsula, por lo cual la tarjeta queda vacia
364
            // vamos a llenarla con la ultima capsula, que debe ser nueva al no tener progreso
365
 
366
            for(Capsule dbCapsule : dbCapsules)
367
            {
368
 
369
                progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
370
 
371
                if (progress == null) {
372
 
17 gabriel 373
                      //  Log.e("Es nueva","");
10 gabriel 374
 
375
                        titulotarjeta.setText(dbCapsule.getName());
376
                        progresotarjeta.setVisibility(View.INVISIBLE);
377
                        progresoporcentaje.setVisibility(View.INVISIBLE);
378
                        empezar.setText("Nueva");
379
                        continuar.setText("Ver cápsula");
380
 
17 gabriel 381
                        capsulafinal=dbCapsule;
10 gabriel 382
 
17 gabriel 383
                    if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
10 gabriel 384
 
385
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
386
                            Calendar calendar = Calendar.getInstance(timeZone);
387
                            TimeZone tz = calendar.getTimeZone();
388
                            int created = (int) (calendar.getTimeInMillis() / 1000);
389
 
390
                            Random random = new Random(created);
391
                            int rand = 1000 + random.nextInt(8999);
392
 
393
 
394
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
395
                            String password = iTwoGetSkills.getPreference().getPassword();
396
 
397
 
398
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
399
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
400
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
401
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
402
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
403
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
404
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
405
                                    .build());
406
 
407
                            RequestOptions options = new RequestOptions()
408
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
409
 
410
                            Glide.with(getContext()).load(url)
411
                                    .thumbnail()
412
                                    .apply(options)
413
                                    .into(imagetarjeta);
414
                        }
415
 
416
                    }
417
 
418
                /*
419
                if (progress != null) {
420
 
421
                    double progre = progress.getProgress();
422
 
423
                    if (progre >= 100) {
424
                        Log.e("Es mayor"," a 100");
425
 
426
                    } else {
427
 
428
                        Log.e("Es nueva","");
429
 
430
                        titulotarjeta.setText(dbCapsule.getName());
431
                        progresotarjeta.setVisibility(View.INVISIBLE);
432
                        progresoporcentaje.setVisibility(View.INVISIBLE);
433
                        empezar.setText("Nueva");
434
                        continuar.setText("Ver cápsula");
435
 
436
                        iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
437
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
438
 
439
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
440
 
441
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
442
                            Calendar calendar = Calendar.getInstance(timeZone);
443
                            TimeZone tz = calendar.getTimeZone();
444
                            int created = (int) (calendar.getTimeInMillis() / 1000);
445
 
446
                            Random random = new Random(created);
447
                            int rand = 1000 + random.nextInt(8999);
448
 
449
 
450
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
451
                            String password = iTwoGetSkills.getPreference().getPassword();
452
 
453
 
454
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
455
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
456
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
457
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
458
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
459
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
460
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
461
                                    .build());
462
 
463
                            RequestOptions options = new RequestOptions()
464
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
465
 
466
                            Glide.with(getContext()).load(url)
467
                                    .thumbnail()
468
                                    .apply(options)
469
                                    .into(imagetarjeta);
470
                        }
471
 
472
                    }
9 gabriel 473
                }
10 gabriel 474
*/
475
            }
9 gabriel 476
 
10 gabriel 477
 
478
 
9 gabriel 479
        }
480
 
10 gabriel 481
 
17 gabriel 482
        Capsule finalCapsulafinal = capsulafinal;
10 gabriel 483
 
9 gabriel 484
        continuar.setOnClickListener(v -> {
485
 
17 gabriel 486
            iTwoGetSkills.getPreference().setCapsuleUuidActive(finalCapsulafinal.getUuid());
487
            iTwoGetSkills.getPreference().setTopicUuidActive(finalCapsulafinal.getTopicUuid());
18 gabriel 488
            iTwoGetSkills.getPreference().setOrigennavigation("welcome");
489
            Log.e("Guardo",""+iTwoGetSkills.getPreference().getOrigenNavigation());
17 gabriel 490
 
9 gabriel 491
            iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
492
        });
493
 
494
        //Fin de primer tarjeta
495
 
496
    }
497
 
13 gabriel 498
    private void loadData(String tabposition, String buscar)
2 gabriel 499
    {
500
 
12 gabriel 501
 
2 gabriel 502
        TopicDao topicDao = iTwoGetSkills.getDatabase().getTopicDao();
503
        ArrayList<Topic> dbTopics = (ArrayList<Topic>) topicDao.selectAll();
504
 
505
        List<Capsule> dbCapsules;
506
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
507
 
9 gabriel 508
 
509
 
510
 
2 gabriel 511
        for (Topic dbTopic : dbTopics) {
512
 
513
            dbCapsules = capsuleDao.selectAllByTopicUuid(dbTopic.getUuid());
514
 
9 gabriel 515
 
2 gabriel 516
            Capsule capsule;
517
            Progress progress;
518
            ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
16 gabriel 519
            SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
2 gabriel 520
 
521
            HashMap<String, String> m_li;
522
 
9 gabriel 523
 
524
 
16 gabriel 525
            for(Capsule dbCapsule : dbCapsules) {
2 gabriel 526
                capsule = new Capsule();
527
                capsule.setTopicUuid(dbCapsule.getTopicUuid());
528
                capsule.setUuid(dbCapsule.getUuid());
529
                capsule.setName(dbCapsule.getName());
530
                capsule.setDescription(dbCapsule.getDescription());
531
                capsule.setImage(dbCapsule.getImage());
532
                capsule.setPosition(dbCapsule.getPosition());
533
 
534
 
535
                m_li = new HashMap<>();
536
 
537
 
538
                //m_li.put("copyright",copy);
539
 
540
 
541
                progress = progressDao.selectByCapsuleUuid(capsule.getUuid());
16 gabriel 542
                if (progress != null) {
543
                    capsule.setCompleted(progress.getCompleted());
2 gabriel 544
                    capsule.setViewSlides(progress.getViewSlides());
545
 
16 gabriel 546
                    capsule.setTotalSlides(progress.getTotalSlides());
2 gabriel 547
                    capsule.setProgress(progress.getProgress());
548
 
21 gabriel 549
                    Log.e("Agregado en"," "+progress.getAddedOn());
550
                   // m_li.put("addedon",progress.getAddedOn());
2 gabriel 551
                    m_li.put("view", String.valueOf(progress.getViewSlides()));
552
                    m_li.put("total", String.valueOf(progress.getTotalSlides()));
553
                    m_li.put("progress", String.valueOf(progress.getProgress()));
17 gabriel 554
                    m_li.put("completado",String.valueOf(progress.getCompleted()));
16 gabriel 555
 
18 gabriel 556
                    if(progress.getCompleted()==0)
557
                    {
558
                        Log.e("Capsula"+capsule.getName()," NO completa");
559
                    }
560
 
2 gabriel 561
                }
562
 
16 gabriel 563
                m_li.put("imagen", capsule.getImage());
564
                m_li.put("nombre", capsule.getName());
565
                m_li.put("uuid", capsule.getUuid());
566
                m_li.put("topicuuid", capsule.getTopicUuid());
567
                m_li.put("description", capsule.getDescription());
2 gabriel 568
 
569
 
13 gabriel 570
                //Lleno la lista segun el requerimiento de filtro accionado por el usuario
571
 
16 gabriel 572
                List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
2 gabriel 573
 
16 gabriel 574
                if (slides.isEmpty()) {
12 gabriel 575
 
17 gabriel 576
                  //  Log.e("Capsula","Es omitida, no tiene slides");
16 gabriel 577
                } else {
18 gabriel 578
 
579
 
16 gabriel 580
                    if (tabposition.equals("pendientes") && progress == null) {
581
 
582
                        if (buscar.equals("")) {
13 gabriel 583
                            capsuleList.add(m_li);
584
 
21 gabriel 585
 
16 gabriel 586
                        } else {
21 gabriel 587
                            String nombre= capsule.getName();
588
                            String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
589
                            normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
590
                            if (normalizada.matches("(?i).*" + buscar + ".*")) {
16 gabriel 591
                                capsuleList.add(m_li);
592
                            }
13 gabriel 593
 
16 gabriel 594
                        }
12 gabriel 595
 
18 gabriel 596
                    } else if (tabposition.equals("cursando") && progress != null && progress.getProgress() <= 100 && progress.getCompleted()==0) {
12 gabriel 597
 
16 gabriel 598
                        if (buscar.equals("")) {
13 gabriel 599
                            capsuleList.add(m_li);
16 gabriel 600
 
601
                        } else {
21 gabriel 602
                            String nombre= capsule.getName();
603
                            String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
604
                            normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
605
                            if (normalizada.matches("(?i).*" + buscar + ".*")) {
16 gabriel 606
                                capsuleList.add(m_li);
607
                            }
608
 
13 gabriel 609
                        }
610
 
18 gabriel 611
                    } else if (tabposition.equals("finalizados") && progress != null && progress.getProgress() >= 100 && progress.getCompleted()==1) {
13 gabriel 612
 
16 gabriel 613
                        if (buscar.equals("")) {
17 gabriel 614
                            //capsule.getCompleted();
16 gabriel 615
                            capsuleList.add(m_li);
2 gabriel 616
 
16 gabriel 617
                        } else {
21 gabriel 618
                            String nombre= capsule.getName();
619
                            String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
620
                            normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
621
                            if (normalizada.matches("(?i).*" + buscar + ".*")) {
16 gabriel 622
                                capsuleList.add(m_li);
623
                            }
2 gabriel 624
 
13 gabriel 625
                        }
626
 
627
                    }
628
 
12 gabriel 629
                }
2 gabriel 630
 
12 gabriel 631
            }
2 gabriel 632
 
12 gabriel 633
 
2 gabriel 634
        }
635
 
21 gabriel 636
 
2 gabriel 637
    }
638
 
639
 
17 gabriel 640
    @Override
641
    public void onItemClick(int position, View v) {
642
 
643
        Log.e("Evento","del click"+position);
644
 
645
        //Cambio de livedata en el Slide cuando se va alla.
646
        SlideRefreshUIViewData slideRefreshUIViewData = mSlideRefreshUi.getSlideRefreshUIViewData();
647
 
648
 
649
        slideRefreshUIViewData.setCapsuleUuidActiveViewData(capsuleList.get(position).get("uuid"));
650
 
651
        iTwoGetSkills.getPreference().setCapsuleUuidActive(capsuleList.get(position).get("uuid"));
652
        iTwoGetSkills.getPreference().setTopicUuidActive(capsuleList.get(position).get("topicuuid"));
653
        iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
654
 
18 gabriel 655
        iTwoGetSkills.getPreference().setOrigennavigation("welcome");
656
        Log.e("Completada",""+capsuleList.get(position).get("completado"));
657
 
17 gabriel 658
       // Log.e("Capsula","topic active"+mDataSet.get(viewHolder.getAbsoluteAdapterPosition()).get("topicuuid"));
659
 
660
    }
2 gabriel 661
}