Search in sources :

Example 1 with LoginResponse

use of in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse in project IITB-App by wncc.

the class LoginActivity method login.

private void login(String authorizationCode, final String redirectURI, String gcmID) {
    RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
    retrofitInterface.login(authorizationCode, redirectURI, gcmID).enqueue(new Callback<LoginResponse>() {

        @Override
        public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
            if (response.isSuccessful()) {
                Log.d(TAG, "Login request successful");
                session.createLoginSession(redirectURI, response.body().getUser(), response.body().getSessionID());
                Intent i = new Intent(mContext, MainActivity.class);
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);
            // Save credentials in AccountManager to keep user logged in
            // Go to MainActivity
            }
        // Server error
        }

        @Override
        public void onFailure(Call<LoginResponse> call, Throwable t) {
        // Network Error
        }
    });
}
Also used : LoginResponse(in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RetrofitInterface(in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface)

Aggregations

PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 RetrofitInterface (in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface)1 LoginResponse (in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse)1