Proyectos de Subversion Android Microlearning

Rev

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