// Path: sample-chat/src/main/java/com/quickblox/sample/chatadapter/utils/ChatHelper.java
// public class ChatHelper {
//     private static final String TAG = ChatHelper.class.getSimpleName();
// 
//     private static final int CHAT_SOCKET_TIMEOUT = 0;
// 
//     private static final int CHAT_HISTORY_ITEMS_PER_PAGE = 100;
//     private static final String CHAT_HISTORY_ITEMS_SORT_FIELD = "date_sent";
// 
//     private static ChatHelper instance;
// 
//     private QBChatService qbChatService;
// 
//     public static synchronized ChatHelper getInstance() {
//         if (instance == null) {
//             QBSettings.getInstance().setLogLevel(LogLevel.DEBUG);
//             QBChatService.setDebugEnabled(true);
//             QBChatService.setConfigurationBuilder(buildChatConfigs());
//             QBChatService.setDefaultPacketReplyTimeout(20 * 1000);
//             instance = new ChatHelper();
//         }
//         return instance;
//     }
// 
//     private ChatHelper() {
//         qbChatService = QBChatService.getInstance();
//     }
// 
//     private static QBChatService.ConfigurationBuilder buildChatConfigs() {
//         QBChatService.ConfigurationBuilder configurationBuilder = new QBChatService.ConfigurationBuilder();
//         configurationBuilder.setKeepAlive(true)
//                 .setSocketTimeout(CHAT_SOCKET_TIMEOUT)
//                 .setAutojoinEnabled(false);
// 
//         return configurationBuilder;
//     }
// 
//     public void loginAndGetUsers(final QBUser user, final QBEntityCallback<ArrayList<QBUser>> callback) {
//         Performer<QBSession> performer = QBAuth.createSession(user);
//         final Observable<QBSession> observableSession = performer.convertTo(RxJavaPerformProcessor.INSTANCE);
// 
//         Observable<Void> observableLoginToChat = Observable.fromCallable(new Callable<Void>() {
//             @Override
//             public Void call() throws Exception {
//                 QBChatService.getInstance().login(user);
//                 return null;
//             }
//         });
// 
//         performMultiRequest(observableSession, observableLoginToChat, callback);
//     }
// 
//     private void performMultiRequest(Observable<QBSession> session, Observable<Void> loginToChat, final QBEntityCallback<ArrayList<QBUser>> callback) {
//         final ArrayList<Integer> usersIds = new ArrayList<>();
//         usersIds.add(Consts.userOneID);
//         usersIds.add(Consts.userTwoID);
// 
//         Observable.zip(
//                 loginToChat.subscribeOn(Schedulers.io()),
//                 session.flatMap(new Func1<QBSession, Observable<ArrayList<QBUser>>>() {
//                     @Override
//                     public Observable<ArrayList<QBUser>> call(QBSession qbSession) {
//                         return QBUsers.getUsersByIDs(usersIds, null).convertTo(RxJavaPerformProcessor.INSTANCE);
//                     }
//                 })
//                         .subscribeOn(Schedulers.io()),
//                 mergeResult()
//         )
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new Observer<ArrayList<QBUser>>() {
//                     @Override
//                     public void onCompleted() {
//                     }
// 
//                     @Override
//                     public void onError(Throwable e) {
//                         Log.d(TAG, "onError " + e);
//                     }
// 
//                     @Override
//                     public void onNext(ArrayList<QBUser> qbUsers) {
//                         Log.d(TAG, "onNext" + qbUsers);
//                         callback.onSuccess(qbUsers, Bundle.EMPTY);
//                     }
//                 });
//     }
// 
//     private Func2<Void, ArrayList<QBUser>, ArrayList<QBUser>> mergeResult() {
//         return new Func2<Void, ArrayList<QBUser>, ArrayList<QBUser>>() {
//             @Override
//             public ArrayList<QBUser> call(Void aVoid, ArrayList<QBUser> qbUsers) {
//                 return qbUsers;
//             }
//         };
//     }
// 
//     public void loadChatHistory(QBChatDialog dialog, int skipPagination,
//                                 final QBEntityCallback<ArrayList<QBChatMessage>> callback) {
//         QBRequestGetBuilder customObjectRequestBuilder = new QBRequestGetBuilder();
//         customObjectRequestBuilder.setSkip(skipPagination);
//         customObjectRequestBuilder.setLimit(CHAT_HISTORY_ITEMS_PER_PAGE);
//         customObjectRequestBuilder.sortDesc(CHAT_HISTORY_ITEMS_SORT_FIELD);
// 
//         QBRestChatService.getDialogMessages(dialog, customObjectRequestBuilder).performAsync(
//                 new QBEntityCallback<ArrayList<QBChatMessage>>() {
//                     @Override
//                     public void onSuccess(ArrayList<QBChatMessage> qbChatMessages, Bundle bundle) {
//                         callback.onSuccess(qbChatMessages, bundle);
//                     }
// 
//                     @Override
//                     public void onError(QBResponseException e) {
//                         callback.onError(e);
//                     }
//                 });
//     }
// 
//     public void logout() {
//         qbChatService.destroy();
//     }
// }
// 
// Path: sample-chat/src/main/java/com/quickblox/sample/chatadapter/utils/Consts.java
// public interface Consts {
//     String APP_ID = "92";
//     String AUTH_KEY = "wJHdOcQSxXQGWx5";
//     String AUTH_SECRET = "BTFsj7Rtt27DAmT";
//     String ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6";
// 
//     String userOneLogin = "firstuserfirstuser";
//     String userTwoLogin = "seconduserseconduser";
// 
//     String userPassword = "x6Bt0VDy5";
// 
//     int userOneID = 16575824;
//     int userTwoID = 16575844;
// }


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.quickblox.core.QBEntityCallback;
import com.quickblox.core.exception.QBResponseException;
import com.quickblox.sample.chatadapter.R;
import com.quickblox.sample.chatadapter.utils.ChatHelper;
import com.quickblox.sample.chatadapter.utils.Consts;
import com.quickblox.users.model.QBUser;
import java.util.ArrayList;
package com.quickblox.sample.chatadapter.ui.activity;




public class SplashActivity extends AppCompatActivity {
    private static final String TAG = SplashActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_splash);
        loginToQB();
    }


    private void loginToQB() {
// Path: sample-chat/src/main/java/com/quickblox/sample/chatadapter/utils/ChatHelper.java
// public class ChatHelper {
//     private static final String TAG = ChatHelper.class.getSimpleName();
// 
//     private static final int CHAT_SOCKET_TIMEOUT = 0;
// 
//     private static final int CHAT_HISTORY_ITEMS_PER_PAGE = 100;
//     private static final String CHAT_HISTORY_ITEMS_SORT_FIELD = "date_sent";
// 
//     private static ChatHelper instance;
// 
//     private QBChatService qbChatService;
// 
//     public static synchronized ChatHelper getInstance() {
//         if (instance == null) {
//             QBSettings.getInstance().setLogLevel(LogLevel.DEBUG);
//             QBChatService.setDebugEnabled(true);
//             QBChatService.setConfigurationBuilder(buildChatConfigs());
//             QBChatService.setDefaultPacketReplyTimeout(20 * 1000);
//             instance = new ChatHelper();
//         }
//         return instance;
//     }
// 
//     private ChatHelper() {
//         qbChatService = QBChatService.getInstance();
//     }
// 
//     private static QBChatService.ConfigurationBuilder buildChatConfigs() {
//         QBChatService.ConfigurationBuilder configurationBuilder = new QBChatService.ConfigurationBuilder();
//         configurationBuilder.setKeepAlive(true)
//                 .setSocketTimeout(CHAT_SOCKET_TIMEOUT)
//                 .setAutojoinEnabled(false);
// 
//         return configurationBuilder;
//     }
// 
//     public void loginAndGetUsers(final QBUser user, final QBEntityCallback<ArrayList<QBUser>> callback) {
//         Performer<QBSession> performer = QBAuth.createSession(user);
//         final Observable<QBSession> observableSession = performer.convertTo(RxJavaPerformProcessor.INSTANCE);
// 
//         Observable<Void> observableLoginToChat = Observable.fromCallable(new Callable<Void>() {
//             @Override
//             public Void call() throws Exception {
//                 QBChatService.getInstance().login(user);
//                 return null;
//             }
//         });
// 
//         performMultiRequest(observableSession, observableLoginToChat, callback);
//     }
// 
//     private void performMultiRequest(Observable<QBSession> session, Observable<Void> loginToChat, final QBEntityCallback<ArrayList<QBUser>> callback) {
//         final ArrayList<Integer> usersIds = new ArrayList<>();
//         usersIds.add(Consts.userOneID);
//         usersIds.add(Consts.userTwoID);
// 
//         Observable.zip(
//                 loginToChat.subscribeOn(Schedulers.io()),
//                 session.flatMap(new Func1<QBSession, Observable<ArrayList<QBUser>>>() {
//                     @Override
//                     public Observable<ArrayList<QBUser>> call(QBSession qbSession) {
//                         return QBUsers.getUsersByIDs(usersIds, null).convertTo(RxJavaPerformProcessor.INSTANCE);
//                     }
//                 })
//                         .subscribeOn(Schedulers.io()),
//                 mergeResult()
//         )
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new Observer<ArrayList<QBUser>>() {
//                     @Override
//                     public void onCompleted() {
//                     }
// 
//                     @Override
//                     public void onError(Throwable e) {
//                         Log.d(TAG, "onError " + e);
//                     }
// 
//                     @Override
//                     public void onNext(ArrayList<QBUser> qbUsers) {
//                         Log.d(TAG, "onNext" + qbUsers);
//                         callback.onSuccess(qbUsers, Bundle.EMPTY);
//                     }
//                 });
//     }
// 
//     private Func2<Void, ArrayList<QBUser>, ArrayList<QBUser>> mergeResult() {
//         return new Func2<Void, ArrayList<QBUser>, ArrayList<QBUser>>() {
//             @Override
//             public ArrayList<QBUser> call(Void aVoid, ArrayList<QBUser> qbUsers) {
//                 return qbUsers;
//             }
//         };
//     }
// 
//     public void loadChatHistory(QBChatDialog dialog, int skipPagination,
//                                 final QBEntityCallback<ArrayList<QBChatMessage>> callback) {
//         QBRequestGetBuilder customObjectRequestBuilder = new QBRequestGetBuilder();
//         customObjectRequestBuilder.setSkip(skipPagination);
//         customObjectRequestBuilder.setLimit(CHAT_HISTORY_ITEMS_PER_PAGE);
//         customObjectRequestBuilder.sortDesc(CHAT_HISTORY_ITEMS_SORT_FIELD);
// 
//         QBRestChatService.getDialogMessages(dialog, customObjectRequestBuilder).performAsync(
//                 new QBEntityCallback<ArrayList<QBChatMessage>>() {
//                     @Override
//                     public void onSuccess(ArrayList<QBChatMessage> qbChatMessages, Bundle bundle) {
//                         callback.onSuccess(qbChatMessages, bundle);
//                     }
// 
//                     @Override
//                     public void onError(QBResponseException e) {
//                         callback.onError(e);
//                     }
//                 });
//     }
// 
//     public void logout() {
//         qbChatService.destroy();
//     }
// }
// 
// Path: sample-chat/src/main/java/com/quickblox/sample/chatadapter/utils/Consts.java
// public interface Consts {
//     String APP_ID = "92";
//     String AUTH_KEY = "wJHdOcQSxXQGWx5";
//     String AUTH_SECRET = "BTFsj7Rtt27DAmT";
//     String ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6";
// 
//     String userOneLogin = "firstuserfirstuser";
//     String userTwoLogin = "seconduserseconduser";
// 
//     String userPassword = "x6Bt0VDy5";
// 
//     int userOneID = 16575824;
//     int userTwoID = 16575844;
// }


// Path: sample-chat/src/main/java/com/quickblox/sample/chatadapter/ui/activity/SplashActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.quickblox.core.QBEntityCallback;
import com.quickblox.core.exception.QBResponseException;
import com.quickblox.sample.chatadapter.R;
import com.quickblox.sample.chatadapter.utils.ChatHelper;
import com.quickblox.sample.chatadapter.utils.Consts;
import com.quickblox.users.model.QBUser;
import java.util.ArrayList;

package com.quickblox.sample.chatadapter.ui.activity;




public class SplashActivity extends AppCompatActivity {
    private static final String TAG = SplashActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_splash);
        loginToQB();
    }


    private void loginToQB() {
        QBUser qbUser = new QBUser(Consts.userTwoLogin, Consts.userPassword);