Proyectos de Subversion Android Microlearning - Inconcert

Rev

Rev 9 | Rev 18 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 9 Rev 14
Línea 46... Línea 46...
46
import com.cesams.twogetskills.inconcert.dao.AppDatabase;
46
import com.cesams.twogetskills.inconcert.dao.AppDatabase;
47
import com.cesams.twogetskills.inconcert.dao.CapsuleDao;
47
import com.cesams.twogetskills.inconcert.dao.CapsuleDao;
48
import com.cesams.twogetskills.inconcert.dao.CompanyDao;
48
import com.cesams.twogetskills.inconcert.dao.CompanyDao;
49
import com.cesams.twogetskills.inconcert.dao.DatabaseHelper;
49
import com.cesams.twogetskills.inconcert.dao.DatabaseHelper;
50
import com.cesams.twogetskills.inconcert.dao.NotificationCenterDao;
50
import com.cesams.twogetskills.inconcert.dao.NotificationCenterDao;
-
 
51
import com.cesams.twogetskills.inconcert.dao.ConfigDao;
51
import com.cesams.twogetskills.inconcert.dao.ProgressDao;
52
import com.cesams.twogetskills.inconcert.dao.ProgressDao;
52
import com.cesams.twogetskills.inconcert.dao.QuestionDao;
53
import com.cesams.twogetskills.inconcert.dao.QuestionDao;
53
import com.cesams.twogetskills.inconcert.dao.QuizDao;
54
import com.cesams.twogetskills.inconcert.dao.QuizDao;
54
import com.cesams.twogetskills.inconcert.dao.SlideDao;
55
import com.cesams.twogetskills.inconcert.dao.SlideDao;
55
import com.cesams.twogetskills.inconcert.dao.SyncDao;
56
import com.cesams.twogetskills.inconcert.dao.SyncDao;
56
import com.cesams.twogetskills.inconcert.dao.TopicDao;
57
import com.cesams.twogetskills.inconcert.dao.TopicDao;
57
import com.cesams.twogetskills.inconcert.dao.UserExtendedDao;
58
import com.cesams.twogetskills.inconcert.dao.UserExtendedDao;
58
import com.cesams.twogetskills.inconcert.dao.UserLogDao;
59
import com.cesams.twogetskills.inconcert.dao.UserLogDao;
-
 
60
import com.cesams.twogetskills.inconcert.entity.Config;
59
import com.cesams.twogetskills.inconcert.entity.UserExtended;
61
import com.cesams.twogetskills.inconcert.entity.UserExtended;
60
import com.cesams.twogetskills.inconcert.fragment.BiometricOptions;
62
import com.cesams.twogetskills.inconcert.fragment.BiometricOptions; 
-
 
63
import com.cesams.twogetskills.inconcert.fragment.CapsuleDetail;
-
 
64
 
61
import com.cesams.twogetskills.inconcert.fragment.CapsuleFragment;
65
import com.cesams.twogetskills.inconcert.fragment.CapsuleFragment;
62
import com.cesams.twogetskills.inconcert.fragment.CompanyFragment;
66
import com.cesams.twogetskills.inconcert.fragment.CompanyFragment;
63
import com.cesams.twogetskills.inconcert.fragment.FinishCapsuleFragment;
67
import com.cesams.twogetskills.inconcert.fragment.FinishCapsuleFragment;
64
import com.cesams.twogetskills.inconcert.fragment.FinishTopicFragment;
68
import com.cesams.twogetskills.inconcert.fragment.FinishTopicFragment;
65
import com.cesams.twogetskills.inconcert.fragment.GalleryFragment;
69
import com.cesams.twogetskills.inconcert.fragment.GalleryFragment;
Línea 182... Línea 186...
182
 
186
 
Línea 183... Línea 187...
183
            Log.d(TAG, "MainActivity onCreate");
187
            Log.d(TAG, "MainActivity onCreate");
Línea -... Línea 188...
-
 
188
 
-
 
189
            mAppDatabase = DatabaseHelper.getInstance(getApplicationContext()).getAppDatabase();
184
 
190
 
Línea 185... Línea 191...
185
            mAppDatabase = DatabaseHelper.getInstance(getApplicationContext()).getAppDatabase();
191
            setNoCapsuleActive();
Línea 186... Línea 192...
186
 
192
 
Línea 369... Línea 375...
369
        } catch (Exception e) {
375
        } catch (Exception e) {
370
            e.printStackTrace();
376
            e.printStackTrace();
371
        }
377
        }
372
    }
378
    }
Línea -... Línea 379...
-
 
379
 
-
 
380
    public void setNoCapsuleActive()
-
 
381
    {
-
 
382
 
-
 
383
        ConfigDao configuracion =  mAppDatabase.getConfigDao();
-
 
384
 
-
 
385
        if(configuracion.selectConfigByTitle("act_capsule") == null)
-
 
386
        {
-
 
387
            Log.e("La capsula activa"," es nula");
-
 
388
            com.cesams.twogetskills.inconcert.entity.Config confignueva;
-
 
389
 
-
 
390
            confignueva = new com.cesams.twogetskills.inconcert.entity.Config();
-
 
391
            confignueva.setTitle("act_capsule");
-
 
392
            confignueva.setNow("");
-
 
393
 
-
 
394
            configuracion.insert(confignueva);
-
 
395
        }
-
 
396
        else{
-
 
397
            Log.e("La capsula activa"," es vacia o tiene algo");
-
 
398
 
-
 
399
            com.cesams.twogetskills.inconcert.entity.Config confignueva;
-
 
400
 
-
 
401
            confignueva = new com.cesams.twogetskills.inconcert.entity.Config();
-
 
402
            confignueva.setTitle("act_capsule");
-
 
403
            confignueva.setNow("");
-
 
404
 
-
 
405
            configuracion.update(confignueva);
-
 
406
        }
-
 
407
 
-
 
408
 
-
 
409
    }
-
 
410
 
373
 
411
 
374
    @Override
412
    @Override
375
    protected void onDestroy() {
413
    protected void onDestroy() {
Línea 376... Línea 414...
376
        super.onDestroy();
414
        super.onDestroy();
Línea 608... Línea 646...
608
    }
646
    }
Línea 609... Línea 647...
609
 
647
 
610
    @Override
648
    @Override
611
    public void signout()
649
    public void signout()
-
 
650
    {
-
 
651
 
-
 
652
 	if(isConnectedInternet()) {
-
 
653
 
-
 
654
 
-
 
655
            try {
-
 
656
 
-
 
657
                Http http = new Http(getCacheDir());
-
 
658
                OkHttpClient client = http.getHttpClient(false);
-
 
659
 
-
 
660
                Request request = new Request.Builder()
-
 
661
                        .url(Configuration.URL_SIGNOUT)
-
 
662
                        //Que parametros se necesitan para un logout?
-
 
663
                        .build();
-
 
664
 
-
 
665
                Call call = client.newCall(request);
-
 
666
 
-
 
667
                call.enqueue(new Callback() {
-
 
668
                    public void onResponse(Call call, Response response)
-
 
669
                            throws IOException {
-
 
670
 
-
 
671
                        Log.e("Respuesta logout",""+response);
-
 
672
 
-
 
673
                    }
-
 
674
                    public void onFailure(Call call, IOException e) {
-
 
675
                        Log.e(TAG, "Error :  " +  e.getMessage());
-
 
676
 
-
 
677
                    }
-
 
678
                });
-
 
679
 
-
 
680
            } catch (Exception e) {
-
 
681
                showMessageSnackBar(e.getMessage());
-
 
682
            }
612
    {
683
        }        
613
        mAppDatabase.getAnswerDao().removeAll();
684
	mAppDatabase.getAnswerDao().removeAll();
614
        mAppDatabase.getQuestionDao().removeAll();
685
        mAppDatabase.getQuestionDao().removeAll();
615
        mAppDatabase.getQuizDao().removeAll();
686
        mAppDatabase.getQuizDao().removeAll();
616
        mAppDatabase.getSlideDao().removeAll();
687
        mAppDatabase.getSlideDao().removeAll();
617
        mAppDatabase.getCapsuleDao().removeAll();
688
        mAppDatabase.getCapsuleDao().removeAll();
Línea 630... Línea 701...
630
        preference.setImage("");
701
        preference.setImage("");
631
        preference.setMaxDateChanges("");
702
        preference.setMaxDateChanges("");
632
        preference.setCompanyCount(0);
703
        preference.setCompanyCount(0);
633
        preference.setCompanyUuidActive("");
704
        preference.setCompanyUuidActive("");
634
        preference.setTopicUuidActive("");
705
        preference.setTopicUuidActive("");
635
        preference.setCapsuleUuidActive("");
706
      //  preference.setCapsuleUuidActive("");
-
 
707
        setNoCapsuleActive();
636
        preference.setSlideUuidActive("");
708
        preference.setSlideUuidActive("");
637
        preference.save();
709
        preference.save();
Línea 638... Línea 710...
638
 
710
 
Línea 683... Línea 755...
683
 
755
 
684
                break;
756
                break;
Línea 685... Línea 757...
685
            case Constants.IDX_FRAGMENT_FINISH_TOPIC :
757
            case Constants.IDX_FRAGMENT_FINISH_TOPIC :
686
 
758
 
-
 
759
                preference.setTopicUuidActive("");
687
                preference.setTopicUuidActive("");
760
               // preference.setCapsuleUuidActive("");
688
                preference.setCapsuleUuidActive("");
761
                setNoCapsuleActive();
Línea 689... Línea 762...
689
                preference.setSlideUuidActive("");
762
                preference.setSlideUuidActive("");
690
                preference.save();
763
                preference.save();
Línea 722... Línea 795...
722
                    invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
795
                    invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
723
                }
796
                }
724
                return;
797
                return;
Línea 725... Línea 798...
725
 
798
 
726
            case Constants.IDX_FRAGMENT_FINISH_CAPSULE :
799
            case Constants.IDX_FRAGMENT_FINISH_CAPSULE :
-
 
800
              //  preference.setCapsuleUuidActive("");
727
                preference.setCapsuleUuidActive("");
801
                setNoCapsuleActive();
728
                preference.setSlideUuidActive("");
802
                preference.setSlideUuidActive("");
Línea 729... Línea 803...
729
                preference.save();
803
                preference.save();
730
 
804
 
Línea 1218... Línea 1292...
1218
                    fragment = new WelcomeFragment();
1292
                    fragment = new WelcomeFragment();
1219
                  //  Log.e("Vete"," a welcome");
1293
                  //  Log.e("Vete"," a welcome");
1220
                }
1294
                }
1221
                break;
1295
                break;
Línea -... Línea 1296...
-
 
1296
 
-
 
1297
            case Constants.IDX_FRAGMENT_DETAIL_CAPSULE:
-
 
1298
                // badgenotification.setVisibility(View.VISIBLE);
-
 
1299
                // getSupportActionBar().show();
-
 
1300
                //  mDrawerToggle.setDrawerIndicatorEnabled(true);
-
 
1301
                if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
-
 
1302
                    fragment = fragmentHashMap.get(fragmentKeyNuevo);
-
 
1303
                } else {
-
 
1304
                    add = true;
-
 
1305
                    fragment = new CapsuleDetail();
-
 
1306
                    //  Log.e("Vete"," a welcome");
-
 
1307
                }
-
 
1308
                break;
1222
 
1309
 
1223
            default :
1310
            default :
1224
               // getSupportActionBar().hide();
1311
               // getSupportActionBar().hide();
1225
               // badgenotification.setVisibility(View.GONE);
1312
               // badgenotification.setVisibility(View.GONE);
1226
                if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
1313
                if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
Línea 1256... Línea 1343...
1256
    {
1343
    {
1257
        Log.d(TAG, "changeTopicActive : " + topicUuid);
1344
        Log.d(TAG, "changeTopicActive : " + topicUuid);
1258
       // Log.e("Guardo", "Topico en Main");
1345
       // Log.e("Guardo", "Topico en Main");
Línea 1259... Línea 1346...
1259
 
1346
 
1260
        preference.setTopicUuidActive(topicUuid);
1347
        preference.setTopicUuidActive(topicUuid);
-
 
1348
       // preference.setCapsuleUuidActive("");
1261
        preference.setCapsuleUuidActive("");
1349
        setNoCapsuleActive();
1262
        preference.setSlideUuidActive("");
1350
        preference.setSlideUuidActive("");
Línea 1263... Línea 1351...
1263
        preference.save();
1351
        preference.save();
1264
 
1352
 
Línea 1269... Línea 1357...
1269
    public void changeCapsuleActive(String capsuleUuid)
1357
    public void changeCapsuleActive(String capsuleUuid)
1270
    {
1358
    {
1271
        Log.d(TAG, "changeCapsuleActive : " + capsuleUuid);
1359
        Log.d(TAG, "changeCapsuleActive : " + capsuleUuid);
Línea 1272... Línea -...
1272
 
-
 
1273
 
1360
 
-
 
1361
 
1274
 
1362
     //   preference.setCapsuleUuidActive(capsuleUuid);
1275
        preference.setCapsuleUuidActive(capsuleUuid);
1363
        setCapsulaActiva(capsuleUuid);
Línea -... Línea 1364...
-
 
1364
        preference.setSlideUuidActive("");
-
 
1365
        preference.save();
-
 
1366
 
-
 
1367
        Progress progress; ProgressDao progressDao = getDatabase().getProgressDao();
-
 
1368
        progress = progressDao.selectByCapsuleUuid(capsuleUuid);
-
 
1369
 
-
 
1370
        if(progress != null) {
-
 
1371
            if (progress.getProgress() >= 100 && progress.getCompleted() == 1) {
-
 
1372
                invokeFragment(Constants.IDX_FRAGMENT_DETAIL_CAPSULE);
-
 
1373
            } else {
-
 
1374
                invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
-
 
1375
            }
1276
        preference.setSlideUuidActive("");
1376
        }
-
 
1377
        else
-
 
1378
        {
-
 
1379
            invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
-
 
1380
 
-
 
1381
        }
-
 
1382
    }
-
 
1383
 
-
 
1384
    public void setCapsulaActiva(String capsuleUuid) {
-
 
1385
 
-
 
1386
        ConfigDao configuracion =  mAppDatabase.getConfigDao();
-
 
1387
 
-
 
1388
        Config actual = configuracion.selectConfigByTitle("act_capsule");
-
 
1389
        com.cesams.twogetskills.inconcert.entity.Config confignueva;
-
 
1390
 
-
 
1391
        confignueva = new com.cesams.twogetskills.inconcert.entity.Config();
-
 
1392
        confignueva.setId(actual.getId());
-
 
1393
        confignueva.setTitle("act_capsule");
1277
        preference.save();
1394
        confignueva.setNow(capsuleUuid);
Línea 1278... Línea 1395...
1278
 
1395
 
1279
        invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
1396
        configuracion.update(confignueva);
1280
    }
1397
    }
Línea 1316... Línea 1433...
1316
    }
1433
    }
Línea 1317... Línea 1434...
1317
 
1434
 
1318
    @Override
1435
    @Override
1319
    public String getCapsuleUuidActive()
1436
    public String getCapsuleUuidActive()
1320
    {
1437
    {
-
 
1438
       // return preference.getCapsuleUuidActive();
-
 
1439
 
-
 
1440
        ConfigDao configuracion =  mAppDatabase.getConfigDao();
-
 
1441
        Config config = configuracion.selectConfigByTitle("act_capsule");
-
 
1442
        Log.e("algo","aqui"+config.getNow());
1321
        return preference.getCapsuleUuidActive();
1443
        return config.getNow();
Línea 1322... Línea 1444...
1322
    }
1444
    }
1323
 
1445
 
1324
    @Override
1446
    @Override
Línea 1523... Línea 1645...
1523
            progressCapsule.setProgress(percentaje);
1645
            progressCapsule.setProgress(percentaje);
Línea 1524... Línea 1646...
1524
 
1646
 
1525
            Log.d(TAG, "Progress Capsule : getLastCapsuleActive : " + preference.getLastCapsuleUuidActive());
1647
            Log.d(TAG, "Progress Capsule : getLastCapsuleActive : " + preference.getLastCapsuleUuidActive());
Línea 1526... Línea 1648...
1526
            Log.d(TAG, "Progress Capsule : CapsuleActive : " + preference.getCapsuleUuidActive());
1648
            Log.d(TAG, "Progress Capsule : CapsuleActive : " + preference.getCapsuleUuidActive());
Línea 1527... Línea 1649...
1527
 
1649
 
1528
            if (!preference.getLastCapsuleUuidActive().equals(preference.getCapsuleUuidActive())) {
1650
            if (!preference.getLastCapsuleUuidActive().equals(getCapsuleUuidActive())) {
1529
 
1651
 
1530
                Log.d(TAG, "Capsule Progress : " + progressCapsule.getProgress());
1652
               // Log.d(TAG, "Capsule Progress : " + progressCapsule.getProgress());
Línea 1531... Línea 1653...
1531
                Log.d(TAG, "Capsule Completed : " + progressCapsule.getCompleted());
1653
               // Log.d(TAG, "Capsule Completed : " + progressCapsule.getCompleted());
1532
                Log.d(TAG, "Capsule Total slides : " + progressCapsule.getTotalSlides());
1654
               // Log.d(TAG, "Capsule Total slides : " + progressCapsule.getTotalSlides());
Línea 1533... Línea 1655...
1533
                Log.d(TAG, "Capsule View slides : " + progressCapsule.getViewSlides());
1655
               // Log.d(TAG, "Capsule View slides : " + progressCapsule.getViewSlides());
Línea 1779... Línea 1901...
1779
 
1901
 
1780
            TopicDao topicDao = mAppDatabase.getTopicDao();
1902
            TopicDao topicDao = mAppDatabase.getTopicDao();
Línea 1781... Línea 1903...
1781
            Topic topic = topicDao.selectByUuid(preference.getTopicUuidActive());
1903
            Topic topic = topicDao.selectByUuid(preference.getTopicUuidActive());
1782
 
1904
 
Línea 1783... Línea 1905...
1783
            CapsuleDao capsuleDao = mAppDatabase.getCapsuleDao();
1905
            CapsuleDao capsuleDao = mAppDatabase.getCapsuleDao();
1784
            Capsule capsule = capsuleDao.selectByUuid(preference.getCapsuleUuidActive());
1906
            Capsule capsule = capsuleDao.selectByUuid(getCapsuleUuidActive());
Línea 1785... Línea 1907...
1785
 
1907
 
Línea 2237... Línea 2359...
2237
                            capsule.setDescription(objCapsule.getString("description"));
2359
                            capsule.setDescription(objCapsule.getString("description"));
2238
                            capsule.setImage(objCapsule.getString("image"));
2360
                            capsule.setImage(objCapsule.getString("image"));
2239
                            capsule.setPosition(objCapsule.getInt("position"));
2361
                            capsule.setPosition(objCapsule.getInt("position"));
2240
                            capsule.setAddedOn(objCapsule.getString("added_on"));
2362
                            capsule.setAddedOn(objCapsule.getString("added_on"));
2241
                            capsule.setUpdatedOn(objCapsule.getString("updated_on"));
2363
                            capsule.setUpdatedOn(objCapsule.getString("updated_on"));
-
 
2364
                            capsule.setLink_comments(objCapsule.getString("link_comments"));
-
 
2365
                            capsule.setLink_comment_add(objCapsule.getString("link_comment_add"));
-
 
2366
                            capsule.setTotal_comments(objCapsule.getInt("total_comments"));
-
 
2367
                            capsule.setTotal_rating(objCapsule.getInt("total_rating"));
-
 
2368
 
-
 
2369
                            Log.e("link1",""+objCapsule.getString("link_comments"));
-
 
2370
                            Log.e("link2",""+objCapsule.getString("link_comment_add"));
-
 
2371
                            Log.e("totalcom",""+objCapsule.getInt("total_comments"));
-
 
2372
                            Log.e("totalta",""+objCapsule.getInt("total_rating"));
-
 
2373
 
2242
                           // Log.e("Capsula ","added on"+objCapsule.getString("added_on"));
2374
                            // Log.e("Capsula ","added on"+objCapsule.getString("added_on"));
2243
                            capsuleDao.insert(capsule);
2375
                            capsuleDao.insert(capsule);
2244
                        } else {
2376
                        } else {
2245
                            capsule = new Capsule();
2377
                            capsule = new Capsule();
2246
                            capsule.setTopicUuid(topic.getUuid());
2378
                            capsule.setTopicUuid(topic.getUuid());
2247
                            capsule.setName(objCapsule.getString("name"));
2379
                            capsule.setName(objCapsule.getString("name"));
2248
                            capsule.setDescription(objCapsule.getString("description"));
2380
                            capsule.setDescription(objCapsule.getString("description"));
2249
                            capsule.setImage(objCapsule.getString("image"));
2381
                            capsule.setImage(objCapsule.getString("image"));
2250
                            capsule.setPosition(objCapsule.getInt("position"));
2382
                            capsule.setPosition(objCapsule.getInt("position"));
2251
                            capsule.setAddedOn(objCapsule.getString("added_on"));
2383
                            capsule.setAddedOn(objCapsule.getString("added_on"));
2252
                            capsule.setUpdatedOn(objCapsule.getString("updated_on"));
2384
                            capsule.setUpdatedOn(objCapsule.getString("updated_on"));
-
 
2385
                            capsule.setLink_comments(objCapsule.getString("link_comments"));
-
 
2386
                            capsule.setLink_comment_add(objCapsule.getString("link_comment_add"));
-
 
2387
                            capsule.setTotal_comments(objCapsule.getInt("total_comments"));
-
 
2388
                            capsule.setTotal_rating(objCapsule.getInt("total_rating"));
2253
                           // Log.e("Capsula ","added on"+objCapsule.getString("added_on"));
2389
                           // Log.e("Capsula ","added on"+objCapsule.getString("added_on"));
2254
                            capsuleDao.update(capsule);
2390
                            capsuleDao.update(capsule);
2255
                        }
2391
                        }