Commit ec8fffe0 by 霍志良

feat:图标更换

parent 898fc71b
package com.yidianling.dynamic.publishTrend;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import com.miracle.view.imageeditor.utils.FileUtils;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydl_image.transform.GlideRoundTransform;
import com.ydl.ydlcommon.ui.ParcelableImage;
import com.yidianling.dynamic.R;
import java.util.List;
public class DynamicPublishImageAdapter extends RecyclerView.Adapter<PublishImageViewHolder> {
private static final String TAG = "RecommendTrendImgAdapte";
protected Context mContext;
protected List<ParcelableImage> mDatas;
protected LayoutInflater mInflater;
public interface OnItemClickLister {
void onItemClick(View view, int position);
void onItemLongClick(View view, int position);
}
public interface OnDeleteClickLister {
void onDeleteClick(View view, int position);
void onDeleteLongClick(View view, int position);
}
public interface OnAddClickLister {
void OnAddClick(View view, int position);
void OnAddLongClick(View view, int position);
}
private OnItemClickLister mOnItemClickLister;
private OnDeleteClickLister mOnDeleteClickLister;
private OnAddClickLister mOnAddClickLister;
public void setOnItemClickLister(OnItemClickLister lister) {
this.mOnItemClickLister = lister;
}
public void setOnDeleteClickLister(OnDeleteClickLister lister) {
this.mOnDeleteClickLister = lister;
}
public void setOnAddClickLister(OnAddClickLister lister) {
this.mOnAddClickLister = lister;
}
public DynamicPublishImageAdapter(List<ParcelableImage> mDatas, Context mContext) {
this.mContext = mContext;
this.mDatas = mDatas;
mInflater = LayoutInflater.from(mContext);
}
@Override
public PublishImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
view = mInflater.inflate(R.layout.dynamic_publish_img_item, parent, false);
PublishImageViewHolder viewHolder = new PublishImageViewHolder(view);
return viewHolder;
}
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onBindViewHolder(PublishImageViewHolder holder, final int position) {
ParcelableImage trendImage = mDatas.get(position);
String path = trendImage.getImage_url();
if ("default".equals(path)) {
holder.bg_iv.setVisibility(View.VISIBLE);
holder.item_publish_iv.setVisibility(View.GONE);
holder.item_publish_cancel_iv.setVisibility(View.GONE);
} else {
holder.item_publish_cancel_iv.setVisibility(View.VISIBLE);
holder.bg_iv.setVisibility(View.GONE);
holder.item_publish_iv.setVisibility(View.VISIBLE);
Uri uriByPath = FileUtils.INSTANCE.getUriByPath(mContext, path);
GlideApp.with(mContext)
.load(uriByPath)
.error(R.drawable.dynamic_add_temp)
.transform(new GlideRoundTransform(mContext, 6))
// .centerCrop()
.into(holder.item_publish_iv);
}
setUpItemEvent(holder);
setUpDeleteEvent(holder);
setUpAddEvent(holder);
}
@Override
public int getItemCount() {
return mDatas.size();
}
public void updateDate(List<ParcelableImage> mDatas) {
this.mDatas = mDatas;
notifyDataSetChanged();
}
/**
* 添加据到指定位置
*
* @param pos 数据添加的位置
* @param trendImage 数据
*/
public void addData(int pos, ParcelableImage trendImage) {
mDatas.add(trendImage);
notifyItemInserted(pos);
}
/**
* 删除指定位置数据
*
* @param pos
*/
public void deleteData(int pos) {
mDatas.remove(pos);
notifyItemRemoved(pos);
}
/**
* 给item添加监听
*
* @param holder
*/
protected void setUpItemEvent(final PublishImageViewHolder holder) {
if (mOnItemClickLister != null) {
holder.item_publish_iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int layoutPosition = holder.getLayoutPosition();
mOnItemClickLister.onItemClick(holder.item_publish_iv, layoutPosition);
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
int layoutPosition = holder.getLayoutPosition();
mOnItemClickLister.onItemLongClick(holder.item_publish_iv, layoutPosition);
return false;
}
});
}
}
/**
* 添加监听
*
* @param holder
*/
protected void setUpDeleteEvent(final PublishImageViewHolder holder) {
if (mOnItemClickLister != null) {
holder.item_publish_cancel_iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int layoutPosition = holder.getLayoutPosition();
mOnDeleteClickLister.onDeleteClick(holder.item_publish_cancel_iv, layoutPosition);
}
});
holder.item_publish_cancel_iv.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
int layoutPosition = holder.getLayoutPosition();
mOnDeleteClickLister.onDeleteLongClick(holder.item_publish_cancel_iv, layoutPosition);
return false;
}
});
}
}
/**
* 添加监听
*
* @param holder
*/
protected void setUpAddEvent(final PublishImageViewHolder holder) {
if (mOnAddClickLister != null) {
holder.bg_iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int layoutPosition = holder.getLayoutPosition();
mOnAddClickLister.OnAddClick(holder.bg_iv, layoutPosition);
}
});
holder.bg_iv.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
int layoutPosition = holder.getLayoutPosition();
mOnAddClickLister.OnAddLongClick(holder.bg_iv, layoutPosition);
return false;
}
});
}
}
}
class PublishImageViewHolder extends RecyclerView.ViewHolder {
ImageView item_publish_iv, item_publish_cancel_iv, bg_iv;
public PublishImageViewHolder(View itemView) {
super(itemView);
bg_iv = (ImageView) itemView.findViewById(R.id.item_publish_defult_iv);
item_publish_iv = (ImageView) itemView.findViewById(R.id.item_publish_iv);
item_publish_cancel_iv = (ImageView) itemView.findViewById(R.id.item_publish_cancel_iv);
}
}
\ No newline at end of file
......@@ -49,7 +49,7 @@ public class PublishTrendActivity extends BaseActivity {
private static final String COVER = "Test_cover";
private static final String TITLE = "Test_title";
private static final String ISFROMFM = "isfromfm";
private ImageView mBackIv;
private TextView mBackIv;
private TextView mToastView;
private NoScrollViewPager mViewPager;
private CommonTabLayout mTableLayout;
......@@ -114,7 +114,7 @@ public class PublishTrendActivity extends BaseActivity {
protected void initDataAndEvent() {
SharedPreferencesEditor.putString("trend_state", "");
handler = new Handler();
mBackIv = findViewById(R.id.img_back);
mBackIv = findViewById(R.id.mBackIv);
mPublishTrendTitle= findViewById(R.id.publish_trend_title_rel);
mBackIv.setOnClickListener(v -> {
......
......@@ -70,6 +70,7 @@ import com.yidianling.dynamic.common.tool.ImageCompress;
import com.yidianling.dynamic.model.Command;
import com.yidianling.dynamic.model.PublishTrendResult;
import com.ydl.ydlcommon.ui.ParcelableImage;
import com.yidianling.dynamic.publishTrend.DynamicPublishImageAdapter;
import com.yidianling.dynamic.publishTrend.PublishTrendActivity;
import com.yidianling.dynamic.publishTrend.SelecTopicActivity;
import com.yidianling.dynamic.router.DynamicIn;
......@@ -130,7 +131,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
private String head_path;//路径
File head_filec;
private List<ParcelableImage> publishTrendImgs, publishTrendImgBrows;
private PublishImageAdapter adapter;
private DynamicPublishImageAdapter adapter;
String topic_id;
String topic_title;
......@@ -261,13 +262,13 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
head_dir = RxFileTool.getStorageDirectory(activity) + "/img/publish_img/";
if (adapter == null) {
adapter = new PublishImageAdapter(publishTrendImgs, activity);
adapter = new DynamicPublishImageAdapter(publishTrendImgs, activity);
} else {
adapter.notifyDataSetChanged();
}
publish_trend_img_rcv.setLayoutManager(new GridLayoutManager(activity, 4));
publish_trend_img_rcv.setAdapter(adapter);
adapter.setOnItemClickLister(new PublishImageAdapter.OnItemClickLister() {
adapter.setOnItemClickLister(new DynamicPublishImageAdapter.OnItemClickLister() {
@Override
public void onItemClick(View view, int position) {
publishTrendImgBrows = new ArrayList<ParcelableImage>();
......@@ -306,7 +307,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
}
});
adapter.setOnDeleteClickLister(new PublishImageAdapter.OnDeleteClickLister() {
adapter.setOnDeleteClickLister(new DynamicPublishImageAdapter.OnDeleteClickLister() {
@Override
public void onDeleteClick(View view, int position) {
DeleteImg(position);
......@@ -317,7 +318,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
}
});
adapter.setOnAddClickLister(new PublishImageAdapter.OnAddClickLister() {
adapter.setOnAddClickLister(new DynamicPublishImageAdapter.OnAddClickLister() {
@Override
public void OnAddClick(View view, int position) {
if (publishTrendImgs.size() < 9) {
......@@ -668,7 +669,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
* @param trend_title 话题标题
* @param publishTrendImgs 图片附件
*/
@SuppressLint("WrongConstant")
@SuppressLint({"WrongConstant", "CheckResult"})
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>();
Observable.fromIterable(publishTrendImgs)
......@@ -720,6 +721,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
* @param trend_title 话题标题
* @param imgFiles 图片附件
*/
@SuppressLint("CheckResult")
private void PublishO(final int is_niming, final String topic_id, final String content, final String trend_title, final List<File> imgFiles) {
BuryPointUtils.getInstance().createMap()
.put("dynamic_type", topic_title)
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/dynamic_white" />
<stroke
android:width="0.5dp"
android:color="@color/platform_line" />
<solid android:color="#ff1da1f2" />
<corners android:radius="12dp" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/dynamic_msg_system_press" />
<solid android:color="#f6f7f8" />
<stroke
android:width="0.5dp"
android:color="@color/platform_line" />
......
......@@ -11,23 +11,30 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/dynamic_background_publish_trend_top"
android:gravity="center_vertical"
android:background="@color/dynamic_white"
>
<RelativeLayout
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="48dp"
>
<ImageView
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:paddingLeft="15dp"
android:paddingRight="@dimen/platform_dp_15"
android:src="@drawable/platform_common_back" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/platform_color_333333"
android:text="取消"
android:id="@+id/mBackIv"
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="@dimen/platform_dp_16"
android:textSize="@dimen/platform_sp_14"
>
</TextView>
<com.flyco.tablayout.CommonTabLayout
android:id="@+id/tab_layout"
......@@ -46,17 +53,19 @@
<TextView
android:id="@+id/publish_trend_sure_tv"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="15dp"
android:background="@drawable/dynamic_bg_publish_button"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingLeft="11dp"
android:paddingRight="11dp"
android:paddingTop="@dimen/platform_dp_3"
android:paddingBottom="@dimen/platform_dp_3"
android:text="发布"
android:textColor="@color/platform_but_text_color_selected"
android:textSize="14sp" />
android:textColor="@color/dynamic_white"
android:textSize="13sp" />
</RelativeLayout>
</LinearLayout>
......
......@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dynamic_white"
android:focusable="true"
android:id="@+id/trends_publish_question"
android:focusableInTouchMode="true"
......@@ -19,7 +20,7 @@
android:id="@+id/publish_trend_title_editext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dynamic_msg_system_press"
android:background="@color/dynamic_white"
android:gravity="center_vertical"
android:hint="标题:准确概括你的问题,且不少于5个字"
android:minHeight="50dp"
......@@ -29,7 +30,7 @@
android:paddingRight="15dp"
android:paddingBottom="13dp"
android:textColor="@color/dynamic_text_trend_title_black"
android:textColorHint="@color/dynamic_text_trend_defult"
android:textColorHint="#bfbfbf"
android:textSize="24sp"
tools:text="标题:说说你的标题:说说你的标题:说说你的困惑标题:说说你的困标题:说说你的困惑标题:说说你的困惑困惑标题:说说你的困惑" />
<RelativeLayout
......@@ -53,7 +54,7 @@
android:padding="15dp"
android:paddingLeft="15dp"
android:textColor="@color/dynamic_text_trend_title_black"
android:textColorHint="@color/dynamic_text_trend_defult"
android:textColorHint="#bfbfbf"
android:textSize="17sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/publish_trend_img_rcv"
......@@ -79,7 +80,7 @@
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="# 选择话题"
android:textColor="@color/platform_color_666666"
android:textColor="#999999"
android:textSize="11sp" />
<TextView
......@@ -91,7 +92,7 @@
android:gravity="center_vertical"
android:includeFontPadding="false"
android:text="0/1000"
android:textColor="#FF757575"
android:textColor="#b8b8b8"
android:textSize="11sp" />
<View
......
......@@ -3,13 +3,14 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dynamic_white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@drawable/dynamic_bg_bottom_trend_line">
>
<ImageView
android:id="@+id/publish_trend_bottom_img_iv"
......
<?xml version="1.0" encoding="utf-8"?>
<com.ydl.ydlcommon.view.SquareRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
>
<ImageView
android:id="@+id/item_publish_defult_iv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/dynamic_add_temp"
android:contentDescription="@null"
android:scaleType="fitXY"
android:visibility="gone" />
<ImageView
android:id="@+id/item_publish_iv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/item_publish_cancel_iv"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/platform_img_delete" />
</com.ydl.ydlcommon.view.SquareRelativeLayout>
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