|
@@ -9,6 +9,8 @@ import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.common.library.okhttp.callback.Callback;
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.ynstkz.shitu.android.R;
|
|
|
import com.ynstkz.shitu.android.activity.MessageListActivity;
|
|
|
import com.ynstkz.shitu.android.activity.MineCollectActivity;
|
|
@@ -18,9 +20,9 @@ import com.ynstkz.shitu.android.activity.SettingActivity;
|
|
|
import com.ynstkz.shitu.android.activity.StudentInfoActivity;
|
|
|
import com.ynstkz.shitu.android.activity.UserInfoActivity;
|
|
|
import com.ynstkz.shitu.android.adapter.UserCenterOptionGridAdapter;
|
|
|
-import com.ynstkz.shitu.android.application.STSign;
|
|
|
import com.ynstkz.shitu.android.base.BaseFragment;
|
|
|
-import com.ynstkz.shitu.android.bean.UserBean;
|
|
|
+import com.ynstkz.shitu.android.bean.UserInfoBean;
|
|
|
+import com.ynstkz.shitu.android.data.RequestGroup;
|
|
|
import com.ynstkz.shitu.android.view.ScrollViewWithGridView;
|
|
|
|
|
|
import java.util.Arrays;
|
|
@@ -28,6 +30,8 @@ import java.util.List;
|
|
|
|
|
|
import butterknife.Bind;
|
|
|
import butterknife.ButterKnife;
|
|
|
+import okhttp3.Call;
|
|
|
+import okhttp3.Response;
|
|
|
|
|
|
/**
|
|
|
* 我
|
|
@@ -62,17 +66,16 @@ public class UserCenterFragment extends BaseFragment {
|
|
|
}
|
|
|
|
|
|
private void initView() {
|
|
|
- UserBean userBean = STSign.getInstance().getUser();
|
|
|
- if (userBean != null) {
|
|
|
- tvUsername.setText(userBean.getUserName());
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void initData() {
|
|
|
List<String> listUserOption = Arrays.asList(getResources().getStringArray(R.array.usercenter_option));
|
|
|
UserCenterOptionGridAdapter userCenterOptionGridAdapter = new UserCenterOptionGridAdapter(getActivity(), listUserOption);
|
|
|
gvMine.setAdapter(userCenterOptionGridAdapter);
|
|
|
userCenterOptionGridAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ getUserInfo();
|
|
|
}
|
|
|
|
|
|
private void setListener() {
|
|
@@ -132,6 +135,43 @@ public class UserCenterFragment extends BaseFragment {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取用户信息
|
|
|
+ */
|
|
|
+ private void getUserInfo(){
|
|
|
+
|
|
|
+ RequestGroup.getUserInfo(new Callback() {
|
|
|
+ @Override
|
|
|
+ public Object parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
+ return new Gson().fromJson(response.body().string(), UserInfoBean.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ showToast(getActivity(), getString(R.string.error_msg));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(Object response, int id) {
|
|
|
+ UserInfoBean userInfoBean = (UserInfoBean)response;
|
|
|
+ if(userInfoBean != null){
|
|
|
+ if("200".equals(userInfoBean.getCode())){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化用户信息
|
|
|
+ */
|
|
|
+ private void initUserInfo(UserInfoBean userInfoBean){
|
|
|
+ if(userInfoBean == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onDestroyView() {
|
|
|
super.onDestroyView();
|