37 lines
991 B
Java
37 lines
991 B
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, OnLoginListener listener) {
|
|
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
|
|
Utils.toast(context, "需要登录");
|
|
LogUtils.login(context, "dialog", null);
|
|
LogUtils.login(context, "activity", null);
|
|
Intent intent = LoginActivity.getIntent(context);
|
|
context.startActivity(intent);
|
|
} else {
|
|
listener.onLogin();
|
|
}
|
|
}
|
|
|
|
public static boolean isLogin() {
|
|
return !TextUtils.isEmpty(UserManager.getInstance().getToken());
|
|
}
|
|
|
|
public interface OnLoginListener {
|
|
void onLogin();
|
|
}
|
|
}
|