Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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

Rev 18 Rev 19
Línea 202... Línea 202...
202
 
202
 
203
        preference = Preference.getInstance(getApplicationContext());
203
        preference = Preference.getInstance(getApplicationContext());
Línea 204... Línea 204...
204
        preference.load();
204
        preference.load();
-
 
205
 
205
 
206
        if(TextUtils.isEmpty(preference.getDeviceUuid())) {
206
        if(TextUtils.isEmpty(preference.getDeviceUuid())) {
207
            Log.e("Encontre","vacio el preferencie"+preference.getDeviceUuid());
-
 
208
            String uuid = UniqueID.id(getApplicationContext());
207
            String uuid = UniqueID.id(getApplicationContext());
209
            preference.setDeviceUuid(uuid);
Línea 208... Línea 210...
208
            preference.setDeviceUuid(uuid);
210
            Log.e("Pero ya setie","uno nuevo"+uuid);
209
            preference.save();
211
            preference.save();
Línea 390... Línea 392...
390
        
392
        
Línea 391... Línea 393...
391
       // reloadNavHeader();
393
       // reloadNavHeader();
Línea -... Línea 394...
-
 
394
 
-
 
395
        Log.e("Se ejecuta", "On resumen");
392
 
396
 
Línea 393... Línea 397...
393
        Log.e("Se ejecuta", "On resumen");
397
        Log.e("El device uuid",""+preference.getDeviceUuid());
394
 
398
 
395
        if(TextUtils.isEmpty(preference.getUserUuid())) {
399
        if(TextUtils.isEmpty(preference.getUserUuid())) {
Línea 403... Línea 407...
403
 
407
 
404
 
408
 
405
        } else {
409
        } else {
-
 
410
            if(preference.getFragmentIdxActive() == 0) {
406
            if(preference.getFragmentIdxActive() == 0) {
411
                invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
407
                invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
412
                Log.e("El device uuid",""+preference.getDeviceUuid());
408
            } else {
413
            } else {
409
                invokeFragment(preference.getFragmentIdxActive());
414
                invokeFragment(preference.getFragmentIdxActive());
Línea 470... Línea 475...
470
                invokeFragment(Constants.IDX_FRAGMENT_WELCOME);
475
                invokeFragment(Constants.IDX_FRAGMENT_WELCOME);
471
                break;
476
                break;
472
            case R.id.action_topicos:
477
            case R.id.action_topicos:
473
                setTitleActionBar(getString(R.string.menu_topics));
478
                setTitleActionBar(getString(R.string.menu_topics));
474
                invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
479
                invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
-
 
480
                break;
-
 
481
            case R.id.nav_timeline:
-
 
482
                setTitleActionBar(getString(R.string.menu_timeline));
-
 
483
                invokeFragment(Constants.IDX_FRAGMENT_TIMELINE);
Línea 475... Línea 484...
475
 
484
 
476
                break;
485
                break;
Línea 477... Línea 486...
477
            case R.id.nav_progress:
486
            case R.id.nav_progress:
Línea 595... Línea 604...
595
        mAppDatabase.getCapsuleDao().removeAll();
604
        mAppDatabase.getCapsuleDao().removeAll();
596
        mAppDatabase.getTopicDao().removeAll();
605
        mAppDatabase.getTopicDao().removeAll();
597
        mAppDatabase.getUserExtendedDao().removeAll();
606
        mAppDatabase.getUserExtendedDao().removeAll();
Línea -... Línea 607...
-
 
607
 
-
 
608
 
-
 
609
        mAppDatabase.getUserLogDao().removeAll();
-
 
610
        mAppDatabase.getProgressDao().removeAll();
598
 
611
        mAppDatabase.getNotificationCenterDao().removeAllnotifications();
599
 
612
 
600
        preference.setUserUuid("");
613
        preference.setUserUuid("");
601
        preference.setFirstName("");
614
        preference.setFirstName("");
602
        preference.setLastName("");
615
        preference.setLastName("");
Línea 639... Línea 652...
639
            case Constants.IDX_FRAGMENT_TIMELINE  :
652
            case Constants.IDX_FRAGMENT_TIMELINE  :
640
            case Constants.IDX_FRAGMENT_CAPSULES :
653
            case Constants.IDX_FRAGMENT_CAPSULES :
641
                if(preference.getOrigenNavigation().equals("welcome"))
654
                if(preference.getOrigenNavigation().equals("welcome"))
642
                {
655
                {
643
                    preference.setOrigennavigation("");
656
                    preference.setOrigennavigation("");
-
 
657
                    setTitleActionBar(getString(R.string.app_name));
644
                    invokeFragment(Constants.IDX_FRAGMENT_WELCOME);
658
                    invokeFragment(Constants.IDX_FRAGMENT_WELCOME);
Línea 645... Línea 659...
645
 
659
 
Línea 646... Línea 660...
646
                }
660
                }
Línea 1135... Línea 1149...
1135
        preference.setCompanyUuidActive(companyUuid);
1149
        preference.setCompanyUuidActive(companyUuid);
1136
        preference.save();
1150
        preference.save();
1137
    }
1151
    }
Línea 1138... Línea 1152...
1138
 
1152
 
1139
    @Override
1153
    @Override
1140
    public void changeSlideActive(String slideUuid, String type, boolean showGallery)
1154
    public synchronized void changeSlideActive(String slideUuid, String type, boolean showGallery)
Línea 1141... Línea 1155...
1141
    {
1155
    {
Línea 1142... Línea 1156...
1142
 
1156
 
Línea 1151... Línea 1165...
1151
        preference.save();
1165
        preference.save();
Línea 1152... Línea 1166...
1152
 
1166
 
1153
 
1167
 
1154
        if(showGallery) {
-
 
1155
            invokeFragment(Constants.IDX_FRAGMENT_GALLERY);
-
 
1156
            Log.e("Aqui","Es donde cambio el capsule");
-
 
1157
 
-
 
1158
            SlideRefreshUIViewData slideRefreshUIViewData = mSlideRefreshUIViewModel.getSlideRefreshUIViewData();
-
 
Línea 1159... Línea -...
1159
            slideRefreshUIViewData.setCambioSlide(true);
-
 
1160
            mSlideRefreshUIViewModel.getSlideRefreshUIMutableLiveData().setValue(slideRefreshUIViewData);
1168
        if(showGallery) {
1161
 
1169
            invokeFragment(Constants.IDX_FRAGMENT_GALLERY);
Línea 1162... Línea 1170...
1162
            //DatabaseHelper.CambioSlide="SI";
1170
 
1163
        }
1171
        }
Línea 1215... Línea 1223...
1215
        UserLogDao userLogDao = mAppDatabase.getUserLogDao();
1223
        UserLogDao userLogDao = mAppDatabase.getUserLogDao();
Línea 1216... Línea 1224...
1216
 
1224
 
1217
        SyncDao syncDao = mAppDatabase.getSyncDao();
1225
        SyncDao syncDao = mAppDatabase.getSyncDao();
Línea -... Línea 1226...
-
 
1226
        Sync sync;
-
 
1227
 
1218
        Sync sync;
1228
        String userUuid = preference.getUserUuid();
1219
 
1229
 
1220
        // Progreso y UserLog  del Slide
1230
        // Progreso y UserLog  del Slide
1221
        ProgressDao progressDao = mAppDatabase.getProgressDao();
1231
        ProgressDao progressDao = mAppDatabase.getProgressDao();
1222
        Progress progressSlide = progressDao.selectBySlideUuid(slide.getUuid());
1232
        Progress progressSlide = progressDao.selectBySlideUuidAndUserUuid(slide.getUuid(), userUuid);
Línea 1223... Línea 1233...
1223
        Progress progressCapsule =  progressDao.selectByCapsuleUuid(slide.getCapsuleUuid());
1233
        Progress progressCapsule =  progressDao.selectByCapsuleUuidAndUserUuid(slide.getCapsuleUuid(),userUuid);
1224
        Progress progressTopic =  progressDao.selectByTopicUuid(slide.getTopicUuid());
1234
        Progress progressTopic =  progressDao.selectByTopicUuidAndUserUuid(slide.getTopicUuid(),userUuid);
1225
 
1235
 
1226
        int totalSlides = 0;
1236
        int totalSlides = 0;
Línea 1275... Línea 1285...
1275
 
1285
 
1276
 
1286
 
Línea 1277... Línea 1287...
1277
        resultCount = slideDao.getCountByTopicUuid(slide.getTopicUuid());
1287
        resultCount = slideDao.getCountByTopicUuid(slide.getTopicUuid());
1278
        totalSlides = resultCount.getCount();
1288
        totalSlides = resultCount.getCount();
1279
 
1289
 
1280
        resultCount = progressDao.getCountSlidesCompletedByTopicUuid(slide.getTopicUuid());
1290
        resultCount = progressDao.getCountSlidesCompletedByTopicUuidAndUserUuid(slide.getTopicUuid(), userUuid);
1281
        viewSlides =  resultCount.getCount();
1291
        viewSlides =  resultCount.getCount();
1282
        if(totalSlides == 0) {
1292
        if(totalSlides == 0) {
Línea 1341... Línea 1351...
1341
 
1351
 
1342
 
1352
 
1343
        /*** INICIO PROCESO CAPSULA ***/
1353
        /*** INICIO PROCESO CAPSULA ***/
1344
        resultCount = slideDao.getCountByCapsuleUuid(slide.getCapsuleUuid());
1354
        resultCount = slideDao.getCountByCapsuleUuid(slide.getCapsuleUuid());
1345
        totalSlides = resultCount.getCount();
1355
        totalSlides = resultCount.getCount();
1346
        resultCount = progressDao.getCountSlidesCompletedByCapsuleUuid(slide.getCapsuleUuid());
1356
        resultCount = progressDao.getCountSlidesCompletedByCapsuleUuidAndUserUuid(slide.getCapsuleUuid(), userUuid);
1347
        viewSlides =  resultCount.getCount();
1357
        viewSlides =  resultCount.getCount();
1348
        if(totalSlides == 0) {
1358
        if(totalSlides == 0) {
1349
            percentaje = 0;
1359
            percentaje = 0;
Línea 1594... Línea 1604...
1594
 
1604
 
1595
    @Override
1605
    @Override
1596
    public void launchQuizViewer(String quizUuid)
1606
    public void launchQuizViewer(String quizUuid)
1597
    {
1607
    {
1598
        ProgressDao progressDao = mAppDatabase.getProgressDao();
1608
        ProgressDao progressDao = mAppDatabase.getProgressDao();
Línea 1599... Línea 1609...
1599
        Progress progress = progressDao.selectBySlideUuid(preference.getSlideUuidActive());
1609
        Progress progress = progressDao.selectBySlideUuidAndUserUuid(preference.getSlideUuidActive(), preference.getUserUuid());
1600
 
1610
 
Línea 1601... Línea 1611...
1601
        boolean launch = false;
1611
        boolean launch = false;
Línea 1952... Línea 1962...
1952
                        userLogDao.insert(userLog);
1962
                        userLogDao.insert(userLog);
1953
                    }
1963
                    }
1954
                }
1964
                }
1955
            }
1965
            }
Línea -... Línea 1966...
-
 
1966
 
-
 
1967
            String uuid;
1956
 
1968
            Company company;
-
 
1969
            if(data.has("quizzes")) {
-
 
1970
                Quiz quiz;
-
 
1971
                Question question;
-
 
1972
                Answer answer;
1957
            if(data.has("quizzes")) {
1973
 
1958
                arrayQuizzes = data.getJSONArray("quizzes");
1974
                arrayQuizzes = data.getJSONArray("quizzes");
1959
                for (i = 0; i < arrayQuizzes.length(); i++) {
1975
                for (i = 0; i < arrayQuizzes.length(); i++) {
1960
                    objQuiz = arrayQuizzes.getJSONObject(i);
-
 
1961
                    Quiz quiz = new Quiz();
-
 
1962
                    quiz.setUuid(  objQuiz.getString("uuid"));
1976
                    objQuiz = arrayQuizzes.getJSONObject(i);
1963
                    quiz.setCompanyUuid(  objQuiz.getString("company_uuid"));
-
 
1964
                    quiz.setFailed(  objQuiz.getString("failed"));
-
 
1965
                    quiz.setName(  objQuiz.getString("name"));
-
 
1966
                    quiz.setText(  objQuiz.getString("text"));
-
 
1967
                    quiz.setPoints(  objQuiz.getInt("points"));
-
 
1968
                    quiz.setMinimumPointsRequired(objQuiz.getInt("minimum_points_required"));
-
 
1969
                    quiz.setMaxTime( objQuiz.getInt("max_time"));
-
 
1970
 
1977
                    uuid = objQuiz.getString("company_uuid");
1971
                    Company company = companyDao.selectByUuid(quiz.getCompanyUuid());
1978
                    company = companyDao.selectByUuid(uuid);
1972
                    if (company == null) {
1979
                    if (company == null) {
1973
                        company = new Company();
1980
                        company = new Company();
1974
                        company.setUuid(objQuiz.getString("company_uuid"));
1981
                        company.setUuid(objQuiz.getString("company_uuid"));
1975
                        company.setName(objQuiz.getString("company_name"));
1982
                        company.setName(objQuiz.getString("company_name"));
Línea 1976... Línea 1983...
1976
                        company.setImage(objQuiz.getString("company_image"));
1983
                        company.setImage(objQuiz.getString("company_image"));
-
 
1984
 
-
 
1985
                        companyDao.insert(company);
-
 
1986
                    } else {
-
 
1987
                        company.setName(objQuiz.getString("company_name"));
-
 
1988
                        company.setImage(objQuiz.getString("company_image"));
1977
 
1989
 
Línea -... Línea 1990...
-
 
1990
                        companyDao.update(company);
-
 
1991
                    }
-
 
1992
 
-
 
1993
                    uuid =  objQuiz.getString("uuid");
-
 
1994
                    quiz = quizDao.selectByUuid(uuid);
-
 
1995
 
-
 
1996
                    if(quiz == null) {
-
 
1997
                        quiz = new Quiz();
-
 
1998
                        quiz.setUuid(  objQuiz.getString("uuid"));
-
 
1999
                        quiz.setCompanyUuid(  company.getUuid() );
-
 
2000
                        quiz.setFailed(  objQuiz.getString("failed"));
-
 
2001
                        quiz.setName(  objQuiz.getString("name"));
-
 
2002
                        quiz.setText(  objQuiz.getString("text"));
1978
                        companyDao.insert(company);
2003
                        quiz.setPoints(  objQuiz.getInt("points"));
-
 
2004
                        quiz.setMinimumPointsRequired(objQuiz.getInt("minimum_points_required"));
-
 
2005
                        quiz.setMaxTime( objQuiz.getInt("max_time"));
-
 
2006
                        quizDao.insert(quiz);
-
 
2007
 
-
 
2008
                    } else {
-
 
2009
                        quiz.setCompanyUuid(  company.getUuid() );
-
 
2010
                        quiz.setFailed(  objQuiz.getString("failed"));
-
 
2011
                        quiz.setName(  objQuiz.getString("name"));
-
 
2012
                        quiz.setText(  objQuiz.getString("text"));
-
 
2013
                        quiz.setPoints(  objQuiz.getInt("points"));
-
 
2014
                        quiz.setMinimumPointsRequired(objQuiz.getInt("minimum_points_required"));
Línea 1979... Línea 2015...
1979
                    }
2015
                        quiz.setMaxTime( objQuiz.getInt("max_time"));
1980
 
2016
                        quizDao.update(quiz);
1981
                    quizDao.insert(quiz);
2017
                    }
1982
 
-
 
1983
                    arrayQuestions = objQuiz.getJSONArray("questions");
-
 
1984
                    for (j = 0; j < arrayQuestions.length(); j++) {
-
 
1985
                        objQuestion = arrayQuestions.getJSONObject(j);
-
 
1986
                        Question question = new Question();
-
 
1987
                        question.setQuizUuid( quiz.getUuid());
-
 
1988
                        question.setUuid( objQuestion.getString("uuid"));
-
 
Línea -... Línea 2018...
-
 
2018
 
-
 
2019
                    arrayQuestions = objQuiz.getJSONArray("questions");
-
 
2020
                    for (j = 0; j < arrayQuestions.length(); j++) {
-
 
2021
                        objQuestion = arrayQuestions.getJSONObject(j);
-
 
2022
 
-
 
2023
                        uuid = objQuestion.getString("uuid");
-
 
2024
                        question = questionDao.selectByUuid(uuid);
-
 
2025
                        if(question == null) {
-
 
2026
                            question = new Question();
-
 
2027
                            question.setQuizUuid( quiz.getUuid());
-
 
2028
                            question.setUuid(uuid) ;
1989
                        question.setText( objQuestion.getString("text"));
2029
                            question.setText( objQuestion.getString("text"));
-
 
2030
                            question.setType( objQuestion.getString("type"));
-
 
2031
                            question.setPoints( objQuestion.getInt("points"));
-
 
2032
                            question.setMaxlength( objQuestion.getInt("maxlength"));
-
 
2033
 
-
 
2034
                            questionDao.insert(question);
-
 
2035
                        } else {
-
 
2036
                            question.setQuizUuid( quiz.getUuid());
-
 
2037
                            question.setText( objQuestion.getString("text"));
-
 
2038
                            question.setType( objQuestion.getString("type"));
-
 
2039
                            question.setPoints( objQuestion.getInt("points"));
-
 
2040
                            question.setMaxlength( objQuestion.getInt("maxlength"));
-
 
2041
 
Línea 1990... Línea 2042...
1990
                        question.setType( objQuestion.getString("type"));
2042
                            questionDao.update(question);
1991
                        question.setPoints( objQuestion.getInt("points"));
2043
                        }
1992
                        question.setMaxlength( objQuestion.getInt("maxlength"));
2044
 
1993
 
-
 
1994
                        questionDao.insert(question);
-
 
1995
 
-
 
1996
                        arrayAnswers = objQuestion.getJSONArray("answers");
-
 
1997
                        for (x = 0; x < arrayAnswers.length(); x++) {
-
 
1998
                            objAnswer = arrayAnswers.getJSONObject(x);
-
 
Línea 1999... Línea 2045...
1999
                            Answer answer = new Answer();
2045
 
2000
                            answer.setQuestionUuid(question.getUuid());
2046
 
Línea -... Línea 2047...
-
 
2047
 
Línea -... Línea 2048...
-
 
2048
                        arrayAnswers = objQuestion.getJSONArray("answers");
-
 
2049
                        for (x = 0; x < arrayAnswers.length(); x++) {
-
 
2050
                            objAnswer = arrayAnswers.getJSONObject(x);
-
 
2051
 
-
 
2052
                            uuid = objAnswer.getString("uuid");
-
 
2053
                            answer = answerDao.selectByUuid(uuid);
-
 
2054
 
-
 
2055
                            if(answer == null) {
-
 
2056
 
-
 
2057
                                answer = new Answer();
-
 
2058
                                answer.setQuestionUuid(question.getUuid());
-
 
2059
                                answer.setUuid(uuid);
-
 
2060
                                answer.setText(objAnswer.getString("text"));
-
 
2061
                                answer.setPoints(objAnswer.getInt("points"));
-
 
2062
                                answer.setCorrect(objAnswer.getString("correct"));
-
 
2063
 
2001
                            answer.setUuid(objAnswer.getString("uuid"));
2064
                                answerDao.insert(answer);
2002
                            answer.setText(objAnswer.getString("text"));
2065
                            } else {
2003
                            answer.setPoints( objAnswer.getInt("points"));
2066
                                answer.setQuestionUuid(question.getUuid());
Línea 2004... Línea 2067...
2004
                            answer.setCorrect(objAnswer.getString("correct"));
2067
                                answer.setText(objAnswer.getString("text"));
-
 
2068
                                answer.setPoints(objAnswer.getInt("points"));
-
 
2069
                                answer.setCorrect(objAnswer.getString("correct"));
-
 
2070
                                answerDao.update(answer);
Línea 2005... Línea 2071...
2005
 
2071
                            }
2006
                            answerDao.insert(answer);
2072
                        }
2007
                        }
2073
                    }
2008
 
-
 
2009
 
-
 
2010
                    }
-
 
2011
                }
-
 
2012
            }
-
 
2013
 
-
 
2014
 
-
 
Línea -... Línea 2074...
-
 
2074
                }
2015
 
2075
            }
2016
 
2076
 
2017
 
2077
 
2018
            if(data.has("topics")) {
2078
 
2019
 
2079
 
2020
                JSONArray arrayTopics = data.getJSONArray("topics");
2080
 
Línea 2021... Línea 2081...
2021
                for (i = 0; i < arrayTopics.length(); i++) {
2081
            if(data.has("topics")) {
-
 
2082
                Topic topic;
-
 
2083
                Capsule capsule;
-
 
2084
                Slide slide;
-
 
2085
 
-
 
2086
                JSONArray arrayTopics = data.getJSONArray("topics");
-
 
2087
                for (i = 0; i < arrayTopics.length(); i++) {
-
 
2088
                    objTopic = arrayTopics.getJSONObject(i);
-
 
2089
 
-
 
2090
                    uuid = objTopic.getString("company_uuid");
-
 
2091
                    company = companyDao.selectByUuid(uuid);
-
 
2092
                    if (company == null) {
-
 
2093
                        company = new Company();
-
 
2094
                        company.setUuid(objTopic.getString("company_uuid"));
-
 
2095
                        company.setName(objTopic.getString("company_name"));
-
 
2096
                        company.setImage(objTopic.getString("company_image"));
-
 
2097
 
-
 
2098
                        companyDao.insert(company);
-
 
2099
                    } else {
-
 
2100
                        company.setName(objTopic.getString("company_name"));
-
 
2101
                        company.setImage(objTopic.getString("company_image"));
-
 
2102
 
-
 
2103
                        companyDao.update(company);
-
 
2104
                    }
-
 
2105
 
-
 
2106
                    uuid = objTopic.getString("uuid");
-
 
2107
                    topic = topicDao.selectByUuid(uuid);
2022
                    objTopic = arrayTopics.getJSONObject(i);
2108
 
Línea 2023... Línea -...
2023
                    Topic topic = new Topic();
-
 
-
 
2109
                    if (topic == null) {
-
 
2110
                        topic = new Topic();
-
 
2111
                        topic.setUuid(uuid);
Línea 2024... Línea 2112...
2024
                    topic.setUuid(objTopic.getString("uuid"));
2112
                        topic.setCompanyUuid(company.getUuid());
2025
                    topic.setCompanyUuid(objTopic.getString("company_uuid"));
2113
                        topic.setName(objTopic.getString("name"));
2026
                    topic.setName(objTopic.getString("name"));
2114
                        topic.setDescription(objTopic.getString("description"));
-
 
2115
                        topic.setImage(objTopic.getString("image"));
-
 
2116
                        topic.setPosition(objTopic.getInt("position"));
-
 
2117
                        topicDao.insert(topic);
2027
                    topic.setDescription(objTopic.getString("description"));
2118
                    } else {
2028
                    topic.setImage(objTopic.getString("image"));
2119
                        topic.setCompanyUuid(company.getUuid());
-
 
2120
                        topic.setName(objTopic.getString("name"));
2029
                    topic.setPosition(objTopic.getInt("position"));
2121
                        topic.setDescription(objTopic.getString("description"));
-
 
2122
                        topic.setImage(objTopic.getString("image"));
-
 
2123
                        topic.setPosition(objTopic.getInt("position"));
-
 
2124
                        topicDao.update(topic);
-
 
2125
                    }
-
 
2126
 
-
 
2127
 
-
 
2128
 
2030
 
2129
 
2031
                    Company company = companyDao.selectByUuid(topic.getCompanyUuid());
2130
 
2032
                    if (company == null) {
2131
                    arrayCapsules = objTopic.getJSONArray("capsules");
2033
                        company = new Company();
2132
                    for (j = 0; j < arrayCapsules.length(); j++) {
2034
                        company.setUuid(objTopic.getString("company_uuid"));
2133
                        objCapsule = arrayCapsules.getJSONObject(j);
-
 
2134
                        uuid = objCapsule.getString("uuid");
-
 
2135
                        capsule = capsuleDao.selectByUuid(uuid);
-
 
2136
                        if(capsule == null) {
-
 
2137
                            capsule = new Capsule();
Línea 2035... Línea 2138...
2035
                        company.setName(objTopic.getString("company_name"));
2138
                            capsule.setTopicUuid(topic.getUuid());
2036
                        company.setImage(objTopic.getString("company_image"));
2139
                            capsule.setUuid(uuid);
2037
 
2140
                            capsule.setName(objCapsule.getString("name"));
2038
                        companyDao.insert(company);
-
 
2039
                    }
-
 
2040
 
-
 
2041
                    topicDao.insert(topic);
-
 
2042
 
-
 
2043
                    arrayCapsules = objTopic.getJSONArray("capsules");
-
 
2044
                    for (j = 0; j < arrayCapsules.length(); j++) {
-
 
2045
                        objCapsule = arrayCapsules.getJSONObject(j);
-
 
2046
                        Capsule capsule = new Capsule();
-
 
2047
                        capsule.setTopicUuid(topic.getUuid());
-
 
2048
                        capsule.setUuid(objCapsule.getString("uuid"));
-
 
Línea -... Línea 2141...
-
 
2141
                            capsule.setDescription(objCapsule.getString("description"));
-
 
2142
                            capsule.setImage(objCapsule.getString("image"));
-
 
2143
                            capsule.setPosition(objCapsule.getInt("position"));
-
 
2144
                            capsuleDao.insert(capsule);
-
 
2145
                        } else {
-
 
2146
                            capsule = new Capsule();
-
 
2147
                            capsule.setTopicUuid(topic.getUuid());
-
 
2148
                            capsule.setName(objCapsule.getString("name"));
-
 
2149
                            capsule.setDescription(objCapsule.getString("description"));
-
 
2150
                            capsule.setImage(objCapsule.getString("image"));
-
 
2151
                            capsule.setPosition(objCapsule.getInt("position"));
-
 
2152
                            capsuleDao.update(capsule);
-
 
2153
                        }
-
 
2154
 
-
 
2155
 
-
 
2156
 
-
 
2157
 
-
 
2158
                        arraySlides = objCapsule.getJSONArray("slides");
2049
                        capsule.setName(objCapsule.getString("name"));
2159
                        for (x = 0; x < arraySlides.length(); x++) {
-
 
2160
                            objSlide = arraySlides.getJSONObject(x);
-
 
2161
 
-
 
2162
 
-
 
2163
                            uuid = objSlide.getString("uuid");
-
 
2164
                            slide = slideDao.selectByUuid(uuid);
-
 
2165
 
-
 
2166
                            if(slide == null) {
-
 
2167
 
-
 
2168
                                slide = new Slide();
-
 
2169
                                slide.setUuid(uuid);
-
 
2170
                                slide.setTopicUuid(capsule.getTopicUuid());
-
 
2171
                                slide.setCapsuleUuid(capsule.getUuid());
-
 
2172
                                slide.setQuizUuid(objSlide.getString("quiz_uuid"));
2050
                        capsule.setDescription(objCapsule.getString("description"));
2173
                                slide.setName(objSlide.getString("name"));
Línea 2051... Línea 2174...
2051
                        capsule.setImage(objCapsule.getString("image"));
2174
                                slide.setDescription(objSlide.getString("description"));
Línea 2052... Línea 2175...
2052
                        capsule.setPosition(objCapsule.getInt("position"));
2175
                                slide.setPosition(objSlide.getInt("position"));
2053
                        capsuleDao.insert(capsule);
2176
                                slide.setType(objSlide.getString("type"));
Línea -... Línea 2177...
-
 
2177
                                slide.setFile(objSlide.getString("file"));
-
 
2178
                                slide.setBackground(objSlide.getString("background"));
-
 
2179
 
-
 
2180
                                slideDao.insert(slide);
-
 
2181
                            } else {
-
 
2182
                                slide.setTopicUuid(capsule.getTopicUuid());
-
 
2183
                                slide.setCapsuleUuid(capsule.getUuid());
-
 
2184
                                slide.setQuizUuid(objSlide.getString("quiz_uuid"));
-
 
2185
                                slide.setName(objSlide.getString("name"));
-
 
2186
                                slide.setDescription(objSlide.getString("description"));
-
 
2187
                                slide.setPosition(objSlide.getInt("position"));
-
 
2188
                                slide.setType(objSlide.getString("type"));
-
 
2189
                                slide.setFile(objSlide.getString("file"));
-
 
2190
                                slide.setBackground(objSlide.getString("background"));
-
 
2191
 
-
 
2192
                                slideDao.update(slide);
-
 
2193
                            }
-
 
2194
                        }
-
 
2195
 
-
 
2196
                    }
-
 
2197
 
-
 
2198
 
-
 
2199
                }
-
 
2200
            }
-
 
2201
 
-
 
2202
            if(data.has( "extended")) {
-
 
2203
 
-
 
2204
                JSONObject objExtended;
-
 
2205
                JSONObject objItem;
-
 
2206
                JSONArray objItems;
-
 
2207
 
-
 
2208
 
-
 
2209
 
-
 
2210
                UserExtended userExtended;
-
 
2211
 
-
 
2212
                JSONArray extendedCompanies = data.getJSONArray("extended");
-
 
2213
                for(i = 0 ; i < extendedCompanies.length(); i++)
-
 
2214
                {
-
 
2215
                    objExtended = extendedCompanies.getJSONObject(i);
-
 
2216
                    if(objExtended.has("details")) {
-
 
2217
                        uuid = objExtended.getString("company_uuid");
-
 
2218
 
-
 
2219
 
-
 
2220
                        company = companyDao.selectByUuid(uuid);
-
 
2221
                        if (company == null) {
-
 
2222
                            company = new Company();
-
 
2223
                            company.setUuid(objExtended.getString("company_uuid"));
-
 
2224
                            company.setName(objExtended.getString("company_name"));
-
 
2225
                            company.setImage(objExtended.getString("company_image"));
-
 
2226
 
-
 
2227
                            companyDao.insert(company);
-
 
2228
                        } else {
-
 
2229
                            company.setName(objExtended.getString("company_name"));
-
 
2230
                            company.setImage(objExtended.getString("company_image"));
-
 
2231
 
-
 
2232
                            companyDao.update(company);
-
 
2233
                        }
-
 
2234
 
-
 
2235
                        objItems = objExtended.getJSONArray("details");
-
 
2236
                        for(j = 0 ; j < objItems.length(); j++) {
-
 
2237
                            objItem = objItems.getJSONObject(j);
-
 
2238
 
-
 
2239
                            uuid =  objItem.getString("uuid");
Línea 2054... Línea 2240...
2054
 
2240
 
2055
                        arraySlides = objCapsule.getJSONArray("slides");
2241
                            userExtended = userExtendedDao.selectByUuid(uuid);
2056
                        for (x = 0; x < arraySlides.length(); x++) {
2242
                            if(userExtended == null) {
2057
                            objSlide = arraySlides.getJSONObject(x);
2243
                                userExtended = new UserExtended();
Línea 2104... Línea 2290...
2104
                    preference.setCompanyUuidActive(companies.get(0).getUuid());
2290
                    preference.setCompanyUuidActive(companies.get(0).getUuid());
Línea 2105... Línea 2291...
2105
 
2291
 
Línea 2106... Línea 2292...
2106
                } else {
2292
                } else {
2107
 
2293
 
-
 
2294
                    boolean companyExist = false;
2108
                    boolean companyExist = false;
2295
                    for(i = 0; i < companies.size(); i++) {
2109
                    for (Company company : companies) {
2296
 
-
 
2297
                        if (companies.get(i).getUuid().equals(preference.getCompanyUuidActive())) {
2110
                        if (company.getUuid().equals(preference.getCompanyUuidActive())) {
2298
                            companyExist = true;
2111
                            companyExist = true;
2299
                            break;
Línea 2112... Línea 2300...
2112
                        }
2300
                        }
2113
                    }
2301
                    }
2114
 
2302
 
2115
                    if(!companyExist) {
2303
                    if(!companyExist && companies.size() > 0) {
Línea 2116... Línea 2304...
2116
                        preference.setCompanyUuidActive(companies.get(0).getUuid());
2304
                        preference.setCompanyUuidActive(companies.get(0).getUuid());
2117
                    }
2305
                    }
2118
                }
2306
                }
Línea 2119... Línea -...
2119
 
-
 
2120
            } else {
-
 
2121
                preference.setCompanyUuidActive("");
-
 
2122
            }
-
 
2123
 
-
 
2124
            if(data.has( "extended")) {
-
 
2125
 
-
 
2126
                JSONObject objExtended;
-
 
2127
                JSONObject objItem;
-
 
2128
                JSONArray objItems;
-
 
2129
 
-
 
2130
                String company_uuid;
-
 
2131
 
-
 
2132
                UserExtended userExtended;
-
 
2133
 
-
 
2134
                JSONArray extendedCompanies = data.getJSONArray("extended");
-
 
2135
                for(i = 0 ; i < extendedCompanies.length(); i++)
-
 
2136
                {
-
 
2137
                    objExtended = extendedCompanies.getJSONObject(i);
-
 
2138
                    if(objExtended.has("details")) {
-
 
2139
                        company_uuid = objExtended.getString("company_uuid");
-
 
2140
 
-
 
2141
                        objItems = objExtended.getJSONArray("details");
-
 
2142
                        for(j = 0 ; j < objItems.length(); j++) {
-
 
2143
                            objItem = objItems.getJSONObject(j);
-
 
2144
                            userExtended = new UserExtended();
-
 
2145
                            userExtended.setCompanyUuid(company_uuid);
-
 
2146
                            userExtended.setUuid(objItem.getString("uuid"));
-
 
2147
                            userExtended.setLabel(objItem.getString("label"));
-
 
2148
                            userExtended.setValue(objItem.getString("value"));
-
 
Línea 2149... Línea -...
2149
                            userExtendedDao.insert(userExtended);
-
 
Línea 2150... Línea 2307...
2150
 
2307
 
2151
                        }
2308
            } else {
2152
                    }
2309
                preference.setCompanyUuidActive("");
Línea 2614... Línea 2771...
2614
    }
2771
    }
2615
     */
2772
     */
Línea 2616... Línea -...
2616
 
-
 
2617
 
2773
 
-
 
2774