<commit_before>package com.quickblox.q_municate_core.models;

import android.text.TextUtils;
import android.util.Log;

import com.quickblox.auth.model.QBProvider;
import com.quickblox.auth.session.BaseService;
import com.quickblox.auth.session.QBSession;
import com.quickblox.auth.session.QBSessionManager;
import com.quickblox.auth.session.QBSessionParameters;
import com.quickblox.core.exception.BaseServiceException;
import com.quickblox.auth.QBAuth;
import com.quickblox.q_municate_base_service.QMServiceManagerListener;
import com.quickblox.q_municate_core.utils.helpers.CoreSharedHelper;
import com.quickblox.users.model.QBUser;

import java.io.Serializable;
import java.util.Date;

public class AppSession implements Serializable {

    private static final Object lock = new Object();
    private static AppSession activeSession;

    private CoreSharedHelper coreSharedHelper;
    private LoginType loginType;
    private QBUser qbUser;

    private AppSession(QBUser qbUser) {
        coreSharedHelper = CoreSharedHelper.getInstance();
        this.qbUser = qbUser;
        this.loginType = getLoginTypeBySessionParameters(QBSessionManager.getInstance().getSessionParameters());
        save();
    }

    public static void startSession(QBUser user) {
        activeSession = new AppSession(user);
    }

    private static AppSession getActiveSession() {
        synchronized (lock) {
            return activeSession;
        }
    }

    public static AppSession load() {

        int userId = CoreSharedHelper.getInstance().getUserId();
        String userFullName = CoreSharedHelper.getInstance().getUserFullName();

        QBUser qbUser = new QBUser();
        qbUser.setId(userId);
        qbUser.setEmail(CoreSharedHelper.getInstance().getUserEmail());
        qbUser.setPassword(CoreSharedHelper.getInstance().getUserPassword());
        qbUser.setFullName(userFullName);
        qbUser.setFacebookId(CoreSharedHelper.getInstance().getFBId());
        qbUser.setTwitterId(CoreSharedHelper.getInstance().getTwitterId());
        qbUser.setTwitterDigitsId(CoreSharedHelper.getInstance().getTwitterDigitsId());
        qbUser.setCustomData(CoreSharedHelper.getInstance().getUserCustomData());


        return new AppSession(qbUser);
    }

    public static boolean isSessionExistOrNotExpired(long expirationTime) {
            QBSessionManager qbSessionManager = QBSessionManager.getInstance();
            String token = qbSessionManager.getToken();
            if (token == null) {
                Log.d("AppSession", "token == null");<commit_msg>Fixed load AppSession<commit_after>package com.quickblox.q_municate_core.models;

import android.text.TextUtils;
import android.util.Log;

import com.quickblox.auth.model.QBProvider;
import com.quickblox.auth.session.BaseService;
import com.quickblox.auth.session.QBSession;
import com.quickblox.auth.session.QBSessionManager;
import com.quickblox.auth.session.QBSessionParameters;
import com.quickblox.core.exception.BaseServiceException;
import com.quickblox.auth.QBAuth;
import com.quickblox.q_municate_base_service.QMServiceManagerListener;
import com.quickblox.q_municate_core.utils.helpers.CoreSharedHelper;
import com.quickblox.users.model.QBUser;

import java.io.Serializable;
import java.util.Date;

public class AppSession implements Serializable {

    private static final Object lock = new Object();
    private static AppSession activeSession;

    private CoreSharedHelper coreSharedHelper;
    private LoginType loginType;
    private QBUser qbUser;

    private AppSession(QBUser qbUser) {
        coreSharedHelper = CoreSharedHelper.getInstance();
        this.qbUser = qbUser;
        this.loginType = getLoginTypeBySessionParameters(QBSessionManager.getInstance().getSessionParameters());
        save();
    }

    public static void startSession(QBUser user) {
        activeSession = new AppSession(user);
    }

    private static AppSession getActiveSession() {
        synchronized (lock) {
            return activeSession;
        }
    }

    public static AppSession load() {

        int userId = CoreSharedHelper.getInstance().getUserId();
        String userFullName = CoreSharedHelper.getInstance().getUserFullName();

        QBUser qbUser = new QBUser();
        qbUser.setId(userId);
        qbUser.setEmail(CoreSharedHelper.getInstance().getUserEmail());
        qbUser.setPassword(CoreSharedHelper.getInstance().getUserPassword());
        qbUser.setFullName(userFullName);
        qbUser.setFacebookId(CoreSharedHelper.getInstance().getFBId());
        qbUser.setTwitterId(CoreSharedHelper.getInstance().getTwitterId());
        qbUser.setTwitterDigitsId(CoreSharedHelper.getInstance().getTwitterDigitsId());
        qbUser.setCustomData(CoreSharedHelper.getInstance().getUserCustomData());

        activeSession = new AppSession(qbUser);

        return activeSession;
    }

    public static boolean isSessionExistOrNotExpired(long expirationTime) {
            QBSessionManager qbSessionManager = QBSessionManager.getInstance();
            String token = qbSessionManager.getToken();
            if (token == null) {
                Log.d("AppSession", "token == null");
{'fraction_non_alphanumeric': 0.09450337512054002, 'fraction_numerical': 0.0, 'mean_word_length': 3.9579349904397705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2896538', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1439, 'n_words': 249}