mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-12 04:55:50 +01:00
use options rather than boolean
This commit is contained in:
parent
0ec120a023
commit
25bc38af87
@ -212,21 +212,18 @@ public abstract class SponsorBlockUtils {
|
|||||||
.setItems(items, new DialogInterface.OnClickListener() {
|
.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Context con = context.getApplicationContext();
|
appContext = new WeakReference<>(context.getApplicationContext());
|
||||||
switch (voteOptions[which]) {
|
switch (voteOptions[which]) {
|
||||||
case UPVOTE:
|
case UPVOTE:
|
||||||
Toast.makeText(con, str("vote_started"), Toast.LENGTH_SHORT).show();
|
voteForSegment(segment, VoteOption.UPVOTE);
|
||||||
voteForSegment(segment, true, null);
|
|
||||||
break;
|
break;
|
||||||
case DOWNVOTE:
|
case DOWNVOTE:
|
||||||
Toast.makeText(con, str("vote_started"), Toast.LENGTH_SHORT).show();
|
voteForSegment(segment, VoteOption.DOWNVOTE);
|
||||||
voteForSegment(segment, false, null);
|
|
||||||
break;
|
break;
|
||||||
case CATEGORY_CHANGE:
|
case CATEGORY_CHANGE:
|
||||||
onNewCategorySelect(segment, context);
|
onNewCategorySelect(segment, context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
appContext = new WeakReference<>(con);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
@ -407,7 +404,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
.setItems(titles, new DialogInterface.OnClickListener() {
|
.setItems(titles, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
voteForSegment(segment, false, values[which].key);
|
voteForSegment(segment, VoteOption.CATEGORY_CHANGE, values[which].key);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
@ -530,14 +527,15 @@ public abstract class SponsorBlockUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void voteForSegment(SponsorSegment segment, boolean upvote, String category) {
|
public static void voteForSegment(SponsorSegment segment, VoteOption voteOption, String... args) {
|
||||||
messageToToast = null;
|
messageToToast = null;
|
||||||
try {
|
try {
|
||||||
String voteUrl = category == null
|
String voteUrl = voteOption == VoteOption.CATEGORY_CHANGE
|
||||||
? getSponsorBlockVoteUrl(segment.UUID, uuid, upvote ? 1 : 0)
|
? getSponsorBlockVoteUrl(segment.UUID, uuid, args[0])
|
||||||
: getSponsorBlockVoteUrl(segment.UUID, uuid, category);
|
: getSponsorBlockVoteUrl(segment.UUID, uuid, voteOption == VoteOption.UPVOTE ? 1 : 0);
|
||||||
URL url = new URL(voteUrl);
|
URL url = new URL(voteUrl);
|
||||||
|
|
||||||
|
Toast.makeText(appContext.get(), str("vote_started"), Toast.LENGTH_SHORT).show();
|
||||||
Log.d("sponsorblock", "requesting: " + url.getPath());
|
Log.d("sponsorblock", "requesting: " + url.getPath());
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
Loading…
Reference in New Issue
Block a user