mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-05-26 06:20:20 -04:00
修复登录框
This commit is contained in:
parent
68cc5eee2c
commit
0f726843a6
@ -313,9 +313,8 @@ public class MainActivity extends BaseActivity {
|
||||
if (valid) {
|
||||
String publicUrl = url + "/system/info/public";
|
||||
String publicInfo = Utils.okhttpSend(publicUrl);
|
||||
if (publicInfo != null && publicInfo.length() > 0) {
|
||||
JsonObject serverInfo = null;
|
||||
serverInfo = new Gson().fromJson(publicInfo, JsonObject.class);
|
||||
JsonObject serverInfo = Utils.JsonToObj(publicInfo,JsonObject.class);
|
||||
if (serverInfo != null) {
|
||||
String ServerId = serverInfo.get("Id").getAsString();
|
||||
if (ServerId == null || ServerId.length() == 0) {
|
||||
return false;
|
||||
@ -339,9 +338,10 @@ public class MainActivity extends BaseActivity {
|
||||
String url = "/Users/authenticatebyname";
|
||||
String reqjson = "{\"Username\":\"" + username + "\",\"Pw\":\"" + password + "\"}";
|
||||
String userinfo = Utils.okhttpSend(url, reqjson);
|
||||
if (userinfo.length() > 0) {
|
||||
JsonObject userObj = new Gson().fromJson(userinfo, JsonObject.class);
|
||||
String userId = userObj.getAsJsonObject("User").get("Id").getAsString();
|
||||
Log.d(TAG, "authenticateByName: userinf:" + userinfo);
|
||||
JsonObject userObj = Utils.JsonToObj(userinfo,JsonObject.class);
|
||||
if (userObj != null) {
|
||||
String userId = Utils.getJsonString(userObj,"User").getAsJsonObject().get("Id").getAsString();
|
||||
String Token = userObj.get("AccessToken").getAsString();
|
||||
if (Token != null) {
|
||||
Utils.UserId = userId;
|
||||
|
@ -116,6 +116,17 @@ public class Utils {
|
||||
return url;
|
||||
}
|
||||
|
||||
public static <T> T JsonToObj(String jsonStr,Class<T> tClass){
|
||||
if(jsonStr != null && jsonStr.length() > 0){
|
||||
try {
|
||||
return new Gson().fromJson(jsonStr,tClass);
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Json项
|
||||
* @param jo
|
||||
|
Loading…
Reference in New Issue
Block a user