You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
package com.community.pocket.ui.main.ui.forum.my;
|
|
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.Toast;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.lifecycle.Observer;
|
|
import androidx.lifecycle.ViewModelProvider;
|
|
|
|
import com.community.pocket.R;
|
|
import com.community.pocket.ui.main.ui.forum.ForumPost;
|
|
|
|
import org.xutils.view.annotation.ContentView;
|
|
|
|
/**
|
|
* 我的帖子
|
|
*/
|
|
@ContentView(R.layout.forum_my_fragment)
|
|
public class ForumMyFragment extends ForumPost {
|
|
|
|
@Override
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
super.onViewCreated(view, savedInstanceState);
|
|
|
|
ForumMyViewModel viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumMyViewModel.class);
|
|
|
|
viewModel.loadForumMy();
|
|
|
|
//监听我的帖子加载状态
|
|
viewModel.getForumMyResponse().observe(getViewLifecycleOwner(), new Observer<ForumMyResponse>() {
|
|
@Override
|
|
public void onChanged(ForumMyResponse forumMyResponse) {
|
|
if (forumMyResponse == null) {
|
|
return;
|
|
}
|
|
|
|
if (forumMyResponse.getSuccess() != null) {
|
|
loadPost(forumMyResponse.getBody());
|
|
}
|
|
|
|
if (forumMyResponse.getError() != null) {
|
|
Toast.makeText(getContext(), forumMyResponse.getError(), Toast.LENGTH_SHORT).show();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
protected int own() {
|
|
return View.GONE;
|
|
}
|
|
}
|
|
|