|
|
@ -6,6 +6,7 @@ import android.view.View; |
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
|
|
|
import androidx.appcompat.widget.SearchView; |
|
|
|
import androidx.lifecycle.Observer; |
|
|
|
import androidx.lifecycle.Observer; |
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
|
|
|
|
|
|
|
@ -14,6 +15,7 @@ import com.community.pocket.ui.main.ui.forum.ForumPost; |
|
|
|
import com.community.pocket.ui.main.ui.share.Response; |
|
|
|
import com.community.pocket.ui.main.ui.share.Response; |
|
|
|
|
|
|
|
|
|
|
|
import org.xutils.view.annotation.ContentView; |
|
|
|
import org.xutils.view.annotation.ContentView; |
|
|
|
|
|
|
|
import org.xutils.view.annotation.ViewInject; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 我的帖子 |
|
|
|
* 我的帖子 |
|
|
@ -23,13 +25,34 @@ public class ForumMyFragment extends ForumPost { |
|
|
|
|
|
|
|
|
|
|
|
private ForumMyViewModel viewModel; |
|
|
|
private ForumMyViewModel viewModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ViewInject(R.id.search) |
|
|
|
|
|
|
|
private SearchView searchView; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
|
|
|
super.onViewCreated(view, savedInstanceState); |
|
|
|
super.onViewCreated(view, savedInstanceState); |
|
|
|
|
|
|
|
|
|
|
|
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumMyViewModel.class); |
|
|
|
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumMyViewModel.class); |
|
|
|
|
|
|
|
|
|
|
|
viewModel.loadForumMy(1); |
|
|
|
viewModel.loadForumMy(1, ""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean onQueryTextSubmit(String query) { |
|
|
|
|
|
|
|
if (!query.isEmpty()) { |
|
|
|
|
|
|
|
viewModel.loadForumMy(1, searchView.getQuery().toString()); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean onQueryTextChange(String newText) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//监听我的帖子加载状态
|
|
|
|
//监听我的帖子加载状态
|
|
|
|
viewModel.getForumMyResponse().observe(getViewLifecycleOwner(), new Observer<ForumMyResponse>() { |
|
|
|
viewModel.getForumMyResponse().observe(getViewLifecycleOwner(), new Observer<ForumMyResponse>() { |
|
|
@ -62,6 +85,6 @@ public class ForumMyFragment extends ForumPost { |
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
|
|
|
super.onActivityResult(requestCode, resultCode, data); |
|
|
|
super.onActivityResult(requestCode, resultCode, data); |
|
|
|
|
|
|
|
|
|
|
|
viewModel.loadForumMy(1); |
|
|
|
viewModel.loadForumMy(1, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|