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