Proyectos de Subversion Android Microlearning

Rev

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

Rev 27 Rev 29
Línea 192... Línea 192...
192
        // Get the content resolver for your app
192
        // Get the content resolver for your app
193
        //mResolver = getContentResolver();
193
        //mResolver = getContentResolver();
Línea 194... Línea 194...
194
 
194
 
Línea 195... Línea 195...
195
        mAppDatabase = DatabaseHelper.getInstance(this).getAppDatabase();
195
        mAppDatabase = DatabaseHelper.getInstance(this).getAppDatabase();
Línea 196... Línea 196...
196
 
196
 
197
        preference = new Preference(getApplicationContext());
197
        preference = Preference.getInstance(getApplicationContext());
198
 
198
 
199
        if(TextUtils.isEmpty(preference.getDeviceUuid())) {
199
        if(TextUtils.isEmpty(preference.getDeviceUuid())) {
Línea 200... Línea 200...
200
            String uuid = UniqueID.id(getApplicationContext());
200
            String uuid = UniqueID.id(getApplicationContext());
201
            preference.setDeviceUuid(uuid);
201
            preference.setDeviceUuid(uuid);
Línea 202... Línea 202...
202
            preference.save(getApplicationContext());
202
            preference.save();
Línea 270... Línea 270...
270
    @Override
270
    @Override
271
    protected void onResume() {
271
    protected void onResume() {
272
        super.onResume();
272
        super.onResume();
273
        isForeground = true;
273
        isForeground = true;
Línea 274... Línea -...
274
 
-
 
275
        if(preference == null) {
274
 
276
            preference = new Preference(getApplicationContext());
-
 
277
        } else {
-
 
278
            preference.load(getApplicationContext());
-
 
279
        }
275
        preference = Preference.getInstance(getApplicationContext());
Línea 280... Línea 276...
280
        reloadNavHeader();
276
        reloadNavHeader();
Línea 281... Línea 277...
281
 
277
 
Línea 304... Línea 300...
304
    @Override
300
    @Override
305
    protected void onPause() {
301
    protected void onPause() {
306
        super.onPause();
302
        super.onPause();
Línea 307... Línea 303...
307
 
303
 
308
        isForeground = false;
304
        isForeground = false;
309
        preference.save(getApplicationContext());
305
        preference.save();
Línea -... Línea 306...
-
 
306
    }
310
    }
307
 
311
 
308
    /*
312
    @Override
309
    @Override
313
    protected void onRestart() {
-
 
314
        super.onRestart();
-
 
315
 
310
    protected void onRestart() {
316
        if(preference == null) {
-
 
317
            preference = new Preference(getApplicationContext());
-
 
318
        } else {
-
 
Línea 319... Línea 311...
319
            preference.load(getApplicationContext());
311
        super.onRestart();
Línea 320... Línea 312...
320
        }
312
        preference = Preference.getInstance(getApplicationContext());
321
 
313
 
Línea 337... Línea 329...
337
            }
329
            }
338
        }
330
        }
Línea 339... Línea 331...
339
 
331
 
-
 
332
 
Línea -... Línea 333...
-
 
333
    }
340
 
334
    */
341
    }
335
 
342
 
336
    /*
343
    @Override
337
    @Override
Línea 344... Línea 338...
344
    protected void onStop() {
338
    protected void onStop() {
-
 
339
        super.onStop();
Línea 345... Línea 340...
345
        super.onStop();
340
        preference.save();
346
        preference.save(getApplicationContext());
341
 
347
 
342
    }
348
    }
343
    */
Línea 493... Línea 488...
493
        preference.setCompanyCount(0);
488
        preference.setCompanyCount(0);
494
        preference.setCompanyUuidActive("");
489
        preference.setCompanyUuidActive("");
495
        preference.setTopicUuidActive("");
490
        preference.setTopicUuidActive("");
496
        preference.setCapsuleUuidActive("");
491
        preference.setCapsuleUuidActive("");
497
        preference.setSlideUuidActive("");
492
        preference.setSlideUuidActive("");
498
        preference.save(getApplicationContext());
493
        preference.save();
Línea 499... Línea 494...
499
 
494
 
500
        invokeFragment(Constants.IDX_FRAGMENT_INTRO);
495
        invokeFragment(Constants.IDX_FRAGMENT_INTRO);
Línea 501... Línea 496...
501
    }
496
    }
Línea 528... Línea 523...
528
            case Constants.IDX_FRAGMENT_FINISH_TOPIC :
523
            case Constants.IDX_FRAGMENT_FINISH_TOPIC :
Línea 529... Línea 524...
529
 
524
 
530
                preference.setTopicUuidActive("");
525
                preference.setTopicUuidActive("");
531
                preference.setCapsuleUuidActive("");
526
                preference.setCapsuleUuidActive("");
532
                preference.setSlideUuidActive("");
527
                preference.setSlideUuidActive("");
Línea 533... Línea 528...
533
                preference.save(getApplicationContext());
528
                preference.save();
534
 
529
 
Línea 535... Línea 530...
535
                invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
530
                invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
Línea 544... Línea 539...
544
                return;
539
                return;
Línea 545... Línea 540...
545
 
540
 
546
            case Constants.IDX_FRAGMENT_FINISH_CAPSULE :
541
            case Constants.IDX_FRAGMENT_FINISH_CAPSULE :
547
                preference.setCapsuleUuidActive("");
542
                preference.setCapsuleUuidActive("");
548
                preference.setSlideUuidActive("");
543
                preference.setSlideUuidActive("");
Línea 549... Línea 544...
549
                preference.save(getApplicationContext());
544
                preference.save();
550
 
545
 
Línea 551... Línea 546...
551
                invokeFragment(Constants.IDX_FRAGMENT_CAPSULES);
546
                invokeFragment(Constants.IDX_FRAGMENT_CAPSULES);
Línea 662... Línea 657...
662
    @Override
657
    @Override
663
    public void createSyncRecordNewToken(String token)
658
    public void createSyncRecordNewToken(String token)
664
    {
659
    {
Línea 665... Línea 660...
665
 
660
 
666
        preference.setDeviceToken (token);
661
        preference.setDeviceToken (token);
Línea 667... Línea 662...
667
        preference.save(getApplicationContext());
662
        preference.save();
668
 
663
 
669
        if(!TextUtils.isEmpty(preference.getDeviceUuid())) {
664
        if(!TextUtils.isEmpty(preference.getDeviceUuid())) {
670
            Sync sync = new Sync(Constants.SYNC_ADAPTER_TYPE_FCM, token);
665
            Sync sync = new Sync(Constants.SYNC_ADAPTER_TYPE_FCM, token);
Línea 731... Línea 726...
731
    public void invokeFragment(int fragmentIdxActiveNuevo)
726
    public void invokeFragment(int fragmentIdxActiveNuevo)
732
    {
727
    {
733
        String fragmentKeyActual    = PREFIX_FRAG + preference.getFragmentIdxActive();
728
        String fragmentKeyActual    = PREFIX_FRAG + preference.getFragmentIdxActive();
734
        String fragmentKeyNuevo 	= PREFIX_FRAG + fragmentIdxActiveNuevo;
729
        String fragmentKeyNuevo 	= PREFIX_FRAG + fragmentIdxActiveNuevo;
735
        preference.setFragmentIdxActive(fragmentIdxActiveNuevo);
730
        preference.setFragmentIdxActive(fragmentIdxActiveNuevo);
736
        preference.save(getApplicationContext());
731
        preference.save();
Línea 737... Línea 732...
737
 
732
 
738
        Fragment fragment;
733
        Fragment fragment;
739
        if(!fragmentKeyActual.equalsIgnoreCase(fragmentKeyNuevo)) {
734
        if(!fragmentKeyActual.equalsIgnoreCase(fragmentKeyNuevo)) {
740
            if(fragmentHashMap.containsKey(fragmentKeyActual)) {
735
            if(fragmentHashMap.containsKey(fragmentKeyActual)) {
Línea 913... Línea 908...
913
       // Log.e("Guardo", "Topico en Main");
908
       // Log.e("Guardo", "Topico en Main");
Línea 914... Línea 909...
914
 
909
 
915
        preference.setTopicUuidActive(topicUuid);
910
        preference.setTopicUuidActive(topicUuid);
916
        preference.setCapsuleUuidActive("");
911
        preference.setCapsuleUuidActive("");
917
        preference.setSlideUuidActive("");
912
        preference.setSlideUuidActive("");
Línea 918... Línea 913...
918
        preference.save(getApplicationContext());
913
        preference.save();
919
 
914
 
Línea 920... Línea 915...
920
        invokeFragment(Constants.IDX_FRAGMENT_CAPSULES);
915
        invokeFragment(Constants.IDX_FRAGMENT_CAPSULES);
Línea 927... Línea 922...
927
 
922
 
928
 
923
 
929
 
-
 
930
        preference.setCapsuleUuidActive(capsuleUuid);
-
 
931
        preference.setSlideUuidActive("");
924
 
Línea 932... Línea 925...
932
 
925
        preference.setCapsuleUuidActive(capsuleUuid);
933
 
926
        preference.setSlideUuidActive("");
Línea 934... Línea 927...
934
        preference.save(getApplicationContext());
927
        preference.save();
935
 
928
 
936
        invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
929
        invokeFragment(Constants.IDX_FRAGMENT_SLIDES);
937
    }
930
    }
Línea 938... Línea 931...
938
 
931
 
939
    @Override
932
    @Override
940
    public void changeCompanyActive(String companyUuid)
933
    public void changeCompanyActive(String companyUuid)
Línea 941... Línea 934...
941
    {
934
    {
942
        Log.d(TAG, "changeCompanyActive : " + companyUuid);
935
        Log.d(TAG, "changeCompanyActive : " + companyUuid);
943
 
936
 
Línea 954... Línea 947...
954
        if(!preference.getSlideUuidActive().equals(slideUuid) && type.equals(Constants.SLIDE_TYPE_IMAGE)) {
947
        if(!preference.getSlideUuidActive().equals(slideUuid) && type.equals(Constants.SLIDE_TYPE_IMAGE)) {
955
            Log.d(TAG, "registerOnPageChangeCallback - createProgressAndSyncRecord");
948
            Log.d(TAG, "registerOnPageChangeCallback - createProgressAndSyncRecord");
Línea 956... Línea 949...
956
 
949
 
957
            createProgressAndSyncRecord(slideUuid, true, false, false);
950
            createProgressAndSyncRecord(slideUuid, true, false, false);
958
        }
-
 
959
 
-
 
960
 
-
 
961
 
951
        }
962
        preference.setSlideUuidActive(slideUuid);
952
        preference.setSlideUuidActive(slideUuid);
Línea 963... Línea 953...
963
        preference.save(getApplicationContext());
953
        preference.save();
964
 
954
 
965
 
955
 
Línea 1203... Línea 1193...
1203
                    Log.d(TAG, "Capsule NEW returningAfterCompleted = " + returningAfterCompleted);
1193
                    Log.d(TAG, "Capsule NEW returningAfterCompleted = " + returningAfterCompleted);
1204
                    progressCapsule.setReturningAfterCompleted(returningAfterCompleted);
1194
                    progressCapsule.setReturningAfterCompleted(returningAfterCompleted);
1205
                }
1195
                }
Línea 1206... Línea 1196...
1206
 
1196
 
1207
                preference.setLastCapsuleUuidActive(capsule.getUuid());
1197
                preference.setLastCapsuleUuidActive(capsule.getUuid());
Línea 1208... Línea 1198...
1208
                preference.save(getApplicationContext());
1198
                preference.save();
1209
 
1199
 
Línea 1210... Línea 1200...
1210
                Log.d(TAG, "Progress Capsule : setLastCapsuleActive : " + preference.getLastCapsuleUuidActive());
1200
                Log.d(TAG, "Progress Capsule : setLastCapsuleActive : " + preference.getLastCapsuleUuidActive());
Línea 1515... Línea 1505...
1515
    public Preference getPreference() {
1505
    public Preference getPreference() {
1516
        return preference;
1506
        return preference;
1517
    }
1507
    }
Línea 1518... Línea 1508...
1518
 
1508
 
1519
    @Override
-
 
1520
    public Preference reloadPreference()
-
 
1521
    {
-
 
1522
        preference = new Preference(getApplicationContext());
-
 
1523
        return preference;
-
 
1524
    }
-
 
1525
 
-
 
1526
    @Override
1509
    @Override
1527
    public void reloadNavHeader() {
1510
    public void reloadNavHeader() {
1528
        Log.d(TAG, "User Image = " + preference.getImage());
1511
        Log.d(TAG, "User Image = " + preference.getImage());
1529
        navHeaderUserName.setText((preference.getFirstName() + " " + preference.getLastName()).trim());
1512
        navHeaderUserName.setText((preference.getFirstName() + " " + preference.getLastName()).trim());
Línea 1972... Línea 1955...
1972
 
1955
 
Línea 1973... Línea 1956...
1973
            }
1956
            }
1974
 
1957
 
1975
            preference.setLastDataRefresh(addedOn);
1958
            preference.setLastDataRefresh(addedOn);
Línea 1976... Línea 1959...
1976
            preference.setCompanyCount(companySize);
1959
            preference.setCompanyCount(companySize);
1977
            preference.save(getApplicationContext());
1960
            preference.save();
1978
 
1961
 
1979
        } catch (JSONException e) {
1962
        } catch (JSONException e) {
Línea 2006... Línea 1989...
2006
 
1989
 
2007
            if(success) {
1990
            if(success) {
2008
                Calendar calendar = Calendar.getInstance();
1991
                Calendar calendar = Calendar.getInstance();
2009
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
1992
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
2010
                preference.setLastDataRefresh(simpleDateFormat.format(calendar.getTime()));
1993
                preference.setLastDataRefresh(simpleDateFormat.format(calendar.getTime()));
Línea 2011... Línea 1994...
2011
                preference.save(getApplicationContext());
1994
                preference.save();
2012
 
1995
 
Línea 2013... Línea 1996...
2013
                String max_date_changes = "";
1996
                String max_date_changes = "";