Android Open Source - HotSpot_Android Logout Response






From Project

Back to project page HotSpot_Android.

License

The source code is released under:

GNU General Public License

If you think the Android project HotSpot_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ticknardif.hotspot.RESTresponses;
/*from   w w w .j  a v a 2 s.co m*/
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;

import com.ticknardif.hotspot.LoginActivity;
import com.ticknardif.hotspot.MainActivity;
import com.ticknardif.hotspot.R;
import com.ticknardif.hotspot.WebService;

import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;

/**
 * Created by Vatsal on 11/21/2014.
 */
public class LogoutResponse {

    public String message;
    public boolean success;
    public static Callback<LogoutResponse> logoutResponseCallback = new Callback<LogoutResponse>(){

        @Override
        public void success(LogoutResponse logoutResponse, Response response) {
            Log.d("Debug Server Logout: ", logoutResponse.toString());
        }
        @Override
        public void failure(RetrofitError error) {
            Log.e("Debug", error.toString());
        }
    };

    public LogoutResponse(String message) {
        this.message = message;

    }

    @Override
    public String toString() {
        return "LogoutResponse{" +
                "message='" + message + '\'' +
                ", success=" + success +
                '}';
    }

    public static void logout(Activity activity, WebService service) {

        Context context = activity.getBaseContext();

        SharedPreferences sharedPref = context.getSharedPreferences(context.getString(R.string.shared_pref_file), Context.MODE_PRIVATE);
        String email = sharedPref.getString(context.getString(R.string.shared_pref_email), "");

        service.logout(email, LogoutResponse.logoutResponseCallback);
        final SharedPreferences prefs = context.getSharedPreferences(MainActivity.class.getSimpleName(), Context.MODE_PRIVATE);

        SharedPreferences.Editor editor = sharedPref.edit();
        editor.clear();
        editor.commit();

        SharedPreferences.Editor gcmEditor = prefs.edit();
        gcmEditor.clear();
        gcmEditor.commit();

        Intent intent = new Intent(context, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);

        // Remove this activity from the Activity stack so the user cannot go back to this
        activity.finish();
    }
}




Java Source Code List

com.example.ticknardif.hotspot.ApplicationTest.java
com.example.ticknardif.hotspot.util.SystemUiHiderBase.java
com.example.ticknardif.hotspot.util.SystemUiHiderHoneycomb.java
com.example.ticknardif.hotspot.util.SystemUiHider.java
com.ticknardif.hotspot.AppStartActivity.java
com.ticknardif.hotspot.ChatroomActivity.java
com.ticknardif.hotspot.ChatroomListAdapter.java
com.ticknardif.hotspot.ChatroomOverlay.java
com.ticknardif.hotspot.Chatroom.java
com.ticknardif.hotspot.CreateAccountActivity.java
com.ticknardif.hotspot.CreateChatroomFragment.java
com.ticknardif.hotspot.GcmBroadcastReceiver.java
com.ticknardif.hotspot.GcmIntentService.java
com.ticknardif.hotspot.LoginActivity.java
com.ticknardif.hotspot.MainActivity.java
com.ticknardif.hotspot.MessageListAdapter.java
com.ticknardif.hotspot.Message.java
com.ticknardif.hotspot.WebService.java
com.ticknardif.hotspot.RESTresponses.ChatRoomCreationResponse.java
com.ticknardif.hotspot.RESTresponses.ChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.ChatroomUserResponse.java
com.ticknardif.hotspot.RESTresponses.CreateChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.GCMResponse.java
com.ticknardif.hotspot.RESTresponses.JoinChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.LeaveChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.LoginResponse.java
com.ticknardif.hotspot.RESTresponses.LogoutResponse.java
com.ticknardif.hotspot.RESTresponses.UpdateLocationResponse.java
com.ticknardif.hotspot.RESTresponses.UserResponse.java