|
@@ -2,15 +2,22 @@ package org.telegram.cricdit.ui;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.text.TextUtils;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewConfiguration;
|
|
import android.view.ViewConfiguration;
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
|
|
+
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
+
|
|
|
|
+import com.lxj.xpopup.XPopup;
|
|
|
|
+import com.lxj.xpopup.interfaces.OnSelectListener;
|
|
|
|
+import com.lxj.xpopup.util.XPopupUtils;
|
|
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
|
|
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
|
|
import com.scwang.smart.refresh.layout.api.RefreshLayout;
|
|
import com.scwang.smart.refresh.layout.api.RefreshLayout;
|
|
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
|
|
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
|
|
|
|
+
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
import org.telegram.cricdit.adapter.NewsAdapter;
|
|
import org.telegram.cricdit.adapter.NewsAdapter;
|
|
@@ -18,15 +25,24 @@ import org.telegram.cricdit.bean.BaseViewFragment;
|
|
import org.telegram.cricdit.bean.NewsBean;
|
|
import org.telegram.cricdit.bean.NewsBean;
|
|
import org.telegram.cricdit.bean.NewsItemEvent;
|
|
import org.telegram.cricdit.bean.NewsItemEvent;
|
|
import org.telegram.cricdit.bean.NewsMsgEvent;
|
|
import org.telegram.cricdit.bean.NewsMsgEvent;
|
|
|
|
+import org.telegram.cricdit.bean.ShieldIdListBean;
|
|
import org.telegram.cricdit.mvp.NewsPresenter;
|
|
import org.telegram.cricdit.mvp.NewsPresenter;
|
|
import org.telegram.cricdit.mvp.NewsView;
|
|
import org.telegram.cricdit.mvp.NewsView;
|
|
import org.telegram.cricdit.utils.ACache;
|
|
import org.telegram.cricdit.utils.ACache;
|
|
import org.telegram.cricdit.utils.ColorUtil;
|
|
import org.telegram.cricdit.utils.ColorUtil;
|
|
import org.telegram.cricdit.utils.EventBusHelper;
|
|
import org.telegram.cricdit.utils.EventBusHelper;
|
|
|
|
+import org.telegram.cricdit.utils.GsonHel;
|
|
|
|
+import org.telegram.cricdit.utils.SPUtils;
|
|
|
|
+import org.telegram.cricdit.view.popup.ChooeseBottomPopup;
|
|
|
|
+import org.telegram.cricdit.view.popup.ReportBottomPopup;
|
|
import org.telegram.messenger.R;
|
|
import org.telegram.messenger.R;
|
|
import org.telegram.messenger.UserConfig;
|
|
import org.telegram.messenger.UserConfig;
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
|
|
+import org.telegram.ui.Components.AlertsCreator;
|
|
|
|
+
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class NewsFragment implements BaseViewFragment, NewsView {
|
|
public class NewsFragment implements BaseViewFragment, NewsView {
|
|
public View view;
|
|
public View view;
|
|
@@ -65,10 +81,29 @@ public class NewsFragment implements BaseViewFragment, NewsView {
|
|
smartRefreshlayout.setVisibility(View.VISIBLE);
|
|
smartRefreshlayout.setVisibility(View.VISIBLE);
|
|
smartRefreshlayout.finishRefresh();
|
|
smartRefreshlayout.finishRefresh();
|
|
smartRefreshlayout.finishLoadMore();
|
|
smartRefreshlayout.finishLoadMore();
|
|
|
|
+
|
|
|
|
+ List<NewsBean.NewsFeedBean> list = mList.getList();
|
|
|
|
+
|
|
|
|
+ String shieldIds = SPUtils.getInstance().get("shield_ids", "");
|
|
|
|
+ if (!TextUtils.isEmpty(shieldIds)) {
|
|
|
|
+ ShieldIdListBean shieldIdListBean = GsonHel.fromJson(shieldIds,ShieldIdListBean.class);
|
|
|
|
+ if (shieldIdListBean.shieldIdsList.size()>0) {
|
|
|
|
+ for (String userID : shieldIdListBean.shieldIdsList) {
|
|
|
|
+ Iterator<NewsBean.NewsFeedBean> iterator =list.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ NewsBean.NewsFeedBean next = iterator.next();
|
|
|
|
+ if ((next.getUserId()).equals(userID)) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (offset == 0) {
|
|
if (offset == 0) {
|
|
- adapter.setData(mList.getList());
|
|
|
|
|
|
+ adapter.setData(list);
|
|
} else {
|
|
} else {
|
|
- adapter.addData(mList.getList());
|
|
|
|
|
|
+ adapter.addData(list);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -146,6 +181,30 @@ public class NewsFragment implements BaseViewFragment, NewsView {
|
|
NewsDetailCommentFragment.newsBean = bean;
|
|
NewsDetailCommentFragment.newsBean = bean;
|
|
mFragment.presentFragment(new NewsDetailCommentFragment(new Bundle()));
|
|
mFragment.presentFragment(new NewsDetailCommentFragment(new Bundle()));
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ adapter.setOnReportClickListener((id, username) -> new XPopup.Builder(mFragment.getContext())
|
|
|
|
+ .moveUpToKeyboard(false) //如果不加这个,评论弹窗会移动到软键盘上面
|
|
|
|
+ .enableDrag(true)
|
|
|
|
+ .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
|
|
|
+ .asCustom(new ChooeseBottomPopup(mFragment.getContext(), id, username, userID -> {
|
|
|
|
+ String shieldIds = SPUtils.getInstance().get("shield_ids", "");
|
|
|
|
+ if (TextUtils.isEmpty(shieldIds)) {
|
|
|
|
+ ShieldIdListBean shieldIdListBean = new ShieldIdListBean();
|
|
|
|
+ shieldIdListBean.shieldIdsList = new ArrayList<>();
|
|
|
|
+ shieldIdListBean.shieldIdsList.add(userID);
|
|
|
|
+ SPUtils.getInstance().save("shield_ids", GsonHel.toJson(shieldIdListBean));
|
|
|
|
+ shieldData(userID);
|
|
|
|
+ } else {
|
|
|
|
+ ShieldIdListBean shieldIdListBean = GsonHel.fromJson(shieldIds, ShieldIdListBean.class);
|
|
|
|
+ if (shieldIdListBean != null && shieldIdListBean.shieldIdsList != null && !shieldIdListBean.shieldIdsList.contains(userID)) {
|
|
|
|
+ shieldIdListBean.shieldIdsList.add(userID);
|
|
|
|
+ SPUtils.getInstance().save("shield_ids", GsonHel.toJson(shieldIdListBean));
|
|
|
|
+ shieldData(userID);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }))
|
|
|
|
+ .show());
|
|
|
|
+
|
|
mRecyclerView.setAdapter(adapter);
|
|
mRecyclerView.setAdapter(adapter);
|
|
|
|
|
|
smartRefreshlayout.setOnRefreshListener(refreshLayout -> {
|
|
smartRefreshlayout.setOnRefreshListener(refreshLayout -> {
|
|
@@ -171,11 +230,11 @@ public class NewsFragment implements BaseViewFragment, NewsView {
|
|
@Override
|
|
@Override
|
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
super.onScrolled(recyclerView, dx, dy);
|
|
super.onScrolled(recyclerView, dx, dy);
|
|
- if(distance < -ViewConfiguration.getTouchSlop() && !topVisible){
|
|
|
|
|
|
+ if (distance < -ViewConfiguration.getTouchSlop() && !topVisible) {
|
|
ivBackTop.setVisibility(View.VISIBLE);
|
|
ivBackTop.setVisibility(View.VISIBLE);
|
|
distance = 0;
|
|
distance = 0;
|
|
topVisible = true;
|
|
topVisible = true;
|
|
- }else if(distance > ViewConfiguration.getTouchSlop() && topVisible){
|
|
|
|
|
|
+ } else if (distance > ViewConfiguration.getTouchSlop() && topVisible) {
|
|
ivBackTop.setVisibility(View.GONE);
|
|
ivBackTop.setVisibility(View.GONE);
|
|
distance = 0;
|
|
distance = 0;
|
|
topVisible = false;
|
|
topVisible = false;
|
|
@@ -195,6 +254,19 @@ public class NewsFragment implements BaseViewFragment, NewsView {
|
|
initData();
|
|
initData();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private List<NewsBean.NewsFeedBean> shieldData(String userID) {
|
|
|
|
+ List<NewsBean.NewsFeedBean> data = adapter.getData();
|
|
|
|
+ Iterator<NewsBean.NewsFeedBean> iterator = data.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ NewsBean.NewsFeedBean next = iterator.next();
|
|
|
|
+ if ((next.getUserId() + "").equals(userID)) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public View getView() {
|
|
public View getView() {
|
|
return view;
|
|
return view;
|