diff --git a/app/src/main/java/ceui/lisa/activities/UActivity.kt b/app/src/main/java/ceui/lisa/activities/UActivity.kt index 35733a9b2..1645c7881 100644 --- a/app/src/main/java/ceui/lisa/activities/UActivity.kt +++ b/app/src/main/java/ceui/lisa/activities/UActivity.kt @@ -243,11 +243,16 @@ fun Fragment.followUser(sender: ProgressTextButton, userId: Int, followType: Str fun FragmentActivity.followUser(sender: ProgressTextButton, userId: Int, followType: String) { lifecycleScope.launch { try { + val pendingFollowType = if (Shaft.sSettings.isPrivateStar) { + Params.TYPE_PRIVATE + } else { + followType + } sender.showProgress() - Client.appApi.postFollow(userId.toLong(), followType) + Client.appApi.postFollow(userId.toLong(), pendingFollowType) delay(500L) ObjectPool.followUser(userId.toLong()) - if (followType == Params.TYPE_PUBLIC) { + if (pendingFollowType == Params.TYPE_PUBLIC) { Shaft.appViewModel.updateFollowUserStatus( userId, AppLevelViewModel.FollowUserStatus.FOLLOWED_PUBLIC diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentSettings.java b/app/src/main/java/ceui/lisa/fragments/FragmentSettings.java index 676e1a523..f2e0e9be8 100644 --- a/app/src/main/java/ceui/lisa/fragments/FragmentSettings.java +++ b/app/src/main/java/ceui/lisa/fragments/FragmentSettings.java @@ -709,21 +709,26 @@ public void onClick(View v) { }); //下载限制类型 - baseBind.downloadLimitType.setText(DownloadLimitTypeUtil.getCurrentStatusName()); + final String[] DOWNLOAD_START_TYPE_NAMES = new String[]{ + getString(DownloadLimitTypeUtil.DOWNLOAD_START_TYPE_IDS[0]), + getString(DownloadLimitTypeUtil.DOWNLOAD_START_TYPE_IDS[1]), + getString(DownloadLimitTypeUtil.DOWNLOAD_START_TYPE_IDS[2]) + }; + baseBind.downloadLimitType.setText(DOWNLOAD_START_TYPE_NAMES[DownloadLimitTypeUtil.getCurrentStatusIndex()]); baseBind.downloadLimitType.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new QMUIDialog.CheckableDialogBuilder(mActivity) .setCheckedIndex(Shaft.sSettings.getDownloadLimitType()) .setSkinManager(QMUISkinManager.defaultInstance(mContext)) - .addItems(DownloadLimitTypeUtil.DOWNLOAD_START_TYPE_NAMES, new DialogInterface.OnClickListener() { + .addItems(DOWNLOAD_START_TYPE_NAMES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == Shaft.sSettings.getDownloadLimitType()) { Common.showLog("什么也不做"); } else { Shaft.sSettings.setDownloadLimitType(which); - baseBind.downloadLimitType.setText(DownloadLimitTypeUtil.getCurrentStatusName()); + baseBind.downloadLimitType.setText(DOWNLOAD_START_TYPE_NAMES[DownloadLimitTypeUtil.getCurrentStatusIndex()]); Common.showToast(getString(R.string.string_428)); Local.setSettings(Shaft.sSettings); } diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentViewPager.java b/app/src/main/java/ceui/lisa/fragments/FragmentViewPager.java index 5947eb7da..cf67aaeb8 100644 --- a/app/src/main/java/ceui/lisa/fragments/FragmentViewPager.java +++ b/app/src/main/java/ceui/lisa/fragments/FragmentViewPager.java @@ -113,10 +113,11 @@ public void onPageScrollStateChanged(int state) { Shaft.getContext().getString(R.string.r_eighteen_female_rank), }; mFragments = new ListFragment[]{ - FragmentRankIllust.newInstance(7, "", false), +// FragmentRankIllust.newInstance(7, "", false), FragmentRankIllust.newInstance(8, "", false), FragmentRankIllust.newInstance(9, "", false), - FragmentRankIllust.newInstance(10, "", false) + FragmentRankIllust.newInstance(10, "", false), + FragmentRankIllust.newInstance(11, "", false) }; baseBind.toolbarTitle.setText(R.string.string_r); baseBind.viewPager.setAdapter(new FragmentPagerAdapter(getChildFragmentManager()) { diff --git a/app/src/main/java/ceui/lisa/utils/DownloadLimitTypeUtil.java b/app/src/main/java/ceui/lisa/utils/DownloadLimitTypeUtil.java index a0b0a02ac..d7255b798 100644 --- a/app/src/main/java/ceui/lisa/utils/DownloadLimitTypeUtil.java +++ b/app/src/main/java/ceui/lisa/utils/DownloadLimitTypeUtil.java @@ -9,20 +9,17 @@ public class DownloadLimitTypeUtil { - private static final Resources resources = Shaft.getContext().getResources(); - - public static String[] DOWNLOAD_START_TYPE_NAMES = new String[]{ - resources.getString(R.string.string_289), - resources.getString(R.string.string_448), - resources.getString(R.string.string_453) + public static int[] DOWNLOAD_START_TYPE_IDS = new int[]{ + R.string.string_289, + R.string.string_448, + R.string.string_453 }; - - public static String getCurrentStatusName() { + public static int getCurrentStatusIndex() { int currentIndex = Shaft.sSettings.getDownloadLimitType(); - if (currentIndex < 0 || currentIndex >= DOWNLOAD_START_TYPE_NAMES.length) { + if (currentIndex < 0 || currentIndex >= DOWNLOAD_START_TYPE_IDS.length) { currentIndex = 0; } - return DOWNLOAD_START_TYPE_NAMES[currentIndex]; + return currentIndex; } /** diff --git a/app/src/main/java/ceui/lisa/utils/PixivOperate.java b/app/src/main/java/ceui/lisa/utils/PixivOperate.java index 91883722d..744d182af 100644 --- a/app/src/main/java/ceui/lisa/utils/PixivOperate.java +++ b/app/src/main/java/ceui/lisa/utils/PixivOperate.java @@ -92,8 +92,9 @@ public static void refreshUserData(UserModel userModel, Callback call } public static void postFollowUser(int userID, String followType) { + String pendingFollowType = Shaft.sSettings.isPrivateStar() ? Params.TYPE_PRIVATE : followType; Retro.getAppApi().postFollow( - sUserModel.getAccess_token(), userID, followType) + sUserModel.getAccess_token(), userID, pendingFollowType) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ErrorCtrl() { @@ -106,7 +107,7 @@ public void next(NullResponse nullResponse) { LocalBroadcastManager.getInstance(Shaft.getContext()).sendBroadcast(intent); ObjectPool.INSTANCE.followUser(userID); - if (followType.equals(Params.TYPE_PUBLIC)) { + if (pendingFollowType.equals(Params.TYPE_PUBLIC)) { Shaft.appViewModel.updateFollowUserStatus(userID, AppLevelViewModel.FollowUserStatus.FOLLOWED_PUBLIC); Common.showToast(getString(R.string.like_success_public)); } else { @@ -137,9 +138,9 @@ public void next(NullResponse nullResponse) { } public static void postLikeDefaultStarType(IllustsBean illustsBean) { - if(Shaft.sSettings.isPrivateStar()){ + if (Shaft.sSettings.isPrivateStar()) { postLike(illustsBean, Params.TYPE_PRIVATE, false, 0); - }else{ + } else{ postLike(illustsBean, Params.TYPE_PUBLIC, false, 0); } } @@ -236,7 +237,8 @@ public void next(NullResponse nullResponse) { }); } else { //没有收藏 novelBean.setIs_bookmarked(true); - Retro.getAppApi().postLikeNovel(userModel.getAccess_token(), novelBean.getId(), starType) + String pendingType = Shaft.sSettings.isPrivateStar() ? Params.TYPE_PRIVATE : starType; + Retro.getAppApi().postLikeNovel(userModel.getAccess_token(), novelBean.getId(), pendingType) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ErrorCtrl() { @@ -250,7 +252,7 @@ public void next(NullResponse nullResponse) { if(view instanceof Button){ ((Button) view).setText(getString(R.string.string_179)); } - if (Params.TYPE_PUBLIC.equals(starType)) { + if (Params.TYPE_PUBLIC.equals(pendingType)) { Common.showToast(getString(R.string.like_novel_success_public)); } else { Common.showToast(getString(R.string.like_novel_success_private));