Commit 1916076d by ydl

首页文章冥想动态剔除完成

parent 7d0db4f6
...@@ -40,6 +40,7 @@ import com.ydl.webview.H5Params; ...@@ -40,6 +40,7 @@ import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity; import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback; import com.ydl.ydlcommon.actions.imagepicker.PickerCallback;
import com.ydl.ydlcommon.adapter.custom.PublishImageAdapter;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.base.BaseApp; import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.BaseFragment; import com.ydl.ydlcommon.base.BaseFragment;
...@@ -49,22 +50,21 @@ import com.ydl.ydlcommon.utils.BuryPointUtils; ...@@ -49,22 +50,21 @@ import com.ydl.ydlcommon.utils.BuryPointUtils;
import com.ydl.ydlcommon.utils.MoonUtil; import com.ydl.ydlcommon.utils.MoonUtil;
import com.ydl.ydlcommon.utils.SharedPreferencesEditor; import com.ydl.ydlcommon.utils.SharedPreferencesEditor;
import com.ydl.ydlcommon.utils.StringUtils; import com.ydl.ydlcommon.utils.StringUtils;
import com.ydl.ydlcommon.view.banner.GlideImageDisplayLoader;
import com.ydl.ydlcommon.view.dialog.CommonDialog; import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.ydl.ydlcommon.view.dialog.NormalDialog; import com.ydl.ydlcommon.view.dialog.NormalDialog;
import com.yidianling.common.tools.LogUtil; import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.RxFileTool; import com.yidianling.common.tools.RxFileTool;
import com.yidianling.dynamic.DynamicConstants; import com.yidianling.dynamic.bean.DynamicConstants;
import com.yidianling.dynamic.R; import com.yidianling.dynamic.R;
import com.yidianling.dynamic.adapter.PublishTrendImgAdapter;
import com.yidianling.dynamic.common.browsePictures.BrowsePicturesActivity; import com.yidianling.dynamic.common.browsePictures.BrowsePicturesActivity;
import com.yidianling.dynamic.common.emoji.EmoticonPickerView; import com.yidianling.dynamic.common.emoji.EmoticonPickerView;
import com.yidianling.dynamic.common.emoji.IEmoticonSelectedListener; import com.yidianling.dynamic.common.emoji.IEmoticonSelectedListener;
import com.yidianling.dynamic.common.net.DynamicApiUtils; import com.yidianling.dynamic.common.net.DynamicApiUtils;
import com.yidianling.dynamic.common.tool.GlideImageLoader;
import com.yidianling.dynamic.common.tool.ImageCompress; import com.yidianling.dynamic.common.tool.ImageCompress;
import com.yidianling.dynamic.model.Command; import com.yidianling.dynamic.model.Command;
import com.yidianling.dynamic.model.PublishTrendResult; import com.yidianling.dynamic.model.PublishTrendResult;
import com.yidianling.dynamic.model.RecommendTrendImage; import com.ydl.ydlcommon.ui.ParcelableImage;
import com.yidianling.dynamic.publishTrend.PublishTrendActivity; import com.yidianling.dynamic.publishTrend.PublishTrendActivity;
import com.yidianling.dynamic.publishTrend.SelecTopicActivity; import com.yidianling.dynamic.publishTrend.SelecTopicActivity;
import com.yidianling.dynamic.router.DynamicIn; import com.yidianling.dynamic.router.DynamicIn;
...@@ -125,8 +125,8 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -125,8 +125,8 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
private String head_dir;//目录 private String head_dir;//目录
private String head_path;//路径 private String head_path;//路径
File head_filec; File head_filec;
private List<RecommendTrendImage> publishTrendImgs, publishTrendImgBrows; private List<ParcelableImage> publishTrendImgs, publishTrendImgBrows;
private PublishTrendImgAdapter adapter; private PublishImageAdapter adapter;
String topic_id; String topic_id;
String topic_title; String topic_title;
...@@ -198,7 +198,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -198,7 +198,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
public void initDataAndEventLazy() { public void initDataAndEventLazy() {
rxPermissions = new RxPermissions(getActivity()); rxPermissions = new RxPermissions(getActivity());
ImagePicker imagePicker = ImagePicker.getInstance(); ImagePicker imagePicker = ImagePicker.getInstance();
imagePicker.setImageLoader(new GlideImageLoader()); //设置图片加载器 imagePicker.setImageLoader(new GlideImageDisplayLoader()); //设置图片加载器
imagePicker.setShowCamera(true); //显示拍照按钮 imagePicker.setShowCamera(true); //显示拍照按钮
imagePicker.setCrop(true); //允许裁剪(单选才有效) imagePicker.setCrop(true); //允许裁剪(单选才有效)
imagePicker.setSaveRectangle(true); //是否按矩形区域保存 imagePicker.setSaveRectangle(true); //是否按矩形区域保存
...@@ -259,16 +259,16 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -259,16 +259,16 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
head_dir = RxFileTool.getStorageDirectory(activity) + "/img/publish_img/"; head_dir = RxFileTool.getStorageDirectory(activity) + "/img/publish_img/";
if (adapter == null) { if (adapter == null) {
adapter = new PublishTrendImgAdapter(publishTrendImgs, activity); adapter = new PublishImageAdapter(publishTrendImgs, activity);
} else { } else {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
publish_trend_img_rcv.setLayoutManager(new GridLayoutManager(activity, 4)); publish_trend_img_rcv.setLayoutManager(new GridLayoutManager(activity, 4));
publish_trend_img_rcv.setAdapter(adapter); publish_trend_img_rcv.setAdapter(adapter);
adapter.setOnItemClickLister(new PublishTrendImgAdapter.OnItemClickLister() { adapter.setOnItemClickLister(new PublishImageAdapter.OnItemClickLister() {
@Override @Override
public void onItemClick(View view, int position) { public void onItemClick(View view, int position) {
publishTrendImgBrows = new ArrayList<RecommendTrendImage>(); publishTrendImgBrows = new ArrayList<ParcelableImage>();
publishTrendImgBrows.clear(); publishTrendImgBrows.clear();
publishTrendImgBrows.addAll(publishTrendImgs); publishTrendImgBrows.addAll(publishTrendImgs);
if (publishTrendImgBrows.size() < 9) { if (publishTrendImgBrows.size() < 9) {
...@@ -304,7 +304,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -304,7 +304,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
} }
}); });
adapter.setOnDeleteClickLister(new PublishTrendImgAdapter.OnDeleteClickLister() { adapter.setOnDeleteClickLister(new PublishImageAdapter.OnDeleteClickLister() {
@Override @Override
public void onDeleteClick(View view, int position) { public void onDeleteClick(View view, int position) {
DeleteImg(position); DeleteImg(position);
...@@ -315,7 +315,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -315,7 +315,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
} }
}); });
adapter.setOnAddClickLister(new PublishTrendImgAdapter.OnAddClickLister() { adapter.setOnAddClickLister(new PublishImageAdapter.OnAddClickLister() {
@Override @Override
public void OnAddClick(View view, int position) { public void OnAddClick(View view, int position) {
if (publishTrendImgs.size() < 9) { if (publishTrendImgs.size() < 9) {
...@@ -517,7 +517,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -517,7 +517,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
if (!"".equals(Test_url) && Test_url != null && !"".equals(Test_cover) && Test_cover != null && !"".equals(Test_title) && Test_title != null) { if (!"".equals(Test_url) && Test_url != null && !"".equals(Test_cover) && Test_cover != null && !"".equals(Test_title) && Test_title != null) {
PublishO(is_niming, topic_id, content, trend_title, null); PublishO(is_niming, topic_id, content, trend_title, null);
} else { } else {
List<RecommendTrendImage> publishImgs = new ArrayList<RecommendTrendImage>(); List<ParcelableImage> publishImgs = new ArrayList<ParcelableImage>();
publishImgs.addAll(publishTrendImgs); publishImgs.addAll(publishTrendImgs);
if (publishTrendImgs.size() < 9 && publishTrendImgs.size() > 1) { if (publishTrendImgs.size() < 9 && publishTrendImgs.size() > 1) {
publishImgs.remove(publishImgs.size() - 1); publishImgs.remove(publishImgs.size() - 1);
...@@ -651,13 +651,13 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -651,13 +651,13 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
* @param publishTrendImgs 图片附件 * @param publishTrendImgs 图片附件
*/ */
@SuppressLint("WrongConstant") @SuppressLint("WrongConstant")
private void DealFile(final int is_niming, final String topic_id, final String content, final String trend_title, final List<RecommendTrendImage> publishTrendImgs) { private void DealFile(final int is_niming, final String topic_id, final String content, final String trend_title, final List<ParcelableImage> publishTrendImgs) {
imgFiles = new ArrayList<File>(); imgFiles = new ArrayList<File>();
Observable.fromIterable(publishTrendImgs) Observable.fromIterable(publishTrendImgs)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.map(recommendTrendImage -> { .map(parcelableImage -> {
LogUtil.d("url: " + recommendTrendImage.getImage_url()); LogUtil.d("url: " + parcelableImage.getImage_url());
return DealFile2(recommendTrendImage.getImage_url(), 1500 / publishTrendImgs.size()); return DealFile2(parcelableImage.getImage_url(), 1500 / publishTrendImgs.size());
}) })
.subscribe(file -> { .subscribe(file -> {
if (file != null) { if (file != null) {
...@@ -830,7 +830,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -830,7 +830,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
Bundle bundle = data.getBundleExtra("bundle"); Bundle bundle = data.getBundleExtra("bundle");
publishTrendImgs = bundle.getParcelableArrayList("publish_img"); publishTrendImgs = bundle.getParcelableArrayList("publish_img");
if (publishTrendImgs.size() > 0) { if (publishTrendImgs.size() > 0) {
publishTrendImgs.add(new RecommendTrendImage("default")); publishTrendImgs.add(new ParcelableImage("default"));
} }
adapter.updateDate(publishTrendImgs); adapter.updateDate(publishTrendImgs);
} }
...@@ -865,11 +865,11 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -865,11 +865,11 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
* 添加照片 * 添加照片
*/ */
private void AddImag(String pic_path) { private void AddImag(String pic_path) {
RecommendTrendImage trendImage = new RecommendTrendImage(pic_path); ParcelableImage trendImage = new ParcelableImage(pic_path);
if (publishTrendImgs.size() < 9 && publishTrendImgs.size() > 0) { if (publishTrendImgs.size() < 9 && publishTrendImgs.size() > 0) {
publishTrendImgs.add(publishTrendImgs.size() - 1, trendImage); publishTrendImgs.add(publishTrendImgs.size() - 1, trendImage);
} else if (publishTrendImgs.size() == 0) { } else if (publishTrendImgs.size() == 0) {
publishTrendImgs.add(new RecommendTrendImage("default")); publishTrendImgs.add(new ParcelableImage("default"));
publishTrendImgs.add(publishTrendImgs.size() - 1, trendImage); publishTrendImgs.add(publishTrendImgs.size() - 1, trendImage);
} else { } else {
publishTrendImgs.remove(8); publishTrendImgs.remove(8);
...@@ -970,7 +970,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -970,7 +970,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
publishTrendImgs.remove(position); publishTrendImgs.remove(position);
} else { } else {
publishTrendImgs.remove(position); publishTrendImgs.remove(position);
publishTrendImgs.add(8, new RecommendTrendImage("default")); publishTrendImgs.add(8, new ParcelableImage("default"));
} }
} }
......
package com.yidianling.dynamic.adapter; package com.ydl.ydlcommon.adapter.custom;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
...@@ -13,20 +13,16 @@ import android.widget.ImageView; ...@@ -13,20 +13,16 @@ import android.widget.ImageView;
import com.miracle.view.imageeditor.utils.FileUtils; import com.miracle.view.imageeditor.utils.FileUtils;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydl_image.transform.GlideRoundTransform; import com.ydl.ydl_image.transform.GlideRoundTransform;
import com.yidianling.dynamic.R; import com.ydl.ydlcommon.R;
import com.yidianling.dynamic.model.RecommendTrendImage; import com.ydl.ydlcommon.ui.ParcelableImage;
import java.util.List; import java.util.List;
/** public class PublishImageAdapter extends RecyclerView.Adapter<PublishImageViewHolder> {
* Created by xiongyu on 2017/3/17.
*/
public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImgViewHolder> {
private static final String TAG = "RecommendTrendImgAdapte"; private static final String TAG = "RecommendTrendImgAdapte";
protected Context mContext; protected Context mContext;
protected List<RecommendTrendImage> mDatas; protected List<ParcelableImage> mDatas;
protected LayoutInflater mInflater; protected LayoutInflater mInflater;
public interface OnItemClickLister { public interface OnItemClickLister {
...@@ -63,24 +59,24 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -63,24 +59,24 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
this.mOnAddClickLister = lister; this.mOnAddClickLister = lister;
} }
public PublishTrendImgAdapter(List<RecommendTrendImage> mDatas, Context mContext) { public PublishImageAdapter(List<ParcelableImage> mDatas, Context mContext) {
this.mContext = mContext; this.mContext = mContext;
this.mDatas = mDatas; this.mDatas = mDatas;
mInflater = LayoutInflater.from(mContext); mInflater = LayoutInflater.from(mContext);
} }
@Override @Override
public PublishTrendImgViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public PublishImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null; View view = null;
view = mInflater.inflate(R.layout.dynamic_item_publish_trend_img, parent, false); view = mInflater.inflate(R.layout.platform_item_publish_img, parent, false);
PublishTrendImgViewHolder viewHolder = new PublishTrendImgViewHolder(view); PublishImageViewHolder viewHolder = new PublishImageViewHolder(view);
return viewHolder; return viewHolder;
} }
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override @Override
public void onBindViewHolder(PublishTrendImgViewHolder holder, final int position) { public void onBindViewHolder(PublishImageViewHolder holder, final int position) {
RecommendTrendImage trendImage = mDatas.get(position); ParcelableImage trendImage = mDatas.get(position);
String path = trendImage.getImage_url(); String path = trendImage.getImage_url();
if ("default".equals(path)) { if ("default".equals(path)) {
...@@ -94,7 +90,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -94,7 +90,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
Uri uriByPath = FileUtils.INSTANCE.getUriByPath(mContext, path); Uri uriByPath = FileUtils.INSTANCE.getUriByPath(mContext, path);
GlideApp.with(mContext) GlideApp.with(mContext)
.load(uriByPath) .load(uriByPath)
.error(R.drawable.dynamic_default_img) .error(R.drawable.platform_default_img)
.transform(new GlideRoundTransform(mContext, 6)) .transform(new GlideRoundTransform(mContext, 6))
// .centerCrop() // .centerCrop()
.into(holder.item_publish_iv); .into(holder.item_publish_iv);
...@@ -111,7 +107,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -111,7 +107,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
} }
public void updateDate(List<RecommendTrendImage> mDatas) { public void updateDate(List<ParcelableImage> mDatas) {
this.mDatas = mDatas; this.mDatas = mDatas;
notifyDataSetChanged(); notifyDataSetChanged();
} }
...@@ -122,7 +118,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -122,7 +118,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
* @param pos 数据添加的位置 * @param pos 数据添加的位置
* @param trendImage 数据 * @param trendImage 数据
*/ */
public void addData(int pos, RecommendTrendImage trendImage) { public void addData(int pos, ParcelableImage trendImage) {
mDatas.add(trendImage); mDatas.add(trendImage);
notifyItemInserted(pos); notifyItemInserted(pos);
} }
...@@ -142,7 +138,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -142,7 +138,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
* *
* @param holder * @param holder
*/ */
protected void setUpItemEvent(final PublishTrendImgViewHolder holder) { protected void setUpItemEvent(final PublishImageViewHolder holder) {
if (mOnItemClickLister != null) { if (mOnItemClickLister != null) {
holder.item_publish_iv.setOnClickListener(new View.OnClickListener() { holder.item_publish_iv.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -168,7 +164,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -168,7 +164,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
* *
* @param holder * @param holder
*/ */
protected void setUpDeleteEvent(final PublishTrendImgViewHolder holder) { protected void setUpDeleteEvent(final PublishImageViewHolder holder) {
if (mOnItemClickLister != null) { if (mOnItemClickLister != null) {
holder.item_publish_cancel_iv.setOnClickListener(new View.OnClickListener() { holder.item_publish_cancel_iv.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -194,7 +190,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -194,7 +190,7 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
* *
* @param holder * @param holder
*/ */
protected void setUpAddEvent(final PublishTrendImgViewHolder holder) { protected void setUpAddEvent(final PublishImageViewHolder holder) {
if (mOnAddClickLister != null) { if (mOnAddClickLister != null) {
holder.bg_iv.setOnClickListener(new View.OnClickListener() { holder.bg_iv.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -218,10 +214,10 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg ...@@ -218,10 +214,10 @@ public class PublishTrendImgAdapter extends RecyclerView.Adapter<PublishTrendImg
} }
class PublishTrendImgViewHolder extends RecyclerView.ViewHolder { class PublishImageViewHolder extends RecyclerView.ViewHolder {
ImageView item_publish_iv, item_publish_cancel_iv, bg_iv; ImageView item_publish_iv, item_publish_cancel_iv, bg_iv;
public PublishTrendImgViewHolder(View itemView) { public PublishImageViewHolder(View itemView) {
super(itemView); super(itemView);
bg_iv = (ImageView) itemView.findViewById(R.id.item_publish_defult_iv); bg_iv = (ImageView) itemView.findViewById(R.id.item_publish_defult_iv);
item_publish_iv = (ImageView) itemView.findViewById(R.id.item_publish_iv); item_publish_iv = (ImageView) itemView.findViewById(R.id.item_publish_iv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment