If you think the Android project kakao-android-sdk-standalone 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
/**
* Copyright 2014 Minyoung Jeong <kkungkkung@gmail.com>
* Copyright 2014 Kakao Corp./*fromwww.java2s.com*/
*
* Redistribution and modification in source or binary forms are not permitted without specific prior written permission.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.kakao.authorization;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import java.io.Serializable;
/**
* @author MJ
*/publicabstractclass Authorizer implements Serializable {
privatestaticfinallong serialVersionUID = -601355608597936016L;
protectedtransient Activity loginActivity;
privatetransient StartActivityDelegate startActivityDelegate;
privatetransientboolean hasInternetPermission;
protectedtransient OnAuthorizationListener onAuthorizationListener;
privatetransient BackgroundProcessingListener backgroundProcessingListener;
publicinterface OnAuthorizationListener {
publicvoid onAuthorizationCompletion(AuthorizationResult result);
}
publicinterface BackgroundProcessingListener {
void onBackgroundProcessingStarted();
void onBackgroundProcessingStopped();
}
publicinterface StartActivityDelegate {
publicvoid startActivityForResult(Intent intent, int requestCode);
public Activity getActivityContext();
}
protectedboolean checkInternetPermission() {
if (hasInternetPermission) {
return true;
}
int permissionCheck = loginActivity.checkCallingOrSelfPermission(Manifest.permission.INTERNET);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
doneOnError("This Operation needs INTERNET permission.");
return false;
} else {
hasInternetPermission = true;
return true;
}
}
protectedabstractvoid completed(AuthorizationResult outcome);
protectedabstractvoid doneOnError(final String resultMessage);
publicvoid setLoginActivity(final Activity loginActivity) {
this.loginActivity = loginActivity;
startActivityDelegate = new StartActivityDelegate() {
@Override
publicvoid startActivityForResult(Intent intent, int requestCode) {
loginActivity.startActivityForResult(intent, requestCode);
}
@Override
public Activity getActivityContext() {
return loginActivity;
}
};
}
OnAuthorizationListener getOnAuthorizationListener() {
return onAuthorizationListener;
}
publicvoid setOnAuthorizationListener(OnAuthorizationListener onAuthorizationListener) {
this.onAuthorizationListener = onAuthorizationListener;
}
BackgroundProcessingListener getBackgroundProcessingListener() {
return backgroundProcessingListener;
}
publicvoid setBackgroundProcessingListener(BackgroundProcessingListener backgroundProcessingListener) {
this.backgroundProcessingListener = backgroundProcessingListener;
}
publicvoid notifyBackgroundProcessingStart() {
if (backgroundProcessingListener != null) {
backgroundProcessingListener.onBackgroundProcessingStarted();
}
}
publicvoid notifyBackgroundProcessingStop() {
if (backgroundProcessingListener != null) {
backgroundProcessingListener.onBackgroundProcessingStopped();
}
}
public StartActivityDelegate getStartActivityDelegate() {
return startActivityDelegate;
}
}