Skip to content

Commit

Permalink
改善emoji输入太多导致卡顿的问题; 修复再次打开评论弹窗崩溃的bug; 修复多次打开评论弹窗莫名自动关闭的bug;细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-P-J committed Jun 1, 2021
1 parent ea01c4b commit bea9acd
Show file tree
Hide file tree
Showing 36 changed files with 568 additions and 779 deletions.
629 changes: 319 additions & 310 deletions app/proguardMapping.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.zpj.recyclerview.EasyViewHolder;
import com.zpj.recyclerview.IEasy;
import com.zpj.shouji.market.R;
import com.zpj.shouji.market.ui.widget.DialogHeaderLayout;
import com.zpj.skin.SkinEngine;

import java.util.ArrayList;
Expand All @@ -34,7 +35,7 @@ public class BottomListMenuDialogFragment<T extends BottomListMenuDialogFragment

protected final List<Integer> hideMenuItemList = new ArrayList<>();

private TextView tvTitle;
private DialogHeaderLayout mHeaderLayout;

@LayoutRes
private int headerRes = -1;
Expand All @@ -55,12 +56,14 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);

findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
tvTitle = findViewById(R.id.tv_title);
mHeaderLayout = findViewById(R.id.layout_dialog_header);
mHeaderLayout.setOnCloseClickListener(view1 -> dismiss());


if (TextUtils.isEmpty(title)) {
title = "更多操作";
}
tvTitle.setText(title);
mHeaderLayout.setTitle(title);

MenuInflater inflater = new MenuInflater(getContext());
@SuppressLint("RestrictedApi") Menu menu = new MenuBuilder(context);
Expand Down Expand Up @@ -136,8 +139,8 @@ public T onItemLongClick(OnItemLongClickListener<T> listener) {

public T setTitle(String title) {
this.title = title;
if (tvTitle != null) {
tvTitle.setText(title);
if (mHeaderLayout != null) {
mHeaderLayout.setTitle(title);
}
return self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.zpj.shouji.market.R;
import com.zpj.shouji.market.api.CommentApi;
import com.zpj.shouji.market.ui.fragment.profile.UserPickerFragment;
import com.zpj.shouji.market.ui.widget.DialogHeaderLayout;
import com.zpj.shouji.market.ui.widget.MaxHeightLayout;
import com.zpj.shouji.market.ui.widget.ReplyPanel;
import com.zpj.toast.ZToast;
Expand Down Expand Up @@ -81,7 +82,9 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
replyPanel.removeAppAction();
}

findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
DialogHeaderLayout headerLayout = findViewById(R.id.layout_dialog_header);
headerLayout.setOnCloseClickListener(view1 -> dismiss());

maxHeightLayout = findViewById(R.id.layout_max_height);
// LinearLayout llContent = findViewById(R.id.ll_scroll_content);
// maxHeightLayout.post(() -> maxHeightLayout.setMaxHeight(ScreenUtils.getScreenHeight(context) - ScreenUtils.getStatusBarHeight(context)));
Expand All @@ -101,23 +104,6 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
}
});

// getContentView()
// .getViewTreeObserver()
// .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
// @Override
// public void onGlobalLayout() {
//
// }
// });

// postDelayed(new Runnable() {
// @Override
// public void run() {
//
//// KeyboardUtils.showSoftInput(replyPanel.getEditor());
// }
// }, 350);

postDelayed(() -> {
replyPanel.getEditor().requestFocus();
showSoftInput(replyPanel.getEditor());
Expand Down Expand Up @@ -217,4 +203,11 @@ public void onBytesWritten(int bytesWritten) {
public boolean shouldContinue() {
return true;
}

@Override
protected void onBeforeShow() {
mSupportVisibleActionQueue.onDestroy();
mEnterAnimationEndActionQueue.onDestroy();
super.onBeforeShow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protected int getContentLayoutId() {
@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
super.initView(view, savedInstanceState);
findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
EmailInputView emailView = findViewById(R.id.et_email);
emailView.getEditText().setHint("请输入新邮箱");
PasswordInputView passwordView = findViewById(R.id.et_password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.zpj.fragmentation.dialog.base.BottomDragDialogFragment;
import com.zpj.shouji.market.R;
import com.zpj.shouji.market.ui.widget.DialogHeaderLayout;
import com.zpj.utils.KeyboardObserver;

public abstract class ModifiedDialogFragment extends BottomDragDialogFragment<ModifiedDialogFragment> {
Expand All @@ -20,6 +21,10 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
DialogHeaderLayout headerLayout = findViewById(R.id.layout_dialog_header);
if (headerLayout != null) {
headerLayout.setOnCloseClickListener(view1 -> dismiss());
}
KeyboardObserver.registerSoftInputChangedListener(_mActivity, contentView, height -> {
contentView.setTranslationY(-height);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ protected int getContentLayoutId() {
@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
super.initView(view, savedInstanceState);
findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
AccountInputView inputView = findViewById(R.id.et_account);
inputView.addValidator(new LengthValidator("昵称长度必须在2-15之间", 2, 15));
SubmitView submitView = findViewById(R.id.sv_submit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ protected int getContentLayoutId() {
@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
super.initView(view, savedInstanceState);
findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());

PasswordInputView oldPasswordView = findViewById(R.id.et_password_old);
PasswordInputView newPasswordView = findViewById(R.id.et_password_new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.zpj.fragmentation.dialog.base.BottomDragDialogFragment;
import com.zpj.shouji.market.R;
import com.zpj.shouji.market.ui.widget.DialogHeaderLayout;
import com.zpj.toast.ZToast;
import com.zpj.utils.Callback;
import com.zpj.utils.ShareUtils;
Expand All @@ -35,7 +36,8 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);

findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
DialogHeaderLayout headerLayout = findViewById(R.id.layout_dialog_header);
headerLayout.setOnCloseClickListener(view1 -> dismiss());

TextView tvTitle = findViewById(R.id.tv_title);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.zpj.shouji.market.constant.Keys;
import com.zpj.shouji.market.model.SupportUserInfo;
import com.zpj.shouji.market.ui.fragment.profile.ProfileFragment;
import com.zpj.shouji.market.ui.widget.DialogHeaderLayout;
import com.zpj.shouji.market.utils.EventBus;
import com.zpj.statemanager.StateManager;
import com.zpj.utils.ScreenUtils;
Expand Down Expand Up @@ -60,7 +61,8 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
themeId = getArguments().getString(Keys.ID);
}

findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
DialogHeaderLayout headerLayout = findViewById(R.id.layout_dialog_header);
headerLayout.setOnCloseClickListener(view1 -> dismiss());

RecyclerView recycler = findViewById(R.id.recycler_view);
recyclerView = new EasyRecyclerView<>(recycler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.zpj.shouji.market.api.HttpApi;
import com.zpj.shouji.market.download.MissionDelegate;
import com.zpj.shouji.market.model.DiscoverInfo;
import com.zpj.shouji.market.ui.widget.DialogHeaderLayout;
import com.zpj.shouji.market.ui.widget.DownloadButton;
import com.zpj.statemanager.StateManager;
import com.zpj.toast.ZToast;
Expand Down Expand Up @@ -120,7 +121,8 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
tvDownload.setAlpha(0.8f);


findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
DialogHeaderLayout headerLayout = findViewById(R.id.layout_dialog_header);
headerLayout.setOnCloseClickListener(view1 -> dismiss());

getPermissions();
stateManager = StateManager.with(findViewById(R.id.scroll_view))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import com.zpj.toast.ZToast;

import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.WrapPagerIndicator;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -341,11 +343,14 @@ private void initViewPager() {
return pagerTitle;
})
.setOnGetIndicatorListener(context -> {
// WrapPagerIndicator indicator = new WrapPagerIndicator(context);
// indicator.setFillColor(Color.parseColor("#80eeeeee"));
// return indicator;
WrapPagerIndicator indicator = new WrapPagerIndicator(context);
indicator.setHorizontalPadding(0);
indicator.setVerticalPadding(0);
indicator.setRoundRadius(UIUtil.dip2px(context, 8));
indicator.setFillColor(Color.parseColor("#80eeeeee"));
return indicator;
// return new BezierPagerIndicator(context);
return null;
// return null;
})
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.zpj.shouji.market.ui.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zpj.shouji.market.R;

public class DialogHeaderLayout extends LinearLayout {

private final TextView mTvTitle;
private final ImageButton mBtnClose;

private CharSequence mTitle;
private OnClickListener mListener;

public DialogHeaderLayout(@NonNull Context context) {
this(context, null);
}

public DialogHeaderLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}

public DialogHeaderLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setOrientation(VERTICAL);
LayoutInflater.from(context).inflate(R.layout.layout_dialog_header, this, true);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DialogHeaderLayout);
mTitle = typedArray.getString(R.styleable.DialogHeaderLayout_dialog_header_title);
typedArray.recycle();


mTvTitle = findViewById(R.id.tv_title);
mTvTitle.setText(mTitle);
mBtnClose = findViewById(R.id.btn_close);
mBtnClose.setOnClickListener(mListener);
}

public void setTitle(CharSequence title) {
mTitle = title;
if (mTvTitle != null) {
mTvTitle.setText(title);
}
}

public void setOnCloseClickListener(OnClickListener listener) {
mListener = listener;
if (mBtnClose != null) {
mBtnClose.setOnClickListener(listener);
}
}


}
11 changes: 11 additions & 0 deletions app/src/main/java/com/zpj/shouji/market/ui/widget/ExpandIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ public ExpandIcon(@NonNull Context context, @Nullable AttributeSet attrs, int de
setState(MORE, false);
}

public void setRoundedCorner(boolean value) {
if (value) {
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
} else {
paint.setStrokeJoin(Paint.Join.MITER);
paint.setStrokeCap(Paint.Cap.BUTT);
}
invalidate();
}

public void switchState() {
switchState(true);
}
Expand Down
Loading

0 comments on commit bea9acd

Please sign in to comment.