mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Rewrite getting current account from database to use an Executor.
This commit is contained in:
parent
9589ec5192
commit
f2d35eeb18
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -22,25 +23,27 @@ import com.r0adkll.slidr.Slidr;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
||||
public class AccountPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
@ -72,6 +75,8 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
SharedPreferences mPostLayoutSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean isInLazyMode = false;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
@ -181,7 +186,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeFragment() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -189,7 +194,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
initializeFragment();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeFragment() {
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -43,7 +44,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
@ -191,7 +192,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeViewPager() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -199,7 +200,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
initializeViewPager();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeViewPager() {
|
||||
|
@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.SuperscriptSpan;
|
||||
import android.text.util.Linkify;
|
||||
@ -32,6 +33,8 @@ import org.commonmark.ext.gfm.tables.TableBlock;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@ -48,7 +51,7 @@ import io.noties.markwon.recycler.table.TableEntry;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.comment.Comment;
|
||||
import ml.docilealligator.infinityforreddit.comment.SendComment;
|
||||
@ -102,6 +105,8 @@ public class CommentActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String parentFullname;
|
||||
@ -292,13 +297,13 @@ public class CommentActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -23,19 +24,20 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -78,6 +80,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -125,7 +129,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
Toast.makeText(this, R.string.logged_out, Toast.LENGTH_SHORT).show();
|
||||
@ -135,7 +139,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
||||
mAccountName = account.getUsername();
|
||||
bindView();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -24,20 +25,22 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.EditMultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.FetchMultiRedditInfo;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -85,6 +88,8 @@ public class EditMultiRedditActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -134,7 +139,7 @@ public class EditMultiRedditActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
Toast.makeText(this, R.string.logged_out, Toast.LENGTH_SHORT).show();
|
||||
@ -144,7 +149,7 @@ public class EditMultiRedditActivity extends BaseActivity {
|
||||
mAccountName = account.getUsername();
|
||||
bindView();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -40,7 +41,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FilteredThingFABMoreOptionsBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchPostSortTypeBottomSheetFragment;
|
||||
@ -277,7 +278,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView(PostFilter postFilter) {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -285,7 +286,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
bindView(postFilter, true);
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView(PostFilter postFilter, boolean initializeFragment) {
|
||||
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -25,18 +26,20 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.adapters.AwardRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.award.GiveAward;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.adapters.AwardRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.award.GiveAward;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -68,6 +71,8 @@ public class GiveAwardActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private String thingFullname;
|
||||
private int itemPosition;
|
||||
private boolean mNullAccessToken = false;
|
||||
@ -118,14 +123,14 @@ public class GiveAwardActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
bindView();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -29,21 +30,23 @@ import com.r0adkll.slidr.model.SlidrInterface;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.InboxFragment;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.message.FetchMessage;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -78,6 +81,8 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private boolean mNullAccessToken = false;
|
||||
@ -159,7 +164,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (mNewAccountName != null) {
|
||||
if (account == null || !account.getUsername().equals(mNewAccountName)) {
|
||||
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
|
||||
@ -188,7 +193,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
|
||||
bindView(savedInstanceState);
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView(Bundle savedInstanceState) {
|
||||
|
@ -8,6 +8,7 @@ import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@ -79,7 +80,7 @@ import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.account.AccountViewModel;
|
||||
import ml.docilealligator.infinityforreddit.adapters.NavigationDrawerRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThingsAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchToAnonymousAccountAsyncTask;
|
||||
@ -358,7 +359,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
boolean enableNotification = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_NOTIFICATION_KEY, true);
|
||||
long notificationInterval = Long.parseLong(mSharedPreferences.getString(SharedPreferencesUtils.NOTIFICATION_INTERVAL_KEY, "1"));
|
||||
TimeUnit timeUnit = (notificationInterval == 15 || notificationInterval == 30) ? TimeUnit.MINUTES : TimeUnit.HOURS;
|
||||
@ -457,7 +458,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
bindView();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bottomAppBarOptionAction(int option) {
|
||||
|
@ -8,6 +8,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -39,6 +40,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -46,17 +48,17 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIconAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitImagePostEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitVideoOrGifPostEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
@ -135,6 +137,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -407,14 +411,14 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void loadImage() {
|
||||
|
@ -6,6 +6,7 @@ import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -30,22 +31,24 @@ import com.libRG.CustomTextView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIconAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitTextOrLinkPostEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
@ -111,6 +114,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String iconUrl;
|
||||
@ -343,13 +348,13 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void displaySubredditIcon() {
|
||||
|
@ -6,6 +6,7 @@ import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -32,23 +33,25 @@ import com.libRG.CustomTextView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIconAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitTextOrLinkPostEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
@ -116,6 +119,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String iconUrl;
|
||||
@ -360,13 +365,13 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void displaySubredditIcon() {
|
||||
|
@ -7,6 +7,7 @@ import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -42,22 +43,24 @@ import com.libRG.CustomTextView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIconAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitVideoOrGifPostEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
@ -139,6 +142,8 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -411,14 +416,14 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void loadVideo() {
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
@ -18,15 +19,13 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.adapters.ReportReasonRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.FetchRules;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
@ -34,6 +33,9 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.ReportReason;
|
||||
import ml.docilealligator.infinityforreddit.ReportThing;
|
||||
import ml.docilealligator.infinityforreddit.Rule;
|
||||
import ml.docilealligator.infinityforreddit.adapters.ReportReasonRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -67,6 +69,8 @@ public class ReportActivity extends BaseActivity {
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mFullname;
|
||||
@ -142,13 +146,13 @@ public class ReportActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -28,21 +29,23 @@ import com.r0adkll.slidr.Slidr;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.adapters.SearchActivityRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.adapters.SearchActivityRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.recentsearchquery.DeleteRecentSearchQuery;
|
||||
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery;
|
||||
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQueryViewModel;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
||||
public class SearchActivity extends BaseActivity {
|
||||
@ -89,6 +92,8 @@ public class SearchActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccountName = false;
|
||||
private String mAccountName;
|
||||
private String query;
|
||||
@ -203,14 +208,14 @@ public class SearchActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeViewPager() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccountName = true;
|
||||
} else {
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
bindView();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -35,6 +36,8 @@ import com.r0adkll.slidr.model.SlidrInterface;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@ -48,7 +51,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment;
|
||||
@ -109,6 +112,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
SharedPreferences mNsfwAndSpoilerSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -223,7 +228,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeViewPager() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -231,7 +236,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
bindView();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@ -21,19 +22,21 @@ import com.r0adkll.slidr.Slidr;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
||||
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
@ -61,6 +64,8 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -141,7 +146,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeFragment(String query) {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -157,7 +162,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
mFragment.setArguments(bundle);
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
public void getSelectedSubreddit(String name, String iconUrl) {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -22,6 +23,7 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -29,15 +31,15 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.adapters.UserFlairRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.FetchUserFlairs;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SelectUserFlair;
|
||||
import ml.docilealligator.infinityforreddit.UserFlair;
|
||||
import ml.docilealligator.infinityforreddit.adapters.UserFlairRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -67,6 +69,8 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
@ -120,7 +124,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -128,7 +132,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
bindView();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -16,17 +17,19 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.message.ComposeMessage;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.message.ComposeMessage;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class SendPrivateMessageActivity extends BaseActivity {
|
||||
@ -59,6 +62,8 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private boolean isSubmitting = false;
|
||||
@ -96,13 +101,13 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -17,6 +18,8 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@ -25,7 +28,7 @@ import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
|
||||
import ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment;
|
||||
@ -57,6 +60,8 @@ public class SettingsActivity extends BaseActivity implements
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -101,7 +106,7 @@ public class SettingsActivity extends BaseActivity implements
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView(Bundle savedInstanceState) {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (getSupportFragmentManager().isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
@ -119,7 +124,7 @@ public class SettingsActivity extends BaseActivity implements
|
||||
} else {
|
||||
setTitle(savedInstanceState.getCharSequence(TITLE_STATE));
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -39,6 +40,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -46,17 +48,17 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIconAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitCrosspostEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
@ -127,6 +129,8 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private Post post;
|
||||
@ -414,13 +418,13 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
}
|
||||
|
||||
private void getCurrentAccount() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void displaySubredditIcon() {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -29,6 +30,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -36,12 +38,12 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.adapters.SubredditMultiselectionRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.adapters.SubredditMultiselectionRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditViewModel;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
@ -81,6 +83,8 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
public SubscribedSubredditViewModel mSubscribedSubredditViewModel;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
@ -150,7 +154,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
Toast.makeText(this, R.string.logged_out, Toast.LENGTH_SHORT).show();
|
||||
@ -160,7 +164,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
||||
mAccountName = account.getUsername();
|
||||
bindView();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -24,6 +25,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -31,15 +33,15 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThingsAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThingsAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
|
||||
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData;
|
||||
@ -77,6 +79,8 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -160,7 +164,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -169,7 +173,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
mAccountProfileImageUrl = account.getProfileImageUrl();
|
||||
}
|
||||
bindView(true);
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView(boolean initializeFragment) {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -30,6 +31,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -37,24 +39,24 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
|
||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultiRedditAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThingsAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.GoBackToMainPageEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.RefreshMultiRedditsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
|
||||
import ml.docilealligator.infinityforreddit.fragments.FollowedUsersListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.fragments.MultiRedditListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.DeleteMultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.FetchMyMultiReddits;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
|
||||
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData;
|
||||
@ -92,6 +94,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
@ -185,7 +189,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeViewPager() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -193,7 +197,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
initializeViewPagerAndLoadSubscriptions();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeViewPagerAndLoadSubscriptions() {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -38,7 +39,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment;
|
||||
@ -188,7 +189,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeFragment() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -196,7 +197,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
initializeFragment();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeFragment() {
|
||||
|
@ -8,6 +8,7 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.KeyEvent;
|
||||
@ -55,6 +56,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -64,10 +66,18 @@ import butterknife.ButterKnife;
|
||||
import im.ene.toro.exoplayer.ExoCreator;
|
||||
import im.ene.toro.media.PlaybackInfo;
|
||||
import im.ene.toro.media.VolumeInfo;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.DeleteThing;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.adapters.CommentAndPostRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostCommentSortTypeBottomSheetFragment;
|
||||
@ -77,26 +87,18 @@ import ml.docilealligator.infinityforreddit.comment.FetchRemovedComment;
|
||||
import ml.docilealligator.infinityforreddit.comment.ParseComment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.CustomToroContainer;
|
||||
import ml.docilealligator.infinityforreddit.DeleteThing;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWBlurEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNetworkStatusEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeSpoilerBlurEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToDetailActivity;
|
||||
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostList;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.Flair;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
||||
import ml.docilealligator.infinityforreddit.post.FetchPost;
|
||||
import ml.docilealligator.infinityforreddit.post.FetchRemovedPost;
|
||||
import ml.docilealligator.infinityforreddit.post.HidePost;
|
||||
import ml.docilealligator.infinityforreddit.post.ParsePost;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
|
||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
@ -206,6 +208,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
ExoCreator mExoCreator;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private RequestManager mGlide;
|
||||
private Locale mLocale;
|
||||
private Menu mMenu;
|
||||
@ -589,7 +593,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (mNewAccountName != null) {
|
||||
if (account == null || !account.getUsername().equals(mNewAccountName)) {
|
||||
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
|
||||
@ -621,7 +625,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
||||
|
||||
bindView();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
@ -24,6 +25,7 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -31,17 +33,17 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.adapters.PrivateMessagesDetailRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadUserDataAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.RepliedToPrivateMessageEvent;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.message.Message;
|
||||
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
||||
import ml.docilealligator.infinityforreddit.message.ReplyMessage;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewPrivateMessagesActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
@ -83,6 +85,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
private PrivateMessagesDetailRecyclerViewAdapter mAdapter;
|
||||
private Message privateMessage;
|
||||
@ -139,7 +143,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
@ -147,7 +151,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
mAccountName = account.getUsername();
|
||||
}
|
||||
bindView();
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
|
@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@ -70,7 +71,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubredditAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditDataAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||
@ -490,7 +491,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (mNewAccountName != null) {
|
||||
if (account == null || !account.getUsername().equals(mNewAccountName)) {
|
||||
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
|
||||
@ -522,7 +523,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
|
||||
bindView();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void fetchSubredditData() {
|
||||
|
@ -9,6 +9,7 @@ import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@ -74,7 +75,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUserAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
@ -557,7 +558,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeViewPager() {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (mNewAccountName != null) {
|
||||
if (account == null || !account.getUsername().equals(mNewAccountName)) {
|
||||
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
|
||||
@ -589,7 +590,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
initializeViewPager();
|
||||
}
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeViewPager() {
|
||||
|
@ -0,0 +1,23 @@
|
||||
package ml.docilealligator.infinityforreddit.asynctasks;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.account.Account;
|
||||
|
||||
public class GetCurrentAccount {
|
||||
|
||||
public static void getCurrentAccount(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
GetCurrentAccountAsyncTaskListener getCurrentAccountAsyncTaskListener) {
|
||||
executor.execute(() -> {
|
||||
Account account = redditDataRoomDatabase.accountDao().getCurrentAccount();
|
||||
handler.post(() -> getCurrentAccountAsyncTaskListener.success(account));
|
||||
});
|
||||
}
|
||||
|
||||
public interface GetCurrentAccountAsyncTaskListener {
|
||||
void success(Account account);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package ml.docilealligator.infinityforreddit.asynctasks;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.account.Account;
|
||||
import ml.docilealligator.infinityforreddit.account.AccountDao;
|
||||
|
||||
public class GetCurrentAccountAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Account account;
|
||||
private AccountDao accountDao;
|
||||
private GetCurrentAccountAsyncTaskListener getCurrentAccountAsyncTaskListener;
|
||||
|
||||
public GetCurrentAccountAsyncTask(AccountDao accountDao, GetCurrentAccountAsyncTaskListener getCurrentAccountAsyncTaskListener) {
|
||||
this.accountDao = accountDao;
|
||||
this.getCurrentAccountAsyncTaskListener = getCurrentAccountAsyncTaskListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
account = accountDao.getCurrentAccount();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
getCurrentAccountAsyncTaskListener.success(account);
|
||||
}
|
||||
|
||||
public interface GetCurrentAccountAsyncTaskListener {
|
||||
void success(Account account);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -31,6 +32,8 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@ -45,7 +48,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
||||
import ml.docilealligator.infinityforreddit.adapters.CommentsListingRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||
import ml.docilealligator.infinityforreddit.comment.CommentViewModel;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
@ -98,6 +101,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
SharedPreferences mPostLayoutSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper customThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private RequestManager mGlide;
|
||||
@ -260,14 +265,14 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndBindView(Resources resources) {
|
||||
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
|
||||
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||
if (account == null) {
|
||||
mNullAccessToken = true;
|
||||
} else {
|
||||
mAccessToken = account.getAccessToken();
|
||||
}
|
||||
bindView(resources);
|
||||
}).execute();
|
||||
});
|
||||
}
|
||||
|
||||
private void bindView(Resources resources) {
|
||||
|
Loading…
Reference in New Issue
Block a user