| 2 |
gabriel |
1 |
package com.cesams.twogetskills.fragment;
|
|
|
2 |
|
|
|
3 |
import android.os.Bundle;
|
|
|
4 |
|
| 9 |
gabriel |
5 |
import androidx.annotation.Nullable;
|
| 2 |
gabriel |
6 |
import androidx.fragment.app.Fragment;
|
|
|
7 |
import androidx.lifecycle.LifecycleOwner;
|
|
|
8 |
import androidx.lifecycle.Observer;
|
|
|
9 |
import androidx.lifecycle.ViewModelProvider;
|
|
|
10 |
import androidx.recyclerview.widget.GridLayoutManager;
|
|
|
11 |
import androidx.recyclerview.widget.RecyclerView;
|
|
|
12 |
|
| 9 |
gabriel |
13 |
import android.text.Layout;
|
| 2 |
gabriel |
14 |
import android.util.Log;
|
| 8 |
gabriel |
15 |
import android.view.DragEvent;
|
| 2 |
gabriel |
16 |
import android.view.LayoutInflater;
|
|
|
17 |
import android.view.View;
|
|
|
18 |
import android.view.ViewGroup;
|
| 9 |
gabriel |
19 |
import android.widget.Button;
|
| 8 |
gabriel |
20 |
import android.widget.EditText;
|
| 9 |
gabriel |
21 |
import android.widget.ImageView;
|
|
|
22 |
import android.widget.ProgressBar;
|
| 2 |
gabriel |
23 |
import android.widget.TextView;
|
| 8 |
gabriel |
24 |
import android.widget.Toast;
|
| 2 |
gabriel |
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;
|
| 8 |
gabriel |
33 |
import com.cesams.twogetskills.activity.MainActivity;
|
| 2 |
gabriel |
34 |
import com.cesams.twogetskills.adapter.CapsuleListViewAdapter;
|
|
|
35 |
import com.cesams.twogetskills.adapter.CardViewAdapter;
|
| 4 |
gabriel |
36 |
import com.cesams.twogetskills.adapter.TabsCapsulesAdapter;
|
| 2 |
gabriel |
37 |
import com.cesams.twogetskills.dao.CapsuleDao;
|
|
|
38 |
import com.cesams.twogetskills.dao.ProgressDao;
|
|
|
39 |
import com.cesams.twogetskills.dao.TopicDao;
|
|
|
40 |
import com.cesams.twogetskills.entity.Capsule;
|
|
|
41 |
import com.cesams.twogetskills.entity.Progress;
|
|
|
42 |
import com.cesams.twogetskills.entity.Topic;
|
| 9 |
gabriel |
43 |
import com.cesams.twogetskills.library.MD5;
|
| 2 |
gabriel |
44 |
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
|
|
|
45 |
import com.cesams.twogetskills.viewmodel.CapsuleViewModel;
|
|
|
46 |
|
|
|
47 |
import java.util.ArrayList;
|
| 9 |
gabriel |
48 |
import java.util.Calendar;
|
| 2 |
gabriel |
49 |
import java.util.HashMap;
|
|
|
50 |
import java.util.List;
|
| 9 |
gabriel |
51 |
import java.util.Random;
|
|
|
52 |
import java.util.TimeZone;
|
| 2 |
gabriel |
53 |
|
|
|
54 |
/**
|
|
|
55 |
* A simple {@link Fragment} subclass.
|
|
|
56 |
* Use the {@link WelcomeFragment#newInstance} factory method to
|
|
|
57 |
* create an instance of this fragment.
|
|
|
58 |
*/
|
|
|
59 |
public class WelcomeFragment extends Fragment implements CapsuleListViewAdapter.ItemClickListener, LifecycleOwner {
|
|
|
60 |
|
| 10 |
gabriel |
61 |
TextView username, titulotarjeta, progresoporcentaje, empezar; ProgressBar progresotarjeta;
|
| 9 |
gabriel |
62 |
private ITwoGetSkills iTwoGetSkills; View card;
|
| 2 |
gabriel |
63 |
ArrayList<HashMap<String, String>> capsuleList;
|
| 9 |
gabriel |
64 |
private CardViewAdapter adapter; ImageView imagetarjeta;
|
| 4 |
gabriel |
65 |
private TabsCapsulesAdapter adapter2;
|
|
|
66 |
RecyclerView capsulas, categorizados;
|
| 9 |
gabriel |
67 |
EditText busqueda; TextView textowelcome; Button continuar;
|
| 2 |
gabriel |
68 |
|
|
|
69 |
public WelcomeFragment() {
|
|
|
70 |
// Required empty public constructor
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
public static WelcomeFragment newInstance() {
|
|
|
74 |
WelcomeFragment fragment = new WelcomeFragment();
|
|
|
75 |
return fragment;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
@Override
|
|
|
79 |
public void onCreate(Bundle savedInstanceState) {
|
|
|
80 |
super.onCreate(savedInstanceState);
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
@Override
|
|
|
84 |
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
85 |
Bundle savedInstanceState) {
|
|
|
86 |
|
| 8 |
gabriel |
87 |
|
| 2 |
gabriel |
88 |
iTwoGetSkills = (ITwoGetSkills) getActivity();
|
| 8 |
gabriel |
89 |
iTwoGetSkills.showNavigationAndToolbar();
|
| 2 |
gabriel |
90 |
|
|
|
91 |
View view= inflater.inflate(R.layout.fragment_welcome, container, false);
|
|
|
92 |
|
|
|
93 |
username=view.findViewById(R.id.textView14);
|
| 8 |
gabriel |
94 |
textowelcome= view.findViewById(R.id.textView15);
|
|
|
95 |
busqueda=view.findViewById(R.id.busqueda);
|
| 10 |
gabriel |
96 |
card= view.findViewById(R.id.include); empezar= view.findViewById(R.id.textView17);
|
| 8 |
gabriel |
97 |
capsuleList = new ArrayList<>();
|
| 2 |
gabriel |
98 |
|
| 9 |
gabriel |
99 |
//Tarjeta Principal
|
|
|
100 |
titulotarjeta = view.findViewById(R.id.titleview); 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 |
|
| 2 |
gabriel |
104 |
username.setText("¡Hola, "+(iTwoGetSkills.getPreference().getFirstName() +"!"));
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
loadData();
|
|
|
108 |
|
| 8 |
gabriel |
109 |
busqueda.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
|
110 |
@Override
|
|
|
111 |
public void onFocusChange(View v, boolean hasFocus) {
|
|
|
112 |
if(hasFocus)
|
|
|
113 |
{
|
| 9 |
gabriel |
114 |
card.setVisibility(View.GONE);
|
| 8 |
gabriel |
115 |
username.setVisibility(View.GONE);
|
|
|
116 |
textowelcome.setVisibility(View.GONE);
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
}
|
|
|
120 |
});
|
|
|
121 |
|
|
|
122 |
|
| 2 |
gabriel |
123 |
adapter = new CardViewAdapter(getContext(),capsuleList);
|
| 4 |
gabriel |
124 |
adapter2 = new TabsCapsulesAdapter(getContext(),capsuleList);
|
| 2 |
gabriel |
125 |
|
|
|
126 |
capsulas = view.findViewById(R.id.capsulescontinuos);
|
|
|
127 |
GridLayoutManager layoutausar = new GridLayoutManager(getContext(),1,GridLayoutManager.HORIZONTAL, false);
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
capsulas.setLayoutManager(layoutausar);
|
|
|
131 |
capsulas.setAdapter(adapter);
|
|
|
132 |
|
| 4 |
gabriel |
133 |
categorizados = view.findViewById(R.id.categorizados);
|
|
|
134 |
GridLayoutManager layoutcategoria = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
|
|
|
135 |
categorizados.setLayoutManager(layoutcategoria);
|
|
|
136 |
categorizados.setAdapter(adapter2);
|
|
|
137 |
|
| 8 |
gabriel |
138 |
categorizados.setOnFlingListener(new RecyclerView.OnFlingListener() {
|
|
|
139 |
@Override
|
|
|
140 |
public boolean onFling(int velocityX, int velocityY) {
|
|
|
141 |
|
|
|
142 |
if (categorizados.canScrollVertically(-1) ) {
|
|
|
143 |
|
|
|
144 |
Log.e("Se activa", "On fling");
|
| 9 |
gabriel |
145 |
card.setVisibility(View.GONE);
|
| 8 |
gabriel |
146 |
username.setVisibility(View.GONE);
|
|
|
147 |
textowelcome.setVisibility(View.GONE);
|
|
|
148 |
}else
|
|
|
149 |
{
|
| 9 |
gabriel |
150 |
card.setVisibility(View.VISIBLE);
|
| 8 |
gabriel |
151 |
username.setVisibility(View.VISIBLE);
|
|
|
152 |
textowelcome.setVisibility(View.VISIBLE);
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
return false;
|
|
|
156 |
}
|
|
|
157 |
});
|
|
|
158 |
|
|
|
159 |
/* categorizados.setOnScrollChangeListener(new View.OnScrollChangeListener() {
|
|
|
160 |
@Override
|
|
|
161 |
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
|
|
162 |
|
|
|
163 |
if (!categorizados.canScrollVertically(-1)) {
|
|
|
164 |
// Toast.makeText(getActivity(), "Last", Toast.LENGTH_LONG).show();
|
|
|
165 |
capsulas.setVisibility(View.VISIBLE);
|
|
|
166 |
username.setVisibility(View.VISIBLE);
|
|
|
167 |
textowelcome.setVisibility(View.VISIBLE);
|
|
|
168 |
Log.e("On scroll"," se activa");
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
}
|
|
|
172 |
});
|
|
|
173 |
*/
|
| 2 |
gabriel |
174 |
return view;
|
|
|
175 |
}
|
|
|
176 |
|
| 9 |
gabriel |
177 |
@Override
|
|
|
178 |
public void onResume() {
|
|
|
179 |
super.onResume();
|
|
|
180 |
loadContinuecard();
|
|
|
181 |
}
|
| 2 |
gabriel |
182 |
|
| 9 |
gabriel |
183 |
@Override
|
|
|
184 |
public void onHiddenChanged(boolean hidden) {
|
|
|
185 |
super.onHiddenChanged(hidden);
|
|
|
186 |
|
|
|
187 |
Log.e("TAG", "onHiddenChanged : " + (hidden ? "true" : "false"));
|
|
|
188 |
|
|
|
189 |
if(!hidden) {
|
|
|
190 |
loadContinuecard();
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
private void loadContinuecard(){
|
|
|
195 |
|
|
|
196 |
Log.e("Cargo datos"," en tarjeta principal");
|
|
|
197 |
|
|
|
198 |
//Capsula de primera tarjeta
|
|
|
199 |
CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
|
|
|
200 |
|
|
|
201 |
Progress progress;
|
|
|
202 |
ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
|
|
|
203 |
|
|
|
204 |
List<Capsule> dbCapsules= capsuleDao.selectAll();
|
|
|
205 |
for(Capsule dbCapsule : dbCapsules)
|
|
|
206 |
{
|
|
|
207 |
progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
|
|
|
208 |
|
|
|
209 |
if (progress != null) {
|
|
|
210 |
|
| 10 |
gabriel |
211 |
if (progress.getProgress() < 100) {
|
|
|
212 |
Log.e("Es menor"," a 100");
|
| 9 |
gabriel |
213 |
|
|
|
214 |
titulotarjeta.setText(dbCapsule.getName());
|
| 10 |
gabriel |
215 |
progresotarjeta.setVisibility(View.VISIBLE);
|
|
|
216 |
progresoporcentaje.setVisibility(View.VISIBLE);
|
| 9 |
gabriel |
217 |
progresotarjeta.setProgress((int) progress.getProgress());
|
|
|
218 |
progresoporcentaje.setText("" + progress.getProgress() + " %");
|
| 10 |
gabriel |
219 |
empezar.setText("En curso");
|
| 9 |
gabriel |
220 |
|
|
|
221 |
iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
|
|
|
222 |
iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
|
|
|
223 |
|
|
|
224 |
if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
|
|
|
225 |
|
|
|
226 |
TimeZone timeZone = TimeZone.getTimeZone("UTC");
|
|
|
227 |
Calendar calendar = Calendar.getInstance(timeZone);
|
|
|
228 |
TimeZone tz = calendar.getTimeZone();
|
|
|
229 |
int created = (int) (calendar.getTimeInMillis() / 1000);
|
|
|
230 |
|
|
|
231 |
Random random = new Random(created);
|
|
|
232 |
int rand = 1000 + random.nextInt(8999);
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
|
|
|
236 |
String password = iTwoGetSkills.getPreference().getPassword();
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
String secret = MD5.generar(password + ':' + created + ':' + rand);
|
|
|
240 |
GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
|
|
|
241 |
.addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
|
|
|
242 |
.addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
|
|
|
243 |
.addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
|
|
|
244 |
.addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
|
|
|
245 |
.addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
|
|
|
246 |
.build());
|
|
|
247 |
|
|
|
248 |
RequestOptions options = new RequestOptions()
|
|
|
249 |
.diskCacheStrategy(DiskCacheStrategy.ALL);
|
|
|
250 |
|
|
|
251 |
Glide.with(getContext()).load(url)
|
|
|
252 |
.thumbnail()
|
|
|
253 |
.apply(options)
|
|
|
254 |
.into(imagetarjeta);
|
|
|
255 |
}
|
|
|
256 |
}
|
|
|
257 |
|
| 10 |
gabriel |
258 |
}
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
if(titulotarjeta.getText().equals(""))
|
|
|
264 |
{
|
|
|
265 |
Log.e("Nombre","vacio");
|
|
|
266 |
|
|
|
267 |
//Despues del recorrido no se encontro progreso en ninguna capsula, por lo cual la tarjeta queda vacia
|
|
|
268 |
// vamos a llenarla con la ultima capsula, que debe ser nueva al no tener progreso
|
|
|
269 |
|
|
|
270 |
for(Capsule dbCapsule : dbCapsules)
|
|
|
271 |
{
|
|
|
272 |
|
|
|
273 |
progress = progressDao.selectByCapsuleUuid(dbCapsule.getUuid());
|
|
|
274 |
|
|
|
275 |
if (progress == null) {
|
|
|
276 |
|
|
|
277 |
Log.e("Es nueva","");
|
|
|
278 |
|
|
|
279 |
titulotarjeta.setText(dbCapsule.getName());
|
|
|
280 |
progresotarjeta.setVisibility(View.INVISIBLE);
|
|
|
281 |
progresoporcentaje.setVisibility(View.INVISIBLE);
|
|
|
282 |
empezar.setText("Nueva");
|
|
|
283 |
continuar.setText("Ver cápsula");
|
|
|
284 |
|
|
|
285 |
iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
|
|
|
286 |
iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
|
|
|
287 |
|
|
|
288 |
if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
|
|
|
289 |
|
|
|
290 |
TimeZone timeZone = TimeZone.getTimeZone("UTC");
|
|
|
291 |
Calendar calendar = Calendar.getInstance(timeZone);
|
|
|
292 |
TimeZone tz = calendar.getTimeZone();
|
|
|
293 |
int created = (int) (calendar.getTimeInMillis() / 1000);
|
|
|
294 |
|
|
|
295 |
Random random = new Random(created);
|
|
|
296 |
int rand = 1000 + random.nextInt(8999);
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
|
|
|
300 |
String password = iTwoGetSkills.getPreference().getPassword();
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
String secret = MD5.generar(password + ':' + created + ':' + rand);
|
|
|
304 |
GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
|
|
|
305 |
.addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
|
|
|
306 |
.addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
|
|
|
307 |
.addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
|
|
|
308 |
.addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
|
|
|
309 |
.addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
|
|
|
310 |
.build());
|
|
|
311 |
|
|
|
312 |
RequestOptions options = new RequestOptions()
|
|
|
313 |
.diskCacheStrategy(DiskCacheStrategy.ALL);
|
|
|
314 |
|
|
|
315 |
Glide.with(getContext()).load(url)
|
|
|
316 |
.thumbnail()
|
|
|
317 |
.apply(options)
|
|
|
318 |
.into(imagetarjeta);
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
/*
|
|
|
324 |
if (progress != null) {
|
|
|
325 |
|
|
|
326 |
double progre = progress.getProgress();
|
|
|
327 |
|
|
|
328 |
if (progre >= 100) {
|
|
|
329 |
Log.e("Es mayor"," a 100");
|
|
|
330 |
|
|
|
331 |
} else {
|
|
|
332 |
|
|
|
333 |
Log.e("Es nueva","");
|
|
|
334 |
|
|
|
335 |
titulotarjeta.setText(dbCapsule.getName());
|
|
|
336 |
progresotarjeta.setVisibility(View.INVISIBLE);
|
|
|
337 |
progresoporcentaje.setVisibility(View.INVISIBLE);
|
|
|
338 |
empezar.setText("Nueva");
|
|
|
339 |
continuar.setText("Ver cápsula");
|
|
|
340 |
|
|
|
341 |
iTwoGetSkills.getPreference().setCapsuleUuidActive(dbCapsule.getUuid());
|
|
|
342 |
iTwoGetSkills.getPreference().setTopicUuidActive(dbCapsule.getTopicUuid());
|
|
|
343 |
|
|
|
344 |
if (dbCapsule.getImage() != null && !dbCapsule.getImage().equals("")) {
|
|
|
345 |
|
|
|
346 |
TimeZone timeZone = TimeZone.getTimeZone("UTC");
|
|
|
347 |
Calendar calendar = Calendar.getInstance(timeZone);
|
|
|
348 |
TimeZone tz = calendar.getTimeZone();
|
|
|
349 |
int created = (int) (calendar.getTimeInMillis() / 1000);
|
|
|
350 |
|
|
|
351 |
Random random = new Random(created);
|
|
|
352 |
int rand = 1000 + random.nextInt(8999);
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
|
|
|
356 |
String password = iTwoGetSkills.getPreference().getPassword();
|
|
|
357 |
|
|
|
358 |
|
|
|
359 |
String secret = MD5.generar(password + ':' + created + ':' + rand);
|
|
|
360 |
GlideUrl url = new GlideUrl(dbCapsule.getImage(), new LazyHeaders.Builder()
|
|
|
361 |
.addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
|
|
|
362 |
.addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
|
|
|
363 |
.addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
|
|
|
364 |
.addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
|
|
|
365 |
.addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
|
|
|
366 |
.build());
|
|
|
367 |
|
|
|
368 |
RequestOptions options = new RequestOptions()
|
|
|
369 |
.diskCacheStrategy(DiskCacheStrategy.ALL);
|
|
|
370 |
|
|
|
371 |
Glide.with(getContext()).load(url)
|
|
|
372 |
.thumbnail()
|
|
|
373 |
.apply(options)
|
|
|
374 |
.into(imagetarjeta);
|
|
|
375 |
}
|
|
|
376 |
|
|
|
377 |
}
|
| 9 |
gabriel |
378 |
}
|
| 10 |
gabriel |
379 |
*/
|
|
|
380 |
}
|
| 9 |
gabriel |
381 |
|
| 10 |
gabriel |
382 |
|
|
|
383 |
|
| 9 |
gabriel |
384 |
}
|
|
|
385 |
|
| 10 |
gabriel |
386 |
|
|
|
387 |
|
| 9 |
gabriel |
388 |
continuar.setOnClickListener(v -> {
|
|
|
389 |
|
|
|
390 |
iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
|
|
|
391 |
});
|
|
|
392 |
|
|
|
393 |
//Fin de primer tarjeta
|
|
|
394 |
|
|
|
395 |
}
|
|
|
396 |
|
| 2 |
gabriel |
397 |
private void loadData()
|
|
|
398 |
{
|
|
|
399 |
|
|
|
400 |
TopicDao topicDao = iTwoGetSkills.getDatabase().getTopicDao();
|
|
|
401 |
ArrayList<Topic> dbTopics = (ArrayList<Topic>) topicDao.selectAll();
|
|
|
402 |
|
|
|
403 |
List<Capsule> dbCapsules;
|
|
|
404 |
CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
|
|
|
405 |
|
| 9 |
gabriel |
406 |
|
|
|
407 |
|
|
|
408 |
|
| 2 |
gabriel |
409 |
for (Topic dbTopic : dbTopics) {
|
|
|
410 |
|
|
|
411 |
dbCapsules = capsuleDao.selectAllByTopicUuid(dbTopic.getUuid());
|
|
|
412 |
|
| 9 |
gabriel |
413 |
|
| 2 |
gabriel |
414 |
Capsule capsule;
|
|
|
415 |
Progress progress;
|
|
|
416 |
ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
|
|
|
417 |
|
|
|
418 |
HashMap<String, String> m_li;
|
|
|
419 |
|
| 9 |
gabriel |
420 |
|
|
|
421 |
|
| 2 |
gabriel |
422 |
for(Capsule dbCapsule : dbCapsules)
|
|
|
423 |
{
|
|
|
424 |
capsule = new Capsule();
|
|
|
425 |
capsule.setTopicUuid(dbCapsule.getTopicUuid());
|
|
|
426 |
capsule.setUuid(dbCapsule.getUuid());
|
|
|
427 |
capsule.setName(dbCapsule.getName());
|
|
|
428 |
capsule.setDescription(dbCapsule.getDescription());
|
|
|
429 |
capsule.setImage(dbCapsule.getImage());
|
|
|
430 |
capsule.setPosition(dbCapsule.getPosition());
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
|
434 |
m_li = new HashMap<>();
|
|
|
435 |
|
|
|
436 |
|
|
|
437 |
//m_li.put("copyright",copy);
|
|
|
438 |
|
|
|
439 |
|
|
|
440 |
progress = progressDao.selectByCapsuleUuid(capsule.getUuid());
|
|
|
441 |
if(progress != null) {
|
|
|
442 |
capsule.setCompleted( progress.getCompleted());
|
|
|
443 |
capsule.setViewSlides(progress.getViewSlides());
|
|
|
444 |
|
|
|
445 |
capsule.setTotalSlides( progress.getTotalSlides());
|
|
|
446 |
capsule.setProgress(progress.getProgress());
|
|
|
447 |
|
|
|
448 |
m_li.put("view", String.valueOf(progress.getViewSlides()));
|
|
|
449 |
m_li.put("total", String.valueOf(progress.getTotalSlides()));
|
|
|
450 |
m_li.put("progress", String.valueOf(progress.getProgress()));
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
m_li.put("imagen",capsule.getImage());
|
|
|
455 |
m_li.put("nombre",capsule.getName());
|
|
|
456 |
|
|
|
457 |
capsuleList.add(m_li);
|
|
|
458 |
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
@Override
|
|
|
469 |
public void onItemClick(View view, int position) {
|
|
|
470 |
|
|
|
471 |
}
|
|
|
472 |
}
|