mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-02 14:27:10 +01:00
SearchUsersResultActivity is added.
This commit is contained in:
parent
9e062126d8
commit
a809cb59c2
@ -32,7 +32,9 @@
|
|||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:replace="android:label">
|
tools:replace="android:label">
|
||||||
<activity android:name=".activities.PostFilterUsageListingActivity"
|
<activity android:name=".activities.SearchUsersResultActivity"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".activities.PostFilterUsageListingActivity"
|
||||||
android:parentActivityName=".activities.SettingsActivity"
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
|
@ -33,6 +33,7 @@ import ml.docilealligator.infinityforreddit.activities.RulesActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.activities.SearchActivity;
|
import ml.docilealligator.infinityforreddit.activities.SearchActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SearchResultActivity;
|
import ml.docilealligator.infinityforreddit.activities.SearchResultActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity;
|
import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.SearchUsersResultActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SelectUserFlairActivity;
|
import ml.docilealligator.infinityforreddit.activities.SelectUserFlairActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SelectedSubredditsActivity;
|
import ml.docilealligator.infinityforreddit.activities.SelectedSubredditsActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SendPrivateMessageActivity;
|
import ml.docilealligator.infinityforreddit.activities.SendPrivateMessageActivity;
|
||||||
@ -236,4 +237,6 @@ public interface AppComponent {
|
|||||||
void inject(PostFilterPreferenceActivity postFilterPreferenceActivity);
|
void inject(PostFilterPreferenceActivity postFilterPreferenceActivity);
|
||||||
|
|
||||||
void inject(PostFilterUsageListingActivity postFilterUsageListingActivity);
|
void inject(PostFilterUsageListingActivity postFilterUsageListingActivity);
|
||||||
|
|
||||||
|
void inject(SearchUsersResultActivity searchUsersResultActivity);
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
SubredditListingFragment mFragment = new SubredditListingFragment();
|
SubredditListingFragment mFragment = new SubredditListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_QUERY, mQuery);
|
bundle.putString(SubredditListingFragment.EXTRA_QUERY, mQuery);
|
||||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_POSTING, false);
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, false);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
mFragment.setArguments(bundle);
|
mFragment.setArguments(bundle);
|
||||||
@ -702,6 +702,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
UserListingFragment mFragment = new UserListingFragment();
|
UserListingFragment mFragment = new UserListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(UserListingFragment.EXTRA_QUERY, mQuery);
|
bundle.putString(UserListingFragment.EXTRA_QUERY, mQuery);
|
||||||
|
bundle.putBoolean(UserListingFragment.EXTRA_IS_GETTING_USER_INFO, false);
|
||||||
bundle.putString(UserListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(UserListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(UserListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
bundle.putString(UserListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
mFragment.setArguments(bundle);
|
mFragment.setArguments(bundle);
|
||||||
|
@ -43,7 +43,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
|||||||
|
|
||||||
static final String EXTRA_QUERY = "EQ";
|
static final String EXTRA_QUERY = "EQ";
|
||||||
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
||||||
static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIU";
|
||||||
|
|
||||||
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||||
private static final String ACCESS_TOKEN_STATE = "ATS";
|
private static final String ACCESS_TOKEN_STATE = "ATS";
|
||||||
@ -157,7 +157,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
|||||||
mFragment = new SubredditListingFragment();
|
mFragment = new SubredditListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_QUERY, query);
|
bundle.putString(SubredditListingFragment.EXTRA_QUERY, query);
|
||||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_POSTING, true);
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, true);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
mFragment.setArguments(bundle);
|
mFragment.setArguments(bundle);
|
||||||
|
@ -0,0 +1,200 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
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.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.UserListingFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
public class SearchUsersResultActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
|
|
||||||
|
static final String EXTRA_QUERY = "EQ";
|
||||||
|
static final String EXTRA_RETURN_USER_NAME = "ERUN";
|
||||||
|
static final String EXTRA_RETURN_USER_ICON_URL = "ERUIU";
|
||||||
|
|
||||||
|
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||||
|
private static final String ACCESS_TOKEN_STATE = "ATS";
|
||||||
|
private static final String ACCOUNT_NAME_STATE = "ANS";
|
||||||
|
private static final String FRAGMENT_OUT_STATE = "FOS";
|
||||||
|
|
||||||
|
@BindView(R.id.coordinator_layout_search_subreddits_result_activity)
|
||||||
|
CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.appbar_layout_search_subreddits_result_activity)
|
||||||
|
AppBarLayout appBarLayout;
|
||||||
|
@BindView(R.id.toolbar_search_subreddits_result_activity)
|
||||||
|
Toolbar toolbar;
|
||||||
|
Fragment mFragment;
|
||||||
|
@Inject
|
||||||
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences mSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor mExecutor;
|
||||||
|
private boolean mNullAccessToken = false;
|
||||||
|
private String mAccessToken;
|
||||||
|
private String mAccountName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_search_users_result);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
|
|
||||||
|
applyCustomTheme();
|
||||||
|
|
||||||
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||||
|
Slidr.attach(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
Window window = getWindow();
|
||||||
|
|
||||||
|
if (isChangeStatusBarIconColor()) {
|
||||||
|
addOnOffsetChangedListener(appBarLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isImmersiveInterface()) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||||
|
} else {
|
||||||
|
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||||
|
}
|
||||||
|
adjustToolbar(toolbar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setToolbarGoToTop(toolbar);
|
||||||
|
|
||||||
|
String query = getIntent().getExtras().getString(EXTRA_QUERY);
|
||||||
|
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
getCurrentAccountAndInitializeFragment(query);
|
||||||
|
} else {
|
||||||
|
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||||
|
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
||||||
|
mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
|
||||||
|
|
||||||
|
if (!mNullAccessToken && mAccessToken == null) {
|
||||||
|
getCurrentAccountAndInitializeFragment(query);
|
||||||
|
} else {
|
||||||
|
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
return mSharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||||
|
return mCustomThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCustomTheme() {
|
||||||
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
|
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getCurrentAccountAndInitializeFragment(String query) {
|
||||||
|
GetCurrentAccount.getCurrentAccount(mExecutor, new Handler(), mRedditDataRoomDatabase, account -> {
|
||||||
|
if (account == null) {
|
||||||
|
mNullAccessToken = true;
|
||||||
|
} else {
|
||||||
|
mAccessToken = account.getAccessToken();
|
||||||
|
mAccountName = account.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
mFragment = new UserListingFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(UserListingFragment.EXTRA_QUERY, query);
|
||||||
|
bundle.putBoolean(UserListingFragment.EXTRA_IS_GETTING_USER_INFO, true);
|
||||||
|
bundle.putString(UserListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
|
bundle.putString(UserListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
|
mFragment.setArguments(bundle);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSelectedUser(String name, String iconUrl) {
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_USER_NAME, name);
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_USER_ICON_URL, iconUrl);
|
||||||
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
|
||||||
|
outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);
|
||||||
|
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
|
||||||
|
outState.putString(ACCOUNT_NAME_STATE, mAccountName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongPress() {
|
||||||
|
if (mFragment != null) {
|
||||||
|
((UserListingFragment) mFragment).goBackToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -71,6 +71,9 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_send_private_message);
|
setContentView(R.layout.activity_send_private_message);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.adapters;
|
package ml.docilealligator.infinityforreddit.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -26,11 +25,10 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUserAsyncTask;
|
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUserAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserDao;
|
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserDao;
|
||||||
import ml.docilealligator.infinityforreddit.user.UserData;
|
import ml.docilealligator.infinityforreddit.user.UserData;
|
||||||
import ml.docilealligator.infinityforreddit.user.UserFollowing;
|
import ml.docilealligator.infinityforreddit.user.UserFollowing;
|
||||||
@ -67,12 +65,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
|||||||
private int unsubscribedColor;
|
private int unsubscribedColor;
|
||||||
|
|
||||||
private NetworkState networkState;
|
private NetworkState networkState;
|
||||||
private UserListingRecyclerViewAdapter.RetryLoadingMoreCallback retryLoadingMoreCallback;
|
private final Callback callback;
|
||||||
|
|
||||||
public UserListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
|
public UserListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
|
||||||
CustomThemeWrapper customThemeWrapper, String accessToken,
|
CustomThemeWrapper customThemeWrapper, String accessToken,
|
||||||
String accountName, SubscribedUserDao subscribedUserDao,
|
String accountName, SubscribedUserDao subscribedUserDao,
|
||||||
UserListingRecyclerViewAdapter.RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
Callback callback) {
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.oauthRetrofit = oauthRetrofit;
|
this.oauthRetrofit = oauthRetrofit;
|
||||||
@ -80,7 +78,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
|||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.accountName = accountName;
|
this.accountName = accountName;
|
||||||
this.subscribedUserDao = subscribedUserDao;
|
this.subscribedUserDao = subscribedUserDao;
|
||||||
this.retryLoadingMoreCallback = retryLoadingMoreCallback;
|
this.callback = callback;
|
||||||
glide = Glide.with(context);
|
glide = Glide.with(context);
|
||||||
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
buttonTextColor = customThemeWrapper.getButtonTextColor();
|
buttonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
@ -110,9 +108,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
|||||||
UserData userData = getItem(position);
|
UserData userData = getItem(position);
|
||||||
if (userData != null) {
|
if (userData != null) {
|
||||||
((UserListingRecyclerViewAdapter.DataViewHolder) holder).constraintLayout.setOnClickListener(view -> {
|
((UserListingRecyclerViewAdapter.DataViewHolder) holder).constraintLayout.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(context, ViewUserDetailActivity.class);
|
callback.userSelected(userData.getName(), userData.getIconUrl());
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userData.getName());
|
|
||||||
context.startActivity(intent);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!userData.getIconUrl().equals("")) {
|
if (!userData.getIconUrl().equals("")) {
|
||||||
@ -211,8 +207,10 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RetryLoadingMoreCallback {
|
public interface Callback {
|
||||||
void retryLoadingMore();
|
void retryLoadingMore();
|
||||||
|
|
||||||
|
void userSelected(String username, String iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DataViewHolder extends RecyclerView.ViewHolder {
|
class DataViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -242,7 +240,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
|||||||
ErrorViewHolder(View itemView) {
|
ErrorViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
retryButton.setOnClickListener(view -> retryLoadingMoreCallback.retryLoadingMore());
|
retryButton.setOnClickListener(view -> callback.retryLoadingMore());
|
||||||
errorTextView.setText(R.string.load_comments_failed);
|
errorTextView.setText(R.string.load_comments_failed);
|
||||||
errorTextView.setTextColor(primaryTextColor);
|
errorTextView.setTextColor(primaryTextColor);
|
||||||
retryButton.setTextColor(buttonTextColor);
|
retryButton.setTextColor(buttonTextColor);
|
||||||
|
@ -53,7 +53,7 @@ import retrofit2.Retrofit;
|
|||||||
public class SubredditListingFragment extends Fragment implements FragmentCommunicator {
|
public class SubredditListingFragment extends Fragment implements FragmentCommunicator {
|
||||||
|
|
||||||
public static final String EXTRA_QUERY = "EQ";
|
public static final String EXTRA_QUERY = "EQ";
|
||||||
public static final String EXTRA_IS_POSTING = "EIP";
|
public static final String EXTRA_IS_GETTING_SUBREDDIT_INFO = "EIGSI";
|
||||||
public static final String EXTRA_ACCESS_TOKEN = "EAT";
|
public static final String EXTRA_ACCESS_TOKEN = "EAT";
|
||||||
public static final String EXTRA_ACCOUNT_NAME = "EAN";
|
public static final String EXTRA_ACCOUNT_NAME = "EAN";
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
mSubredditListingRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mSubredditListingRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
|
|
||||||
String query = getArguments().getString(EXTRA_QUERY);
|
String query = getArguments().getString(EXTRA_QUERY);
|
||||||
boolean isPosting = getArguments().getBoolean(EXTRA_IS_POSTING);
|
boolean isGettingSubredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_SUBREDDIT_INFO);
|
||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subredditSelected(String subredditName, String iconUrl) {
|
public void subredditSelected(String subredditName, String iconUrl) {
|
||||||
if (isPosting) {
|
if (isGettingSubredditInfo) {
|
||||||
((SearchSubredditsResultActivity) mActivity).getSelectedSubreddit(subredditName, iconUrl);
|
((SearchSubredditsResultActivity) mActivity).getSelectedSubreddit(subredditName, iconUrl);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.fragments;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -37,6 +38,8 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.SearchUsersResultActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.adapters.UserListingRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.adapters.UserListingRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.user.UserListingViewModel;
|
import ml.docilealligator.infinityforreddit.user.UserListingViewModel;
|
||||||
@ -50,6 +53,7 @@ import retrofit2.Retrofit;
|
|||||||
public class UserListingFragment extends Fragment implements FragmentCommunicator {
|
public class UserListingFragment extends Fragment implements FragmentCommunicator {
|
||||||
|
|
||||||
public static final String EXTRA_QUERY = "EQ";
|
public static final String EXTRA_QUERY = "EQ";
|
||||||
|
public static final String EXTRA_IS_GETTING_USER_INFO = "EIGUI";
|
||||||
public static final String EXTRA_ACCESS_TOKEN = "EAT";
|
public static final String EXTRA_ACCESS_TOKEN = "EAT";
|
||||||
public static final String EXTRA_ACCOUNT_NAME = "EAN";
|
public static final String EXTRA_ACCOUNT_NAME = "EAN";
|
||||||
|
|
||||||
@ -124,6 +128,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
mUserListingRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mUserListingRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
|
|
||||||
mQuery = getArguments().getString(EXTRA_QUERY);
|
mQuery = getArguments().getString(EXTRA_QUERY);
|
||||||
|
boolean isGettingUserInfo = getArguments().getBoolean(EXTRA_IS_GETTING_USER_INFO);
|
||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, SortType.Type.RELEVANCE.value);
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, SortType.Type.RELEVANCE.value);
|
||||||
@ -132,7 +137,23 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
|
|
||||||
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
||||||
customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase.subscribedUserDao(),
|
customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase.subscribedUserDao(),
|
||||||
() -> mUserListingViewModel.retryLoadingMore());
|
new UserListingRecyclerViewAdapter.Callback() {
|
||||||
|
@Override
|
||||||
|
public void retryLoadingMore() {
|
||||||
|
mUserListingViewModel.retryLoadingMore();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void userSelected(String username, String iconUrl) {
|
||||||
|
if (isGettingUserInfo) {
|
||||||
|
((SearchUsersResultActivity) mActivity).getSelectedUser(username, iconUrl);
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, username);
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mUserListingRecyclerView.setAdapter(mAdapter);
|
mUserListingRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
32
app/src/main/res/layout/activity_search_users_result.xml
Normal file
32
app/src/main/res/layout/activity_search_users_result.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/coordinator_layout_search_users_result_activity"
|
||||||
|
tools:application=".SearchUsersResultActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar_layout_search_users_result_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_search_users_result_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frame_layout_search_users_result_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -993,7 +993,7 @@
|
|||||||
<string name="subreddit">Subreddit</string>
|
<string name="subreddit">Subreddit</string>
|
||||||
<string name="user">User</string>
|
<string name="user">User</string>
|
||||||
<string name="edit_post_filter_name_of_usage_info">Leave it blank to apply this post filter to all the subreddits / users / multireddits</string>
|
<string name="edit_post_filter_name_of_usage_info">Leave it blank to apply this post filter to all the subreddits / users / multireddits</string>
|
||||||
|
|
||||||
<string name="read_all_messages_time_limit">You are doing this too frequently. Try again later. This is Reddit API\'s rate limit.</string>
|
<string name="read_all_messages_time_limit">You are doing this too frequently. Try again later. This is Reddit API\'s rate limit.</string>
|
||||||
<string name="read_all_messages_success">Read all messages successfully</string>
|
<string name="read_all_messages_success">Read all messages successfully</string>
|
||||||
<string name="read_all_messages_failed">Unable to read all messages</string>
|
<string name="read_all_messages_failed">Unable to read all messages</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user