-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hiding and unhiding posts are now available.
- Loading branch information
1 parent
010a230
commit 5dbe271
Showing
12 changed files
with
236 additions
and
46 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package ml.docilealligator.infinityforreddit; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
import retrofit2.Retrofit; | ||
|
||
class HidePost { | ||
interface HidePostListener { | ||
void success(); | ||
void failed(); | ||
} | ||
|
||
static void hidePost(Retrofit oauthRetrofit, String accessToken, String fullname, | ||
HidePostListener hidePostListener) { | ||
Map<String, String> params = new HashMap<>(); | ||
params.put(RedditUtils.ID_KEY, fullname); | ||
oauthRetrofit.create(RedditAPI.class).hide(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() { | ||
@Override | ||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { | ||
if(response.isSuccessful()) { | ||
hidePostListener.success(); | ||
} else { | ||
hidePostListener.failed(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { | ||
hidePostListener.failed(); | ||
} | ||
}); | ||
} | ||
|
||
static void unhidePost(Retrofit oauthRetrofit, String accessToken, String fullname, | ||
HidePostListener hidePostListener) { | ||
Map<String, String> params = new HashMap<>(); | ||
params.put(RedditUtils.ID_KEY, fullname); | ||
oauthRetrofit.create(RedditAPI.class).unhide(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() { | ||
@Override | ||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { | ||
if(response.isSuccessful()) { | ||
hidePostListener.success(); | ||
} else { | ||
hidePostListener.failed(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { | ||
hidePostListener.failed(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.