37 lines
1.0 KiB
Java
37 lines
1.0 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;
|
|
import com.lightgame.utils.Utils;
|
|
|
|
/**
|
|
* Created by khy on 28/06/17.
|
|
*/
|
|
|
|
public class CheckLoginUtils {
|
|
|
|
public static void checkLogin(final Context context, String entrance, OnLoginListener listener) {
|
|
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
|
|
if (listener != null) Utils.toast(context, "需要登录");
|
|
LogUtils.login("dialog", null, entrance);
|
|
LogUtils.login("activity", null, entrance);
|
|
Intent intent = LoginActivity.getIntent(context, entrance);
|
|
context.startActivity(intent);
|
|
} else {
|
|
listener.onLogin();
|
|
}
|
|
}
|
|
|
|
public static boolean isLogin() {
|
|
return !TextUtils.isEmpty(UserManager.getInstance().getToken());
|
|
}
|
|
|
|
public interface OnLoginListener {
|
|
void onLogin();
|
|
}
|
|
}
|