1
This commit is contained in:
@@ -47,9 +47,11 @@ import com.sl.house_property.databinding.ItemCommentBinding;
|
||||
import com.sl.house_property.databinding.ItemDiscoveryBinding;
|
||||
import com.sl.house_property.db.CommentBeanData;
|
||||
import com.sl.house_property.db.dao.CommentDao;
|
||||
import com.sl.house_property.discovery.DeleteCommentDialog;
|
||||
import com.sl.house_property.discovery.GoodsInfoDialog;
|
||||
import com.sl.house_property.discovery.HistoryRecordActivity;
|
||||
import com.sl.house_property.discovery.HistoryRecordActivitytwo;
|
||||
import com.sl.house_property.discovery.SelectDialog;
|
||||
import com.sl.house_property.okgonet.HttpConstants;
|
||||
import com.sl.house_property.okgonet.Observer;
|
||||
import com.sl.house_property.order.SettleActivity;
|
||||
@@ -886,6 +888,7 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> implements V
|
||||
itemCommentBinding.tvName.setText(dis_content.get(itemPosition).getNickname() + ": ");
|
||||
itemCommentBinding.tvInfo.setText(dis_content.get(itemPosition).getContents());
|
||||
} else {
|
||||
|
||||
itemCommentBinding.ll.setVisibility(View.GONE);
|
||||
itemCommentBinding.llHf.setVisibility(View.VISIBLE);
|
||||
itemCommentBinding.tvName2.setText(dis_content.get(itemPosition).getNickname());
|
||||
@@ -897,29 +900,48 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> implements V
|
||||
itemCommentBinding.llItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final int mBottomY = getCoordinateY(homeGridAdapterItemBinding.ivComment) + homeGridAdapterItemBinding.ivComment.getHeight();
|
||||
|
||||
itemIndex =itemPosition;
|
||||
|
||||
mDataBinding.llComment.setVisibility(View.VISIBLE);
|
||||
mDataBinding.etComment.requestFocus();
|
||||
mDataBinding.etComment.setHint("回复 " + dis_content.get(itemPosition).getNickname());
|
||||
if (getActivity() instanceof MainTabActivity) {
|
||||
MainTabActivity activity = (MainTabActivity) getActivity();
|
||||
activity.visibilyBottom(View.GONE);
|
||||
final RegisterUser registerUser = Config.getInstance(getContext()).getUser();
|
||||
if (registerUser == null) {
|
||||
return;
|
||||
}
|
||||
KeyboardUtil.showSoftInput(getContext());
|
||||
commentPosition = position;
|
||||
// commentDialog.dismiss();
|
||||
mDataBinding.etComment.setText("");
|
||||
homeGridAdapterItemBinding.ivComment.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int y = getCoordinateY(mDataBinding.llComment) - 20;
|
||||
//评论时滑动到对应item底部和输入框顶部对齐
|
||||
mDataBinding.scrollViewExtend.smoothScrollBy(0, mBottomY - y);
|
||||
|
||||
final int mBottomY = getCoordinateY(homeGridAdapterItemBinding.ivComment) + homeGridAdapterItemBinding.ivComment.getHeight();
|
||||
if (dis_content.get(itemPosition).getFrom_id()==null
|
||||
||registerUser.getUserid().equals(dis_content.get(itemPosition).getFrom_id())){
|
||||
mDataBinding.llComment.setVisibility(View.GONE);
|
||||
DeleteCommentDialog deleteCommentDialog = new DeleteCommentDialog(getContext());
|
||||
deleteCommentDialog.setOnSelectListener(new SelectDialog.OnSelectListener() {
|
||||
@Override
|
||||
public void select(int type) {
|
||||
deleteComment(dis_content.get(itemPosition).getDis_id(),registerUser.getUserid(),position,itemPosition);
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(getContext()).asCustom(deleteCommentDialog).show();
|
||||
}else {
|
||||
itemIndex =itemPosition;
|
||||
|
||||
mDataBinding.llComment.setVisibility(View.VISIBLE);
|
||||
mDataBinding.etComment.requestFocus();
|
||||
mDataBinding.etComment.setHint("回复 " + dis_content.get(itemPosition).getNickname());
|
||||
if (getActivity() instanceof MainTabActivity) {
|
||||
MainTabActivity activity = (MainTabActivity) getActivity();
|
||||
activity.visibilyBottom(View.GONE);
|
||||
}
|
||||
}, 300);
|
||||
KeyboardUtil.showSoftInput(getContext());
|
||||
commentPosition = position;
|
||||
// commentDialog.dismiss();
|
||||
mDataBinding.etComment.setText("");
|
||||
homeGridAdapterItemBinding.ivComment.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int y = getCoordinateY(mDataBinding.llComment) - 20;
|
||||
//评论时滑动到对应item底部和输入框顶部对齐
|
||||
mDataBinding.scrollViewExtend.smoothScrollBy(0, mBottomY - y);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1574,4 +1596,36 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> implements V
|
||||
});
|
||||
|
||||
}
|
||||
private void deleteComment(String dis_id, String userid, final int superPosition, final int itemPosition) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
progressDialog.show();
|
||||
map.put("app", "Goods");
|
||||
|
||||
map.put("class", "DelDis");
|
||||
map.put("sign", Md5.md5("Goods" + "DelDis" + Md5.secret));
|
||||
map.put("dis_id", dis_id);
|
||||
map.put("userid", userid);
|
||||
mGankLoader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
progressDialog.dismiss();
|
||||
if (!(resultcode.status == 0)) {
|
||||
Toast.makeText(getContext(), resultcode.msg, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
BaseRecycleViewAdapter adapter = (BaseRecycleViewAdapter) mDataBinding.recyView.getAdapter();
|
||||
DiscoveryListEntity discoveryListEntity = discoveryListEntities.get(superPosition);
|
||||
ArrayList<DiscoveryListEntity.Dis_content> dis_content1 = discoveryListEntity.getDis_content();
|
||||
dis_content1.remove(itemPosition);
|
||||
discoveryListEntity.setDis_content(dis_content1);
|
||||
adapter.upDateOne(superPosition, discoveryListEntity);
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
Toast.makeText(getContext(), getString(R.string.getdatafailure), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
@@ -452,13 +453,13 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
homeGridAdapterItemBinding.tvLike.setVisibility(View.VISIBLE);
|
||||
StringBuilder likeString = new StringBuilder();
|
||||
for (int i = 0; i < discoveryListEntity.getLike().size(); i++) {
|
||||
// if (i != 0 && i != discoveryListEntity.getLike().size() - 1) {
|
||||
// likeString.append(",");
|
||||
// }
|
||||
// if (i != 0 && i != discoveryListEntity.getLike().size() - 1) {
|
||||
// likeString.append(",");
|
||||
// }
|
||||
|
||||
if (i != 0) {
|
||||
likeString.append(",");
|
||||
}
|
||||
if (i != 0) {
|
||||
likeString.append(",");
|
||||
}
|
||||
likeString.append(discoveryListEntity.getLike().get(i).getNickname());
|
||||
|
||||
}
|
||||
@@ -512,29 +513,48 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
itemCommentBinding.llItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final RegisterUser registerUser = Config.getInstance(getContext()).getUser();
|
||||
if (registerUser == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int mBottomY = getCoordinateY(homeGridAdapterItemBinding.ivComment) + homeGridAdapterItemBinding.ivComment.getHeight();
|
||||
|
||||
itemIndex =itemPosition;
|
||||
if (dis_content.get(itemPosition).getFrom_id() == null
|
||||
|| registerUser.getUserid().equals(dis_content.get(itemPosition).getFrom_id())) {
|
||||
mDataBinding.llComment.setVisibility(View.GONE);
|
||||
DeleteCommentDialog deleteCommentDialog = new DeleteCommentDialog(getContext());
|
||||
deleteCommentDialog.setOnSelectListener(new SelectDialog.OnSelectListener() {
|
||||
@Override
|
||||
public void select(int type) {
|
||||
deleteComment(dis_content.get(itemPosition).getDis_id(), registerUser.getUserid(), position, itemPosition);
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(getContext()).asCustom(deleteCommentDialog).show();
|
||||
} else {
|
||||
itemIndex = itemPosition;
|
||||
|
||||
mDataBinding.llComment.setVisibility(View.VISIBLE);
|
||||
mDataBinding.etComment.requestFocus();
|
||||
mDataBinding.etComment.setHint("回复 " + dis_content.get(itemPosition).getNickname());
|
||||
if (getActivity() instanceof MainTabActivity) {
|
||||
MainTabActivity activity = (MainTabActivity) getActivity();
|
||||
activity.visibilyBottom(View.GONE);
|
||||
}
|
||||
KeyboardUtil.showSoftInput(getContext());
|
||||
commentPosition = position;
|
||||
// commentDialog.dismiss();
|
||||
mDataBinding.etComment.setText("");
|
||||
homeGridAdapterItemBinding.ivComment.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int y = getCoordinateY(mDataBinding.llComment) - 20;
|
||||
//评论时滑动到对应item底部和输入框顶部对齐
|
||||
mDataBinding.sv.smoothScrollBy(0, mBottomY - y);
|
||||
mDataBinding.llComment.setVisibility(View.VISIBLE);
|
||||
mDataBinding.etComment.requestFocus();
|
||||
mDataBinding.etComment.setHint("回复 " + dis_content.get(itemPosition).getNickname());
|
||||
if (getActivity() instanceof MainTabActivity) {
|
||||
MainTabActivity activity = (MainTabActivity) getActivity();
|
||||
activity.visibilyBottom(View.GONE);
|
||||
}
|
||||
}, 300);
|
||||
KeyboardUtil.showSoftInput(getContext());
|
||||
commentPosition = position;
|
||||
// commentDialog.dismiss();
|
||||
mDataBinding.etComment.setText("");
|
||||
homeGridAdapterItemBinding.ivComment.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int y = getCoordinateY(mDataBinding.llComment) - 20;
|
||||
//评论时滑动到对应item底部和输入框顶部对齐
|
||||
mDataBinding.sv.smoothScrollBy(0, mBottomY - y);
|
||||
}
|
||||
}, 300);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -640,25 +660,25 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
if (resultcode.status == 0) {
|
||||
// intRecycleView();
|
||||
Gson gs = new Gson();
|
||||
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||
String s = gs.toJson(adta);
|
||||
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||
String s = gs.toJson(adta);
|
||||
|
||||
// String s = new GetJsonDataUtil().getJson(getActivity(), "controlStatus.json");//获取assets目录下的json文件数据
|
||||
// String s = new GetJsonDataUtil().getJson(getActivity(), "controlStatus.json");//获取assets目录下的json文件数据
|
||||
try {
|
||||
DiscoverEntity discoverEntity = gs.fromJson(s, DiscoverEntity.class);
|
||||
// JSONObject jsonObject = new JSONObject(s);
|
||||
// org.json.JSONArray array = jsonObject.getJSONArray("info");
|
||||
// Type type = new TypeToken<ArrayList<DiscoveryListEntity>>() {
|
||||
// }.getType();
|
||||
// JSONObject jsonObject = new JSONObject(s);
|
||||
// org.json.JSONArray array = jsonObject.getJSONArray("info");
|
||||
// Type type = new TypeToken<ArrayList<DiscoveryListEntity>>() {
|
||||
// }.getType();
|
||||
if (page == 1) {
|
||||
String fengmian = discoverEntity.getFengmian();
|
||||
String avatar = discoverEntity.getAvatar();
|
||||
if (!TextUtils.isEmpty(fengmian)){
|
||||
if (!TextUtils.isEmpty(fengmian)) {
|
||||
Picasso.with(getActivity()).load(fengmian)
|
||||
.placeholder(R.mipmap.icon_default_rectangle)
|
||||
.into(target);
|
||||
}
|
||||
if (!TextUtils.isEmpty(avatar)){
|
||||
if (!TextUtils.isEmpty(avatar)) {
|
||||
Picasso.with(getActivity()).load(avatar)
|
||||
.placeholder(R.mipmap.icon_default_rectangle)
|
||||
.transform(new PicassoRoundTransform())
|
||||
@@ -672,7 +692,7 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
baseRecycleViewAdapter.setData(discoveryListEntities);
|
||||
page++;
|
||||
} else {
|
||||
// ArrayList<DiscoveryListEntity> o = new Gson().fromJson(array.toString(), type);
|
||||
// ArrayList<DiscoveryListEntity> o = new Gson().fromJson(array.toString(), type);
|
||||
List<DiscoveryListEntity> info = discoverEntity.getInfo();
|
||||
discoveryListEntities.addAll(info);
|
||||
|
||||
@@ -841,8 +861,10 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
});
|
||||
baseActivity.addSubscription(subscription);
|
||||
}
|
||||
|
||||
private int itemIndex = -1;
|
||||
private void comment(String goodsId, final int position, final int itemIndex, final String content) {
|
||||
|
||||
private void comment(String goodsId, final int position, final int itemIndex, final String content) {
|
||||
final RegisterUser user =
|
||||
Config.getInstance(getContext()).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
@@ -855,7 +877,7 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
map.put("app", "Goods");
|
||||
map.put("class", "DisGoods");
|
||||
map.put("goods_id", goodsId);
|
||||
if (itemIndex!=-1){
|
||||
if (itemIndex != -1) {
|
||||
DiscoveryListEntity discoveryListEntity = discoveryListEntities.get(position);
|
||||
ArrayList<DiscoveryListEntity.Dis_content> dis_content1 = discoveryListEntity.getDis_content();
|
||||
String from_id = dis_content1.get(itemIndex).getFrom_id();
|
||||
@@ -890,7 +912,7 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
|
||||
DiscoveryListEntity discoveryListEntity = discoveryListEntities.get(position);
|
||||
ArrayList<DiscoveryListEntity.Dis_content> dis_content1 = discoveryListEntity.getDis_content();
|
||||
if (itemIndex!=-1){
|
||||
if (itemIndex != -1) {
|
||||
dis_content.setReply(dis_content1.get(itemIndex).getNickname());
|
||||
}
|
||||
dis_content1.add(dis_content);
|
||||
@@ -944,4 +966,36 @@ public class DiscoveryFragment extends BaseFragment<FragmentDiscoveryBinding> im
|
||||
}
|
||||
|
||||
}
|
||||
private void deleteComment(String dis_id, String userid, final int superPosition, final int itemPosition) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
progressDialog.show();
|
||||
map.put("app", "Goods");
|
||||
|
||||
map.put("class", "DelDis");
|
||||
map.put("sign", Md5.md5("Goods" + "DelDis" + Md5.secret));
|
||||
map.put("dis_id", dis_id);
|
||||
map.put("userid", userid);
|
||||
mGankLoader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
progressDialog.dismiss();
|
||||
if (!(resultcode.status == 0)) {
|
||||
Toast.makeText(getContext(), resultcode.msg, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
BaseRecycleViewAdapter adapter = (BaseRecycleViewAdapter) mDataBinding.recyView.getAdapter();
|
||||
DiscoveryListEntity discoveryListEntity = discoveryListEntities.get(superPosition);
|
||||
ArrayList<DiscoveryListEntity.Dis_content> dis_content1 = discoveryListEntity.getDis_content();
|
||||
dis_content1.remove(itemPosition);
|
||||
discoveryListEntity.setDis_content(dis_content1);
|
||||
adapter.upDateOne(superPosition, discoveryListEntity);
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
Toast.makeText(getContext(), getString(R.string.getdatafailure), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,15 +316,20 @@ public class HistoryRecordFragment extends BaseFragment<FragmentHistoryRecordBin
|
||||
itemCommentBinding.llItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final RegisterUser registerUser = Config.getInstance(getContext()).getUser();
|
||||
if (registerUser == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int mBottomY = getCoordinateY(homeGridAdapterItemBinding.ivComment) + homeGridAdapterItemBinding.ivComment.getHeight();
|
||||
if (dis_content.get(itemPosition).getFrom_id()==null
|
||||
||userId.equals(dis_content.get(itemPosition).getFrom_id())){
|
||||
||registerUser.getUserid().equals(dis_content.get(itemPosition).getFrom_id())){
|
||||
mDataBinding.llComment.setVisibility(View.GONE);
|
||||
DeleteCommentDialog deleteCommentDialog = new DeleteCommentDialog(getContext());
|
||||
deleteCommentDialog.setOnSelectListener(new SelectDialog.OnSelectListener() {
|
||||
@Override
|
||||
public void select(int type) {
|
||||
deleteComment(dis_content.get(itemPosition).getDis_id(),userId,position,itemPosition);
|
||||
deleteComment(dis_content.get(itemPosition).getDis_id(),registerUser.getUserid(),position,itemPosition);
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(getContext()).asCustom(deleteCommentDialog).show();
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@null"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
@@ -45,7 +43,6 @@
|
||||
android:layout_marginTop="15dp"
|
||||
android:background="@drawable/selector_bottom_dialog_btn"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="取消"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="16sp" />
|
||||
|
||||
Reference in New Issue
Block a user