40 lines
1.2 KiB
Java
40 lines
1.2 KiB
Java
package com.gh.common.util;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.text.TextUtils;
|
|
|
|
import com.gh.gamecenter.LoginActivity;
|
|
import com.gh.gamecenter.manager.UserManager;
|
|
|
|
/**
|
|
* Created by khy on 28/06/17.
|
|
*/
|
|
|
|
public class CheckLoginUtils {
|
|
|
|
public static void checkLogin(final Context context, OnLoginListener listener) {
|
|
// String token = LoginUtils.getToken(context);
|
|
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
|
|
DialogUtils.showWarningDialog(context, "登录提示", "需要登录才能使用该功能喔!", "取消", "快速登录",
|
|
new DialogUtils.ConfirmListener() {
|
|
@Override
|
|
public void onConfirm() {
|
|
Intent intent = LoginActivity.getIntent(context);
|
|
context.startActivity(intent);
|
|
}
|
|
}, null);
|
|
} else {
|
|
listener.onLogin();
|
|
}
|
|
}
|
|
|
|
public static boolean isLogin() {
|
|
return !TextUtils.isEmpty(UserManager.getInstance().getToken());
|
|
}
|
|
|
|
public interface OnLoginListener {
|
|
void onLogin();
|
|
}
|
|
}
|