mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 13:26:59 +00:00
Comment/remove unused code
This commit is contained in:
parent
b6d0457a3e
commit
133abcca85
@ -1,24 +1,12 @@
|
|||||||
package awais.instagrabber.adapters.viewholder.feed;
|
package awais.instagrabber.adapters.viewholder.feed;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.ViewSwitcher;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
|
||||||
import com.google.android.exoplayer2.Player;
|
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
|
||||||
import com.google.android.exoplayer2.ui.PlayerView;
|
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory;
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import awais.instagrabber.adapters.FeedAdapterV2;
|
import awais.instagrabber.adapters.FeedAdapterV2;
|
||||||
@ -27,23 +15,15 @@ import awais.instagrabber.adapters.SliderItemsAdapter;
|
|||||||
import awais.instagrabber.databinding.ItemFeedSliderBinding;
|
import awais.instagrabber.databinding.ItemFeedSliderBinding;
|
||||||
import awais.instagrabber.models.FeedModel;
|
import awais.instagrabber.models.FeedModel;
|
||||||
import awais.instagrabber.models.PostChild;
|
import awais.instagrabber.models.PostChild;
|
||||||
import awais.instagrabber.utils.Constants;
|
|
||||||
import awais.instagrabber.utils.NumberUtils;
|
import awais.instagrabber.utils.NumberUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
import awais.instagrabber.utils.Utils;
|
||||||
|
|
||||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
|
||||||
|
|
||||||
public class FeedSliderViewHolder extends FeedItemViewHolder {
|
public class FeedSliderViewHolder extends FeedItemViewHolder {
|
||||||
private static final String TAG = "FeedSliderViewHolder";
|
private static final String TAG = "FeedSliderViewHolder";
|
||||||
private static final boolean shouldAutoPlay = settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS);
|
// private static final boolean shouldAutoPlay = settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS);
|
||||||
|
|
||||||
private final ItemFeedSliderBinding binding;
|
private final ItemFeedSliderBinding binding;
|
||||||
private final FeedAdapterV2.FeedItemCallback feedItemCallback;
|
private final FeedAdapterV2.FeedItemCallback feedItemCallback;
|
||||||
private final DefaultDataSourceFactory dataSourceFactory;
|
|
||||||
|
|
||||||
private CacheDataSourceFactory cacheDataSourceFactory;
|
|
||||||
private SimpleExoPlayer pagerPlayer;
|
|
||||||
private int playerPosition = 0;
|
|
||||||
|
|
||||||
public FeedSliderViewHolder(@NonNull final ItemFeedSliderBinding binding,
|
public FeedSliderViewHolder(@NonNull final ItemFeedSliderBinding binding,
|
||||||
final FeedAdapterV2.FeedItemCallback feedItemCallback) {
|
final FeedAdapterV2.FeedItemCallback feedItemCallback) {
|
||||||
@ -55,12 +35,7 @@ public class FeedSliderViewHolder extends FeedItemViewHolder {
|
|||||||
final ViewGroup.LayoutParams layoutParams = binding.mediaList.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.mediaList.getLayoutParams();
|
||||||
layoutParams.height = Utils.displayMetrics.widthPixels + 1;
|
layoutParams.height = Utils.displayMetrics.widthPixels + 1;
|
||||||
binding.mediaList.setLayoutParams(layoutParams);
|
binding.mediaList.setLayoutParams(layoutParams);
|
||||||
final Context context = binding.getRoot().getContext();
|
// final Context context = binding.getRoot().getContext();
|
||||||
dataSourceFactory = new DefaultDataSourceFactory(context, "instagram");
|
|
||||||
final SimpleCache simpleCache = Utils.getSimpleCacheInstance(context);
|
|
||||||
if (simpleCache != null) {
|
|
||||||
cacheDataSourceFactory = new CacheDataSourceFactory(simpleCache, dataSourceFactory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -91,36 +66,6 @@ public class FeedSliderViewHolder extends FeedItemViewHolder {
|
|||||||
setDimensions(binding.mediaList, sliderItems.get(0));
|
setDimensions(binding.mediaList, sliderItems.get(0));
|
||||||
binding.itemFeedBottom.btnDownload.setOnClickListener(v -> feedItemCallback.onDownloadClick(feedModel, 0));
|
binding.itemFeedBottom.btnDownload.setOnClickListener(v -> feedItemCallback.onDownloadClick(feedModel, 0));
|
||||||
adapter.submitList(sliderItems);
|
adapter.submitList(sliderItems);
|
||||||
// final View.OnClickListener muteClickListener = v -> {
|
|
||||||
// final int currentItem = binding.mediaList.getCurrentItem();
|
|
||||||
// if (currentItem < 0 || currentItem >= binding.mediaList.getChildCount()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// final PostChild sliderItem = sliderItems.get(currentItem);
|
|
||||||
// if (sliderItem.getItemType() != MediaItemType.MEDIA_TYPE_VIDEO) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// final View currentView = binding.mediaList.getChildAt(currentItem);
|
|
||||||
// if (!(currentView instanceof ViewSwitcher)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// final ViewSwitcher viewSwitcher = (ViewSwitcher) currentView;
|
|
||||||
// final Object tag = viewSwitcher.getTag();
|
|
||||||
// if (!(tag instanceof SimpleExoPlayer)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// final SimpleExoPlayer player = (SimpleExoPlayer) tag;
|
|
||||||
// final float intVol = player.getVolume() == 0f ? 1f : 0f;
|
|
||||||
// player.setVolume(intVol);
|
|
||||||
// // binding.itemFeedBottom.btnMute.setImageResource(intVol == 0f ? R.drawable.ic_volume_up_24 : R.drawable.ic_volume_off_24);
|
|
||||||
// // Utils.sessionVolumeFull = intVol == 1f;
|
|
||||||
// };
|
|
||||||
// final PostChild firstItem = sliderItems.get(0);
|
|
||||||
// if (firstItem.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO) {
|
|
||||||
// binding.itemFeedBottom.btnMute.setVisibility(View.VISIBLE);
|
|
||||||
// }
|
|
||||||
// binding.itemFeedBottom.btnMute.setImageResource(Utils.sessionVolumeFull ? R.drawable.ic_volume_off_24 : R.drawable.ic_volume_up_24);
|
|
||||||
// binding.itemFeedBottom.btnMute.setOnClickListener(muteClickListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDimensions(final View view, final PostChild model) {
|
private void setDimensions(final View view, final PostChild model) {
|
||||||
@ -149,74 +94,74 @@ public class FeedSliderViewHolder extends FeedItemViewHolder {
|
|||||||
view.requestLayout();
|
view.requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void autoPlay(final int position) {
|
// private void autoPlay(final int position) {
|
||||||
// if (!shouldAutoPlay) {
|
// if (!shouldAutoPlay) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// final ChildMediaItemsAdapter adapter = (ChildMediaItemsAdapter) binding.mediaList.getAdapter();
|
// final ChildMediaItemsAdapter adapter = (ChildMediaItemsAdapter) binding.mediaList.getAdapter();
|
||||||
// if (adapter == null) {
|
// if (adapter == null) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// final ViewerPostModel sliderItem = adapter.getItemAtPosition(position);
|
// final ViewerPostModel sliderItem = adapter.getItemAtPosition(position);
|
||||||
// if (sliderItem.getItemType() != MediaItemType.MEDIA_TYPE_VIDEO) {
|
// if (sliderItem.getItemType() != MediaItemType.MEDIA_TYPE_VIDEO) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// final ViewSwitcher viewSwitcher = (ViewSwitcher) binding.mediaList.getChildAt(position);
|
// final ViewSwitcher viewSwitcher = (ViewSwitcher) binding.mediaList.getChildAt(position);
|
||||||
// loadPlayer(binding.getRoot().getContext(),
|
// loadPlayer(binding.getRoot().getContext(),
|
||||||
// position, sliderItem.getDisplayUrl(),
|
// position, sliderItem.getDisplayUrl(),
|
||||||
// viewSwitcher,
|
// viewSwitcher,
|
||||||
// cacheDataSourceFactory != null ? cacheDataSourceFactory : dataSourceFactory,
|
// cacheDataSourceFactory != null ? cacheDataSourceFactory : dataSourceFactory,
|
||||||
// playerChangeListener);
|
// playerChangeListener);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void startPlayingVideo() {
|
// public void startPlayingVideo() {
|
||||||
autoPlay(playerPosition);
|
// final int playerPosition = 0;
|
||||||
}
|
// autoPlay(playerPosition);
|
||||||
|
// }
|
||||||
public void stopPlayingVideo() {
|
//
|
||||||
if (pagerPlayer == null) {
|
// public void stopPlayingVideo() {
|
||||||
return;
|
// if (pagerPlayer == null) {
|
||||||
}
|
// return;
|
||||||
pagerPlayer.setPlayWhenReady(false);
|
// }
|
||||||
}
|
// pagerPlayer.setPlayWhenReady(false);
|
||||||
|
// }
|
||||||
private interface PlayerChangeListener {
|
|
||||||
void playerChanged(final int position, final SimpleExoPlayer player);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadPlayer(final Context context,
|
|
||||||
final int position,
|
|
||||||
final String displayUrl,
|
|
||||||
final ViewSwitcher viewSwitcher,
|
|
||||||
final DataSource.Factory factory,
|
|
||||||
final PlayerChangeListener playerChangeListener) {
|
|
||||||
if (viewSwitcher == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SimpleExoPlayer player = (SimpleExoPlayer) viewSwitcher.getTag();
|
|
||||||
if (player != null) {
|
|
||||||
player.setPlayWhenReady(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player = new SimpleExoPlayer.Builder(context).build();
|
|
||||||
final PlayerView playerView = (PlayerView) viewSwitcher.getChildAt(1);
|
|
||||||
playerView.setPlayer(player);
|
|
||||||
if (viewSwitcher.getDisplayedChild() == 0) {
|
|
||||||
viewSwitcher.showNext();
|
|
||||||
}
|
|
||||||
playerView.setControllerShowTimeoutMs(1000);
|
|
||||||
float vol = settingsHelper.getBoolean(Constants.MUTED_VIDEOS) ? 0f : 1f;
|
|
||||||
if (vol == 0f && Utils.sessionVolumeFull) vol = 1f;
|
|
||||||
player.setVolume(vol);
|
|
||||||
player.setPlayWhenReady(Utils.settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS));
|
|
||||||
final MediaItem mediaItem = MediaItem.fromUri(displayUrl);
|
|
||||||
final ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory(factory).createMediaSource(mediaItem);
|
|
||||||
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
|
||||||
player.setMediaSource(mediaSource);
|
|
||||||
player.prepare();
|
|
||||||
player.setVolume(vol);
|
|
||||||
playerChangeListener.playerChanged(position, player);
|
|
||||||
viewSwitcher.setTag(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// private interface PlayerChangeListener {
|
||||||
|
// void playerChanged(final int position, final SimpleExoPlayer player);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void loadPlayer(final Context context,
|
||||||
|
// final int position,
|
||||||
|
// final String displayUrl,
|
||||||
|
// final ViewSwitcher viewSwitcher,
|
||||||
|
// final DataSource.Factory factory,
|
||||||
|
// final PlayerChangeListener playerChangeListener) {
|
||||||
|
// if (viewSwitcher == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// SimpleExoPlayer player = (SimpleExoPlayer) viewSwitcher.getTag();
|
||||||
|
// if (player != null) {
|
||||||
|
// player.setPlayWhenReady(true);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// player = new SimpleExoPlayer.Builder(context).build();
|
||||||
|
// final PlayerView playerView = (PlayerView) viewSwitcher.getChildAt(1);
|
||||||
|
// playerView.setPlayer(player);
|
||||||
|
// if (viewSwitcher.getDisplayedChild() == 0) {
|
||||||
|
// viewSwitcher.showNext();
|
||||||
|
// }
|
||||||
|
// playerView.setControllerShowTimeoutMs(1000);
|
||||||
|
// float vol = settingsHelper.getBoolean(Constants.MUTED_VIDEOS) ? 0f : 1f;
|
||||||
|
// if (vol == 0f && Utils.sessionVolumeFull) vol = 1f;
|
||||||
|
// player.setVolume(vol);
|
||||||
|
// player.setPlayWhenReady(Utils.settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS));
|
||||||
|
// final MediaItem mediaItem = MediaItem.fromUri(displayUrl);
|
||||||
|
// final ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory(factory).createMediaSource(mediaItem);
|
||||||
|
// player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
||||||
|
// player.setMediaSource(mediaSource);
|
||||||
|
// player.prepare();
|
||||||
|
// player.setVolume(vol);
|
||||||
|
// playerChangeListener.playerChanged(position, player);
|
||||||
|
// viewSwitcher.setTag(player);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import awais.instagrabber.ProfileNavGraphDirections;
|
|
||||||
import awais.instagrabber.R;
|
import awais.instagrabber.R;
|
||||||
import awais.instagrabber.activities.MainActivity;
|
import awais.instagrabber.activities.MainActivity;
|
||||||
import awais.instagrabber.adapters.FeedAdapterV2;
|
import awais.instagrabber.adapters.FeedAdapterV2;
|
||||||
@ -67,7 +66,6 @@ import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
|
|||||||
import awais.instagrabber.dialogs.ProfilePicDialogFragment;
|
import awais.instagrabber.dialogs.ProfilePicDialogFragment;
|
||||||
import awais.instagrabber.fragments.PostViewV2Fragment;
|
import awais.instagrabber.fragments.PostViewV2Fragment;
|
||||||
import awais.instagrabber.interfaces.FetchListener;
|
import awais.instagrabber.interfaces.FetchListener;
|
||||||
import awais.instagrabber.interfaces.MentionClickListener;
|
|
||||||
import awais.instagrabber.models.FeedModel;
|
import awais.instagrabber.models.FeedModel;
|
||||||
import awais.instagrabber.models.PostsLayoutPreferences;
|
import awais.instagrabber.models.PostsLayoutPreferences;
|
||||||
import awais.instagrabber.models.ProfileModel;
|
import awais.instagrabber.models.ProfileModel;
|
||||||
@ -160,24 +158,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> {
|
|
||||||
Log.d(TAG, "action...");
|
|
||||||
if (isHashtag) {
|
|
||||||
final NavDirections action = ProfileFragmentDirections
|
|
||||||
.actionGlobalHashTagFragment(text);
|
|
||||||
NavHostFragment.findNavController(this).navigate(action);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isLocation) {
|
|
||||||
final NavDirections action = FeedFragmentDirections.actionGlobalLocationFragment(text);
|
|
||||||
NavHostFragment.findNavController(this).navigate(action);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final ProfileNavGraphDirections.ActionGlobalProfileFragment action = ProfileFragmentDirections
|
|
||||||
.actionGlobalProfileFragment();
|
|
||||||
action.setUsername("@" + text);
|
|
||||||
NavHostFragment.findNavController(this).navigate(action);
|
|
||||||
};
|
|
||||||
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
|
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPostClick(final FeedModel feedModel, final View profilePicView, final View mainPostImage) {
|
public void onPostClick(final FeedModel feedModel, final View profilePicView, final View mainPostImage) {
|
||||||
@ -748,7 +728,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupCommonListeners() {
|
private void setupCommonListeners() {
|
||||||
|
|
||||||
final String userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie);
|
final String userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie);
|
||||||
binding.btnFollow.setOnClickListener(v -> {
|
binding.btnFollow.setOnClickListener(v -> {
|
||||||
if (profileModel.getFollowing() || profileModel.getRequested()) {
|
if (profileModel.getFollowing() || profileModel.getRequested()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user