package com.qiscus.dragonfly;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.qiscus.sdk.Qiscus;
import com.qiscus.sdk.ui.QiscusActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class MainActivity extends QiscusActivity {

    @BindView(R.id.bt_login) Button loginButton;

    private ProgressDialog progressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        onViewReady(savedInstanceState);
    }

    @Override
    protected void onViewReady(Bundle savedInstanceState) {
        loginButton.setText(Qiscus.isLogged() ? "Logout" : "Login");
    }

    public void loginOrLogout(View view) {
        if (Qiscus.isLogged()) {
            Qiscus.logout();
            loginButton.setText("Login");
        } else {
            showLoading();
            Qiscus.with("zetra1@gmail.com", "12345678")
                    .withUsername("Zetra")
                    .login()
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .compose(bindToLifecycle())
                    .subscribe(qiscusAccount -> {
                        Log.i("MainActivity", "Login with account: " + qiscusAccount);
                        loginButton.setText("Logout");
                        dismissLoading();
                    }, throwable -> {
                        throwable.printStackTrace();
                        showError(throwable.getMessage());
                        dismissLoading();
                    });
        }
    }

    public void openChat(View view) {
        showLoading();
        Qiscus.buildChatWith("rya.meyvriska1@gmail.com")
                .withTitle("Rya Meyvriska")
                .build(this)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(bindToLifecycle())
                .subscribe(intent -> {
                    startActivity(intent);
                    dismissLoading();
                }, throwable -> {
                    throwable.printStackTrace();
                    showError(throwable.getMessage());
                    dismissLoading();
                });
    }

    public void showError(String errorMessage) {
        Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
    }

    public void showLoading() {
        if (progressDialog == null) {
            progressDialog = new ProgressDialog(this);
            progressDialog.setMessage("Please wait...");
        }
        progressDialog.setCancelable(false);
        progressDialog.show();
    }

    public void dismissLoading() {
        progressDialog.dismiss();
    }
}

@@ -85,16 +85,65 @@
 Bundle;%0A
+import android.support.v7.app.AppCompatActivity;%0A
 import a
@@ -155,24 +155,24 @@
 d.util.Log;%0A
-
 import andro
@@ -278,49 +278,8 @@
 cus;
-%0Aimport com.qiscus.sdk.ui.QiscusActivity;
 %0A%0Aim
@@ -453,22 +453,25 @@
 extends 
-Qiscus
+AppCompat
 Activity
@@ -767,130 +767,8 @@
 s);%0A
-        onViewReady(savedInstanceState);%0A    %7D%0A%0A    @Override%0A    protected void onViewReady(Bundle savedInstanceState) %7B%0A
     
@@ -1275,56 +1275,8 @@
 ())%0A
-                    .compose(bindToLifecycle())%0A
     
@@ -1967,32 +1967,32 @@
 chedulers.io())%0A
+
                 
@@ -2038,52 +2038,8 @@
 ())%0A
-                .compose(bindToLifecycle())%0A
     

Change main activity to extend AppCompatActivity