Skip to content

Commit

Permalink
Merge pull request #525 from LoxiaLiSA/master
Browse files Browse the repository at this point in the history
fix #522
  • Loading branch information
CeuiLiSA authored Mar 16, 2023
2 parents e591e68 + 483211d commit fe4e5f2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/ceui/lisa/activities/UActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/ceui/lisa/fragments/FragmentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/ceui/lisa/fragments/FragmentViewPager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
17 changes: 7 additions & 10 deletions app/src/main/java/ceui/lisa/utils/DownloadLimitTypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/ceui/lisa/utils/PixivOperate.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public static void refreshUserData(UserModel userModel, Callback<UserModel> 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<NullResponse>() {
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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<NullResponse>() {
Expand All @@ -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));
Expand Down

0 comments on commit fe4e5f2

Please sign in to comment.