Proyectos de Subversion Android Microlearning

Rev

Rev 19 | Rev 42 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
package com.cesams.twogetskills.fragment;
2
 
4 gabriel 3
import android.app.Activity;
4
import android.content.Context;
1 efrain 5
import android.content.Intent;
4 gabriel 6
import android.location.GnssAntennaInfo;
1 efrain 7
import android.net.Uri;
8
import android.os.Bundle;
9
 
10
import androidx.annotation.NonNull;
11
import androidx.annotation.Nullable;
12
import androidx.fragment.app.Fragment;
13
import androidx.lifecycle.LifecycleOwner;
14
 
15
import android.text.TextUtils;
16
import android.util.Log;
17
import android.view.KeyEvent;
18
import android.view.LayoutInflater;
19
import android.view.Menu;
20
import android.view.MenuInflater;
21
import android.view.View;
22
import android.view.ViewGroup;
23
import android.view.inputmethod.EditorInfo;
4 gabriel 24
import android.view.inputmethod.InputMethodManager;
1 efrain 25
import android.widget.Button;
26
import android.widget.EditText;
27
import android.widget.ProgressBar;
28
import android.widget.TextView;
29
 
30
import com.cesams.twogetskills.Configuration;
31
import com.cesams.twogetskills.Constants;
32
import com.cesams.twogetskills.R;
4 gabriel 33
import com.cesams.twogetskills.activity.MainActivity;
1 efrain 34
import com.cesams.twogetskills.dao.SyncDao;
35
import com.cesams.twogetskills.library.AesCipher;
36
import com.cesams.twogetskills.library.Functions;
37
import com.cesams.twogetskills.library.Http;
38
import com.cesams.twogetskills.entity.Sync;
39
import com.cesams.twogetskills.entity.UserLog;
40
import com.cesams.twogetskills.preference.Preference;
41
import com.cesams.twogetskills.room.ResultCount;
42
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
43
 
44
import org.json.JSONException;
45
import org.json.JSONObject;
46
 
47
import java.io.IOException;
48
import java.text.SimpleDateFormat;
49
import java.util.Calendar;
50
import java.util.Date;
51
 
52
import okhttp3.Call;
53
import okhttp3.Callback;
54
import okhttp3.FormBody;
55
import okhttp3.OkHttpClient;
56
import okhttp3.Request;
57
import okhttp3.RequestBody;
58
import okhttp3.Response;
59
 
60
 
61
public class SigninFragment extends Fragment implements LifecycleOwner  {
62
    //implements ITaskCallback {
63
    private final static String TAG = "C2GS - SigninFragment";
64
    private ITwoGetSkills iTwoGetSkills;
65
    private EditText mEditTextEmail;
66
    private EditText mEditTextPassword;
67
    private boolean inProgress = false;
68
    private Button mButtonSignIn;
69
    private Button mButtonSignUp;
70
    private ProgressBar mProgressBar;
71
 
72
 
73
    @Override
74
    public void onCreate(@Nullable Bundle savedInstanceState) {
75
        super.onCreate(savedInstanceState);
76
        setHasOptionsMenu(true);
77
    }
78
 
79
    @Override
80
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
81
        super.onCreateOptionsMenu(menu, inflater);
82
        menu.clear();
83
    }
84
 
85
 
86
    @Override
87
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
88
        super.onViewCreated(view, savedInstanceState);
89
        iTwoGetSkills = (ITwoGetSkills) getActivity();
90
        mProgressBar = (ProgressBar) getView().findViewById(R.id.signin_progress_bar);
91
        mEditTextEmail = (EditText) getView().findViewById(R.id.signin_edittext_email);
92
        //mEditTextEmail.setText("santiago.olivera@leaderslinked.com");
93
        //mEditTextEmail.setText("efrain.yanez@leaderslinked.com");
94
        //mEditTextEmail.setText("snof@adinet.com.uy");
95
        //mEditTextEmail.setText("mmarrugo@coosalud.com");
96
 
97
 
98
        mEditTextEmail.setOnEditorActionListener(new TextView.OnEditorActionListener() {
99
            @Override
100
            public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
101
                mEditTextPassword.requestFocus();
102
                return true;
103
            }
104
        });
105
 
106
        mEditTextPassword = (EditText) getView().findViewById(R.id.signin_edittext_password);
107
        //mEditTextPassword.setText("Cesa2020");
108
        //mEditTextPassword.setText("Aalmiron2021");
109
        //mEditTextPassword.setText("Mmarrugo2021");
110
        //mEditTextPassword.setText("Cesa2020*");
111
        mEditTextPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
112
            @Override
113
            public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
114
                if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
115
                    attemptLogin();
116
                    return true;
117
                }
118
                return false;
119
            }
120
        });
121
 
122
        mButtonSignIn = (Button) getView().findViewById(R.id.signin_button_sign_in);
123
        mButtonSignIn.setOnClickListener(new View.OnClickListener() {
124
            @Override
125
            public void onClick(View view) {
4 gabriel 126
 
127
                //Ocultar el teclado al intentar inicia sesion
128
                hideKeyboard(view);
129
 
1 efrain 130
                attemptLogin();
131
            }
132
        });
133
 
134
 
135
        //
136
 
137
        mButtonSignUp = (Button) getView().findViewById(R.id.signin_button_sign_up);
138
        mButtonSignUp.setOnClickListener(new View.OnClickListener() {
139
            @Override
140
            public void onClick(View view) {
141
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://leaderslinked.com/signup"));
142
                startActivity(browserIntent);
143
            }
144
        });
145
 
4 gabriel 146
        mEditTextEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
147
            @Override
148
            public void onFocusChange(View v, boolean hasFocus) {
149
                if(!hasFocus) {
150
                    hideKeyboard(v);
151
                }
152
            }
153
        });
1 efrain 154
 
4 gabriel 155
 
1 efrain 156
    }
157
 
4 gabriel 158
    public void hideKeyboard(View view) {
159
        // Check if no view has focus:
160
        //View view = getActivity().getCurrentFocus();
161
 
162
        try {
163
            InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
164
            inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
165
        } catch (Exception e) {
166
            e.printStackTrace();
167
        }
168
    }
169
 
1 efrain 170
    private void attemptLogin() {
4 gabriel 171
 
172
 
173
 
1 efrain 174
        if (inProgress) {
175
            return;
176
        }
177
 
29 efrain 178
        /*
1 efrain 179
        if(TextUtils.isEmpty(iTwoGetSkills.getPreference().getAes())) {
180
            iTwoGetSkills.reloadPreference();
181
        }
29 efrain 182
        */
1 efrain 183
 
184
 
185
        mEditTextEmail.setError(null);
186
        mEditTextPassword.setError(null);
187
 
188
        String email = Functions.trimNull(mEditTextEmail.getText().toString());
189
        String password = Functions.trimNull(mEditTextPassword.getText().toString());
190
 
191
        if (TextUtils.isEmpty(email)) {
192
            mEditTextEmail.setError(getString(R.string.error_field_required));
193
            mEditTextEmail.requestFocus();
194
            return;
195
        }
196
 
19 gabriel 197
        if (!Functions.emailcheckengine(email)) {
198
            mEditTextEmail.setError("Formato de email invalido");
199
            mEditTextEmail.requestFocus();
200
            return;
201
        }
202
 
1 efrain 203
        if (TextUtils.isEmpty(password)) {
204
            mEditTextPassword.setError(getString(R.string.error_field_required));
205
            mEditTextPassword.requestFocus();
206
            return;
207
        }
208
 
209
 
210
        if (!Functions.passwordStrengthCheck(password)) {
211
            mEditTextPassword.setError(getString(R.string.error_invalid_password_format));
212
            mEditTextPassword.requestFocus();
213
            return;
214
        }
215
 
216
        if(iTwoGetSkills.isConnectedInternet()) {
217
            inProgress = true;
218
 
219
 
220
            String aes = iTwoGetSkills.getPreference().getAes();
221
 
222
            mEditTextEmail.setEnabled(false);
223
            mEditTextPassword.setEnabled(false);
224
 
225
            mButtonSignIn.setEnabled(false);
226
            mProgressBar.setVisibility(View.VISIBLE);
227
 
228
            inProgress = false;
229
            mEditTextEmail.setEnabled(true);
230
            mEditTextPassword.setEnabled(true);
231
 
232
            mButtonSignIn.setEnabled(true);
233
            mProgressBar.setVisibility(View.INVISIBLE);
234
 
235
            try {
236
 
237
                Log.d("AES", aes);
238
 
239
                Http http = new Http(getActivity().getCacheDir());
240
                OkHttpClient client = http.getHttpClient(false);
241
 
242
                Log.d(TAG, "URL = " + Configuration.URL_SIGNIN);
243
 
244
                RequestBody formBody = null;
245
                if(aes.isEmpty()) {
246
                    formBody = new FormBody.Builder()
247
                            .add(Constants.POST_SIGNIN_FIELD_APPLICATION_ID, String.valueOf(Configuration.APPLICATION_ID))
248
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_UUID, iTwoGetSkills.getPreference().getDeviceUuid())
249
                            .add(Constants.POST_SIGNIN_FIELD_EMAIL, email)
250
                            .add(Constants.POST_SIGNIN_FIELD_PASSWORD, password)
251
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_ENCRYPTER, "") //Constants.SIGNIN_ENCRYPTER)
252
                            .build();
253
                } else {
254
                    AesCipher encryptedEmail    = AesCipher.encrypt(aes, email);
255
                    AesCipher encryptedPassword = AesCipher.encrypt(aes, password);
256
 
257
                    formBody = new FormBody.Builder()
258
                            .add(Constants.POST_SIGNIN_FIELD_APPLICATION_ID, String.valueOf(Configuration.APPLICATION_ID))
259
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_UUID, iTwoGetSkills.getPreference().getDeviceUuid())
260
                            .add(Constants.POST_SIGNIN_FIELD_EMAIL, encryptedEmail.getData())
261
                            .add(Constants.POST_SIGNIN_FIELD_PASSWORD, encryptedPassword.getData())
262
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_ENCRYPTER, Constants.SIGNIN_ENCRYPTER)
263
                            .build();
264
                }
265
 
266
 
267
 
268
 
269
 
270
 
271
                Request request = new Request.Builder()
272
                        .url(Configuration.URL_SIGNIN)
273
                        .post(formBody)
274
                        .build();
275
 
276
                Call call = client.newCall(request);
277
          /*  try {
278
                mProgressBar.setVisibility(View.VISIBLE);
279
 
280
                Response response = call.execute();
281
 
282
                processResponseServer(response.body().string());
283
 
284
            } catch(IOException e) {
285
                Log.d(TAG, e.getMessage());
286
            }*/
287
                iTwoGetSkills.showProgressBar();
288
                call.enqueue(new Callback() {
289
                    public void onResponse(Call call, Response response)
290
                            throws IOException {
291
 
292
                        iTwoGetSkills.hideProgressBar();
293
                        processResponseServer(response.body().string());
294
 
295
 
296
                    }
297
 
298
                    public void onFailure(Call call, IOException e) {
299
                        Log.d(TAG, "Error :  " +  e.getMessage());
300
                        iTwoGetSkills.hideProgressBar();
301
                    }
302
                });
303
 
304
            } catch (Exception e) {
305
                iTwoGetSkills.showMessageSnackBar(e.getMessage());
306
            } finally {
307
 
308
            }
309
 
310
 
311
        }
312
    }
313
 
314
    private boolean isPasswordValid(String password) {
315
        //TODO: Replace this with your own logic
316
        return password.length() > 5;
317
    }
318
 
319
    private void processResponseServer(String dataString) {
320
        boolean success = false;
321
        boolean fatal = false;
322
        String message = "";
323
 
324
        mProgressBar.setVisibility(View.INVISIBLE);
325
 
326
        try {
327
            JSONObject objData = new JSONObject(dataString);
328
            success = objData.has("success") ? objData.getBoolean("success")  : false;
329
            if(objData.has("data")) {
330
                Object item = objData.get("data");
331
                if (item instanceof String) {
332
                    message = (String) item;
333
                }
334
                fatal = objData.has("fatal");
335
            }
336
 
337
            if(success) {
338
                JSONObject data = objData.getJSONObject("data");
339
 
340
 
341
                Calendar calendar = Calendar.getInstance();
342
                Date date = calendar.getTime();
343
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
344
                String  addedOn = simpleDateFormat.format(date);
345
                iTwoGetSkills.syncFromServer(data);
346
 
347
 
348
                Preference preference = iTwoGetSkills.getPreference();
349
                JSONObject objUser = data.getJSONObject("user");
350
                preference.setUserUuid(objUser.getString("uuid"));
351
                preference.setFirstName(objUser.getString("first_name"));
352
                preference.setLastName(objUser.getString("last_name"));
353
                preference.setEmail(objUser.getString("email"));
354
                preference.setImage(objUser.getString("image"));
355
                preference.setLastDataRefresh(addedOn);
356
 
357
                JSONObject objDevice = data.getJSONObject("device");
358
                preference.setAes(objDevice.getString("aes"));
359
                preference.setPassword(objDevice.getString("password"));
29 efrain 360
                preference.save();
1 efrain 361
 
362
 
363
 
364
 
365
                UserLog userLog = new UserLog();
366
                userLog.setUserUuid(preference.getUserUuid());
367
                userLog.setActivity(Constants.USER_LOG_ACTIVITY_SIGNIN);
368
                userLog.setAddedOn(addedOn);
369
                JSONObject json = userLog.toJson();
370
                json.put(Constants.SYNC_ADAPTER_DATA_TYPE_FIELD_NAME, Constants.SYNC_ADAPTER_DATA_TYPE_USER_LOG);
371
 
372
                Sync sync = new Sync(Constants.SYNC_ADAPTER_TYPE_SYNC, json.toString());
373
 
374
                SyncDao syncDao = iTwoGetSkills.getDatabase().getSyncDao();
375
                syncDao.insert(sync);
376
 
377
 
378
                getActivity().runOnUiThread(new Runnable() {
379
 
380
                    @Override
381
                    public void run() {
382
 
383
                        ResultCount resultCount = iTwoGetSkills.getDatabase().getCapsuleDao().getCount();
384
                        String message = resultCount.getCount() == 1
385
                                ? "Hay 1 cápsula nueva disponible"
386
                                : "Hay " + resultCount.getCount() + " cápsulas disponible";
387
 
388
                        iTwoGetSkills.showMessageSnackBarWithClose(message);
389
 
390
 
391
                        iTwoGetSkills.reloadNavHeader();
392
                        iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
393
                    }
394
                });
395
 
396
 
397
 
398
 
399
            } else {
400
                if(!TextUtils.isEmpty(message)) {
401
                    iTwoGetSkills.showMessageSnackBar(message);
402
                }
403
                if(fatal) {
404
                    iTwoGetSkills.onErrorFatal();
405
                }
406
            }
407
 
408
 
409
        } catch (JSONException e) {
410
            e.printStackTrace();
411
            Log.e(TAG,  e.getMessage());
412
        }
413
 
414
 
415
    }
416
 
417
    /*
418
    @Override
419
    public void taskCallback(HttpCommResponse httpCommResponse) {
420
        inProgress = false;
421
        mEditTextEmail.setEnabled(true);
422
        mEditTextPassword.setEnabled(true);
423
 
424
        mButtonSignIn.setEnabled(true);
425
        mProgressBar.setVisibility(View.INVISIBLE);
426
 
427
        if(httpCommResponse.isSuccess()) {
428
 
429
            AnswerDao answerDao = new AnswerDao(getActivity());
430
            answerDao.removeAll();
431
 
432
            QuestionDao questionDao = new QuestionDao(getActivity());
433
            questionDao.removeAll();
434
 
435
            QuizDao quizDao = new QuizDao(getActivity());
436
            questionDao.removeAll();
437
 
438
            SlideDao slideDao = new SlideDao(getActivity());
439
            slideDao.removeAll();
440
 
441
            CapsuleDao capsuleDao = new CapsuleDao(getActivity());
442
            capsuleDao.removeAll();
443
 
444
            TopicDao topicDao = new TopicDao(getActivity());
445
            topicDao.removeAll();
446
 
447
            CompanyDao companyDao = new CompanyDao(getActivity());
448
            companyDao.removeAll();
449
 
450
            ProgressDao progressDao = new ProgressDao(getActivity());
451
            progressDao.removeAll();
452
 
453
            UserLogDao userLogDao = new UserLogDao(getActivity());
454
 
455
            UserNotificationDao userNotificationDao = new UserNotificationDao(getActivity());
456
            userNotificationDao.removeAll();
457
 
458
            try {
459
                JSONObject objData = httpCommResponse.getObjJSON().getJSONObject("data");
460
 
461
 
462
 
463
 
464
                JSONArray arrayCapsules;
465
                JSONArray arraySlides;
466
                JSONArray arrayAnswers;
467
                JSONArray arrayQuestions;
468
                JSONArray arrayProgress;
469
                JSONArray arrayQuizzes;
470
                JSONArray arrayUserLog;
471
 
472
 
473
                JSONObject objTopic;
474
                JSONObject objCapsule;
475
                JSONObject objSlide;
476
                JSONObject objAnswer;
477
                JSONObject objQuestion;
478
                JSONObject objQuiz;
479
                JSONObject objProgress;
480
                JSONObject objUserLog;
481
                int i,j,x;
482
 
483
                arrayProgress = objData.getJSONArray("progress");
484
                for(i = 0; i <  arrayProgress.length(); i++) {
485
                    objProgress = arrayProgress.getJSONObject(i);
486
 
487
                    Progress progress = new Progress();
488
                    progress.companyUuid = objProgress.getInt("company_uuid");
489
                    progress.topicUuid = objProgress.getInt("topic_uuid");
490
                    progress.capsuleUuid = objProgress.getInt("capsule_uuid");
491
                    progress.SlideUuid = objProgress.getInt("Slide_uuid");
492
                    progress.progress = objProgress.getDouble("progress");
493
                    progress.totalSlides = objProgress.getInt("total_slides");
494
                    progress.viewSlides = objProgress.getInt("view_slides");
495
                    progress.type = objProgress.getString("type");
496
                    progress.returning = objProgress.getInt("returning");
497
                    progress.returningAfterCompleted = objProgress.getInt("returning_after_completed");
498
                    progress.completed = objProgress.getInt("completed");
499
                    progress.addedOn = objProgress.getString("added_on");
500
                    progress.updatedOn = objProgress.getString("updated_on");
501
 
502
                    progressDao.insert(progress);
503
 
504
                }
505
 
506
                arrayUserLog = objData.getJSONArray("userlog");
507
                for(i = 0; i <   arrayUserLog.length(); i++) {
508
                    objUserLog =  arrayUserLog.getJSONObject(i);
509
 
510
                    UserLog userLog = new UserLog();
511
                    userLog.companyUuid  = objUserLog.getInt("company_uuid");
512
                    userLog.topicUuid    = objUserLog.getInt("topic_uuid");
513
                    userLog.capsuleUuid  = objUserLog.getInt("capsule_uuid");
514
                    userLog.SlideUuid    = objUserLog.getInt("Slide_uuid");
515
                    userLog.activity   = objUserLog.getString("activity");
516
                    userLog.addedOn    = objUserLog.getString("added_on");
517
                    userLogDao.insert(userLog);
518
                }
519
 
520
                arrayQuizzes = objData.getJSONArray("quizzes");
521
                for(i = 0; i <  arrayQuizzes.length(); i++)
522
                {
523
                    objQuiz = arrayQuizzes.getJSONObject(i);
524
                    Quiz quiz = new Quiz();
525
                    quiz.id = objQuiz.getInt("id");
526
                    quiz.companyUuid = objQuiz.getInt("company_uuid");
527
                    quiz.name = objQuiz.getString("name");
528
                    quiz.text = objQuiz.getString("text");
529
                    quiz.points = objQuiz.getInt("points");
530
                    quiz.minimumPointsRequired  = objQuiz.getInt("minimum_points_required");
531
 
532
                    Company company =  companyDao.selectById(quiz.companyUuid);
533
                    if(company == null) {
534
                        company = new Company();
535
                        company.id = objQuiz.getInt("company_uuid");
536
                        company.name  = objQuiz.getString("company_name");
537
                        company.image = objQuiz.getString("company_image");
538
 
539
                        companyDao.insert(company);
540
                    }
541
 
542
                    quizDao.insert(quiz);
543
 
544
                    arrayQuestions = objQuiz.getJSONArray("questions");
545
                    for(j = 0; j < arrayQuestions.length(); j++) {
546
                        objQuestion = arrayQuestions.getJSONObject(j);
547
                       Question question = new Question();
548
                       question.quizId = quiz.id;
549
                       question.id = objQuestion.getInt("id");
550
                       question.text = objQuestion.getString("text");
551
                       question.type = objQuestion.getString("type");
552
                       question.points = objQuestion.getInt("points");
553
                       question.maxlength = objQuestion.getInt("maxlength");
554
 
555
                        questionDao.insert(question);
556
 
557
                        arrayAnswers = objQuestion.getJSONArray("answers");
558
                        for(x = 0; x < arrayAnswers.length(); x++)
559
                        {
560
                            objAnswer = arrayAnswers.getJSONObject(x);
561
                            Answer answer = new Answer();
562
                            answer.questionId =question.id;
563
                            answer.id = objAnswer.getInt("id");
564
                            answer.text = objAnswer.getString("text");
565
                            answer.points = objAnswer.getInt("points");
566
                            answer.position = objAnswer.getInt("position");
567
                            answer.correct = objAnswer.getString("correct");
568
 
569
                            answerDao.insert(answer);
570
                        }
571
 
572
 
573
                    }
574
                }
575
 
576
 
577
 
578
 
579
 
580
                JSONArray arrayTopics = objData.getJSONArray("topics");
581
                for(i = 0; i < arrayTopics.length(); i++)
582
                {
583
                    objTopic = arrayTopics.getJSONObject(i);
584
                    Topic topic = new Topic();
585
                    topic.id = objTopic.getInt("id");
586
                    topic.companyUuid = objTopic.getInt("company_uuid");
587
                    topic.name = objTopic.getString("name");
588
                    topic.description = objTopic.getString("description");
589
                    topic.image = objTopic.getString("image");
590
                    topic.position = objTopic.getInt("position");
591
 
592
                    Company company = companyDao.selectById(topic.companyUuid);
593
                    if(company == null) {
594
                        company = new Company();
595
                        company.id = objTopic.getInt("company_uuid");
596
                        company.name  = objTopic.getString("company_name");
597
                        company.image  = objTopic.getString("company_image");
598
 
599
                        companyDao.insert(company);
600
                    }
601
 
602
                    topicDao.insert(topic);
603
 
604
                    arrayCapsules = objTopic.getJSONArray("capsules");
605
                    for(j = 0; j < arrayCapsules.length(); j++)
606
                    {
607
                        objCapsule = arrayCapsules.getJSONObject(j);
608
                        Capsule capsule = new Capsule();
609
                        capsule.topicUuid = topic.id;
610
                        capsule.id = objCapsule.getInt("id");
611
                        capsule.name = objCapsule.getString("name");
612
                        capsule.description = objCapsule.getString("description");
613
                        capsule.image = objCapsule.getString("image");
614
                        capsule.position = objCapsule.getInt("position");
615
                        capsuleDao.insert(capsule);
616
 
617
                        arraySlides = objCapsule.getJSONArray("slides");
618
                        for( x = 0; x < arraySlides.length(); x++) {
619
                            objSlide = arraySlides.getJSONObject(x);
620
                            Slide slide = new Slide();
621
                            slide.id = objSlide.getInt("id");
622
                            slide.topicUuid = capsule.topicUuid;
623
                            slide.capsuleUuid = capsule.id;
624
                            slide.quizId = objSlide.getInt("quiz_id");
625
                            slide.name = objSlide.getString("name");
626
                            slide.description = objSlide.getString("description");
627
                            slide.position = objSlide.getInt("position");
628
                            slide.type = objSlide.getString("type");
629
                            slide.file = objSlide.getString("file");
630
                            slide.background = objSlide.getString("background");
631
 
632
                            slideDao.insert(slide);
633
                        }
634
 
635
                    }
636
 
637
 
638
                }
639
 
640
                Calendar calendar = Calendar.getInstance();
641
                Date date = calendar.getTime();
642
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
643
                String  addedOn = simpleDateFormat.format(date);
644
 
645
 
646
                UserLog userLog = new UserLog();
647
                userLog.activity = Constants.USER_LOG_ACTIVITY_SIGNIN;
648
                userLog.addedOn = addedOn;
649
 
650
              //  mSharedViewModel.insertUserLog(userLog);
651
 
652
                Preference preference = iTwoGetSkills.getPreference();
653
 
654
                JSONObject objUser = objData.getJSONObject("user");
655
                //mUser.id  =  objUser.getInt("id");
656
                preference.userId = objUser.getInt("id");
657
                preference.firstName =  objUser.getString("first_name");
658
                preference.lastName =  objUser.getString("last_name");
659
                preference.email =  objUser.getString("email");
660
                preference.image =  objUser.getString("image");
661
                preference.password =  objUser.getString("password");
662
                preference.rsaE = objUser.getInt("rsa_e");
663
                preference.rsaD = objUser.getInt("rsa_d");
664
                preference.rsaN = objUser.getInt("rsa_n");
665
                preference.save(getActivity());
666
 
667
 
668
                JSONObject json = userLog.toJson();
669
                json.put("user_id", preference.userId);
670
                json.put(Constants.SYNC_ADAPTER_DATA_TYPE_FIELD_NAME, Constants.SYNC_ADAPTER_DATA_TYPE_USER_LOG);
671
 
672
                Sync sync = new Sync();
673
                sync.type = Constants.SYNC_ADAPTER_TYPE_SYNC;
674
                sync.data = json.toString();
675
 
676
                SyncDao syncDao = new SyncDao(getActivity());
677
                syncDao.insert(sync);
678
                syncDao.close();
679
 
680
                iTwoGetSkills.reloadNavHeader();
681
                iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
682
 
683
            } catch (JSONException e) {
684
                iTwoGetSkills.showMessageSnackBar(e.getMessage());
685
            }
686
 
687
            answerDao.close();
688
            questionDao.close();
689
            questionDao.close();
690
            slideDao.close();
691
            capsuleDao.close();
692
            topicDao.close();
693
            companyDao.close();
694
            progressDao.close();
695
            userLogDao.close();
696
            userNotificationDao.close();
697
 
698
 
699
        } else {
700
            iTwoGetSkills.showMessageSnackBar(httpCommResponse.getMessage());
701
            if(httpCommResponse.isFatal()) {
702
                iTwoGetSkills.onErrorFatal();
703
            }
704
        }
705
    }
706
 
707
     */
708
 
709
    @Override
710
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
711
                             Bundle savedInstanceState) {
712
        // Inflate the layout for this fragment
713
        return inflater.inflate(R.layout.fragment_signin, container, false);
714
    }
715
}