mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 02:48:23 +01:00
Multiple bug fixes
Fixes issue #6 Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
parent
4fe4b1e692
commit
4d1822aaae
@ -123,6 +123,7 @@ import eu.toldi.infinityforlemmy.user.FetchUserData;
|
||||
import eu.toldi.infinityforlemmy.user.UserData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Call;
|
||||
@ -864,12 +865,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
drawer.closeDrawers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribedSubredditClick(String subredditName) {
|
||||
Intent intent = new Intent(MainActivity.this, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
||||
startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void onSubscribedSubredditClick(String subredditName, String communityQualifiedName) {
|
||||
Intent intent = new Intent(MainActivity.this, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityQualifiedName);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountClick(String accountName) {
|
||||
@ -974,7 +976,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
});
|
||||
|
||||
subscribedSubredditViewModel = new ViewModelProvider(this,
|
||||
new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
|
||||
new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountQualifiedName == null ? "-" : mAccountQualifiedName))
|
||||
.get(SubscribedSubredditViewModel.class);
|
||||
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
|
||||
subscribedSubredditData -> {
|
||||
@ -1405,6 +1407,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
Utils.hideKeyboard(this);
|
||||
Intent intent = new Intent(MainActivity.this, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditData.getName());
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, LemmyUtils.actorID2FullName(subredditData.getActorId()));
|
||||
startActivity(intent);
|
||||
});
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
@ -118,6 +118,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
Executor mExecutor;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private boolean mInsertSuccess = false;
|
||||
private boolean mInsertMultiredditSuccess = false;
|
||||
private boolean showMultiReddits = false;
|
||||
@ -172,6 +174,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
|
||||
@ -322,7 +325,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
|
||||
public void loadSubscriptions(boolean forceLoad) {
|
||||
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
|
||||
FetchSubscribedThing.fetchSubscribedThing(mRetrofit.getRetrofit(), mAccessToken, mAccountName, null,
|
||||
FetchSubscribedThing.fetchSubscribedThing(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, null,
|
||||
new ArrayList<>(), new ArrayList<>(),
|
||||
new ArrayList<>(),
|
||||
new FetchSubscribedThing.FetchSubscribedThingListener() {
|
||||
@ -334,7 +337,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
mExecutor,
|
||||
new Handler(),
|
||||
mRedditDataRoomDatabase,
|
||||
mAccountName,
|
||||
mAccountQualifiedName,
|
||||
subscribedSubredditData,
|
||||
subscribedUserData,
|
||||
subredditData,
|
||||
@ -479,6 +482,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, false);
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
|
@ -58,15 +58,6 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.MarkwonPlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
||||
import eu.toldi.infinityforlemmy.AppBarStateChangeListener;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
@ -74,6 +65,7 @@ import eu.toldi.infinityforlemmy.MarkPostAsReadInterface;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RecyclerViewContentScrollingInterface;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
|
||||
import eu.toldi.infinityforlemmy.adapters.SubredditAutocompleteRecyclerViewAdapter;
|
||||
@ -110,8 +102,16 @@ import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditSubscription;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditViewModel;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.MarkwonPlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -406,7 +406,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
});
|
||||
|
||||
mSubredditViewModel = new ViewModelProvider(this,
|
||||
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName))
|
||||
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, LemmyUtils.qualifiedCommunityName2ActorId(qualifiedName)))
|
||||
.get(SubredditViewModel.class);
|
||||
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
|
||||
if (subredditData != null) {
|
||||
|
@ -1555,6 +1555,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
}
|
||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, comment.getAuthorQualifiedName());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
|
@ -1098,6 +1098,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||
mPost.getSubredditName());
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, mPost.getSubredditNamePrefixed());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
@ -1107,6 +1108,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
}
|
||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mPost.getAuthorNamePrefixed());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
|
@ -18,12 +18,12 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
public class FavoriteSubscribedSubredditsSectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
@ -108,7 +108,7 @@ public class FavoriteSubscribedSubredditsSectionRecyclerViewAdapter extends Recy
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
itemClickListener.onSubscribedSubredditClick(subredditName);
|
||||
itemClickListener.onSubscribedSubredditClick(subredditName, subreddit.getQualified_name());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,9 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onMenuClick(int stringId);
|
||||
void onSubscribedSubredditClick(String subredditName);
|
||||
|
||||
void onSubscribedSubredditClick(String subredditName, String communityQualifiedName);
|
||||
|
||||
void onAccountClick(String accountName);
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,12 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
@ -108,7 +108,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
itemClickListener.onSubscribedSubredditClick(subredditName);
|
||||
itemClickListener.onSubscribedSubredditClick(subredditName, subreddit.getQualified_name());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
||||
}
|
||||
|
||||
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(
|
||||
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, query, sortType, accessToken, nsfw);
|
||||
mRetrofit.getRetrofit(), query, sortType, accessToken, nsfw);
|
||||
mSubredditListingViewModel = new ViewModelProvider(this, factory).get(SubredditListingViewModel.class);
|
||||
mSubredditListingViewModel.getSubreddits().observe(getViewLifecycleOwner(), subredditData -> mAdapter.submitList(subredditData));
|
||||
|
||||
|
@ -29,7 +29,6 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
@ -42,6 +41,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditViewModel;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
public static final String EXTRA_ACCOUNT_PROFILE_IMAGE_URL = "EAPIU";
|
||||
public static final String EXTRA_IS_SUBREDDIT_SELECTION = "EISS";
|
||||
public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
|
||||
public static final String EXTRA_ACCOUNT_QUALIFIED_NAME = "EAQN";
|
||||
|
||||
@BindView(R.id.swipe_refresh_layout_subscribed_subreddits_listing_fragment)
|
||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
@ -110,6 +111,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
}
|
||||
|
||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME, "-");
|
||||
String accountQualifiedName = getArguments().getString(EXTRA_ACCOUNT_QUALIFIED_NAME, "-");
|
||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||
|
||||
if (accessToken == null) {
|
||||
@ -135,7 +137,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
|
||||
|
||||
mSubscribedSubredditViewModel = new ViewModelProvider(this,
|
||||
new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountName))
|
||||
new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountQualifiedName))
|
||||
.get(SubscribedSubredditViewModel.class);
|
||||
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(getViewLifecycleOwner(), subscribedSubredditData -> {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
|
@ -17,6 +17,9 @@ public interface SubredditDao {
|
||||
@Query("SELECT * from subreddits WHERE name = :namePrefixed COLLATE NOCASE LIMIT 1")
|
||||
LiveData<SubredditData> getSubredditLiveDataByName(String namePrefixed);
|
||||
|
||||
@Query("SELECT * from subreddits WHERE actor_id = :actor_id COLLATE NOCASE LIMIT 1")
|
||||
LiveData<SubredditData> getSubredditLiveDataByActorId(String actor_id);
|
||||
|
||||
@Query("SELECT * from subreddits WHERE name = :namePrefixed COLLATE NOCASE LIMIT 1")
|
||||
SubredditData getSubredditData(String namePrefixed);
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ public class SubredditRepository {
|
||||
private SubredditDao mSubredditDao;
|
||||
private LiveData<SubredditData> mSubredditLiveData;
|
||||
|
||||
SubredditRepository(RedditDataRoomDatabase redditDataRoomDatabase, String subredditName) {
|
||||
SubredditRepository(RedditDataRoomDatabase redditDataRoomDatabase, String actor_id) {
|
||||
mSubredditDao = redditDataRoomDatabase.subredditDao();
|
||||
mSubredditLiveData = mSubredditDao.getSubredditLiveDataByName(subredditName);
|
||||
mSubredditLiveData = mSubredditDao.getSubredditLiveDataByActorId(actor_id);
|
||||
}
|
||||
|
||||
LiveData<SubredditData> getSubredditLiveData() {
|
||||
|
@ -7,4 +7,18 @@ public class LemmyUtils {
|
||||
String domain = splitURL[2];
|
||||
return userName + "@" + domain;
|
||||
}
|
||||
|
||||
public static String qualifiedCommunityName2ActorId(String qualifiedName) {
|
||||
String[] splitQualifiedName = qualifiedName.split("@");
|
||||
String userName = splitQualifiedName[0];
|
||||
String domain = splitQualifiedName[1];
|
||||
return "https://" + domain + "/c/" + userName;
|
||||
}
|
||||
|
||||
public static String qualifiedUserName2ActorId(String qualifiedName) {
|
||||
String[] splitQualifiedName = qualifiedName.split("@");
|
||||
String userName = splitQualifiedName[0];
|
||||
String domain = splitQualifiedName[1];
|
||||
return "https://" + domain + "/u/" + userName;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user