1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-14 02:37:30 +00:00

remove redundant arguments in FeedItemCallback

This commit is contained in:
Austin Huang 2021-07-10 15:59:14 -04:00
parent db8af26b35
commit e6594e086c
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
12 changed files with 52 additions and 85 deletions

View File

@ -208,15 +208,11 @@ public final class FeedAdapterV2 extends ListAdapter<Media, RecyclerView.ViewHol
// } // }
public interface FeedItemCallback { public interface FeedItemCallback {
void onPostClick(final Media feedModel, void onPostClick(final Media feedModel);
final View profilePicView,
final View mainPostImage);
void onProfilePicClick(final Media feedModel, void onProfilePicClick(final Media feedModel);
final View profilePicView);
void onNameClick(final Media feedModel, void onNameClick(final Media feedModel);
final View profilePicView);
void onLocationClick(final Media feedModel); void onLocationClick(final Media feedModel);

View File

@ -7,13 +7,13 @@ import awais.instagrabber.repositories.responses.Media;
public class FeedItemCallbackAdapter implements FeedAdapterV2.FeedItemCallback { public class FeedItemCallbackAdapter implements FeedAdapterV2.FeedItemCallback {
@Override @Override
public void onPostClick(final Media media, final View profilePicView, final View mainPostImage) {} public void onPostClick(final Media media) {}
@Override @Override
public void onProfilePicClick(final Media media, final View profilePicView) {} public void onProfilePicClick(final Media media) {}
@Override @Override
public void onNameClick(final Media media, final View profilePicView) {} public void onNameClick(final Media media) {}
@Override @Override
public void onLocationClick(final Media media) {} public void onLocationClick(final Media media) {}

View File

@ -49,7 +49,7 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
final boolean selected) { final boolean selected) {
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
if (!selectionModeActive && feedItemCallback != null) { if (!selectionModeActive && feedItemCallback != null) {
feedItemCallback.onPostClick(media, binding.profilePic, binding.postImage); feedItemCallback.onPostClick(media);
return; return;
} }
if (selectionModeActive && adapterSelectionCallback != null) { if (selectionModeActive && adapterSelectionCallback != null) {

View File

@ -61,7 +61,7 @@ public class FeedPhotoViewHolder extends FeedItemViewHolder {
@Override @Override
public boolean onSingleTapConfirmed(final MotionEvent e) { public boolean onSingleTapConfirmed(final MotionEvent e) {
if (feedItemCallback != null) { if (feedItemCallback != null) {
feedItemCallback.onPostClick(media, binding.itemFeedTop.ivProfilePic, binding.imageViewer); feedItemCallback.onPostClick(media);
return true; return true;
} }
return false; return false;

View File

@ -70,7 +70,7 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
@Override @Override
public void onThumbnailClick() { public void onThumbnailClick() {
feedItemCallback.onPostClick(media, binding.itemFeedTop.ivProfilePic, binding.videoPost.thumbnail); feedItemCallback.onPostClick(media);
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package awais.instagrabber.fragments;
import android.animation.ArgbEvaluator; import android.animation.ArgbEvaluator;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Animatable; import android.graphics.drawable.Animatable;
@ -107,13 +106,13 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
}); });
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) { public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1); openPostDialog(feedModel, -1);
} }
@Override @Override
public void onSliderClick(final Media feedModel, final int position) { public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position); openPostDialog(feedModel, position);
} }
@Override @Override
@ -151,12 +150,12 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
} }
@Override @Override
public void onNameClick(final Media feedModel, final View profilePicView) { public void onNameClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@Override @Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) { public void onProfilePicClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@ -170,10 +169,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(final Media feedModel, private void openPostDialog(final Media feedModel, final int position) {
final View profilePicView,
final View mainPostImage,
final int position) {
final NavController navController = NavHostFragment.findNavController(CollectionPostsFragment.this); final NavController navController = NavHostFragment.findNavController(CollectionPostsFragment.this);
final Bundle bundle = new Bundle(); final Bundle bundle = new Bundle();
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel); bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);

View File

@ -2,7 +2,6 @@ package awais.instagrabber.fragments;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -53,7 +52,7 @@ import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.FavoriteType;
import awais.instagrabber.models.enums.FollowingType; import awais.instagrabber.models.enums.FollowingType;
import awais.instagrabber.repositories.requests.StoryViewerOptions; //import awais.instagrabber.repositories.requests.StoryViewerOptions;
import awais.instagrabber.repositories.responses.Hashtag; import awais.instagrabber.repositories.responses.Hashtag;
import awais.instagrabber.repositories.responses.Location; import awais.instagrabber.repositories.responses.Location;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
@ -125,13 +124,13 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
}); });
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) { public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1); openPostDialog(feedModel, -1);
} }
@Override @Override
public void onSliderClick(final Media feedModel, final int position) { public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position); openPostDialog(feedModel, position);
} }
@Override @Override
@ -171,12 +170,12 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
@Override @Override
public void onNameClick(final Media feedModel, final View profilePicView) { public void onNameClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@Override @Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) { public void onProfilePicClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@ -190,10 +189,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(@NonNull final Media feedModel, private void openPostDialog(@NonNull final Media feedModel, final int position) {
final View profilePicView,
final View mainPostImage,
final int position) {
if (opening) return; if (opening) return;
final User user = feedModel.getUser(); final User user = feedModel.getUser();
if (user == null) return; if (user == null) return;
@ -207,7 +203,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
return; return;
} }
if (media == null) return; if (media == null) return;
AppExecutors.INSTANCE.getMainThread().execute(() -> openPostDialog(media, profilePicView, mainPostImage, position)); AppExecutors.INSTANCE.getMainThread().execute(() -> openPostDialog(media, position));
}, Dispatchers.getIO())); }, Dispatchers.getIO()));
return; return;
} }

View File

@ -3,7 +3,6 @@ package awais.instagrabber.fragments;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -50,7 +49,7 @@ import awais.instagrabber.db.repositories.FavoriteRepository;
import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment; import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.FavoriteType;
import awais.instagrabber.repositories.requests.StoryViewerOptions; //import awais.instagrabber.repositories.requests.StoryViewerOptions;
import awais.instagrabber.repositories.responses.Location; import awais.instagrabber.repositories.responses.Location;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.User;
@ -119,13 +118,13 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
}); });
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) { public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1); openPostDialog(feedModel, -1);
} }
@Override @Override
public void onSliderClick(final Media feedModel, final int position) { public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position); openPostDialog(feedModel, position);
} }
@Override @Override
@ -163,12 +162,12 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
} }
@Override @Override
public void onNameClick(final Media feedModel, final View profilePicView) { public void onNameClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@Override @Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) { public void onProfilePicClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@ -182,10 +181,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(@NonNull final Media feedModel, private void openPostDialog(@NonNull final Media feedModel, final int position) {
final View profilePicView,
final View mainPostImage,
final int position) {
if (opening) return; if (opening) return;
final User user = feedModel.getUser(); final User user = feedModel.getUser();
if (user == null) return; if (user == null) return;
@ -200,7 +196,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
return; return;
} }
if (media == null) return; if (media == null) return;
openPostDialog(media, profilePicView, mainPostImage, position); openPostDialog(media, position);
})) }))
); );
return; return;

View File

@ -1,7 +1,6 @@
package awais.instagrabber.fragments; package awais.instagrabber.fragments;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
@ -90,13 +89,13 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
}); });
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) { public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1); openPostDialog(feedModel, -1);
} }
@Override @Override
public void onSliderClick(final Media feedModel, final int position) { public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position); openPostDialog(feedModel, position);
} }
@Override @Override
@ -134,12 +133,12 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
} }
@Override @Override
public void onNameClick(final Media feedModel, final View profilePicView) { public void onNameClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@Override @Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) { public void onProfilePicClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@ -153,10 +152,7 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(final Media feedModel, private void openPostDialog(final Media feedModel, final int position) {
final View profilePicView,
final View mainPostImage,
final int position) {
final NavController navController = NavHostFragment.findNavController(SavedViewerFragment.this); final NavController navController = NavHostFragment.findNavController(SavedViewerFragment.this);
final Bundle bundle = new Bundle(); final Bundle bundle = new Bundle();
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel); bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);

View File

@ -2,7 +2,6 @@ package awais.instagrabber.fragments;
import android.animation.ArgbEvaluator; import android.animation.ArgbEvaluator;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Animatable; import android.graphics.drawable.Animatable;
@ -101,13 +100,13 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
}); });
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) { public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1); openPostDialog(feedModel, -1);
} }
@Override @Override
public void onSliderClick(final Media feedModel, final int position) { public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position); openPostDialog(feedModel, position);
} }
@Override @Override
@ -145,12 +144,12 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
} }
@Override @Override
public void onNameClick(final Media feedModel, final View profilePicView) { public void onNameClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@Override @Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) { public void onProfilePicClick(final Media feedModel) {
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@ -164,10 +163,7 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(final Media feedModel, private void openPostDialog(final Media feedModel, final int position) {
final View profilePicView,
final View mainPostImage,
final int position) {
final NavController navController = NavHostFragment.findNavController(TopicPostsFragment.this); final NavController navController = NavHostFragment.findNavController(TopicPostsFragment.this);
final Bundle bundle = new Bundle(); final Bundle bundle = new Bundle();
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel); bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);

View File

@ -92,13 +92,13 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) { public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1); openPostDialog(feedModel, -1);
} }
@Override @Override
public void onSliderClick(final Media feedModel, final int position) { public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position); openPostDialog(feedModel, position);
} }
@Override @Override
@ -140,13 +140,13 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
} }
@Override @Override
public void onNameClick(final Media feedModel, final View profilePicView) { public void onNameClick(final Media feedModel) {
if (feedModel.getUser() == null) return; if (feedModel.getUser() == null) return;
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@Override @Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) { public void onProfilePicClick(final Media feedModel) {
if (feedModel.getUser() == null) return; if (feedModel.getUser() == null) return;
navigateToProfile("@" + feedModel.getUser().getUsername()); navigateToProfile("@" + feedModel.getUser().getUsername());
} }
@ -161,16 +161,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(final Media feedModel, private void openPostDialog(final Media feedModel, final int position) {
final View profilePicView,
final View mainPostImage,
final int position) {
// ViewCompat.setTransitionName(profilePicView, "profile_pic");
// ViewCompat.setTransitionName(mainPostImage, "post_image");
// final FragmentNavigator.Extras extras = new FragmentNavigator.Extras.Builder()
// .addSharedElement(profilePicView, "profile_pic")
// .addSharedElement(mainPostImage, "post_image")
// .build();
final NavController navController = NavHostFragment.findNavController(FeedFragment.this); final NavController navController = NavHostFragment.findNavController(FeedFragment.this);
final Bundle bundle = new Bundle(); final Bundle bundle = new Bundle();
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel); bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);

View File

@ -92,15 +92,15 @@ class ProfileFragment : Fragment(), OnRefreshListener, ConfirmDialogFragmentCall
private val bioDialogRequestCode = 102 private val bioDialogRequestCode = 102
private val translationDialogRequestCode = 103 private val translationDialogRequestCode = 103
private val feedItemCallback: FeedAdapterV2.FeedItemCallback = object : FeedAdapterV2.FeedItemCallback { private val feedItemCallback: FeedAdapterV2.FeedItemCallback = object : FeedAdapterV2.FeedItemCallback {
override fun onPostClick(media: Media?, profilePicView: View?, mainPostImage: View?) { override fun onPostClick(media: Media) {
openPostDialog(media ?: return, -1) openPostDialog(media ?: return, -1)
} }
override fun onProfilePicClick(media: Media?, profilePicView: View?) { override fun onProfilePicClick(media: Media) {
navigateToProfile(media?.user?.username) navigateToProfile(media?.user?.username)
} }
override fun onNameClick(media: Media?, profilePicView: View?) { override fun onNameClick(media: Media) {
navigateToProfile(media?.user?.username) navigateToProfile(media?.user?.username)
} }