mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-24 05:23:56 +01:00
Fixed vote failed message not shown. Fixed subreddit icon not load online if the subreddit info is not in the database.
This commit is contained in:
parent
8940d4da68
commit
b42db1fbfe
@ -201,7 +201,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||||||
}
|
}
|
||||||
mLoadSubredditIconAsyncTask = new LoadSubredditIconAsyncTask(
|
mLoadSubredditIconAsyncTask = new LoadSubredditIconAsyncTask(
|
||||||
SubredditRoomDatabase.getDatabase(mActivity).subredditDao(), mPost.getSubredditNamePrefixed().substring(2),
|
SubredditRoomDatabase.getDatabase(mActivity).subredditDao(), mPost.getSubredditNamePrefixed().substring(2),
|
||||||
iconImageUrl -> {
|
mRetrofit, iconImageUrl -> {
|
||||||
if(!iconImageUrl.equals("")) {
|
if(!iconImageUrl.equals("")) {
|
||||||
mGlide.load(iconImageUrl)
|
mGlide.load(iconImageUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
@ -22,8 +22,7 @@ public class FetchUserData {
|
|||||||
void onFetchUserListingDataFailed();
|
void onFetchUserListingDataFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fetchUserData(final Retrofit retrofit, String userName,
|
public static void fetchUserData(Retrofit retrofit, String userName, FetchUserDataListener fetchUserDataListener) {
|
||||||
final FetchUserDataListener fetchUserDataListener) {
|
|
||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Call<String> userInfo = api.getUserData(userName);
|
Call<String> userInfo = api.getUserData(userName);
|
||||||
|
@ -2,7 +2,11 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import SubredditDatabase.SubredditDao;
|
import SubredditDatabase.SubredditDao;
|
||||||
|
import SubredditDatabase.SubredditData;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
|
class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
interface LoadSubredditIconAsyncTaskListener {
|
interface LoadSubredditIconAsyncTaskListener {
|
||||||
@ -11,22 +15,27 @@ class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
|
|
||||||
private SubredditDao subredditDao;
|
private SubredditDao subredditDao;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private Retrofit retrofit;
|
||||||
private String iconImageUrl;
|
private String iconImageUrl;
|
||||||
|
private boolean hasSubredditInDb;
|
||||||
private LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener;
|
private LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener;
|
||||||
|
|
||||||
LoadSubredditIconAsyncTask(SubredditDao subredditDao, String subredditName,
|
LoadSubredditIconAsyncTask(SubredditDao subredditDao, String subredditName, Retrofit retrofit,
|
||||||
LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) {
|
LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) {
|
||||||
this.subredditDao = subredditDao;
|
this.subredditDao = subredditDao;
|
||||||
this.subredditName = subredditName;
|
this.subredditName = subredditName;
|
||||||
|
this.retrofit = retrofit;
|
||||||
this.loadSubredditIconAsyncTaskListener = loadSubredditIconAsyncTaskListener;
|
this.loadSubredditIconAsyncTaskListener = loadSubredditIconAsyncTaskListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
if(subredditDao.getSubredditData(subredditName) != null) {
|
SubredditData subredditData = subredditDao.getSubredditData(subredditName);
|
||||||
|
if(subredditData != null) {
|
||||||
iconImageUrl = subredditDao.getSubredditData(subredditName).getIconUrl();
|
iconImageUrl = subredditDao.getSubredditData(subredditName).getIconUrl();
|
||||||
|
hasSubredditInDb = true;
|
||||||
} else {
|
} else {
|
||||||
iconImageUrl = "";
|
hasSubredditInDb = false;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -35,7 +44,25 @@ class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
super.onPostExecute(aVoid);
|
super.onPostExecute(aVoid);
|
||||||
if(!isCancelled()) {
|
if(!isCancelled()) {
|
||||||
loadSubredditIconAsyncTaskListener.loadIconSuccess(iconImageUrl);
|
if(hasSubredditInDb) {
|
||||||
|
loadSubredditIconAsyncTaskListener.loadIconSuccess(iconImageUrl);
|
||||||
|
} else {
|
||||||
|
FetchSubredditData.fetchSubredditData(retrofit, subredditName, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
|
ArrayList<SubredditData> singleSubredditDataList = new ArrayList<>();
|
||||||
|
singleSubredditDataList.add(subredditData);
|
||||||
|
new InsertSubscribedThingsAsyncTask(null, null, subredditDao,
|
||||||
|
null, null, singleSubredditDataList,
|
||||||
|
() -> loadSubredditIconAsyncTaskListener.loadIconSuccess(subredditData.getIconUrl())).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail() {
|
||||||
|
loadSubredditIconAsyncTaskListener.loadIconSuccess(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class LoadUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchUserDataFailed() {
|
public void onFetchUserDataFailed() {
|
||||||
loadUserDataAsyncTaskListener.loadUserDataSuccess("");
|
loadUserDataAsyncTaskListener.loadUserDataSuccess(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,6 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
getPost.enqueue(new Callback<String>() {
|
getPost.enqueue(new Callback<String>() {
|
||||||
@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) {
|
||||||
Log.i("initial", call.request().url().toString());
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
ParsePost.parsePosts(response.body(), locale, -1,
|
ParsePost.parsePosts(response.body(), locale, -1,
|
||||||
new ParsePost.ParsePostsListingListener() {
|
new ParsePost.ParsePostsListingListener() {
|
||||||
@ -518,7 +517,6 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
getPost.enqueue(new Callback<String>() {
|
getPost.enqueue(new Callback<String>() {
|
||||||
@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) {
|
||||||
Log.i("after", call.request().url().toString());
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
ParsePost.parsePosts(response.body(), locale, -1, new ParsePost.ParsePostsListingListener() {
|
ParsePost.parsePosts(response.body(), locale, -1, new ParsePost.ParsePostsListingListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,7 +178,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
String query = getArguments().getString(EXTRA_QUERY);
|
String query = getArguments().getString(EXTRA_QUERY);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit,
|
||||||
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, subredditName, query, postType, sortType, new PostDataSource.OnPostFetchedCallback() {
|
getResources().getConfiguration().locale, subredditName, query, postType, sortType, new PostDataSource.OnPostFetchedCallback() {
|
||||||
@ -199,7 +199,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
|
|
||||||
boolean displaySubredditName = subredditName.equals("popular") || subredditName.equals("all");
|
boolean displaySubredditName = subredditName.equals("popular") || subredditName.equals("all");
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit,
|
||||||
mSharedPreferences, postType, displaySubredditName, () -> mPostViewModel.retryLoadingMore());
|
mSharedPreferences, postType, displaySubredditName, () -> mPostViewModel.retryLoadingMore());
|
||||||
|
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
@ -224,7 +224,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit,
|
||||||
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
||||||
|
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
@ -244,7 +244,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit,
|
||||||
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
||||||
|
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
|
@ -97,6 +97,10 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
Retrofit mRetrofit;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mOauthRetrofit;
|
||||||
@ -288,7 +292,7 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
subredditName, iconImageUrl -> {
|
subredditName, mRetrofit, iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
loadSubredditIconSuccessful = true;
|
loadSubredditIconSuccessful = true;
|
||||||
|
@ -74,6 +74,10 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
Retrofit mRetrofit;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mOauthRetrofit;
|
||||||
@ -215,7 +219,7 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
subredditName, iconImageUrl -> {
|
subredditName, mRetrofit, iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
loadSubredditIconSuccessful = true;
|
loadSubredditIconSuccessful = true;
|
||||||
|
@ -59,6 +59,7 @@ import retrofit2.Retrofit;
|
|||||||
class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHolder> {
|
class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHolder> {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Retrofit mOauthRetrofit;
|
private Retrofit mOauthRetrofit;
|
||||||
|
private Retrofit mRetrofit;
|
||||||
private SharedPreferences mSharedPreferences;
|
private SharedPreferences mSharedPreferences;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private SubredditDao subredditDao;
|
private SubredditDao subredditDao;
|
||||||
@ -78,12 +79,14 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
|||||||
void retryLoadingMore();
|
void retryLoadingMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
PostRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, SharedPreferences sharedPreferences, int postType,
|
PostRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
|
||||||
boolean displaySubredditName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
SharedPreferences sharedPreferences, int postType, boolean displaySubredditName,
|
||||||
|
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
if(context != null) {
|
if(context != null) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mOauthRetrofit = oauthRetrofit;
|
mOauthRetrofit = oauthRetrofit;
|
||||||
|
mRetrofit = retrofit;
|
||||||
mSharedPreferences = sharedPreferences;
|
mSharedPreferences = sharedPreferences;
|
||||||
this.postType = postType;
|
this.postType = postType;
|
||||||
this.displaySubredditName = displaySubredditName;
|
this.displaySubredditName = displaySubredditName;
|
||||||
@ -159,7 +162,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
|||||||
if(displaySubredditName) {
|
if(displaySubredditName) {
|
||||||
if(author.equals(subredditNamePrefixed)) {
|
if(author.equals(subredditNamePrefixed)) {
|
||||||
if(post.getAuthorIconUrl() == null) {
|
if(post.getAuthorIconUrl() == null) {
|
||||||
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mOauthRetrofit, iconImageUrl -> {
|
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mRetrofit, iconImageUrl -> {
|
||||||
if(mContext != null && getItemCount() > 0) {
|
if(mContext != null && getItemCount() > 0) {
|
||||||
if(!iconImageUrl.equals("")) {
|
if(!iconImageUrl.equals("")) {
|
||||||
glide.load(iconImageUrl)
|
glide.load(iconImageUrl)
|
||||||
@ -191,10 +194,12 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(post.getSubredditIconUrl() == null) {
|
if(post.getSubredditIconUrl() == null) {
|
||||||
new LoadSubredditIconAsyncTask(subredditDao, subredditName,
|
new LoadSubredditIconAsyncTask(subredditDao, subredditName, mRetrofit,
|
||||||
iconImageUrl -> {
|
iconImageUrl -> {
|
||||||
if(mContext != null && getItemCount() > 0) {
|
if(mContext != null && getItemCount() > 0) {
|
||||||
if(!iconImageUrl.equals("")) {
|
if(iconImageUrl == null) {
|
||||||
|
|
||||||
|
} else if(!iconImageUrl.equals("")) {
|
||||||
glide.load(iconImageUrl)
|
glide.load(iconImageUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -245,7 +250,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(post.getAuthorIconUrl() == null) {
|
if(post.getAuthorIconUrl() == null) {
|
||||||
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mOauthRetrofit, iconImageUrl -> {
|
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mRetrofit, iconImageUrl -> {
|
||||||
if(mContext != null && getItemCount() > 0) {
|
if(mContext != null && getItemCount() > 0) {
|
||||||
if(!iconImageUrl.equals("")) {
|
if(!iconImageUrl.equals("")) {
|
||||||
glide.load(iconImageUrl)
|
glide.load(iconImageUrl)
|
||||||
|
@ -74,6 +74,10 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
Retrofit mRetrofit;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mOauthRetrofit;
|
||||||
@ -220,7 +224,7 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
subredditName, iconImageUrl -> {
|
subredditName, mRetrofit, iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
loadSubredditIconSuccessful = true;
|
loadSubredditIconSuccessful = true;
|
||||||
|
@ -94,6 +94,10 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
Retrofit mRetrofit;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mOauthRetrofit;
|
||||||
@ -286,7 +290,7 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
subredditName, iconImageUrl -> {
|
subredditName, mRetrofit, iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
loadSubredditIconSuccessful = true;
|
loadSubredditIconSuccessful = true;
|
||||||
|
@ -45,6 +45,28 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
simpleSearchView.setOnSearchViewListener(new SimpleSearchView.SearchViewListener() {
|
||||||
|
@Override
|
||||||
|
public void onSearchViewShown() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchViewClosed() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchViewShownAnimation() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchViewClosedAnimation() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() {
|
simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -42,7 +43,11 @@ class VoteThing {
|
|||||||
voteThingCall.enqueue(new Callback<String>() {
|
voteThingCall.enqueue(new Callback<String>() {
|
||||||
@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) {
|
||||||
voteThingListener.onVoteThingSuccess(position);
|
if(response.isSuccessful()) {
|
||||||
|
voteThingListener.onVoteThingSuccess(position);
|
||||||
|
} else {
|
||||||
|
voteThingListener.onVoteThingFail(position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,7 +73,11 @@ class VoteThing {
|
|||||||
voteThingCall.enqueue(new Callback<String>() {
|
voteThingCall.enqueue(new Callback<String>() {
|
||||||
@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) {
|
||||||
voteThingWithoutPositionListener.onVoteThingSuccess();
|
if(response.isSuccessful()) {
|
||||||
|
voteThingWithoutPositionListener.onVoteThingSuccess();
|
||||||
|
} else {
|
||||||
|
voteThingWithoutPositionListener.onVoteThingFail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user