修改帮助反馈的UI

This commit is contained in:
2024-04-24 17:48:21 +08:00
parent d4d191fad6
commit 34e4765e13
10 changed files with 765 additions and 286 deletions

View File

@@ -0,0 +1,112 @@
package com.yunbao.common.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/11/28.
*/
public class ImagePreviewAdapter extends RecyclerView.Adapter<ImagePreviewAdapter.Vh> {
private LayoutInflater mInflater;
private ActionListener mActionListener;
private int mPageCount;
private LinearLayoutManager mLayoutManager;
private int mCurPosition;
public ImagePreviewAdapter(Context context, int pageCount) {
mPageCount = pageCount;
mInflater = LayoutInflater.from(context);
}
@NonNull
@Override
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new Vh(mInflater.inflate(R.layout.item_preview_img, parent, false));
}
@Override
public void onBindViewHolder(@NonNull Vh vh, int position) {
vh.setData(position);
}
@Override
public int getItemCount() {
return mPageCount;
}
class Vh extends RecyclerView.ViewHolder {
ImageView mImg;
public Vh(View itemView) {
super(itemView);
mImg = (ImageView) itemView;
}
void setData(int position) {
if (mActionListener != null) {
mActionListener.loadImage(mImg, position);
}
}
}
public void setActionListener(ActionListener actionListener) {
mActionListener = actionListener;
}
public void setCurPosition(int curPosition) {
mCurPosition = curPosition;
if (mActionListener != null) {
mActionListener.onPageChanged(curPosition);
}
}
public int getCurPosition(){
return mCurPosition;
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
mLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
pagerSnapHelper.attachToRecyclerView(recyclerView);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int position = mLayoutManager.findFirstCompletelyVisibleItemPosition();
if (position >= 0 && mCurPosition != position) {
mCurPosition = position;
if (mActionListener != null) {
mActionListener.onPageChanged(position);
}
}
}
});
}
public interface ActionListener {
void onPageChanged(int position);
void loadImage(ImageView imageView, int position);
}
}

View File

@@ -0,0 +1,160 @@
package com.yunbao.common.dialog;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.adapter.ImagePreviewAdapter;
import com.yunbao.common.utils.StringUtil;
/**
* Created by Martin on 2024/3/15.
* 图片预览弹窗
*/
public class ImagePreviewDialog extends AbsDialogFragment implements View.OnClickListener {
private View mBg;
private RecyclerView mRecyclerView;
private ValueAnimator mAnimator;
private int mPosition;
private int mPageCount;
private ActionListener mActionListener;
private TextView mCount;
private ImagePreviewAdapter mAdapter;
private boolean mNeedDelete;
@Override
protected int getLayoutId() {
return R.layout.view_preview_image;
}
@Override
protected int getDialogStyle() {
return R.style.dialog2;
}
@Override
protected boolean canCancel() {
return true;
}
@Override
protected void setWindowAttributes(Window window) {
WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(params);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mBg = mRootView.findViewById(R.id.bg);
mCount = (TextView) findViewById(R.id.count);
findViewById(R.id.btn_close).setOnClickListener(this);
if (mNeedDelete) {
View btnDelete = findViewById(R.id.btn_delete);
btnDelete.setVisibility(View.VISIBLE);
btnDelete.setOnClickListener(this);
}
mRecyclerView = mRootView.findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
mAnimator = ValueAnimator.ofFloat(0, 1);
mAnimator.setDuration(150);
mAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = (float) animation.getAnimatedValue();
mBg.setAlpha(v);
}
});
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mRecyclerView != null && mPageCount > 0) {
ImagePreviewAdapter adapter = new ImagePreviewAdapter(mContext, mPageCount);
mAdapter = adapter;
adapter.setActionListener(new ImagePreviewAdapter.ActionListener() {
@Override
public void onPageChanged(int position) {
if (mCount != null) {
mCount.setText(StringUtil.contact(String.valueOf(position + 1), "/", String.valueOf(mPageCount)));
}
}
@Override
public void loadImage(ImageView imageView, int position) {
if (mActionListener != null) {
mActionListener.loadImage(imageView, position);
}
}
});
mRecyclerView.setAdapter(adapter);
if (mPosition >= 0 && mPosition < mPageCount) {
adapter.setCurPosition(mPosition);
mRecyclerView.scrollToPosition(mPosition);
}
}
}
});
mAnimator.start();
}
public void setImageInfo(int pageCount, int position, boolean needDelete, ActionListener actionListener) {
mActionListener = actionListener;
mPageCount = pageCount;
mPosition = position;
mNeedDelete = needDelete;
}
@Override
public void onDestroy() {
if (mAnimator != null) {
mAnimator.cancel();
}
mContext = null;
mActionListener = null;
super.onDestroy();
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.btn_close) {
dismiss();
} else if (i == R.id.btn_delete) {
delete();
}
}
private void delete() {
if (mAdapter != null && mActionListener != null) {
mActionListener.onDeleteClick(mAdapter.getCurPosition());
}
dismiss();
}
public interface ActionListener {
void loadImage(ImageView imageView, int position);
void onDeleteClick(int position);
}
}

View File

@@ -1206,4 +1206,8 @@ public interface PDLiveApi {
@GET("/api/public/?service=User.userFeedback")
Observable<ResponseModel<List<BaseModel>>> feedback(@Query("problem_description") String content, @Query("problem_image") String images, @Query("contact_information") String ci);
@GET("/api/public/?service=User.userFeedbackRestrict")
Observable<ResponseModel<List<BaseModel>>> checkFeedback();
}

View File

@@ -3219,6 +3219,32 @@ public class LiveNetManager {
}).isDisposed();
}
public void checkFeedback(
HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.checkFeedback()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<BaseModel>>>() {
@Override
public void accept(ResponseModel<List<BaseModel>> responseModel) {
if (callback != null) {
HttpCallbackModel model = new HttpCallbackModel();
model.setCode(responseModel.getData().getCode());
model.setMsg(responseModel.getData().getMsg());
callback.onSuccess(model);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
}
}
}).isDisposed();
}
private MultipartBody.Part createUploadFile(File file) {
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
return MultipartBody.Part.createFormData("file", file.getName(), requestBody);

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:background="#000"
/>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:background="#000" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="40dp">
<TextView
android:id="@+id/titleView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/preview"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/btn_close"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:padding="9dp"
android:src="@mipmap/icon_back"
app:tint="@color/white" />
<TextView
android:id="@+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:padding="5dp"
android:textColor="@color/white"
android:textSize="14sp" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/btn_delete"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:background="#000"
android:gravity="center"
android:text="@string/delete"
android:textColor="@color/white"
android:textSize="15sp"
android:visibility="gone" />
</LinearLayout>
</FrameLayout>