diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-01-04 09:13:31 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-01-04 09:13:31 +0000 |
commit | a809cb59c27a01e2bbd155809780f187ae52d355 (patch) | |
tree | 08ee3f8a0b97245427e959343e5de8f86ae05f74 /app/src | |
parent | 9e062126d824795821ff76c22edbe39f9dbcf5f8 (diff) | |
download | infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.tar infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.tar.gz infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.tar.bz2 infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.tar.lz infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.tar.xz infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.tar.zst infinity-for-reddit-a809cb59c27a01e2bbd155809780f187ae52d355.zip |
SearchUsersResultActivity is added.
Diffstat (limited to '')
11 files changed, 281 insertions, 21 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 910d92b6..4cd7c035 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,7 +32,9 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" 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:theme="@style/AppTheme.NoActionBar" /> <activity diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index 45b0eba0..d2797aad 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -33,6 +33,7 @@ import ml.docilealligator.infinityforreddit.activities.RulesActivity; import ml.docilealligator.infinityforreddit.activities.SearchActivity; import ml.docilealligator.infinityforreddit.activities.SearchResultActivity; import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity; +import ml.docilealligator.infinityforreddit.activities.SearchUsersResultActivity; import ml.docilealligator.infinityforreddit.activities.SelectUserFlairActivity; import ml.docilealligator.infinityforreddit.activities.SelectedSubredditsActivity; import ml.docilealligator.infinityforreddit.activities.SendPrivateMessageActivity; @@ -236,4 +237,6 @@ public interface AppComponent { void inject(PostFilterPreferenceActivity postFilterPreferenceActivity); void inject(PostFilterUsageListingActivity postFilterUsageListingActivity); + + void inject(SearchUsersResultActivity searchUsersResultActivity); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index f58d010f..2b5b2141 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -692,7 +692,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect SubredditListingFragment mFragment = new SubredditListingFragment(); Bundle bundle = new Bundle(); 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_ACCOUNT_NAME, mAccountName); mFragment.setArguments(bundle); @@ -702,6 +702,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect UserListingFragment mFragment = new UserListingFragment(); Bundle bundle = new Bundle(); 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_ACCOUNT_NAME, mAccountName); mFragment.setArguments(bundle); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java index 270e9728..9caccdae 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java @@ -43,7 +43,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti static final String EXTRA_QUERY = "EQ"; 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 ACCESS_TOKEN_STATE = "ATS"; @@ -157,7 +157,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti mFragment = new SubredditListingFragment(); Bundle bundle = new Bundle(); 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_ACCOUNT_NAME, mAccountName); mFragment.setArguments(bundle); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java new file mode 100644 index 00000000..23dc6fd4 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java @@ -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(); + } + } +}
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java index 9f707702..57744487 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java @@ -71,6 +71,9 @@ public class SendPrivateMessageActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_send_private_message); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserListingRecyclerViewAdapter.java index a7bd4bc3..2fb83bae 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserListingRecyclerViewAdapter.java @@ -1,7 +1,6 @@ package ml.docilealligator.infinityforreddit.adapters; import android.content.Context; -import android.content.Intent; import android.content.res.ColorStateList; import android.view.LayoutInflater; import android.view.View; @@ -26,11 +25,10 @@ import com.bumptech.glide.request.RequestOptions; import butterknife.BindView; import butterknife.ButterKnife; 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.R; +import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUserAsyncTask; +import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserDao; import ml.docilealligator.infinityforreddit.user.UserData; import ml.docilealligator.infinityforreddit.user.UserFollowing; @@ -67,12 +65,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R private int unsubscribedColor; private NetworkState networkState; - private UserListingRecyclerViewAdapter.RetryLoadingMoreCallback retryLoadingMoreCallback; + private final Callback callback; public UserListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit, CustomThemeWrapper customThemeWrapper, String accessToken, String accountName, SubscribedUserDao subscribedUserDao, - UserListingRecyclerViewAdapter.RetryLoadingMoreCallback retryLoadingMoreCallback) { + Callback callback) { super(DIFF_CALLBACK); this.context = context; this.oauthRetrofit = oauthRetrofit; @@ -80,7 +78,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R this.accessToken = accessToken; this.accountName = accountName; this.subscribedUserDao = subscribedUserDao; - this.retryLoadingMoreCallback = retryLoadingMoreCallback; + this.callback = callback; glide = Glide.with(context); primaryTextColor = customThemeWrapper.getPrimaryTextColor(); buttonTextColor = customThemeWrapper.getButtonTextColor(); @@ -110,9 +108,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R UserData userData = getItem(position); if (userData != null) { ((UserListingRecyclerViewAdapter.DataViewHolder) holder).constraintLayout.setOnClickListener(view -> { - Intent intent = new Intent(context, ViewUserDetailActivity.class); - intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userData.getName()); - context.startActivity(intent); + callback.userSelected(userData.getName(), userData.getIconUrl()); }); if (!userData.getIconUrl().equals("")) { @@ -211,8 +207,10 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R } } - public interface RetryLoadingMoreCallback { + public interface Callback { void retryLoadingMore(); + + void userSelected(String username, String iconUrl); } class DataViewHolder extends RecyclerView.ViewHolder { @@ -242,7 +240,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R ErrorViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); - retryButton.setOnClickListener(view -> retryLoadingMoreCallback.retryLoadingMore()); + retryButton.setOnClickListener(view -> callback.retryLoadingMore()); errorTextView.setText(R.string.load_comments_failed); errorTextView.setTextColor(primaryTextColor); retryButton.setTextColor(buttonTextColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java index 2924b393..ef0d7a89 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java @@ -53,7 +53,7 @@ import retrofit2.Retrofit; public class SubredditListingFragment extends Fragment implements FragmentCommunicator { 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_ACCOUNT_NAME = "EAN"; @@ -127,7 +127,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun mSubredditListingRecyclerView.setLayoutManager(mLinearLayoutManager); 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 accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); @@ -145,7 +145,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun @Override public void subredditSelected(String subredditName, String iconUrl) { - if (isPosting) { + if (isGettingSubredditInfo) { ((SearchSubredditsResultActivity) mActivity).getSelectedSubreddit(subredditName, iconUrl); } else { Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java index c663bd63..ecd16441 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java @@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.fragments; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; @@ -37,6 +38,8 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; 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.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.user.UserListingViewModel; @@ -50,6 +53,7 @@ import retrofit2.Retrofit; public class UserListingFragment extends Fragment implements FragmentCommunicator { 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_ACCOUNT_NAME = "EAN"; @@ -124,6 +128,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato mUserListingRecyclerView.setLayoutManager(mLinearLayoutManager); mQuery = getArguments().getString(EXTRA_QUERY); + boolean isGettingUserInfo = getArguments().getBoolean(EXTRA_IS_GETTING_USER_INFO); String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); 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, 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); diff --git a/app/src/main/res/layout/activity_search_users_result.xml b/app/src/main/res/layout/activity_search_users_result.xml new file mode 100644 index 00000000..b594ccb5 --- /dev/null +++ b/app/src/main/res/layout/activity_search_users_result.xml @@ -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>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5aa5353..9658a65a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -993,7 +993,7 @@ <string name="subreddit">Subreddit</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="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_failed">Unable to read all messages</string> |