Skip to content

Commit

Permalink
更新ZRecyclerView、Fragmentation和Fragmentation-Dialog库,细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-P-J committed Apr 7, 2021
1 parent 776063e commit ff61459
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 120 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.github.nanchen2251:CompressHelper:1.0.5'



// TabLayout
implementation 'com.github.hackware1993:MagicIndicator:1.6.0'

Expand All @@ -102,7 +104,8 @@ dependencies {

// RecyclerView
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.zpj.widget:ZRecyclerView:1.2.1'
// implementation 'com.zpj.widget:ZRecyclerView:1.2.1'
implementation 'com.github.Z-P-J:ZRecyclerView:1.2.2'
implementation 'com.yanyusong.y_divideritemdecoration:y_divideritemdecoration:2.0'

// up/down arrow
Expand Down Expand Up @@ -155,8 +158,9 @@ dependencies {
implementation 'com.github.promeg:tinypinyin:2.0.3'
implementation 'com.nex3z:flow-layout:1.2.4'

implementation 'com.github.Z-P-J:Fragmentation-Dialog:1.1.8'
implementation 'com.zpj.widget:Fragmentation:1.1.1'
implementation 'com.github.Z-P-J:Fragmentation-Dialog:1.1.9'
implementation 'com.github.Z-P-J:Fragmentation:1.1.2'
// implementation 'com.zpj.widget:Fragmentation:1.1.1'
implementation 'com.zpj.widget:SmoothCheckBox:1.0.0'
implementation 'com.zpj.widget:ZSwitcher:1.0.5'
implementation 'com.zpj.widget:ZSettingItem:1.0.7'
Expand All @@ -166,7 +170,6 @@ dependencies {
implementation 'com.zpj.toast:ZToast:1.0.1'
implementation 'com.zpj.http:ZHttp:1.0.5'
implementation 'com.zpj.downloader:ZDownloader:1.0.0'
// implementation 'com.zpj.progressbar:ZProgressBar:1.0.0'
implementation 'com.github.Z-P-J:ZProgressBar:1.0.0'

// implementation project(':zmarkdown')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import android.widget.TextView;

import com.zpj.recyclerview.EasyViewHolder;
import com.zpj.recyclerview.footer.AbsFooterViewHolder;
import com.zpj.recyclerview.footer.IFooterViewHolder;
import com.zpj.shouji.market.R;

public class FooterViewHolder implements IFooterViewHolder {
public class FooterViewHolder extends AbsFooterViewHolder {

private View view;
private View progressLayout;
private TextView tvMsg;
private final boolean showSpace;
Expand All @@ -27,26 +27,14 @@ public FooterViewHolder(boolean showSpace) {

@Override
public View onCreateFooterView(ViewGroup root) {
if (view == null) {
view = LayoutInflater.from(root.getContext()).inflate(R.layout.item_footer_home, null, false);
progressLayout = view.findViewById(R.id.ll_container_progress);
tvMsg = view.findViewById(R.id.tv_msg);
Space space = view.findViewById(R.id.space);
space.setVisibility(showSpace ? View.VISIBLE : View.GONE);
}
View view = LayoutInflater.from(root.getContext()).inflate(R.layout.item_footer_home, null, false);
progressLayout = view.findViewById(R.id.ll_container_progress);
tvMsg = view.findViewById(R.id.tv_msg);
Space space = view.findViewById(R.id.space);
space.setVisibility(showSpace ? View.VISIBLE : View.GONE);
return view;
}

@Override
public View getView() {
return view;
}

@Override
public void onBindFooter(EasyViewHolder holder) {

}

@Override
public void onShowLoading() {
progressLayout.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void run() {
// Log.d("getData222222222222", "start=" + start + " count=" + count);
recyclerLayout.notifyItemRangeChanged(start, count);
} else {
IFooterViewHolder viewHolder = recyclerLayout.getAdapter().getFooterViewBinder();
IFooterViewHolder viewHolder = recyclerLayout.getAdapter().getFooterViewHolder();
if (viewHolder != null) {
viewHolder.onShowHasNoMore();
}
Expand Down Expand Up @@ -176,7 +176,7 @@ public void run() {
// tvMsg.setText(R.string.easy_has_no_more);
// }
// }
IFooterViewHolder viewHolder = recyclerLayout.getAdapter().getFooterViewBinder();
IFooterViewHolder viewHolder = recyclerLayout.getAdapter().getFooterViewHolder();
if (viewHolder != null) {
viewHolder.onShowHasNoMore();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ protected int getContentLayoutId() {

@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);
contentView.setBackgroundResource(R.drawable.background_bottom_sheet_dialog);

findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
tvTitle = findViewById(R.id.tv_title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected int getContentLayoutId() {

@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);

if (TextUtils.isEmpty(replyId) || TextUtils.isEmpty(contentType)) {
Expand All @@ -57,8 +58,6 @@ protected void initView(View view, @Nullable Bundle savedInstanceState) {
return;
}

contentView.setBackgroundResource(R.drawable.background_bottom_sheet_dialog);

Activity activity = ContextUtils.getActivity(context);

replyPanel = findViewById(R.id.panel_reply);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public abstract class ModifiedDialogFragment extends BottomDragDialogFragment {

@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);
contentView.setBackgroundResource(R.drawable.background_bottom_sheet_dialog);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ protected int getContentLayoutId() {

@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);
contentView.setBackgroundResource(R.drawable.background_bottom_sheet_dialog);

findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ protected int getContentLayoutId() {

@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);
contentView.setBackgroundResource(R.drawable.background_bottom_sheet_dialog);

if (getArguments() != null) {
contentType = getArguments().getString(Keys.TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ protected int getContentLayoutId() {

@Override
protected void initView(View view, @Nullable Bundle savedInstanceState) {
setCornerRadiusDp(20);
super.initView(view, savedInstanceState);

contentView.setBackgroundResource(R.drawable.background_bottom_sheet_dialog);

contentView.setMinimumHeight(ScreenUtils.getScreenHeight(context) / 2);

if (TextUtils.isEmpty(id) || discoverInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ public void onSupportInvisible() {

@Override
protected void initStatusBar() {
if (getContext() == null) {
return;
}
boolean isDark = alpha < 0.5f && isLazyInit();
boolean isNightMode = AppConfig.isNightMode();
if (isNightMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
public void onAccept(Boolean isSuccess, String errorMsg) throws Exception {
if (isSuccess) {
ZToast.success("登录成功!");
EventBus.hideLoading(() -> pop());
EventBus.hideLoading(() -> popThis());
} else {
EventBus.hideLoading();
}
Expand All @@ -84,7 +84,7 @@ public void onAccept(Boolean isSuccess, String errorMsg) throws Exception {
public void onAccept(Boolean isSuccess, String errorMsg) throws Exception {
if (isSuccess) {
ZToast.success("注册成功,请输入账账户信息登录!");
if (SupportHelper.getPreFragment(LoginFragment.this) instanceof LoginFragment) {
if (getPreFragment() instanceof LoginFragment) {
pop();
} else {
startWithPop(LoginFragment.newInstance(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,64 +148,6 @@ protected void buildRecyclerLayout(EasyRecyclerLayout<AppUpdateInfo> recyclerLay
recyclerLayout.setEnableSwipeRefresh(false);
}

// @Override
// public void onCheckUpdateFinish(List<AppUpdateInfo> updateInfoList) {
// Observable.create(
// (ObservableOnSubscribe<List<AppUpdateInfo>>) emitter -> {
// ignoredUpdateInfoList.clear();
// ignoredUpdateInfoList.addAll(IgnoredUpdateManager.getAllIgnoredUpdateApp());
// data.clear();
// for (int i = updateInfoList.size() - 1; i >= 0; i--) {
// AppUpdateInfo info = updateInfoList.get(i);
// for (IgnoredUpdateInfo ignoredUpdateInfo : ignoredUpdateInfoList) {
// if (TextUtils.equals(info.getPackageName(), ignoredUpdateInfo.getPackageName())) {
// ignoredUpdateInfo.setUpdateInfo(info);
// updateInfoList.remove(i);
// }
// }
// }
// data.addAll(updateInfoList);
// emitter.onComplete();
// })
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .doOnComplete(() -> {
// recyclerLayout.notifyDataSetChanged();
// if (data.isEmpty()) {
// topLayout.setVisibility(View.GONE);
// recyclerLayout.showEmptyView("所有应用均为最新版");
// } else {
// topLayout.setVisibility(View.VISIBLE);
// updateTopBar();
// }
// })
// .compose(RxLife.bindLifeOwner(this))
// .subscribe();
//
//
//// ignoredUpdateInfoList.clear();
//// ignoredUpdateInfoList.addAll(IgnoredUpdateManager.getAllIgnoredUpdateApp());
//// data.clear();
//// for (int i = updateInfoList.size() - 1; i >= 0; i--) {
//// AppUpdateInfo info = updateInfoList.get(i);
//// for (IgnoredUpdateInfo ignoredUpdateInfo : ignoredUpdateInfoList) {
//// if (TextUtils.equals(info.getPackageName(), ignoredUpdateInfo.getPackageName())) {
//// ignoredUpdateInfo.setUpdateInfo(info);
//// updateInfoList.remove(i);
//// }
//// }
//// }
//// data.addAll(updateInfoList);
//// recyclerLayout.notifyDataSetChanged();
//// if (updateInfoList.isEmpty()) {
//// topLayout.setVisibility(View.GONE);
//// recyclerLayout.showEmptyView("所有应用均为最新版");
//// } else {
//// topLayout.setVisibility(View.VISIBLE);
//// updateTopBar();
//// }
// }

@Override
public void onCheckUpdateFinish(List<AppUpdateInfo> updateInfoList, List<IgnoredUpdateInfo> ignoredUpdateInfoList) {
this.ignoredUpdateInfoList.clear();
Expand Down Expand Up @@ -351,27 +293,17 @@ public void onBindViewHolder(EasyViewHolder holder, List<AppUpdateInfo> list, in
versionTextView.setText(getVersionText(updateInfo));
infoTextView.setText(updateInfo.getNewSize() + " | " + updateInfo.getUpdateTimeInfo());

updateTextView.setMaxLines(updateInfo.isExpand() ? 0 : 1);
updateTextView.setMaxLines(updateInfo.isExpand() ? Integer.MAX_VALUE : 1);
updateTextView.setText(updateInfo.getUpdateInfo());

// expandBtn.setTag(false);
// expandBtn.setOnClickListener(v -> {
// boolean tag = (boolean) expandBtn.getTag();
// expandBtn.setImageResource(tag ? R.drawable.ic_expand_more_black_24dp : R.drawable.ic_expand_less_black_24dp);
// updateTextView.setMaxLines(tag ? 1 : 0);
// updateTextView.setText(updateInfo.getUpdateInfo());
// expandBtn.setTag(!tag);
// });


expandBtn.setTag(updateInfo);
expandBtn.setState(updateInfo.isExpand() ? ExpandIconView.LESS : ExpandIconView.MORE, false);
expandBtn.setOnClickListener(v -> {
AppUpdateInfo info = (AppUpdateInfo) v.getTag();
boolean isExpand = info.isExpand();
info.setExpand(!isExpand);

updateTextView.setMaxLines(isExpand ? 1 : 0);
updateTextView.setMaxLines(isExpand ? 1 : Integer.MAX_VALUE);
updateTextView.setText(updateInfo.getUpdateInfo());

expandBtn.switchState();
Expand All @@ -382,7 +314,8 @@ public void onBindViewHolder(EasyViewHolder holder, List<AppUpdateInfo> list, in
updateTextView.post(new Runnable() {
@Override
public void run() {
if (updateInfo.isExpand() || (updateTextView.getLayout() != null && updateTextView.getLayout().getEllipsisCount(updateTextView.getLineCount() - 1) > 0)) {
if (updateInfo.isExpand() || (updateTextView.getLayout() != null &&
updateTextView.getLayout().getEllipsisCount(updateTextView.getLineCount() - 1) > 0)) {
expandBtn.setVisibility(View.VISIBLE);
} else {
expandBtn.setVisibility(View.GONE);
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/res/drawable/background_bottom_sheet_dialog.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/layout/layout_sign_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
android:id="@+id/sv_login"
style="@style/button_submit"
android:layout_marginTop="16dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:text="登录"
app:sv_bindEditText1="@+id/piv_login_account"
app:sv_bindEditText2="@+id/piv_login_password" />
Expand Down

0 comments on commit ff61459

Please sign in to comment.