|
|
|
@ -13,31 +13,30 @@ import androidx.fragment.app.Fragment;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.APNActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.AboutActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.AttentionActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.BaseActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.CollectActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.ConcernedProblemActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.EventActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.HistoryActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.LoginActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.MdctRmdActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.MyQuestionActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Activity.SafetyActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Model.User;
|
|
|
|
|
import com.example.leudaemialikeme.R;
|
|
|
|
|
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A simple {@link Fragment} subclass.
|
|
|
|
|
* Use the {@link MyFragment#newInstance} factory method to
|
|
|
|
|
* create an instance of this fragment.
|
|
|
|
|
*/
|
|
|
|
|
public class MyFragment extends Fragment {
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
// TODO: Rename parameter arguments, choose names that match
|
|
|
|
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
|
|
|
|
private static final String ARG_PARAM1 = "param1";
|
|
|
|
|
private static final String ARG_PARAM2 = "param2";
|
|
|
|
|
import okhttp3.Call;
|
|
|
|
|
import okhttp3.Callback;
|
|
|
|
|
import okhttp3.Response;
|
|
|
|
|
|
|
|
|
|
// TODO: Rename and change types of parameters
|
|
|
|
|
private String mParam1;
|
|
|
|
|
private String mParam2;
|
|
|
|
|
|
|
|
|
|
public class MyFragment extends Fragment {
|
|
|
|
|
private User user;
|
|
|
|
|
private TextView text_nickname;
|
|
|
|
|
|
|
|
|
|
public MyFragment() {
|
|
|
|
|
// Required empty public constructor
|
|
|
|
@ -46,10 +45,6 @@ public class MyFragment extends Fragment {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
if (getArguments() != null) {
|
|
|
|
|
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
|
|
|
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -58,9 +53,43 @@ public class MyFragment extends Fragment {
|
|
|
|
|
// Inflate the layout for this fragment
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_my, container, false);
|
|
|
|
|
initClick(view);
|
|
|
|
|
text_nickname = view.findViewById(R.id.nickname);
|
|
|
|
|
getUser();
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getUser() {
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try{
|
|
|
|
|
String url = LoginActivity.SERVER_URL+"/my-servlet?action=getUser&username="+ BaseActivity.owner.getUsername();
|
|
|
|
|
OkHttpUtil.asyGet(url, new Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Call call, IOException e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onResponse(Call call, Response response) throws IOException {
|
|
|
|
|
String jsonStr = response.body().string();
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
user = gson.fromJson(jsonStr, User.class);
|
|
|
|
|
getActivity().runOnUiThread(new Runnable(){
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
text_nickname.setText(user.getUsername());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initClick(View view) {
|
|
|
|
|
//关注的问题,提醒和大事记的线性布局
|
|
|
|
|
LinearLayout remindLinear = view.findViewById(R.id.my_remind_linear);
|
|
|
|
|