Skip to content

Commit

Permalink
支持按标签屏蔽
Browse files Browse the repository at this point in the history
  • Loading branch information
CeuiLiSA authored and CeuiLiSA committed Mar 9, 2020
1 parent 5e76fb9 commit b96b24b
Show file tree
Hide file tree
Showing 46 changed files with 962 additions and 293 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "ceui.lisa.pixiv"
minSdkVersion 21
targetSdkVersion 28
versionCode 63
versionName "1.2.1"
versionCode 65
versionName "1.4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/ceui/lisa/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ public boolean onNavigationItemSelected(MenuItem item) {
intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "最新作品");
intent.putExtra("hideStatusBar", false);
startActivity(intent);
} else if (id == R.id.muted_list) {
Intent intent = new Intent(mContext, TemplateActivity.class);
intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "标签屏蔽记录");
startActivity(intent);
}

baseBind.drawerLayout.closeDrawer(GravityCompat.START);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/ceui/lisa/activities/TemplateActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import ceui.lisa.fragments.FragmentLive;
import ceui.lisa.fragments.FragmentLocalUsers;
import ceui.lisa.fragments.FragmentMultiDownload;
import ceui.lisa.fragments.FragmentMutedTags;
import ceui.lisa.fragments.FragmentNew;
import ceui.lisa.fragments.FragmentNiceFriend;
import ceui.lisa.fragments.FragmentNovelHolder;
Expand Down Expand Up @@ -178,6 +179,8 @@ protected Fragment createNewFragment() {
return new FragmentEditFile();
case "热门直播":
return new FragmentLive();
case "标签屏蔽记录":
return new FragmentMutedTags();
default:
return new FragmentBlank();
}
Expand Down
26 changes: 21 additions & 5 deletions app/src/main/java/ceui/lisa/adapters/BAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import java.util.List;

import ceui.lisa.R;
import ceui.lisa.databinding.RecyBookTagBinding;
import ceui.lisa.models.BookmarkTagsBean;
import ceui.lisa.models.TagsBean;
import ceui.lisa.utils.PixivOperate;

public class BAdapter extends BaseAdapter<BookmarkTagsBean, RecyBookTagBinding> {
public class BAdapter extends BaseAdapter<TagsBean, RecyBookTagBinding> {

private boolean isMuted = false;

public BAdapter(List<BookmarkTagsBean> targetList, Context context) {
public BAdapter(List<TagsBean> targetList, Context context, boolean muted) {
super(targetList, context);
isMuted = muted;
}

@Override
Expand All @@ -22,7 +26,7 @@ public void initLayout() {
}

@Override
public void bindData(BookmarkTagsBean target, ViewHolder<RecyBookTagBinding> bindView, int position) {
public void bindData(TagsBean target, ViewHolder<RecyBookTagBinding> bindView, int position) {
if (TextUtils.isEmpty(allIllust.get(position).getName())) {
bindView.baseBind.starSize.setText("#全部");
} else {
Expand All @@ -32,7 +36,19 @@ public void bindData(BookmarkTagsBean target, ViewHolder<RecyBookTagBinding> bin
if (allIllust.get(position).getCount() == -1) {
bindView.baseBind.illustCount.setText("");
} else {
bindView.baseBind.illustCount.setText(allIllust.get(position).getCount() + "个作品");
if (isMuted) {
bindView.baseBind.illustCount.setText("取消屏蔽");
bindView.baseBind.illustCount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PixivOperate.unMuteTag(target);
allIllust.remove(target);
notifyItemRemoved(position);
}
});
} else {
bindView.baseBind.illustCount.setText(allIllust.get(position).getCount() + "个作品");
}
}
if (mOnItemClickListener != null) {
bindView.itemView.setOnClickListener(v -> mOnItemClickListener.onItemClick(v, position, 0));
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/ceui/lisa/adapters/BaseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public abstract class BaseAdapter<Item, BindView extends ViewDataBinding> extend
public static final int ITEM_NORMAL = 1024;

public BaseAdapter(List<Item> targetList, Context context) {
Common.showLog(getClass().getSimpleName() + " newInstance");
this.allIllust = targetList;
this.mContext = context;
initLayout();
Expand Down
107 changes: 99 additions & 8 deletions app/src/main/java/ceui/lisa/adapters/IAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import androidx.fragment.app.FragmentActivity;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.popup.QMUIPopup;
import com.qmuiteam.qmui.widget.popup.QMUIPopups;

import java.util.List;

import ceui.lisa.R;
import ceui.lisa.activities.VActivity;
import ceui.lisa.activities.TemplateActivity;
import ceui.lisa.activities.ViewPagerActivity;
import ceui.lisa.databinding.RecyIllustStaggerBinding;
import ceui.lisa.dialogs.MuteDialog;
import ceui.lisa.interfaces.MultiDownload;
import ceui.lisa.interfaces.OnItemClickListener;
import ceui.lisa.models.IllustsBean;
import ceui.lisa.utils.Common;
import ceui.lisa.utils.DataChannel;
import ceui.lisa.utils.GlideUtil;
import ceui.lisa.utils.Params;
import jp.wasabeef.glide.transformations.BlurTransformation;

import static com.bumptech.glide.request.RequestOptions.bitmapTransform;

public class IAdapter extends BaseAdapter<IllustsBean, RecyIllustStaggerBinding> implements MultiDownload {

Expand Down Expand Up @@ -71,12 +85,37 @@ public void bindData(IllustsBean target, ViewHolder<RecyIllustStaggerBinding> bi
params.height = MAX_HEIGHT;
}
}

bindView.baseBind.illustImage.setLayoutParams(params);
Glide.with(mContext)
.load(GlideUtil.getMediumImg(target))
.placeholder(R.color.second_light_bg)
.into(bindView.baseBind.illustImage);


if (target.isShield()) {
bindView.baseBind.hide.setVisibility(View.VISIBLE);
Glide.with(mContext)
.load(GlideUtil.getMediumImg(target))
.apply(bitmapTransform(new BlurTransformation(5, 15)))
.into(bindView.baseBind.illustImage);
} else {
bindView.baseBind.hide.setVisibility(View.INVISIBLE);
Glide.with(mContext)
.load(GlideUtil.getMediumImg(target))
.placeholder(R.color.second_light_bg)
.into(bindView.baseBind.illustImage);
}
bindView.baseBind.hide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (target.isShield()) {
bindView.baseBind.hide.setVisibility(View.INVISIBLE);
Glide.with(mContext)
.load(GlideUtil.getMediumImg(target))
.placeholder(bindView.baseBind.illustImage.getDrawable())
.transition(DrawableTransitionOptions.withCrossFade(800))
.into(bindView.baseBind.illustImage);
target.setShield(false);
}
}
});


if (target.getPage_count() == 1) {
bindView.baseBind.pSize.setVisibility(View.GONE);
Expand All @@ -87,13 +126,18 @@ public void bindData(IllustsBean target, ViewHolder<RecyIllustStaggerBinding> bi
bindView.baseBind.pGif.setVisibility(target.isGif() ? View.VISIBLE : View.GONE);
bindView.itemView.setOnClickListener(view -> {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(view, position, 0);
if (target.isShield()) {
Common.showToast("屏蔽了还要看?");
} else {
mOnItemClickListener.onItemClick(view, position, 0);
}
}
});
bindView.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
startDownload();
handleLongClick(v, target);
//startDownload();
return true;
}
});
Expand All @@ -120,4 +164,51 @@ public void onItemClick(View v, int position, int viewType) {
}
});
}

private void handleLongClick(View v, IllustsBean illust) {
View popView = LayoutInflater.from(mContext).inflate(R.layout.pop_window_2, null);
QMUIPopup mNormalPopup = QMUIPopups.popup(mContext, QMUIDisplayHelper.dp2px(getContext(), 250))
.preferredDirection(QMUIPopup.DIRECTION_BOTTOM)
.view(popView)
.dimAmount(0.5f)
.edgeProtection(QMUIDisplayHelper.dp2px(getContext(), 20))
.offsetX(QMUIDisplayHelper.dp2px(getContext(), 80))
.offsetYIfBottom(QMUIDisplayHelper.dp2px(getContext(), 5))
.shadow(true)
.arrow(true)
.animStyle(QMUIPopup.ANIM_GROW_FROM_RIGHT)
.onDismiss(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
}
})
.show(v);

popView.findViewById(R.id.not_interested).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MuteDialog muteDialog = MuteDialog.newInstance(illust);
muteDialog.show(((FragmentActivity) mContext).getSupportFragmentManager(), "MuteDialog");
mNormalPopup.dismiss();
}
});
popView.findViewById(R.id.share).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startDownload();
mNormalPopup.dismiss();
}
});
popView.findViewById(R.id.show_comment).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, TemplateActivity.class);
intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "相关评论");
intent.putExtra(Params.ILLUST_ID, illust.getId());
intent.putExtra(Params.ILLUST_TITLE, illust.getTitle());
mContext.startActivity(intent);
mNormalPopup.dismiss();
}
});
}
}
Loading

0 comments on commit b96b24b

Please sign in to comment.