if (!TextUtils.isEmpty(user1.name) && !TextUtils.isEmpty(user1.pass)) {


final Request request = new Request.Builder()
.url(Info.url)
.header("Cookie", Var.cookie)
.build();
Call call = Var.client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {

}

@Override
public void onResponse(Call call, final Response response) throws IOException {
if (response.isSuccessful()) {
final String content=response.body().string();
runOnUiThread(new Runnable() {
@Override
public void run() {
// }});}}});}
String uname=StringUtils.substringBetween(content, "window.hy_user = \"", "\";");
if(!StringUtils.isEmpty(uname)){
usernameT.setText(uname);
nameTextView.setText(uname);
Glide.with(MainActivity.this).load(Info.url+ StringUtils.substringBetween(content, "window.hy_avatar = WWW + \"", "\";")).into(avatar);
Var.isLogin = true;
// //获取详细信息(出bug的地方)
Request gRequest=new Request.Builder().url(Info.url+"?api/user?user=" + uname).header("Cookie", cookie).build();
Call gCall=(new OkHttpClient()).newCall(gRequest);
gCall.enqueue(new Callback(){
@Override
public void onFailure(Call p1, IOException p2) {
}
@Override
public void onResponse(Call p1, Response p2) throws IOException {
if (p2.isSuccessful()) {
String s=p2.body().string();
final String source=StringEscapeUtils.unescapeJavaScript(s);
runOnUiThread(new Runnable(){
@Override
public void run() {
Gson gson=new Gson();
UserInfo myInfo=gson.fromJson(source, UserInfo.class);
follow_n.setText(myInfo.getData().getData().getFollow());
fans_n.setText(myInfo.getData().getData().getFans());
golds_n.setText(myInfo.getData().getData().getGold());
post_n.setText(myInfo.getData().getData().getPosts());
ps.setText(myInfo.getData().getData().getPs());
switch (myInfo.getData().getData().getGid()) {
case "1":
gid.setText("管理员");
gid.setBackgroundColor(Color.BLUE);
break;
case "2":
gid.setText("萌新");
gid.setBackgroundColor(Color.CYAN);
break;
case "3":
gid.setText("路人");
gid.setBackgroundColor(Color.CYAN);
break;
case "4":
gid.setText("伙伴");
gid.setBackgroundColor(Color.YELLOW);
break;
case "5":
gid.setText("活跃用户");
gid.setBackgroundColor(Color.GREEN);
break;
case "6":
gid.setText("VIP");
gid.setBackgroundColor(Color.GREEN);
break;
}
}
});
}
}
});

//end

}

}
});
}
}
});

}


Back to home | File page

Subscribe | Register | Login | N