Start replacing AsyncTask with Executor in ParsePost.

This commit is contained in:
Alex Ning 2021-06-23 19:20:37 +08:00
parent 866db8c681
commit 260bd45433
7 changed files with 167 additions and 67 deletions

View File

@ -1093,27 +1093,32 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private void initializeAndBindPostViewModel(String accessToken) { private void initializeAndBindPostViewModel(String accessToken) {
if (postType == PostDataSource.TYPE_SEARCH) { if (postType == PostDataSource.TYPE_SEARCH) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType, mPostFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class); postFilter, readPosts)).get(PostViewModel.class);
} else if (postType == PostDataSource.TYPE_SUBREDDIT) { } else if (postType == PostDataSource.TYPE_SUBREDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, mPostFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class); postFilter, readPosts)).get(PostViewModel.class);
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) { } else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, mPostFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class); postFilter, readPosts)).get(PostViewModel.class);
} else if (postType == PostDataSource.TYPE_USER) { } else if (postType == PostDataSource.TYPE_USER) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter, mPostFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter,
where, readPosts)).get(PostViewModel.class); where, readPosts)).get(PostViewModel.class);
} else { } else {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), mOauthRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
postType, sortType, postFilter, readPosts)).get(PostViewModel.class); postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
} }
@ -1124,28 +1129,33 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private void initializeAndBindPostViewModelForAnonymous(String concatenatedSubredditNames) { private void initializeAndBindPostViewModelForAnonymous(String concatenatedSubredditNames) {
//For anonymous user //For anonymous user
if (postType == PostDataSource.TYPE_SEARCH) { if (postType == PostDataSource.TYPE_SEARCH) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mRetrofit, null, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), mRetrofit, null,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType, mPostFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class); postFilter, readPosts)).get(PostViewModel.class);
} else if (postType == PostDataSource.TYPE_SUBREDDIT) { } else if (postType == PostDataSource.TYPE_SUBREDDIT) {
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, null, mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mExecutor,
new Handler(), mRetrofit, null,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, mPostFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class); postFilter, readPosts)).get(PostViewModel.class);
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) { } else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mRetrofit, null, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), mRetrofit, null,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, postFilter, mPostFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, postFilter,
readPosts)).get(PostViewModel.class); readPosts)).get(PostViewModel.class);
} else if (postType == PostDataSource.TYPE_USER) { } else if (postType == PostDataSource.TYPE_USER) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mRetrofit, null, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), mRetrofit, null,
accountName, mSharedPreferences, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter, mPostFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter,
where, readPosts)).get(PostViewModel.class); where, readPosts)).get(PostViewModel.class);
} else { } else {
//Anonymous Front Page //Anonymous Front Page
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mRetrofit, mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
new Handler(), mRetrofit,
mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter)).get(PostViewModel.class); mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter)).get(PostViewModel.class);
} }

View File

@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.post;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Handler;
import android.text.Html; import android.text.Html;
import org.json.JSONArray; import org.json.JSONArray;
@ -12,6 +13,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -25,9 +27,58 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
*/ */
public class ParsePost { public class ParsePost {
public static void parsePosts(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList, public static void parsePosts(Executor executor, Handler handler, String response, int nPosts,
PostFilter postFilter, List<ReadPost> readPostList,
ParsePostsListingListener parsePostsListingListener) { ParsePostsListingListener parsePostsListingListener) {
new ParsePostDataAsyncTask(response, nPosts, postFilter, readPostList, parsePostsListingListener).execute(); executor.execute(() -> {
boolean parseFailed = false;
LinkedHashSet<Post> newPosts = new LinkedHashSet<>();
String lastItem = null;
try {
JSONObject jsonResponse = new JSONObject(response);
JSONArray allData = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
lastItem = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
//Posts listing
int size;
if (nPosts < 0 || nPosts > allData.length()) {
size = allData.length();
} else {
size = nPosts;
}
HashSet<ReadPost> readPostHashSet = null;
if (readPostList != null) {
readPostHashSet = new HashSet<>(readPostList);
}
for (int i = 0; i < size; i++) {
try {
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
Post post = parseBasicData(data);
if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) {
post.markAsRead(false);
}
if (PostFilter.isPostAllowed(post, postFilter)) {
newPosts.add(post);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
} catch (JSONException e) {
e.printStackTrace();
parseFailed = true;
}
if (!parseFailed) {
String finalLastItem = lastItem;
handler.post(() -> parsePostsListingListener.onParsePostsListingSuccess(newPosts, finalLastItem));
} else {
handler.post(parsePostsListingListener::onParsePostsListingFail);
}
});
} }
public static void parsePost(String response, ParsePostListener parsePostListener) { public static void parsePost(String response, ParsePostListener parsePostListener) {

View File

@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.post; package ml.docilealligator.infinityforreddit.post;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Handler;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
@ -9,6 +10,7 @@ import androidx.paging.PageKeyedDataSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
@ -37,6 +39,8 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
public static final String USER_WHERE_SAVED = "saved"; public static final String USER_WHERE_SAVED = "saved";
public static final String USER_WHERE_GILDED = "gilded"; public static final String USER_WHERE_GILDED = "gilded";
private Executor executor;
private Handler handler;
private Retrofit retrofit; private Retrofit retrofit;
private String accessToken; private String accessToken;
private String accountName; private String accountName;
@ -59,10 +63,12 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
private LoadParams<String> params; private LoadParams<String> params;
private LoadCallback<String, Post> callback; private LoadCallback<String, Post> callback;
PostDataSource(Retrofit retrofit, String accessToken, String accountName, PostDataSource(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences sharedPreferences,
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType, SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -78,10 +84,12 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
postLinkedHashSet = new LinkedHashSet<>(); postLinkedHashSet = new LinkedHashSet<>();
} }
PostDataSource(Retrofit retrofit, String accessToken, String accountName, PostDataSource(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String path, int postType, SortType sortType, PostFilter postFilter, String path, int postType, SortType sortType, PostFilter postFilter,
List<ReadPost> readPostList) { List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -118,10 +126,12 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
postLinkedHashSet = new LinkedHashSet<>(); postLinkedHashSet = new LinkedHashSet<>();
} }
PostDataSource(Retrofit retrofit, String accessToken, String accountName, PostDataSource(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter, String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter,
String where, List<ReadPost> readPostList) { String where, List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -139,10 +149,12 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
postLinkedHashSet = new LinkedHashSet<>(); postLinkedHashSet = new LinkedHashSet<>();
} }
PostDataSource(Retrofit retrofit, String accessToken, String accountName, PostDataSource(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String subredditOrUserName, String query, int postType, SortType sortType, PostFilter postFilter, String subredditOrUserName, String query, int postType, SortType sortType, PostFilter postFilter,
List<ReadPost> readPostList) { List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -254,7 +266,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -317,7 +329,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -377,7 +389,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -451,7 +463,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -512,7 +524,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -583,7 +595,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -666,7 +678,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -757,7 +769,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -817,7 +829,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -888,7 +900,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, readPostList,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -938,7 +950,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, null, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, null,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
@ -1002,7 +1014,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
ParsePost.parsePosts(response.body(), -1, postFilter, null, ParsePost.parsePosts(executor, handler, response.body(), -1, postFilter, null,
new ParsePost.ParsePostsListingListener() { new ParsePost.ParsePostsListingListener() {
@Override @Override
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {

View File

@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.post; package ml.docilealligator.infinityforreddit.post;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -8,13 +9,16 @@ import androidx.lifecycle.MutableLiveData;
import androidx.paging.DataSource; import androidx.paging.DataSource;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.readpost.ReadPost; import ml.docilealligator.infinityforreddit.readpost.ReadPost;
import retrofit2.Retrofit; import retrofit2.Retrofit;
class PostDataSourceFactory extends DataSource.Factory { class PostDataSourceFactory extends DataSource.Factory {
private Executor executor;
private Handler handler;
private Retrofit retrofit; private Retrofit retrofit;
private String accessToken; private String accessToken;
private String accountName; private String accountName;
@ -31,10 +35,12 @@ class PostDataSourceFactory extends DataSource.Factory {
private PostDataSource postDataSource; private PostDataSource postDataSource;
private MutableLiveData<PostDataSource> postDataSourceLiveData; private MutableLiveData<PostDataSource> postDataSourceLiveData;
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, PostDataSourceFactory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences sharedPreferences,
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType, SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -47,10 +53,12 @@ class PostDataSourceFactory extends DataSource.Factory {
this.readPostList = readPostList; this.readPostList = readPostList;
} }
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, PostDataSourceFactory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String name, int postType, SortType sortType, PostFilter postFilter, String name, int postType, SortType sortType, PostFilter postFilter,
List<ReadPost> readPostList) { List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -64,10 +72,12 @@ class PostDataSourceFactory extends DataSource.Factory {
this.readPostList = readPostList; this.readPostList = readPostList;
} }
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, PostDataSourceFactory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String name, int postType, SortType sortType, PostFilter postFilter, String name, int postType, SortType sortType, PostFilter postFilter,
String where, List<ReadPost> readPostList) { String where, List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -82,10 +92,12 @@ class PostDataSourceFactory extends DataSource.Factory {
this.readPostList = readPostList; this.readPostList = readPostList;
} }
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, PostDataSourceFactory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String name, String query, int postType, SortType sortType, PostFilter postFilter, String name, String query, int postType, SortType sortType, PostFilter postFilter,
List<ReadPost> readPostList) { List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -104,24 +116,24 @@ class PostDataSourceFactory extends DataSource.Factory {
@Override @Override
public DataSource<String, Post> create() { public DataSource<String, Post> create() {
if (postType == PostDataSource.TYPE_FRONT_PAGE) { if (postType == PostDataSource.TYPE_FRONT_PAGE) {
postDataSource = new PostDataSource(retrofit, accessToken, accountName, postDataSource = new PostDataSource(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, postType, sortType, sharedPreferences, postFeedScrolledPositionSharedPreferences, postType, sortType,
postFilter, readPostList); postFilter, readPostList);
} else if (postType == PostDataSource.TYPE_SEARCH) { } else if (postType == PostDataSource.TYPE_SEARCH) {
postDataSource = new PostDataSource(retrofit, accessToken, accountName, postDataSource = new PostDataSource(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, query, sharedPreferences, postFeedScrolledPositionSharedPreferences, name, query,
postType, sortType, postFilter, readPostList); postType, sortType, postFilter, readPostList);
} else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) { } else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) {
Log.i("asdasfd", "s5 " + (postFilter == null)); Log.i("asdasfd", "s5 " + (postFilter == null));
postDataSource = new PostDataSource(retrofit, accessToken, accountName, postDataSource = new PostDataSource(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType, sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType,
sortType, postFilter, readPostList); sortType, postFilter, readPostList);
} else if (postType == PostDataSource.TYPE_ANONYMOUS_FRONT_PAGE) { } else if (postType == PostDataSource.TYPE_ANONYMOUS_FRONT_PAGE) {
postDataSource = new PostDataSource(retrofit, null, null, postDataSource = new PostDataSource(executor, handler, retrofit, null, null,
sharedPreferences, null, name, postType, sharedPreferences, null, name, postType,
sortType, postFilter, null); sortType, postFilter, null);
} else { } else {
postDataSource = new PostDataSource(retrofit, accessToken, accountName, postDataSource = new PostDataSource(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType, sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType,
sortType, postFilter, userWhere, readPostList); sortType, postFilter, userWhere, readPostList);
} }

View File

@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.post; package ml.docilealligator.infinityforreddit.post;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Handler;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.util.Pair; import androidx.core.util.Pair;
@ -14,6 +15,7 @@ import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList; import androidx.paging.PagedList;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter; import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
@ -31,10 +33,10 @@ public class PostViewModel extends ViewModel {
private MutableLiveData<PostFilter> postFilterLiveData; private MutableLiveData<PostFilter> postFilterLiveData;
private SortTypeAndPostFilterLiveData sortTypeAndPostFilterLiveData; private SortTypeAndPostFilterLiveData sortTypeAndPostFilterLiveData;
public PostViewModel(Retrofit retrofit, String accessToken, String accountName, public PostViewModel(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences cache, int postType, SharedPreferences sharedPreferences, SharedPreferences cache, int postType,
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, postDataSourceFactory = new PostDataSourceFactory(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, cache, postType, sortType, postFilter, readPostList); sharedPreferences, cache, postType, sortType, postFilter, readPostList);
initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(), initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
@ -64,11 +66,11 @@ public class PostViewModel extends ViewModel {
}); });
} }
public PostViewModel(Retrofit retrofit, String accessToken, String accountName, public PostViewModel(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName, SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName,
int postType, SortType sortType, PostFilter postFilter, int postType, SortType sortType, PostFilter postFilter,
List<ReadPost> readPostList) { List<ReadPost> readPostList) {
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, postDataSourceFactory = new PostDataSourceFactory(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, cache, subredditName, postType, sortType, postFilter, sharedPreferences, cache, subredditName, postType, sortType, postFilter,
readPostList); readPostList);
@ -99,11 +101,11 @@ public class PostViewModel extends ViewModel {
}); });
} }
public PostViewModel(Retrofit retrofit, String accessToken, String accountName, public PostViewModel(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences cache, String username, SharedPreferences sharedPreferences, SharedPreferences cache, String username,
int postType, SortType sortType, PostFilter postFilter, String where, int postType, SortType sortType, PostFilter postFilter, String where,
List<ReadPost> readPostList) { List<ReadPost> readPostList) {
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, postDataSourceFactory = new PostDataSourceFactory(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, cache, username, postType, sortType, postFilter, where, readPostList); sharedPreferences, cache, username, postType, sortType, postFilter, where, readPostList);
initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(), initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
@ -133,10 +135,10 @@ public class PostViewModel extends ViewModel {
}); });
} }
public PostViewModel(Retrofit retrofit, String accessToken, String accountName, public PostViewModel(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName, SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName,
String query, int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { String query, int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, postDataSourceFactory = new PostDataSourceFactory(executor, handler, retrofit, accessToken, accountName,
sharedPreferences, cache, subredditName, query, postType, sortType, postFilter, sharedPreferences, cache, subredditName, query, postType, sortType, postFilter,
readPostList); readPostList);
@ -200,6 +202,8 @@ public class PostViewModel extends ViewModel {
} }
public static class Factory extends ViewModelProvider.NewInstanceFactory { public static class Factory extends ViewModelProvider.NewInstanceFactory {
private Executor executor;
private Handler handler;
private Retrofit retrofit; private Retrofit retrofit;
private String accessToken; private String accessToken;
private String accountName; private String accountName;
@ -213,9 +217,11 @@ public class PostViewModel extends ViewModel {
private String userWhere; private String userWhere;
private List<ReadPost> readPostList; private List<ReadPost> readPostList;
public Factory(Retrofit retrofit, String accessToken, String accountName, public Factory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -227,10 +233,11 @@ public class PostViewModel extends ViewModel {
this.readPostList = readPostList; this.readPostList = readPostList;
} }
public Factory(Retrofit retrofit, String accessToken, String accountName, public Factory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postFeedScrolledPositionSharedPreferences, String name, String name, int postType, SortType sortType, PostFilter postFilter,
int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { List<ReadPost> readPostList) {this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -244,9 +251,12 @@ public class PostViewModel extends ViewModel {
} }
//User posts //User posts
public Factory(Retrofit retrofit, String accessToken, String accountName, public Factory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String username, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
int postType, SortType sortType, PostFilter postFilter, String where, List<ReadPost> readPostList) { String username, int postType, SortType sortType, PostFilter postFilter, String where,
List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -260,9 +270,12 @@ public class PostViewModel extends ViewModel {
this.readPostList = readPostList; this.readPostList = readPostList;
} }
public Factory(Retrofit retrofit, String accessToken, String accountName, public Factory(Executor executor, Handler handler, Retrofit retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String name, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String query, int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { String name, String query, int postType, SortType sortType, PostFilter postFilter,
List<ReadPost> readPostList) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.accountName = accountName; this.accountName = accountName;
@ -277,8 +290,10 @@ public class PostViewModel extends ViewModel {
} }
//Anonymous Front Page //Anonymous Front Page
public Factory(Retrofit retrofit, SharedPreferences sharedPreferences, String concatenatedSubredditNames, public Factory(Executor executor, Handler handler, Retrofit retrofit, SharedPreferences sharedPreferences,
int postType, SortType sortType, PostFilter postFilter) { String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter) {
this.executor = executor;
this.handler = handler;
this.retrofit = retrofit; this.retrofit = retrofit;
this.sharedPreferences = sharedPreferences; this.sharedPreferences = sharedPreferences;
this.name = concatenatedSubredditNames; this.name = concatenatedSubredditNames;
@ -291,22 +306,22 @@ public class PostViewModel extends ViewModel {
@Override @Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
if (postType == PostDataSource.TYPE_FRONT_PAGE) { if (postType == PostDataSource.TYPE_FRONT_PAGE) {
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences, return (T) new PostViewModel(executor, handler, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postType, sortType, postFilter, readPostList); postFeedScrolledPositionSharedPreferences, postType, sortType, postFilter, readPostList);
} else if (postType == PostDataSource.TYPE_SEARCH) { } else if (postType == PostDataSource.TYPE_SEARCH) {
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences, return (T) new PostViewModel(executor, handler, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, name, query, postType, sortType, postFeedScrolledPositionSharedPreferences, name, query, postType, sortType,
postFilter, readPostList); postFilter, readPostList);
} else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) { } else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) {
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences, return (T) new PostViewModel(executor, handler, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, name, postType, sortType, postFeedScrolledPositionSharedPreferences, name, postType, sortType,
postFilter, readPostList); postFilter, readPostList);
} else if (postType == PostDataSource.TYPE_ANONYMOUS_FRONT_PAGE) { } else if (postType == PostDataSource.TYPE_ANONYMOUS_FRONT_PAGE) {
return (T) new PostViewModel(retrofit, null, null, sharedPreferences, return (T) new PostViewModel(executor, handler, retrofit, null, null, sharedPreferences,
null, name, postType, sortType, null, name, postType, sortType,
postFilter, null); postFilter, null);
} else { } else {
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences, return (T) new PostViewModel(executor, handler, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, name, postType, sortType, postFeedScrolledPositionSharedPreferences, name, postType, sortType,
postFilter, userWhere, readPostList); postFilter, userWhere, readPostList);
} }

View File

@ -30,7 +30,7 @@ public class MaterialYouUtils {
if (wallpaperColors != null) { if (wallpaperColors != null) {
int colorPrimaryInt = shiftColorTo255(wallpaperColors.getPrimaryColor().toArgb(), 0.4); int colorPrimaryInt = shiftColorTo255(wallpaperColors.getPrimaryColor().toArgb(), 0.4);
int colorPrimaryDarkInt = shiftColorTo0(colorPrimaryInt, 0.4); int colorPrimaryDarkInt = shiftColorTo0(colorPrimaryInt, 0.3);
int backgroundColor = shiftColorTo255(colorPrimaryInt, 0.6); int backgroundColor = shiftColorTo255(colorPrimaryInt, 0.6);
int cardViewBackgroundColor = shiftColorTo255(colorPrimaryInt, 0.9); int cardViewBackgroundColor = shiftColorTo255(colorPrimaryInt, 0.9);
Color colorAccent = wallpaperColors.getSecondaryColor(); Color colorAccent = wallpaperColors.getSecondaryColor();
@ -62,7 +62,7 @@ public class MaterialYouUtils {
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR, colorPrimaryAppropriateTextColor) .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR, colorPrimaryAppropriateTextColor)
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR, colorPrimaryAppropriateTextColor) .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR, colorPrimaryAppropriateTextColor)
.putInt(CustomThemeSharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND, colorPrimaryInt) .putInt(CustomThemeSharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND, colorPrimaryInt)
.putBoolean(CustomThemeSharedPreferencesUtils.LIGHT_STATUS_BAR, getAppropriateTextColor(colorPrimaryDarkInt) == Color.toArgb(Color.BLACK)) .putBoolean(CustomThemeSharedPreferencesUtils.LIGHT_STATUS_BAR, getAppropriateTextColor(colorPrimaryInt) == Color.toArgb(Color.BLACK))
.apply(); .apply();
darkThemeSharedPreferences.edit() darkThemeSharedPreferences.edit()
.putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorPrimaryInt) .putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorPrimaryInt)

View File

@ -86,7 +86,7 @@
<com.google.android.exoplayer2.ui.DefaultTimeBar <com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress" android:id="@id/exo_progress"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="26dp" android:layout_height="24dp"
app:bar_height="2dp" /> app:bar_height="2dp" />
</LinearLayout> </LinearLayout>