Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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

Rev 67 Rev 71
Línea 1... Línea 1...
1
package com.cesams.twogetskills.fragment;
1
package com.cesams.twogetskills.fragment;
Línea 2... Línea 2...
2
 
2
 
Línea -... Línea 3...
-
 
3
import android.os.Bundle;
3
import android.os.Bundle;
4
 
4
 
5
import androidx.annotation.Nullable;
-
 
6
import androidx.fragment.app.Fragment;
-
 
7
import androidx.lifecycle.LifecycleOwner;
5
import androidx.fragment.app.Fragment;
8
import androidx.lifecycle.Observer;
6
import androidx.lifecycle.LifecycleOwner;
9
import androidx.lifecycle.ViewModelProvider;
Línea 7... Línea 10...
7
import androidx.recyclerview.widget.GridLayoutManager;
10
import androidx.recyclerview.widget.GridLayoutManager;
8
import androidx.recyclerview.widget.RecyclerView;
11
import androidx.recyclerview.widget.RecyclerView;
Línea 18... Línea 21...
18
import android.widget.ImageView;
21
import android.widget.ImageView;
19
import android.widget.ProgressBar;
22
import android.widget.ProgressBar;
20
import android.widget.TextView;
23
import android.widget.TextView;
21
import android.widget.Toast;
24
import android.widget.Toast;
Línea 22... Línea -...
22
 
-
 
23
import com.bumptech.glide.Glide;
-
 
24
import com.bumptech.glide.load.engine.DiskCacheStrategy;
-
 
25
import com.bumptech.glide.load.model.GlideUrl;
-
 
26
import com.bumptech.glide.load.model.LazyHeaders;
-
 
-
 
25
 
27
import com.bumptech.glide.request.RequestOptions;
26
 
28
import com.cesams.twogetskills.Constants;
27
import com.cesams.twogetskills.Constants;
29
import com.cesams.twogetskills.R;
28
import com.cesams.twogetskills.R;
30
import com.cesams.twogetskills.adapter.TabsCapsulesAdapter;
29
import com.cesams.twogetskills.adapter.MyCapsulesAdapter;
31
import com.cesams.twogetskills.dao.CapsuleDao;
30
import com.cesams.twogetskills.dao.CapsuleDao;
32
import com.cesams.twogetskills.dao.ProgressDao;
31
import com.cesams.twogetskills.dao.ProgressDao;
33
import com.cesams.twogetskills.dao.SlideDao;
-
 
34
import com.cesams.twogetskills.dao.TopicDao;
32
import com.cesams.twogetskills.dao.SlideDao;
35
import com.cesams.twogetskills.entity.Capsule;
33
import com.cesams.twogetskills.entity.Capsule;
36
import com.cesams.twogetskills.entity.Progress;
34
import com.cesams.twogetskills.entity.Progress;
37
import com.cesams.twogetskills.entity.Slide;
-
 
38
import com.cesams.twogetskills.entity.Topic;
35
import com.cesams.twogetskills.entity.Slide;
39
import com.cesams.twogetskills.library.MD5;
36
import com.cesams.twogetskills.library.ImageService;
-
 
37
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
-
 
38
import com.cesams.twogetskills.viewmodel.MyCapsulesInProgressViewModel;
40
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
39
import com.cesams.twogetskills.viewmodel.MyCapsulesViewModel;
Línea 41... Línea 40...
41
import com.google.android.material.tabs.TabLayout;
40
import com.google.android.material.tabs.TabLayout;
42
 
41
 
43
import java.text.Normalizer;
-
 
44
import java.util.ArrayList;
-
 
45
import java.util.Calendar;
42
import java.text.DecimalFormat;
46
import java.util.HashMap;
-
 
47
import java.util.List;
43
import java.util.ArrayList;
Línea 48... Línea -...
48
import java.util.Random;
-
 
49
import java.util.TimeZone;
-
 
50
 
-
 
51
/**
-
 
52
 * A simple {@link Fragment} subclass.
-
 
53
 * Use the {@link WelcomeFragment#newInstance} factory method to
-
 
54
 * create an instance of this fragment.
-
 
55
 */
-
 
56
public class WelcomeFragment extends Fragment implements TabsCapsulesAdapter.ClickListener, LifecycleOwner {
-
 
57
 
-
 
58
    TextView username, titulotarjeta, progresoporcentaje, empezar, ningunelemento; ProgressBar progresotarjeta;
-
 
59
    private ITwoGetSkills iTwoGetSkills; View card;
-
 
60
    ArrayList<HashMap<String, String>> capsuleList;
-
 
61
    ImageView imagetarjeta;
-
 
62
    TabsCapsulesAdapter adapter2;
-
 
Línea -... Línea 44...
-
 
44
import java.util.List;
-
 
45
import org.apache.commons.lang3.StringUtils;
-
 
46
 
-
 
47
 
-
 
48
 
-
 
49
public class MyCapsulesFragment extends Fragment implements MyCapsulesAdapter.ClickListener, LifecycleOwner {
-
 
50
 
63
    RecyclerView categorizados;
51
    private ITwoGetSkills iTwoGetSkills;
-
 
52
    private TextView textViewHelloUsername;
64
    EditText busqueda; TextView textowelcome; Button continuar;
53
    private EditText editTextSearch;
-
 
54
    private TextView textViewWelcome;
-
 
55
    private RecyclerView recyclerViewCapsules;
-
 
56
    private TabLayout tabLayout;
-
 
57
    private MyCapsulesAdapter myCapsulesAdapter;
-
 
58
    private TextView textViewListingEmpty;
-
 
59
    private MyCapsulesViewModel myCapsulesViewModel;
-
 
60
    private MyCapsulesInProgressViewModel myCapsulesInProgressViewModel;
-
 
61
 
-
 
62
    private View cardView;
-
 
63
    private TextView cardTextViewStatus;
65
    TabLayout tabs; String tabactual="pendientes";
64
    private TextView cardTextViewTitle;
-
 
65
    private ProgressBar cardProgressBar;
Línea 66... Línea -...
66
 
-
 
67
 
-
 
68
    public WelcomeFragment() {
-
 
69
        // Required empty public constructor
-
 
Línea 70... Línea 66...
70
    }
66
    private TextView cardTextViewProgress;
71
 
67
    private ImageView cardImageView;
72
    public static WelcomeFragment newInstance() {
68
    private Button cardButtonContinue;
-
 
69
 
-
 
70
    private DecimalFormat mDecimalFormat;
73
        WelcomeFragment fragment = new WelcomeFragment();
71
 
Línea 74... Línea 72...
74
        return fragment;
72
 
75
    }
73
    @Override
76
 
74
    public void onCreate(@Nullable Bundle savedInstanceState) {
Línea 77... Línea -...
77
    @Override
-
 
78
    public void onCreate(Bundle savedInstanceState) {
75
        super.onCreate(savedInstanceState);
Línea 79... Línea 76...
79
        super.onCreate(savedInstanceState);
76
 
-
 
77
        this.mDecimalFormat = new DecimalFormat("#.##");
Línea 80... Línea -...
80
          }
-
 
81
 
-
 
82
    @Override
-
 
83
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-
 
84
                             Bundle savedInstanceState) {
-
 
Línea -... Línea 78...
-
 
78
    }
-
 
79
 
-
 
80
    @Override
-
 
81
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-
 
82
                             Bundle savedInstanceState) {
-
 
83
 
-
 
84
        iTwoGetSkills = (ITwoGetSkills) getActivity();
Línea 85... Línea 85...
85
 
85
 
86
 
-
 
87
        iTwoGetSkills = (ITwoGetSkills) getActivity();
-
 
Línea -... Línea 86...
-
 
86
 
-
 
87
        View view = inflater.inflate(R.layout.fragment_my_capsules, container, false);
-
 
88
        textViewHelloUsername =view.findViewById(R.id.fragment_my_capsules_textview_hello_username);
-
 
89
 
-
 
90
 
-
 
91
        String helloUsername = StringUtils.replace(requireActivity().getString(R.string.my_capsules_hello), "%", iTwoGetSkills.getPreference().getFirstName());
-
 
92
        textViewHelloUsername .setText(helloUsername);
-
 
93
 
-
 
94
        textViewListingEmpty = view.findViewById(R.id.fragment_my_capsules_textview_listing_empty);
-
 
95
        textViewWelcome= view.findViewById(R.id.fragment_my_capsules_textview_welcome);
-
 
96
        editTextSearch=view.findViewById(R.id.fragment_my_capsules_edit_text_search);
-
 
97
        cardView = view.findViewById(R.id.fragment_my_capsules_include_cardview);
-
 
98
 
-
 
99
        //Tarjeta Principal
-
 
100
 
-
 
101
        cardTextViewStatus = view.findViewById(R.id.cardview_item_textview_status);
-
 
102
        cardTextViewTitle = view.findViewById(R.id.cardview_item_textview_title);
-
 
103
        cardImageView = view.findViewById(R.id.cardview_item_imageview);
-
 
104
        cardProgressBar = view.findViewById(R.id.cardview_item_progressbar);
-
 
105
        cardTextViewProgress = view.findViewById(R.id.cardview_item_textview_progress);
-
 
106
        cardButtonContinue = view.findViewById(R.id.cardview_item_button_continue);
-
 
107
        cardButtonContinue.setOnClickListener(new View.OnClickListener() {
-
 
108
            @Override
-
 
109
            public void onClick(View view) {
-
 
110
                if (!StringUtils.isEmpty(myCapsulesInProgressViewModel.getCapsule().getTopicUuid()) || !StringUtils.isEmpty(myCapsulesInProgressViewModel.getCapsule().getUuid())) {
-
 
111
                    iTwoGetSkills.changeCapsuleActiveSourceNavigationMyCapsules(myCapsulesInProgressViewModel.getCapsule().getTopicUuid(), myCapsulesInProgressViewModel.getCapsule().getUuid());
-
 
112
 
-
 
113
                }
-
 
114
            }
-
 
115
        });
-
 
116
 
-
 
117
 
-
 
118
 
-
 
119
        myCapsulesViewModel = new ViewModelProvider(requireActivity()).get(MyCapsulesViewModel.class);
-
 
120
        myCapsulesAdapter = new MyCapsulesAdapter(requireActivity(), myCapsulesViewModel.getCapsuleArrayList());
-
 
121
        myCapsulesAdapter.setClickListener(this);
-
 
122
 
-
 
123
        Observer<ArrayList<Capsule>> myCapsuleListUpdateObserver = new Observer<ArrayList<Capsule>>() {
-
 
124
            @Override
-
 
125
            public void onChanged(ArrayList<Capsule> capsuleList) {
-
 
126
                myCapsulesAdapter.notifyDataSetChanged();
-
 
127
            }
-
 
128
        };
-
 
129
 
-
 
130
        myCapsulesViewModel.getCapsuleMutableLiveData().observe(requireActivity(), myCapsuleListUpdateObserver);
-
 
131
 
-
 
132
 
-
 
133
        myCapsulesInProgressViewModel = new ViewModelProvider(requireActivity()).get(MyCapsulesInProgressViewModel.class);
-
 
134
        Observer<Capsule> myCapsuleInProgressUpdateObserver = new Observer<Capsule>() {
-
 
135
            @Override
-
 
136
            public void onChanged(Capsule capsuleInProgress) {
-
 
137
                if (capsuleInProgress == null || StringUtils.isEmpty(capsuleInProgress.getUuid()))  {
-
 
138
                    cardTextViewStatus.setText(getContext().getString(R.string.my_capsules_capsule_in_progress_not_found));
-
 
139
                    cardTextViewTitle.setText("");
-
 
140
                    cardProgressBar.setProgress(0);
-
 
141
                    cardTextViewProgress.setText("0 %");
-
 
142
                    cardButtonContinue.setVisibility(View.GONE);
-
 
143
                } else {
-
 
144
 
-
 
145
                    String title = StringUtils.trim(capsuleInProgress.getName());
Línea 88... Línea -...
88
 
-
 
Línea -... Línea 146...
-
 
146
                    title = title.length() > Constants.TITLE_MAX_LENGTH ? StringUtils.substring(title, 0, Constants.TITLE_MAX_LENGTH) + "...": title;
-
 
147
 
-
 
148
                    cardTextViewStatus.setText(getContext().getString(R.string.my_capsules_capsule_in_progress_found));
89
 
149
                    cardTextViewTitle.setText(title);
90
        View view= inflater.inflate(R.layout.fragment_welcome, container, false);
150
                    cardProgressBar.setProgress((int) capsuleInProgress.getProgress());
91
 
151
                    cardTextViewProgress.setText(mDecimalFormat.format(capsuleInProgress.getProgress()) + " %");
92
        username=view.findViewById(R.id.textView14); ningunelemento=view.findViewById(R.id.textView25);
-
 
Línea 93... Línea 152...
93
        textowelcome= view.findViewById(R.id.textView15);
152
 
94
        busqueda=view.findViewById(R.id.busqueda);
153
                    cardButtonContinue.setVisibility(View.VISIBLE);
-
 
154
 
-
 
155
                    ImageService.retrieve(getContext(), capsuleInProgress.getImage(), cardImageView);
Línea 95... Línea -...
95
        card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.titlenotifi); tabs=view.findViewById(R.id.tabLayout);
-
 
96
        capsuleList = new ArrayList<>();
-
 
97
 
-
 
98
 
-
 
99
        //Tarjeta Principal
156
                }
100
        titulotarjeta = view.findViewById(R.id.description); progresotarjeta= view.findViewById(R.id.progressBar2); imagetarjeta= view.findViewById(R.id.imagelist);
-
 
101
        continuar = view.findViewById(R.id.button); progresoporcentaje = view.findViewById(R.id.textView16);
-
 
102
 
-
 
103
 
157
            }
104
        username.setText("¡Hola, "+(iTwoGetSkills.getPreference().getFirstName() +"!"));
-
 
105
 
-
 
106
        tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
-
 
107
            @Override
-
 
108
            public void onTabSelected(TabLayout.Tab tab) {
-
 
109
                int position=tab.getPosition();
-
 
110
 
-
 
111
                capsuleList.clear();
158
        };
112
                adapter2.notifyDataSetChanged();
159
 
-
 
160
        myCapsulesInProgressViewModel.getCapsuleMutableLiveData().observe(requireActivity(), myCapsuleInProgressUpdateObserver);
-
 
161
 
-
 
162
 
113
 
163
 
Línea 114... Línea 164...
114
                if(position==0)
164
 
115
                {
165
        tabLayout = view.findViewById(R.id.fragment_my_capsules_tabLayout);
Línea 140... Línea 190...
140
            public void onTabReselected(TabLayout.Tab tab) {
190
            public void onTabReselected(TabLayout.Tab tab) {
Línea 141... Línea 191...
141
 
191
 
142
            }
192
            }
Línea 143... Línea -...
143
        });
-
 
144
 
-
 
145
        loadData("pendientes","");
193
        });
146
 
194
 
147
        busqueda.setOnFocusChangeListener(new View.OnFocusChangeListener() {
195
        editTextSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
148
            @Override
196
            @Override
149
            public void onFocusChange(View v, boolean hasFocus) {
-
 
150
                if(hasFocus)
197
            public void onFocusChange(View v, boolean hasFocus) {
151
                {
198
                if(hasFocus)  {
152
                        card.setVisibility(View.GONE);
199
                    cardView.setVisibility(View.GONE);
153
                        username.setVisibility(View.GONE);
-
 
154
                        textowelcome.setVisibility(View.GONE);
200
                    textViewHelloUsername.setVisibility(View.GONE);
Línea 155... Línea 201...
155
                        Log.e("Tengo foco"," Oculto");
201
                    textViewWelcome.setVisibility(View.GONE);
156
                }
202
                }
Línea 157... Línea 203...
157
 
203
 
158
            }
204
            }
159
        });
205
        });
Línea 160... Línea 206...
160
 
206
 
Línea 161... Línea 207...
161
        busqueda.addTextChangedListener(new TextWatcher() {
207
        editTextSearch.addTextChangedListener(new TextWatcher() {
162
            @Override
208
            @Override
-
 
209
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
163
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
210
 
-
 
211
            }
-
 
212
 
-
 
213
            @Override
-
 
214
            public void onTextChanged(CharSequence s, int start, int before, int count) {
164
 
215
                String search = "";
165
            }
216
                if (editTextSearch != null) {
-
 
217
                    search = StringUtils.trimToEmpty(editTextSearch.getText().toString());
-
 
218
                }
-
 
219
 
166
 
220
                int tabPosition = Constants.MY_CAPSULES_TAB_PENDING;
167
            @Override
221
                if (tabLayout != null) {
Línea 168... Línea 222...
168
            public void onTextChanged(CharSequence s, int start, int before, int count) {
222
                    tabPosition = tabLayout.getSelectedTabPosition();
169
            //    Log.e("El texto","buscado: "+s);
223
                }
Línea 170... Línea -...
170
                capsuleList.clear();
-
 
171
                adapter2.notifyDataSetChanged();
-
 
172
                loadData(tabactual, s.toString());
224
 
173
            }
225
 
Línea 174... Línea -...
174
 
-
 
175
            @Override
226
                loadData(tabPosition, search);
176
            public void afterTextChanged(Editable s) {
-
 
177
 
-
 
178
 
-
 
179
 
227
            }
180
            }
-
 
181
        });
228
 
182
 
229
            @Override
183
 
-
 
184
        adapter2 = new TabsCapsulesAdapter(getContext(),capsuleList);
-
 
185
 
-
 
186
 
-
 
187
 
230
            public void afterTextChanged(Editable s) {
188
        categorizados = view.findViewById(R.id.categorizados);
231
 
189
        GridLayoutManager layoutcategoria = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
232
            }
-
 
233
        });
-
 
234
 
-
 
235
        GridLayoutManager recyclerViewCapsulesLayout = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
-
 
236
        recyclerViewCapsules = view.findViewById(R.id.fragment_my_capsules_listing_capsules);
-
 
237
        recyclerViewCapsules.setLayoutManager(recyclerViewCapsulesLayout);
-
 
238
        recyclerViewCapsules.setAdapter(myCapsulesAdapter);
-
 
239
        recyclerViewCapsules.setOnFlingListener(new RecyclerView.OnFlingListener() {
-
 
240
            @Override
-
 
241
            public boolean onFling(int velocityX, int velocityY) {
Línea 190... Línea -...
190
        categorizados.setLayoutManager(layoutcategoria);
-
 
191
        categorizados.setAdapter(adapter2);
-
 
192
 
-
 
193
 
-
 
194
        adapter2.setClickListener(this);
-
 
195
 
-
 
196
        categorizados.setOnFlingListener(new RecyclerView.OnFlingListener() {
-
 
197
            @Override
-
 
198
            public boolean onFling(int velocityX, int velocityY) {
-
 
199
 
-
 
200
                if (categorizados.canScrollVertically(-1) ) {
-
 
201
 
-
 
202
                   // Log.e("Se activa", "On fling");
-
 
203
                    card.setVisibility(View.GONE);
242
            if (recyclerViewCapsules.canScrollVertically(-1) ) {
204
                    username.setVisibility(View.GONE);
243
                cardView.setVisibility(View.GONE);
205
                    textowelcome.setVisibility(View.GONE);
244
                textViewHelloUsername.setVisibility(View.GONE);
Línea 206... Línea 245...
206
                }else
245
                textViewWelcome.setVisibility(View.GONE);
Línea 229... Línea 268...
229
 
268
 
230
            }
269
            }
231
        });
270
        });
232
*/
271
*/
233
        getActivity().runOnUiThread(() -> {
-
 
234
            String message = capsuleList.size() == 1
-
 
235
                    ? "Hay 1 cápsula nueva disponible"
-
 
Línea 236... Línea -...
236
                    : "Tiene " + capsuleList.size() + " cápsulas pendientes para ver";
-
 
Línea -... Línea 272...
-
 
272
        getActivity().runOnUiThread(() -> {
-
 
273
 
-
 
274
 
-
 
275
            String message;
-
 
276
            if (myCapsulesViewModel.getCapsuleArrayList().size() == 1) {
-
 
277
                message = getContext().getString(R.string.common_one_capsule_available);
-
 
278
            } else {
-
 
279
                message = getContext().getString(R.string.common_more_capsules_available);
-
 
280
                message = StringUtils.replace(message, "%", String.valueOf(myCapsulesViewModel.getCapsuleArrayList().size()));
-
 
281
            }
237
 
282
            Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
Línea 238... Línea 283...
238
            Toast.makeText(getContext(), ""+message, Toast.LENGTH_LONG).show();
283
 
239
 
284
 
Línea 240... Línea 285...
240
            iTwoGetSkills.saveNotificationCenter("Contenidos disponibles","",message);
285
            iTwoGetSkills.saveNotificationCenter(getContext().getString(R.string.common_content_available),"",message);
241
 
286
 
Línea -... Línea 287...
-
 
287
        });
-
 
288
        iTwoGetSkills.showNavigationAndToolbar();
-
 
289
 
-
 
290
        return view;
-
 
291
    }
-
 
292
 
-
 
293
 
-
 
294
 
-
 
295
    @Override
-
 
296
    public void onStart() {
-
 
297
        super.onStart();
-
 
298
        getActivity().runOnUiThread(() -> {
-
 
299
 
-
 
300
            String search = "";
-
 
301
            if (editTextSearch != null) {
-
 
302
                search = StringUtils.trimToEmpty(editTextSearch.getText().toString());
-
 
303
            }
-
 
304
 
-
 
305
            int tabPosition = Constants.MY_CAPSULES_TAB_PENDING;
-
 
306
            if (tabLayout != null) {
-
 
307
                tabPosition = tabLayout.getSelectedTabPosition();
-
 
308
            }
242
        });
309
 
243
        iTwoGetSkills.showNavigationAndToolbar();
310
            loadData(tabPosition, search);
244
 
311
            loadCapsuleInProgerss();
245
        return view;
312
        });
Línea -... Línea 313...
-
 
313
    }
-
 
314
 
246
    }
315
    @Override
-
 
316
    public void onResume() {
Línea 247... Línea 317...
247
 
317
        super.onResume();
248
    @Override
318
        getActivity().runOnUiThread(() -> {
249
    public void onResume() {
319
 
250
        super.onResume();
320
            String search = "";
-
 
321
            if (editTextSearch != null) {
-
 
322
                search = StringUtils.trimToEmpty(editTextSearch.getText().toString());
251
        getActivity().runOnUiThread(() -> {
323
            }
252
 
324
 
253
            int fragmentIdxActive = iTwoGetSkills.getPreference().getFragmentIdxActive();
325
            int tabPosition = Constants.MY_CAPSULES_TAB_PENDING;
Línea 254... Línea 326...
254
 
326
            if (tabLayout != null) {
255
            if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
327
                tabPosition = tabLayout.getSelectedTabPosition();
256
            ) {
328
            }
Línea 257... Línea -...
257
                return;
-
 
Línea 258... Línea 329...
258
            }
329
 
259
            loadContinuecard();
-
 
Línea 260... Línea 330...
260
        });
330
            loadData(tabPosition, search);
Línea 261... Línea 331...
261
    }
331
            loadCapsuleInProgerss();
262
 
-
 
263
    @Override
-
 
264
    public void onHiddenChanged(boolean hidden) {
332
        });
265
        super.onHiddenChanged(hidden);
-
 
266
 
-
 
267
       // Log.e("TAG", "onHiddenChanged : " + (hidden ? "true" : "false"));
-
 
268
 
-
 
269
        if(!hidden) {
-
 
270
          //  Log.e("Esta oculto", "el fragmento");
-
 
271
 
333
    }
272
            getActivity().runOnUiThread(() -> {
-
 
273
 
334
 
274
                capsuleList.clear();
-
 
275
 
-
 
276
                loadContinuecard();
-
 
Línea -... Línea 335...
-
 
335
    @Override
-
 
336
    public void onHiddenChanged(boolean hidden) {
-
 
337
        super.onHiddenChanged(hidden);
277
                loadData("pendientes","");
338
 
278
 
-
 
279
                if (capsuleList.size() == 0) //Si no tenemos capsulas pendientes nos vamos a en curso
-
 
Línea -... Línea 339...
-
 
339
 
-
 
340
        if(!hidden) {
280
                {
341
 
281
                    capsuleList.clear();
-
 
282
                    loadData("cursando","");
-
 
283
 
342
            getActivity().runOnUiThread(() -> {
284
                    tabs.selectTab(tabs.getTabAt(1),true);
343
 
Línea 285... Línea 344...
285
 
344
                String search = "";
286
                }
345
                if (editTextSearch != null) {
287
                else
-
 
288
                {
-
 
289
                    tabs.selectTab(tabs.getTabAt(0),true);
-
 
290
 
346
                    search = StringUtils.trimToEmpty(editTextSearch.getText().toString());
291
                }
-
 
292
                adapter2.notifyDataSetChanged();
-
 
293
 
347
                }
Línea -... Línea 348...
-
 
348
 
-
 
349
                int tabPosition = Constants.MY_CAPSULES_TAB_PENDING;
-
 
350
                if (tabLayout != null) {
-
 
351
                    tabPosition = tabLayout.getSelectedTabPosition();
-
 
352
                }
-
 
353
 
-
 
354
                loadData(tabPosition, search);
-
 
355
                loadCapsuleInProgerss();
-
 
356
            });
-
 
357
        }
-
 
358
    }
-
 
359
 
-
 
360
    private void loadCapsuleInProgerss()
-
 
361
    {
-
 
362
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
-
 
363
        Capsule capsule = capsuleDao.selectLastInProgress(iTwoGetSkills.getPreference().getUserUuid());
-
 
364
 
-
 
365
        if (capsule == null) {
-
 
366
            myCapsulesInProgressViewModel.getCapsule().setUuid("");
-
 
367
            myCapsulesInProgressViewModel.getCapsule().setTopicUuid("");
-
 
368
            myCapsulesInProgressViewModel.getCapsule().setName("");
-
 
369
            myCapsulesInProgressViewModel.getCapsule().setDescription("");
-
 
370
            myCapsulesInProgressViewModel.getCapsule().setPosition(0);
-
 
371
            myCapsulesInProgressViewModel.getCapsule().setImage("");
-
 
372
            myCapsulesInProgressViewModel.getCapsule().setCompleted(0);
-
 
373
            myCapsulesInProgressViewModel.getCapsule().setTotalComments(0);
-
 
374
            myCapsulesInProgressViewModel.getCapsule().setLinkComments("");
-
 
375
            myCapsulesInProgressViewModel.getCapsule().setLinkCommentAdd("");
-
 
376
            myCapsulesInProgressViewModel.getCapsule().setViewSlides(0);
-
 
377
            myCapsulesInProgressViewModel.getCapsule().setTotalSlides(0);
-
 
378
            myCapsulesInProgressViewModel.getCapsule().setProgress(0);
-
 
379
            myCapsulesInProgressViewModel.getCapsule().setAddedOn("");
-
 
380
            myCapsulesInProgressViewModel.getCapsule().setUpdatedOn("");
-
 
381
 
Línea 294... Línea 382...
294
 
382
 
295
            });
-
 
296
 
-
 
297
 
383
        } else {
Línea 298... Línea 384...
298
        }
384
            myCapsulesInProgressViewModel.getCapsule().setUuid(capsule.getUuid());
299
    }
-
 
300
 
-
 
301
    private void loadContinuecard(){
-
 
302
 
-
 
303
        Log.e("Cargo datos"," en tarjeta principal");
385
            myCapsulesInProgressViewModel.getCapsule().setTopicUuid(capsule.getTopicUuid());
304
 
-
 
305
        //Capsula de primera tarjeta
-
 
306
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
-
 
307
        boolean continues=false;
-
 
308
        Progress progress;
-
 
309
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
-
 
310
 
-
 
311
 
-
 
312
        List<Capsule> dbCapsules= capsuleDao.selectAll();
-
 
313
        for(Capsule dbCapsule : dbCapsules)
-
 
314
        {
-
 
315
            progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
-
 
316
 
-
 
317
            if (progress != null) {
-
 
318
              //  Log.e("Capsula para"," continuar "+dbCapsule.getUuid());
-
 
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);
386
            myCapsulesInProgressViewModel.getCapsule().setName(capsule.getName());
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))
387
            myCapsulesInProgressViewModel.getCapsule().setDescription(capsule.getDescription());
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());
-
 
355
                    }
-
 
356
                }
-
 
357
                    if (progress.getProgress() < 100 && progress.getCompleted()==0) {
-
 
358
                       // Log.e("Es menor"," a 100");
-
 
359
                        continues=true;
-
 
360
                        titulotarjeta.setText(dbCapsule.getName());
-
 
361
                        progresotarjeta.setVisibility(View.VISIBLE);
-
 
362
                        progresoporcentaje.setVisibility(View.VISIBLE);
-
 
363
                        progresotarjeta.setProgress((int) progress.getProgress());
-
 
364
                        progresoporcentaje.setText("" + progress.getProgress() + " %");
-
 
365
                        empezar.setText("En curso");
-
 
366
 
-
 
367
                        iTwoGetSkills.getPreference().setOrigennavigation("welcome");
-
 
368
 
-
 
369
                        int fragmentIdxActive = iTwoGetSkills.getPreference().getFragmentIdxActive();
-
 
370
 
-
 
371
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
-
 
372
                        ) {
-
 
373
                            return;
-
 
374
                        }
-
 
375
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
-
 
376
                     //   Log.e("La capsula","activa en loadcurso"+dbCapsule.getUuid());
-
 
377
 
-
 
378
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
-
 
379
 
-
 
380
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
-
 
381
 
-
 
382
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
-
 
383
                            Calendar calendar = Calendar.getInstance(timeZone);
-
 
384
                            TimeZone tz = calendar.getTimeZone();
-
 
385
                            int created = (int) (calendar.getTimeInMillis() / 1000);
-
 
386
 
-
 
387
                            Random random = new Random(created);
-
 
388
                            int rand = 1000 + random.nextInt(8999);
-
 
389
 
-
 
390
 
-
 
391
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
-
 
392
                            String password = iTwoGetSkills.getPreference().getPassword();
-
 
393
 
-
 
394
 
-
 
395
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
-
 
396
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
-
 
397
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
-
 
398
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
-
 
399
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
-
 
400
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
-
 
401
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
-
 
402
                                    .build());
-
 
403
 
-
 
404
                            RequestOptions options = new RequestOptions()
-
 
405
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
-
 
406
 
-
 
407
                            Glide.with(getContext()).load(url)
-
 
408
                                    .thumbnail()
-
 
409
                                    .apply(options)
-
 
410
                                    .into(imagetarjeta);
-
 
411
                        }
-
 
412
                    }
-
 
413
 
-
 
414
            }
-
 
415
 
-
 
416
 
-
 
417
        }
-
 
418
        if(titulotarjeta.getText().equals(""))
-
 
419
        {
-
 
420
           // Log.e("Nombre","vacio");
-
 
421
            SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
-
 
422
 
-
 
423
 
-
 
424
            //Despues del recorrido no se encontro progreso en ninguna capsula, por lo cual la tarjeta queda vacia
-
 
425
            // vamos a llenarla con la ultima capsula, que debe ser nueva al no tener progreso
-
 
426
 
-
 
427
 
-
 
428
            for(Capsule dbCapsule : dbCapsules)
-
 
429
            {
-
 
430
                List<Slide> slides = slideDao.selectAllByCapsuleUuid(dbCapsule.getUuid());
-
 
431
 
-
 
432
                if (slides.isEmpty()) {
-
 
433
 
-
 
434
                } else {
-
 
435
                progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
-
 
436
 
-
 
437
                    //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
438
 
-
 
439
                    if (progress == null) {
-
 
440
 
-
 
441
                        //  Log.e("Es nueva","");
-
 
442
 
-
 
Línea 443... Línea -...
443
                        titulotarjeta.setText(dbCapsule.getName());
-
 
444
                        progresotarjeta.setVisibility(View.INVISIBLE);
-
 
445
                        progresoporcentaje.setVisibility(View.INVISIBLE);
-
 
446
                        empezar.setText("Nueva");
-
 
447
                        continuar.setText("Ver cápsula");
-
 
448
 
-
 
449
                        iTwoGetSkills.getPreference().setOrigennavigation("welcome");
-
 
450
 
-
 
451
                        int fragmentIdxActive = iTwoGetSkills.getPreference().getFragmentIdxActive();
-
 
452
 
-
 
453
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
-
 
454
                        ) {
-
 
455
                            return;
-
 
456
                        }
-
 
457
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
-
 
458
                      //  Log.e("La capsula","activa en load"+dbCapsule.getUuid());
-
 
459
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
-
 
460
 
-
 
461
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
-
 
462
 
-
 
463
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
-
 
464
                            Calendar calendar = Calendar.getInstance(timeZone);
-
 
465
                            TimeZone tz = calendar.getTimeZone();
-
 
466
                            int created = (int) (calendar.getTimeInMillis() / 1000);
-
 
467
 
-
 
468
                            Random random = new Random(created);
-
 
469
                            int rand = 1000 + random.nextInt(8999);
-
 
470
 
-
 
471
 
-
 
472
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
-
 
473
                            String password = iTwoGetSkills.getPreference().getPassword();
-
 
474
 
-
 
475
 
-
 
Línea -... Línea 388...
-
 
388
            myCapsulesInProgressViewModel.getCapsule().setPosition(capsule.getPosition());
-
 
389
            myCapsulesInProgressViewModel.getCapsule().setImage(capsule.getImage());
-
 
390
            myCapsulesInProgressViewModel.getCapsule().setCompleted(capsule.getCompleted());
476
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
391
            myCapsulesInProgressViewModel.getCapsule().setTotalComments(capsule.getTotalComments());
477
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
-
 
478
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
-
 
479
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
-
 
480
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
392
            myCapsulesInProgressViewModel.getCapsule().setLinkComments(capsule.getLinkComments());
481
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
-
 
482
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
-
 
483
                                    .build());
-
 
484
 
-
 
485
                            RequestOptions options = new RequestOptions()
-
 
Línea 486... Línea -...
486
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
-
 
487
 
393
            myCapsulesInProgressViewModel.getCapsule().setLinkCommentAdd(capsule.getLinkCommentAdd());
Línea 488... Línea -...
488
                            Glide.with(getContext()).load(url)
-
 
489
                                    .thumbnail()
-
 
490
                                    .apply(options)
-
 
Línea 491... Línea -...
491
                                    .into(imagetarjeta);
-
 
492
                        }
-
 
493
 
-
 
494
                    }
-
 
495
                }
-
 
496
 
-
 
497
            }
-
 
498
 
-
 
499
 
-
 
500
 
-
 
501
        }
-
 
502
        else if (!titulotarjeta.getText().equals("") && !continues)
-
 
503
        {
-
 
504
            // Log.e("Nombre","vacio");
-
 
505
            SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
-
 
506
 
-
 
507
 
-
 
508
            //Despues del recorrido no se encontro progreso en ninguna capsula, por lo cual la tarjeta queda vacia
-
 
509
            // vamos a llenarla con la ultima capsula, que debe ser nueva al no tener progreso
-
 
510
 
-
 
511
 
-
 
512
            for(Capsule dbCapsule : dbCapsules)
-
 
513
            {
-
 
514
                List<Slide> slides = slideDao.selectAllByCapsuleUuid(dbCapsule.getUuid());
-
 
515
 
-
 
516
                if (slides.isEmpty()) {
-
 
517
 
-
 
518
                } else {
-
 
519
                    progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
-
 
520
 
-
 
521
                    //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
522
 
-
 
523
                    if (progress == null) {
-
 
524
 
-
 
525
                        //  Log.e("Es nueva","");
-
 
526
 
-
 
527
                        titulotarjeta.setText(dbCapsule.getName());
-
 
528
                        progresotarjeta.setVisibility(View.INVISIBLE);
-
 
529
                        progresoporcentaje.setVisibility(View.INVISIBLE);
-
 
530
                        empezar.setText("Nueva");
-
 
531
                        continuar.setText("Ver cápsula");
-
 
532
 
-
 
533
                        iTwoGetSkills.getPreference().setOrigennavigation("welcome");
-
 
534
 
-
 
535
 
-
 
536
                        int fragmentIdxActive = iTwoGetSkills.getPreference().getFragmentIdxActive();
-
 
537
 
-
 
538
                        if (fragmentIdxActive != Constants.IDX_FRAGMENT_WELCOME
-
 
539
                        ) {
-
 
540
                            return;
-
 
541
                        }
-
 
542
                        iTwoGetSkills.setCapsulaActiva(dbCapsule.getUuid());
-
 
543
                       // Log.e("La capsula","activa en load"+dbCapsule.getUuid());
-
 
544
                        iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
-
 
545
 
-
 
546
                        if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
-
 
547
 
-
 
548
                            TimeZone timeZone = TimeZone.getTimeZone("UTC");
-
 
549
                            Calendar calendar = Calendar.getInstance(timeZone);
-
 
550
                            TimeZone tz = calendar.getTimeZone();
-
 
551
                            int created = (int) (calendar.getTimeInMillis() / 1000);
-
 
552
 
-
 
553
                            Random random = new Random(created);
-
 
554
                            int rand = 1000 + random.nextInt(8999);
-
 
555
 
-
 
556
 
-
 
557
                            String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
-
 
558
                            String password = iTwoGetSkills.getPreference().getPassword();
-
 
559
 
-
 
560
 
-
 
561
                            String secret = MD5.generar(password + ':' + created + ':' + rand);
-
 
562
                            GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
-
 
563
                                    .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
-
 
564
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
-
 
565
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
-
 
566
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
-
 
567
                                    .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
-
 
568
                                    .build());
-
 
569
 
-
 
570
                            RequestOptions options = new RequestOptions()
-
 
571
                                    .diskCacheStrategy(DiskCacheStrategy.ALL);
-
 
572
 
-
 
573
                            Glide.with(getContext()).load(url)
-
 
574
                                    .thumbnail()
-
 
575
                                    .apply(options)
-
 
576
                                    .into(imagetarjeta);
-
 
577
                        }
-
 
578
 
-
 
579
                    }
-
 
580
                }
-
 
581
 
-
 
582
            }
-
 
583
        }
-
 
584
 
-
 
585
        continuar.setOnClickListener(v -> {
-
 
Línea 586... Línea 394...
586
 
394
            myCapsulesInProgressViewModel.getCapsule().setViewSlides(capsule.getViewSlides());
Línea 587... Línea -...
587
 
-
 
588
           // Log.e("Guardo",""+iTwoGetSkills.getPreference().getOrigenNavigation());
-
 
Línea 589... Línea 395...
589
           // Log.e("Capsule","active"+iTwoGetSkills.getPreference().getCapsuleUuidActive());
395
            myCapsulesInProgressViewModel.getCapsule().setTotalSlides(capsule.getTotalSlides());
590
 
-
 
-
 
396
            myCapsulesInProgressViewModel.getCapsule().setProgress(capsule.getProgress());
Línea -... Línea 397...
-
 
397
            myCapsulesInProgressViewModel.getCapsule().setAddedOn(capsule.getAddedOn());
591
            Progress progresscontinue; ProgressDao progressDaocontinue = iTwoGetSkills.getDatabase().getProgressDao();
398
            myCapsulesInProgressViewModel.getCapsule().setUpdatedOn(capsule.getUpdatedOn());
592
            progresscontinue = progressDaocontinue.selectByCapsuleUuid(iTwoGetSkills.getCapsuleUuidActive());
399
 
Línea 593... Línea -...
593
            if (progresscontinue != null) {
-
 
594
                if (progresscontinue.getProgress() >= 100 && progresscontinue.getCompleted() == 1) {
400
            ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
595
                    iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_DETAIL_CAPSULE);
-
 
596
                } else {
-
 
-
 
401
            Progress progress = progressDao.selectByCapsuleUuid(capsule.getUuid());
-
 
402
 
597
                    iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
403
            if (progress != null) {
598
                }
404
                capsule.setViewSlides(progress.getViewSlides());
599
 
-
 
600
                iTwoGetSkills.getPreference().setOrigennavigation("welcome");
-
 
601
                iTwoGetSkills.hideKeyboard(v); //Ocultamos el teclado
-
 
602
            }
-
 
603
            else
-
 
604
            {
-
 
605
                iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
-
 
606
 
-
 
607
            }
-
 
608
        });
-
 
609
 
-
 
610
        //Fin de primer tarjeta
405
                capsule.setTotalSlides(progress.getTotalSlides());
611
 
-
 
612
    }
-
 
613
 
-
 
614
    private void loadData(String tabposition, String buscar)
-
 
615
    {
-
 
616
 
-
 
617
 
-
 
618
        TopicDao topicDao = iTwoGetSkills.getDatabase().getTopicDao();
-
 
619
        ArrayList<Topic> dbTopics = (ArrayList<Topic>) topicDao.selectAll();
-
 
620
 
-
 
621
        List<Capsule> dbCapsules;
-
 
622
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
-
 
623
 
-
 
624
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
-
 
625
        SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
-
 
626
 
-
 
627
 
406
                capsule.setProgress(progress.getProgress());
628
        if (tabposition.equals("pendientes"))
-
 
629
        {
-
 
630
            for (Topic dbTopic : dbTopics) {
-
 
631
 
-
 
632
                dbCapsules = capsuleDao.selectAllByTopicUuidandOrder(dbTopic.getUuid());
407
 
633
 
-
 
634
                Capsule capsule;
-
 
635
                Progress progress;
-
 
636
 
-
 
637
                HashMap<String, String> m_li;
-
 
638
 
-
 
639
 
-
 
640
 
-
 
641
                for(Capsule dbCapsule : dbCapsules) {
-
 
642
                    capsule = new Capsule();
-
 
643
                    capsule.setTopicUuid(dbCapsule.getTopicUuid());
-
 
644
                    capsule.setUuid(dbCapsule.getUuid());
-
 
645
                    capsule.setName(dbCapsule.getName());
-
 
646
                    capsule.setDescription(dbCapsule.getDescription());
-
 
647
                    capsule.setImage(dbCapsule.getImage());
-
 
648
                    capsule.setPosition(dbCapsule.getPosition());
-
 
649
                    capsule.setUpdatedOn(dbCapsule.getUpdatedOn());
-
 
650
 
-
 
651
                    m_li = new HashMap<>();
-
 
652
 
-
 
653
 
-
 
654
                    //m_li.put("copyright",copy);
-
 
655
 
-
 
656
                    progress = progressDao.selectByCapsuleUuid(capsule.getUuid());
-
 
657
 
-
 
658
                    if (progress != null) {
-
 
659
                        capsule.setCompleted(progress.getCompleted());
408
 
660
                        capsule.setViewSlides(progress.getViewSlides());
-
 
661
 
-
 
662
                        capsule.setTotalSlides(progress.getTotalSlides());
-
 
663
                        capsule.setProgress(progress.getProgress());
-
 
664
                        capsule.setAddedOn(progress.getAddedOn());
-
 
665
 
-
 
666
                        // Log.e("Agregado en"," "+progress.getAddedOn());
-
 
667
                        // m_li.put("addedon",progress.getAddedOn());
-
 
668
                        m_li.put("view", String.valueOf(progress.getViewSlides()));
-
 
669
                        m_li.put("total", String.valueOf(progress.getTotalSlides()));
-
 
670
                        m_li.put("progress", String.valueOf(progress.getProgress()));
-
 
671
                        m_li.put("completado",String.valueOf(progress.getCompleted()));
409
                myCapsulesInProgressViewModel.getCapsule().setViewSlides(progress.getViewSlides());
672
                        m_li.put("agregado",progress.getAddedOn());
-
 
673
 
-
 
674
                    }
-
 
675
 
-
 
676
                    m_li.put("imagen", capsule.getImage());
-
 
677
                    m_li.put("nombre", capsule.getName());
-
 
678
                    m_li.put("uuid", capsule.getUuid());
-
 
679
                    m_li.put("topicuuid", capsule.getTopicUuid());
-
 
680
                    m_li.put("description", capsule.getDescription());
-
 
681
 
-
 
682
 
-
 
683
                    //Lleno la lista segun el requerimiento de filtro accionado por el usuario
410
                myCapsulesInProgressViewModel.getCapsule().setTotalSlides(progress.getTotalSlides());
-
 
411
                myCapsulesInProgressViewModel.getCapsule().setProgress(progress.getProgress());
Línea -... Línea 412...
-
 
412
            }
-
 
413
        }
-
 
414
 
-
 
415
        myCapsulesInProgressViewModel.getCapsuleMutableLiveData().setValue(capsule);
-
 
416
 
-
 
417
 
-
 
418
 
Línea 684... Línea -...
684
 
-
 
-
 
419
 
-
 
420
    }
-
 
421
 
-
 
422
 
-
 
423
 
685
                    List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
424
    private void loadData(int tabPosition, String search)
-
 
425
    {
Línea 686... Línea 426...
686
 
426
 
687
                    if (slides.isEmpty()) {
427
        Capsule capsule;
688
 
-
 
689
                        //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
690
                    } else {
-
 
691
 
428
        List<Capsule> dbCapsules;
692
 
429
        CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
693
                        if (progress == null) {
-
 
694
 
-
 
695
                            if (buscar.equals("")) {
-
 
696
 
430
 
697
                                capsuleList.add(m_li);
-
 
698
 
431
        SlideDao slideDao = iTwoGetSkills.getDatabase().getSlideDao();
699
 
432
        ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
700
                            } else {
-
 
701
                                String nombre= capsule.getName();
433
        Progress progress;
702
                                String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
-
 
703
                                normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
434
        switch (tabPosition)
704
                                if (normalizada.matches("(?i).*" + buscar + ".*")) {
435
        {
705
                                    capsuleList.add(m_li);
436
            case Constants.MY_CAPSULES_TAB_IN_PROGRESS :
706
                                }
437
                if (StringUtils.isEmpty(search)) {
707
 
438
                    dbCapsules = capsuleDao.selectAllInProgress(iTwoGetSkills.getPreference().getUserUuid());
708
                            }
-
 
709
 
-
 
710
                        }
439
                } else {
711
 
-
 
712
                    }
440
                    dbCapsules = capsuleDao.selectAllInProgressWithSearch(iTwoGetSkills.getPreference().getUserUuid(), '%' + search + '%');
713
 
-
 
714
                }
441
                }
715
 
442
               break;
716
 
443
 
717
 
444
            case Constants.MY_CAPSULES_TAB_COMPLETED:
718
            }
-
 
719
 
-
 
720
        }
-
 
721
        else if (tabposition.equals("cursando"))
-
 
722
        {
445
                if (StringUtils.isEmpty(search)) {
723
 
-
 
724
                HashMap<String, String> m_li;
-
 
725
                List<Progress> progress;
446
                    dbCapsules = capsuleDao.selectAllCompleted(iTwoGetSkills.getPreference().getUserUuid());
726
                Capsule capsule;
447
                } else {
727
 
-
 
728
 
-
 
729
 
-
 
730
            progress = progressDao.selectAllCapsulesProgress();
-
 
731
 
448
                    dbCapsules = capsuleDao.selectAllCompletedWithSearch(iTwoGetSkills.getPreference().getUserUuid(), '%' + search + '%');
732
                for(Progress dbProgress : progress) {
-
 
733
                    m_li = new HashMap<>();
449
                }
734
 
-
 
735
                    capsule = capsuleDao.selectByUuid(dbProgress.getCapsuleUuid());
-
 
736
 
-
 
737
                    m_li.put("view", String.valueOf(dbProgress.getViewSlides()));
-
 
738
                    m_li.put("total", String.valueOf(dbProgress.getTotalSlides()));
450
                break;
739
                    m_li.put("progress", String.valueOf(dbProgress.getProgress()));
451
 
740
                    m_li.put("completado",String.valueOf(dbProgress.getCompleted()));
-
 
741
                    m_li.put("agregado",dbProgress.getAddedOn());
452
            default :
742
 
453
                if (StringUtils.isEmpty(search)) {
743
 
-
 
744
                    if(capsule == null)
-
 
745
                    {
-
 
746
                        Log.e("El objeto es"," nulo");
454
                    dbCapsules = capsuleDao.selectAllPending(iTwoGetSkills.getPreference().getUserUuid());
747
                    }
-
 
748
                    else {
-
 
749
                        m_li.put("imagen", capsule.getImage());
-
 
750
                        m_li.put("nombre", capsule.getName());
-
 
751
                        m_li.put("uuid", capsule.getUuid());
-
 
752
                        m_li.put("topicuuid", capsule.getTopicUuid());
-
 
753
                        m_li.put("description", capsule.getDescription());
-
 
754
 
-
 
755
 
-
 
756
 
-
 
757
                    //Log.e("Lista",""+m_li);
-
 
758
                    //Lleno la lista segun el requerimiento de filtro accionado por el usuario
-
 
759
 
-
 
760
                    List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
-
 
761
 
-
 
762
                    if (slides.isEmpty()) {
-
 
763
 
-
 
764
                        //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
765
                    } else {
-
 
766
 
-
 
767
            if(dbProgress.getProgress() <= 100 && dbProgress.getCompleted()==0)
-
 
768
            {
-
 
769
            if (buscar.equals("")) {
-
 
770
                capsuleList.add(m_li);
-
 
771
 
-
 
772
            } else {
-
 
773
                String nombre= capsule.getName();
-
 
774
                String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
-
 
775
                normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
-
 
776
                if (normalizada.matches("(?i).*" + buscar + ".*")) {
-
 
777
                    capsuleList.add(m_li);
-
 
778
                }
-
 
779
 
-
 
780
            }
-
 
781
        }}
-
 
782
                }}}
-
 
783
 
-
 
784
       else if (tabposition.equals("finalizados")){
-
 
785
 
-
 
786
            HashMap<String, String> m_li;
-
 
787
            List<Progress> progress;
-
 
788
            Capsule capsule;
-
 
789
 
-
 
790
 
-
 
791
 
-
 
792
            progress = progressDao.selectAllCapsulesProgress();
-
 
793
 
-
 
794
            for(Progress dbProgress : progress) {
-
 
795
                m_li = new HashMap<>();
-
 
796
 
-
 
797
                capsule = capsuleDao.selectByUuid(dbProgress.getCapsuleUuid());
-
 
798
 
-
 
799
                m_li.put("view", String.valueOf(dbProgress.getViewSlides()));
-
 
800
                m_li.put("total", String.valueOf(dbProgress.getTotalSlides()));
-
 
801
                m_li.put("progress", String.valueOf(dbProgress.getProgress()));
-
 
802
                m_li.put("completado",String.valueOf(dbProgress.getCompleted()));
-
 
803
                m_li.put("agregado",dbProgress.getAddedOn());
-
 
804
 
-
 
805
                if(capsule == null)
-
 
806
                {
-
 
807
                    Log.e("El objeto esta", "nulo");
-
 
808
                }
-
 
Línea -... Línea 455...
-
 
455
                } else {
-
 
456
                    dbCapsules = capsuleDao.selectAllPendingWithSearch(iTwoGetSkills.getPreference().getUserUuid(), '%' + search + '%');
Línea 809... Línea -...
809
                else{
-
 
810
 
-
 
811
                m_li.put("imagen", capsule.getImage());
457
                }
812
                m_li.put("nombre", capsule.getName());
-
 
813
                m_li.put("uuid", capsule.getUuid());
-
 
814
                m_li.put("topicuuid", capsule.getTopicUuid());
-
 
815
                m_li.put("description", capsule.getDescription());
-
 
816
 
-
 
Línea -... Línea 458...
-
 
458
                break;
817
                //Lleno la lista segun el requerimiento de filtro accionado por el usuario
459
 
Línea 818... Línea 460...
818
 
460
        }
819
                    List<Slide> slides = slideDao.selectAllByCapsuleUuid(capsule.getUuid());
461
        myCapsulesViewModel.getCapsuleArrayList().clear();
Línea 820... Línea 462...
820
 
462
        for (Capsule dbCapsule: dbCapsules) {
821
                    if (slides.isEmpty()) {
-
 
822
 
-
 
823
                        //  Log.e("Capsula","Es omitida, no tiene slides");
-
 
824
                    } else {
-
 
Línea 825... Línea -...
825
           if(dbProgress.getProgress() >= 100 && dbProgress.getCompleted()==1){
-
 
826
 
-
 
827
               if (buscar.equals("")) {
-
 
828
                   //capsule.getCompleted();
-
 
829
                   capsuleList.add(m_li);
463
            capsule = new Capsule();
830
 
-
 
831
               } else {
-
 
832
                   String nombre= capsule.getName();
464
            capsule.setUuid(dbCapsule.getUuid());
833
                   String normalizada= Normalizer.normalize(nombre, Normalizer.Form.NFD);
-
 
834
                   normalizada= normalizada.replaceAll("[^\\p{ASCII}]", "");
-
 
835
                   if (normalizada.matches("(?i).*" + buscar + ".*")) {
-
 
836
                       capsuleList.add(m_li);
-
 
837
                   }
-
 
838
 
-
 
839
               }
-
 
840
           }
465
            capsule.setTopicUuid(dbCapsule.getTopicUuid());
841
    }
466
            capsule.setName(dbCapsule.getName());