Browse Source

remove redundant arguments in FeedItemCallback

renovate/androidx.fragment-fragment-ktx-1.x
Austin Huang 4 years ago
parent
commit
e6594e086c
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 10
      app/src/main/java/awais/instagrabber/adapters/FeedAdapterV2.java
  2. 6
      app/src/main/java/awais/instagrabber/adapters/FeedItemCallbackAdapter.java
  3. 2
      app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java
  4. 2
      app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedPhotoViewHolder.java
  5. 2
      app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedVideoViewHolder.java
  6. 16
      app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java
  7. 20
      app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java
  8. 20
      app/src/main/java/awais/instagrabber/fragments/LocationFragment.java
  9. 16
      app/src/main/java/awais/instagrabber/fragments/SavedViewerFragment.java
  10. 16
      app/src/main/java/awais/instagrabber/fragments/TopicPostsFragment.java
  11. 21
      app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java
  12. 6
      app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.kt

10
app/src/main/java/awais/instagrabber/adapters/FeedAdapterV2.java

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

6
app/src/main/java/awais/instagrabber/adapters/FeedItemCallbackAdapter.java

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

2
app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java

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

2
app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedPhotoViewHolder.java

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

2
app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedVideoViewHolder.java

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

16
app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java

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

20
app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java

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

20
app/src/main/java/awais/instagrabber/fragments/LocationFragment.java

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

16
app/src/main/java/awais/instagrabber/fragments/SavedViewerFragment.java

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

16
app/src/main/java/awais/instagrabber/fragments/TopicPostsFragment.java

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

21
app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java

@ -92,13 +92,13 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override
public void onPostClick(final Media feedModel, final View profilePicView, final View mainPostImage) {
openPostDialog(feedModel, profilePicView, mainPostImage, -1);
public void onPostClick(final Media feedModel) {
openPostDialog(feedModel, -1);
}
@Override
public void onSliderClick(final Media feedModel, final int position) {
openPostDialog(feedModel, null, null, position);
openPostDialog(feedModel, position);
}
@Override
@ -140,13 +140,13 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
}
@Override
public void onNameClick(final Media feedModel, final View profilePicView) {
public void onNameClick(final Media feedModel) {
if (feedModel.getUser() == null) return;
navigateToProfile("@" + feedModel.getUser().getUsername());
}
@Override
public void onProfilePicClick(final Media feedModel, final View profilePicView) {
public void onProfilePicClick(final Media feedModel) {
if (feedModel.getUser() == null) return;
navigateToProfile("@" + feedModel.getUser().getUsername());
}
@ -161,16 +161,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
Utils.openEmailAddress(getContext(), emailId);
}
private void openPostDialog(final Media feedModel,
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();
private void openPostDialog(final Media feedModel, final int position) {
final NavController navController = NavHostFragment.findNavController(FeedFragment.this);
final Bundle bundle = new Bundle();
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);

6
app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.kt

@ -92,15 +92,15 @@ class ProfileFragment : Fragment(), OnRefreshListener, ConfirmDialogFragmentCall
private val bioDialogRequestCode = 102
private val translationDialogRequestCode = 103
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)
}
override fun onProfilePicClick(media: Media?, profilePicView: View?) {
override fun onProfilePicClick(media: Media) {
navigateToProfile(media?.user?.username)
}
override fun onNameClick(media: Media?, profilePicView: View?) {
override fun onNameClick(media: Media) {
navigateToProfile(media?.user?.username)
}

Loading…
Cancel
Save