Proyectos de Subversion Android Microlearning

Rev

Rev 4 | Rev 29 | 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
 
178
        if(TextUtils.isEmpty(iTwoGetSkills.getPreference().getAes())) {
179
            iTwoGetSkills.reloadPreference();
180
        }
181
 
182
 
183
 
184
        mEditTextEmail.setError(null);
185
        mEditTextPassword.setError(null);
186
 
187
        String email = Functions.trimNull(mEditTextEmail.getText().toString());
188
        String password = Functions.trimNull(mEditTextPassword.getText().toString());
189
 
190
        if (TextUtils.isEmpty(email)) {
191
            mEditTextEmail.setError(getString(R.string.error_field_required));
192
            mEditTextEmail.requestFocus();
193
            return;
194
        }
195
 
19 gabriel 196
        if (!Functions.emailcheckengine(email)) {
197
            mEditTextEmail.setError("Formato de email invalido");
198
            mEditTextEmail.requestFocus();
199
            return;
200
        }
201
 
1 efrain 202
        if (TextUtils.isEmpty(password)) {
203
            mEditTextPassword.setError(getString(R.string.error_field_required));
204
            mEditTextPassword.requestFocus();
205
            return;
206
        }
207
 
208
 
209
        if (!Functions.passwordStrengthCheck(password)) {
210
            mEditTextPassword.setError(getString(R.string.error_invalid_password_format));
211
            mEditTextPassword.requestFocus();
212
            return;
213
        }
214
 
215
        if(iTwoGetSkills.isConnectedInternet()) {
216
            inProgress = true;
217
 
218
 
219
            String aes = iTwoGetSkills.getPreference().getAes();
220
 
221
            mEditTextEmail.setEnabled(false);
222
            mEditTextPassword.setEnabled(false);
223
 
224
            mButtonSignIn.setEnabled(false);
225
            mProgressBar.setVisibility(View.VISIBLE);
226
 
227
            inProgress = false;
228
            mEditTextEmail.setEnabled(true);
229
            mEditTextPassword.setEnabled(true);
230
 
231
            mButtonSignIn.setEnabled(true);
232
            mProgressBar.setVisibility(View.INVISIBLE);
233
 
234
            try {
235
 
236
                Log.d("AES", aes);
237
 
238
                Http http = new Http(getActivity().getCacheDir());
239
                OkHttpClient client = http.getHttpClient(false);
240
 
241
                Log.d(TAG, "URL = " + Configuration.URL_SIGNIN);
242
 
243
                RequestBody formBody = null;
244
                if(aes.isEmpty()) {
245
                    formBody = new FormBody.Builder()
246
                            .add(Constants.POST_SIGNIN_FIELD_APPLICATION_ID, String.valueOf(Configuration.APPLICATION_ID))
247
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_UUID, iTwoGetSkills.getPreference().getDeviceUuid())
248
                            .add(Constants.POST_SIGNIN_FIELD_EMAIL, email)
249
                            .add(Constants.POST_SIGNIN_FIELD_PASSWORD, password)
250
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_ENCRYPTER, "") //Constants.SIGNIN_ENCRYPTER)
251
                            .build();
252
                } else {
253
                    AesCipher encryptedEmail    = AesCipher.encrypt(aes, email);
254
                    AesCipher encryptedPassword = AesCipher.encrypt(aes, password);
255
 
256
                    formBody = new FormBody.Builder()
257
                            .add(Constants.POST_SIGNIN_FIELD_APPLICATION_ID, String.valueOf(Configuration.APPLICATION_ID))
258
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_UUID, iTwoGetSkills.getPreference().getDeviceUuid())
259
                            .add(Constants.POST_SIGNIN_FIELD_EMAIL, encryptedEmail.getData())
260
                            .add(Constants.POST_SIGNIN_FIELD_PASSWORD, encryptedPassword.getData())
261
                            .add(Constants.POST_SIGNIN_FIELD_DEVICE_ENCRYPTER, Constants.SIGNIN_ENCRYPTER)
262
                            .build();
263
                }
264
 
265
 
266
 
267
 
268
 
269
 
270
                Request request = new Request.Builder()
271
                        .url(Configuration.URL_SIGNIN)
272
                        .post(formBody)
273
                        .build();
274
 
275
                Call call = client.newCall(request);
276
          /*  try {
277
                mProgressBar.setVisibility(View.VISIBLE);
278
 
279
                Response response = call.execute();
280
 
281
                processResponseServer(response.body().string());
282
 
283
            } catch(IOException e) {
284
                Log.d(TAG, e.getMessage());
285
            }*/
286
                iTwoGetSkills.showProgressBar();
287
                call.enqueue(new Callback() {
288
                    public void onResponse(Call call, Response response)
289
                            throws IOException {
290
 
291
                        iTwoGetSkills.hideProgressBar();
292
                        processResponseServer(response.body().string());
293
 
294
 
295
                    }
296
 
297
                    public void onFailure(Call call, IOException e) {
298
                        Log.d(TAG, "Error :  " +  e.getMessage());
299
                        iTwoGetSkills.hideProgressBar();
300
                    }
301
                });
302
 
303
            } catch (Exception e) {
304
                iTwoGetSkills.showMessageSnackBar(e.getMessage());
305
            } finally {
306
 
307
            }
308
 
309
 
310
        }
311
    }
312
 
313
    private boolean isPasswordValid(String password) {
314
        //TODO: Replace this with your own logic
315
        return password.length() > 5;
316
    }
317
 
318
    private void processResponseServer(String dataString) {
319
        boolean success = false;
320
        boolean fatal = false;
321
        String message = "";
322
 
323
        mProgressBar.setVisibility(View.INVISIBLE);
324
 
325
        try {
326
            JSONObject objData = new JSONObject(dataString);
327
            success = objData.has("success") ? objData.getBoolean("success")  : false;
328
            if(objData.has("data")) {
329
                Object item = objData.get("data");
330
                if (item instanceof String) {
331
                    message = (String) item;
332
                }
333
                fatal = objData.has("fatal");
334
            }
335
 
336
            if(success) {
337
                JSONObject data = objData.getJSONObject("data");
338
 
339
 
340
                Calendar calendar = Calendar.getInstance();
341
                Date date = calendar.getTime();
342
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
343
                String  addedOn = simpleDateFormat.format(date);
344
                iTwoGetSkills.syncFromServer(data);
345
 
346
 
347
                Preference preference = iTwoGetSkills.getPreference();
348
                JSONObject objUser = data.getJSONObject("user");
349
                preference.setUserUuid(objUser.getString("uuid"));
350
                preference.setFirstName(objUser.getString("first_name"));
351
                preference.setLastName(objUser.getString("last_name"));
352
                preference.setEmail(objUser.getString("email"));
353
                preference.setImage(objUser.getString("image"));
354
                preference.setLastDataRefresh(addedOn);
355
 
356
                JSONObject objDevice = data.getJSONObject("device");
357
                preference.setAes(objDevice.getString("aes"));
358
                preference.setPassword(objDevice.getString("password"));
359
                preference.save(getActivity());
360
 
361
 
362
 
363
 
364
                UserLog userLog = new UserLog();
365
                userLog.setUserUuid(preference.getUserUuid());
366
                userLog.setActivity(Constants.USER_LOG_ACTIVITY_SIGNIN);
367
                userLog.setAddedOn(addedOn);
368
                JSONObject json = userLog.toJson();
369
                json.put(Constants.SYNC_ADAPTER_DATA_TYPE_FIELD_NAME, Constants.SYNC_ADAPTER_DATA_TYPE_USER_LOG);
370
 
371
                Sync sync = new Sync(Constants.SYNC_ADAPTER_TYPE_SYNC, json.toString());
372
 
373
                SyncDao syncDao = iTwoGetSkills.getDatabase().getSyncDao();
374
                syncDao.insert(sync);
375
 
376
 
377
                getActivity().runOnUiThread(new Runnable() {
378
 
379
                    @Override
380
                    public void run() {
381
 
382
                        ResultCount resultCount = iTwoGetSkills.getDatabase().getCapsuleDao().getCount();
383
                        String message = resultCount.getCount() == 1
384
                                ? "Hay 1 cápsula nueva disponible"
385
                                : "Hay " + resultCount.getCount() + " cápsulas disponible";
386
 
387
                        iTwoGetSkills.showMessageSnackBarWithClose(message);
388
 
389
 
390
                        iTwoGetSkills.reloadNavHeader();
391
                        iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
392
                    }
393
                });
394
 
395
 
396
 
397
 
398
            } else {
399
                if(!TextUtils.isEmpty(message)) {
400
                    iTwoGetSkills.showMessageSnackBar(message);
401
                }
402
                if(fatal) {
403
                    iTwoGetSkills.onErrorFatal();
404
                }
405
            }
406
 
407
 
408
        } catch (JSONException e) {
409
            e.printStackTrace();
410
            Log.e(TAG,  e.getMessage());
411
        }
412
 
413
 
414
    }
415
 
416
    /*
417
    @Override
418
    public void taskCallback(HttpCommResponse httpCommResponse) {
419
        inProgress = false;
420
        mEditTextEmail.setEnabled(true);
421
        mEditTextPassword.setEnabled(true);
422
 
423
        mButtonSignIn.setEnabled(true);
424
        mProgressBar.setVisibility(View.INVISIBLE);
425
 
426
        if(httpCommResponse.isSuccess()) {
427
 
428
            AnswerDao answerDao = new AnswerDao(getActivity());
429
            answerDao.removeAll();
430
 
431
            QuestionDao questionDao = new QuestionDao(getActivity());
432
            questionDao.removeAll();
433
 
434
            QuizDao quizDao = new QuizDao(getActivity());
435
            questionDao.removeAll();
436
 
437
            SlideDao slideDao = new SlideDao(getActivity());
438
            slideDao.removeAll();
439
 
440
            CapsuleDao capsuleDao = new CapsuleDao(getActivity());
441
            capsuleDao.removeAll();
442
 
443
            TopicDao topicDao = new TopicDao(getActivity());
444
            topicDao.removeAll();
445
 
446
            CompanyDao companyDao = new CompanyDao(getActivity());
447
            companyDao.removeAll();
448
 
449
            ProgressDao progressDao = new ProgressDao(getActivity());
450
            progressDao.removeAll();
451
 
452
            UserLogDao userLogDao = new UserLogDao(getActivity());
453
 
454
            UserNotificationDao userNotificationDao = new UserNotificationDao(getActivity());
455
            userNotificationDao.removeAll();
456
 
457
            try {
458
                JSONObject objData = httpCommResponse.getObjJSON().getJSONObject("data");
459
 
460
 
461
 
462
 
463
                JSONArray arrayCapsules;
464
                JSONArray arraySlides;
465
                JSONArray arrayAnswers;
466
                JSONArray arrayQuestions;
467
                JSONArray arrayProgress;
468
                JSONArray arrayQuizzes;
469
                JSONArray arrayUserLog;
470
 
471
 
472
                JSONObject objTopic;
473
                JSONObject objCapsule;
474
                JSONObject objSlide;
475
                JSONObject objAnswer;
476
                JSONObject objQuestion;
477
                JSONObject objQuiz;
478
                JSONObject objProgress;
479
                JSONObject objUserLog;
480
                int i,j,x;
481
 
482
                arrayProgress = objData.getJSONArray("progress");
483
                for(i = 0; i <  arrayProgress.length(); i++) {
484
                    objProgress = arrayProgress.getJSONObject(i);
485
 
486
                    Progress progress = new Progress();
487
                    progress.companyUuid = objProgress.getInt("company_uuid");
488
                    progress.topicUuid = objProgress.getInt("topic_uuid");
489
                    progress.capsuleUuid = objProgress.getInt("capsule_uuid");
490
                    progress.SlideUuid = objProgress.getInt("Slide_uuid");
491
                    progress.progress = objProgress.getDouble("progress");
492
                    progress.totalSlides = objProgress.getInt("total_slides");
493
                    progress.viewSlides = objProgress.getInt("view_slides");
494
                    progress.type = objProgress.getString("type");
495
                    progress.returning = objProgress.getInt("returning");
496
                    progress.returningAfterCompleted = objProgress.getInt("returning_after_completed");
497
                    progress.completed = objProgress.getInt("completed");
498
                    progress.addedOn = objProgress.getString("added_on");
499
                    progress.updatedOn = objProgress.getString("updated_on");
500
 
501
                    progressDao.insert(progress);
502
 
503
                }
504
 
505
                arrayUserLog = objData.getJSONArray("userlog");
506
                for(i = 0; i <   arrayUserLog.length(); i++) {
507
                    objUserLog =  arrayUserLog.getJSONObject(i);
508
 
509
                    UserLog userLog = new UserLog();
510
                    userLog.companyUuid  = objUserLog.getInt("company_uuid");
511
                    userLog.topicUuid    = objUserLog.getInt("topic_uuid");
512
                    userLog.capsuleUuid  = objUserLog.getInt("capsule_uuid");
513
                    userLog.SlideUuid    = objUserLog.getInt("Slide_uuid");
514
                    userLog.activity   = objUserLog.getString("activity");
515
                    userLog.addedOn    = objUserLog.getString("added_on");
516
                    userLogDao.insert(userLog);
517
                }
518
 
519
                arrayQuizzes = objData.getJSONArray("quizzes");
520
                for(i = 0; i <  arrayQuizzes.length(); i++)
521
                {
522
                    objQuiz = arrayQuizzes.getJSONObject(i);
523
                    Quiz quiz = new Quiz();
524
                    quiz.id = objQuiz.getInt("id");
525
                    quiz.companyUuid = objQuiz.getInt("company_uuid");
526
                    quiz.name = objQuiz.getString("name");
527
                    quiz.text = objQuiz.getString("text");
528
                    quiz.points = objQuiz.getInt("points");
529
                    quiz.minimumPointsRequired  = objQuiz.getInt("minimum_points_required");
530
 
531
                    Company company =  companyDao.selectById(quiz.companyUuid);
532
                    if(company == null) {
533
                        company = new Company();
534
                        company.id = objQuiz.getInt("company_uuid");
535
                        company.name  = objQuiz.getString("company_name");
536
                        company.image = objQuiz.getString("company_image");
537
 
538
                        companyDao.insert(company);
539
                    }
540
 
541
                    quizDao.insert(quiz);
542
 
543
                    arrayQuestions = objQuiz.getJSONArray("questions");
544
                    for(j = 0; j < arrayQuestions.length(); j++) {
545
                        objQuestion = arrayQuestions.getJSONObject(j);
546
                       Question question = new Question();
547
                       question.quizId = quiz.id;
548
                       question.id = objQuestion.getInt("id");
549
                       question.text = objQuestion.getString("text");
550
                       question.type = objQuestion.getString("type");
551
                       question.points = objQuestion.getInt("points");
552
                       question.maxlength = objQuestion.getInt("maxlength");
553
 
554
                        questionDao.insert(question);
555
 
556
                        arrayAnswers = objQuestion.getJSONArray("answers");
557
                        for(x = 0; x < arrayAnswers.length(); x++)
558
                        {
559
                            objAnswer = arrayAnswers.getJSONObject(x);
560
                            Answer answer = new Answer();
561
                            answer.questionId =question.id;
562
                            answer.id = objAnswer.getInt("id");
563
                            answer.text = objAnswer.getString("text");
564
                            answer.points = objAnswer.getInt("points");
565
                            answer.position = objAnswer.getInt("position");
566
                            answer.correct = objAnswer.getString("correct");
567
 
568
                            answerDao.insert(answer);
569
                        }
570
 
571
 
572
                    }
573
                }
574
 
575
 
576
 
577
 
578
 
579
                JSONArray arrayTopics = objData.getJSONArray("topics");
580
                for(i = 0; i < arrayTopics.length(); i++)
581
                {
582
                    objTopic = arrayTopics.getJSONObject(i);
583
                    Topic topic = new Topic();
584
                    topic.id = objTopic.getInt("id");
585
                    topic.companyUuid = objTopic.getInt("company_uuid");
586
                    topic.name = objTopic.getString("name");
587
                    topic.description = objTopic.getString("description");
588
                    topic.image = objTopic.getString("image");
589
                    topic.position = objTopic.getInt("position");
590
 
591
                    Company company = companyDao.selectById(topic.companyUuid);
592
                    if(company == null) {
593
                        company = new Company();
594
                        company.id = objTopic.getInt("company_uuid");
595
                        company.name  = objTopic.getString("company_name");
596
                        company.image  = objTopic.getString("company_image");
597
 
598
                        companyDao.insert(company);
599
                    }
600
 
601
                    topicDao.insert(topic);
602
 
603
                    arrayCapsules = objTopic.getJSONArray("capsules");
604
                    for(j = 0; j < arrayCapsules.length(); j++)
605
                    {
606
                        objCapsule = arrayCapsules.getJSONObject(j);
607
                        Capsule capsule = new Capsule();
608
                        capsule.topicUuid = topic.id;
609
                        capsule.id = objCapsule.getInt("id");
610
                        capsule.name = objCapsule.getString("name");
611
                        capsule.description = objCapsule.getString("description");
612
                        capsule.image = objCapsule.getString("image");
613
                        capsule.position = objCapsule.getInt("position");
614
                        capsuleDao.insert(capsule);
615
 
616
                        arraySlides = objCapsule.getJSONArray("slides");
617
                        for( x = 0; x < arraySlides.length(); x++) {
618
                            objSlide = arraySlides.getJSONObject(x);
619
                            Slide slide = new Slide();
620
                            slide.id = objSlide.getInt("id");
621
                            slide.topicUuid = capsule.topicUuid;
622
                            slide.capsuleUuid = capsule.id;
623
                            slide.quizId = objSlide.getInt("quiz_id");
624
                            slide.name = objSlide.getString("name");
625
                            slide.description = objSlide.getString("description");
626
                            slide.position = objSlide.getInt("position");
627
                            slide.type = objSlide.getString("type");
628
                            slide.file = objSlide.getString("file");
629
                            slide.background = objSlide.getString("background");
630
 
631
                            slideDao.insert(slide);
632
                        }
633
 
634
                    }
635
 
636
 
637
                }
638
 
639
                Calendar calendar = Calendar.getInstance();
640
                Date date = calendar.getTime();
641
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
642
                String  addedOn = simpleDateFormat.format(date);
643
 
644
 
645
                UserLog userLog = new UserLog();
646
                userLog.activity = Constants.USER_LOG_ACTIVITY_SIGNIN;
647
                userLog.addedOn = addedOn;
648
 
649
              //  mSharedViewModel.insertUserLog(userLog);
650
 
651
                Preference preference = iTwoGetSkills.getPreference();
652
 
653
                JSONObject objUser = objData.getJSONObject("user");
654
                //mUser.id  =  objUser.getInt("id");
655
                preference.userId = objUser.getInt("id");
656
                preference.firstName =  objUser.getString("first_name");
657
                preference.lastName =  objUser.getString("last_name");
658
                preference.email =  objUser.getString("email");
659
                preference.image =  objUser.getString("image");
660
                preference.password =  objUser.getString("password");
661
                preference.rsaE = objUser.getInt("rsa_e");
662
                preference.rsaD = objUser.getInt("rsa_d");
663
                preference.rsaN = objUser.getInt("rsa_n");
664
                preference.save(getActivity());
665
 
666
 
667
                JSONObject json = userLog.toJson();
668
                json.put("user_id", preference.userId);
669
                json.put(Constants.SYNC_ADAPTER_DATA_TYPE_FIELD_NAME, Constants.SYNC_ADAPTER_DATA_TYPE_USER_LOG);
670
 
671
                Sync sync = new Sync();
672
                sync.type = Constants.SYNC_ADAPTER_TYPE_SYNC;
673
                sync.data = json.toString();
674
 
675
                SyncDao syncDao = new SyncDao(getActivity());
676
                syncDao.insert(sync);
677
                syncDao.close();
678
 
679
                iTwoGetSkills.reloadNavHeader();
680
                iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_TOPICS);
681
 
682
            } catch (JSONException e) {
683
                iTwoGetSkills.showMessageSnackBar(e.getMessage());
684
            }
685
 
686
            answerDao.close();
687
            questionDao.close();
688
            questionDao.close();
689
            slideDao.close();
690
            capsuleDao.close();
691
            topicDao.close();
692
            companyDao.close();
693
            progressDao.close();
694
            userLogDao.close();
695
            userNotificationDao.close();
696
 
697
 
698
        } else {
699
            iTwoGetSkills.showMessageSnackBar(httpCommResponse.getMessage());
700
            if(httpCommResponse.isFatal()) {
701
                iTwoGetSkills.onErrorFatal();
702
            }
703
        }
704
    }
705
 
706
     */
707
 
708
    @Override
709
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
710
                             Bundle savedInstanceState) {
711
        // Inflate the layout for this fragment
712
        return inflater.inflate(R.layout.fragment_signin, container, false);
713
    }
714
}