Browse Source

add #122 point 2

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
bf9dcacd40
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 32
      app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
  2. 4
      app/src/main/res/layout/fragment_post_view.xml
  3. 33
      app/src/main/res/layout/fragment_story_viewer.xml
  4. 2
      app/src/main/res/layout/item_story.xml

32
app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java

@ -319,15 +319,7 @@ public class StoryViewerFragment extends Fragment {
final Object feedStoryModel = isRightSwipe final Object feedStoryModel = isRightSwipe
? finalModels.get(index - 1) ? finalModels.get(index - 1)
: finalModels.size() == index + 1 ? null : finalModels.get(index + 1); : finalModels.size() == index + 1 ? null : finalModels.get(index + 1);
if (feedStoryModel != null) {
if (fetching) {
Toast.makeText(context, R.string.be_patient, Toast.LENGTH_SHORT).show();
return;
}
fetching = true;
currentFeedStoryIndex = isRightSwipe ? (index - 1) : (index + 1);
resetView();
}
paginateStories(feedStoryModel, context, isRightSwipe, currentFeedStoryIndex == finalModels.size() - 2);
return; return;
} }
if (isRightSwipe) { if (isRightSwipe) {
@ -362,6 +354,14 @@ public class StoryViewerFragment extends Fragment {
return false; return false;
} }
}; };
if (hasFeedStories) {
binding.btnBackward.setVisibility(currentFeedStoryIndex == 0 ? View.INVISIBLE : View.VISIBLE);
binding.btnForward.setVisibility(currentFeedStoryIndex == finalModels.size() - 1 ? View.INVISIBLE : View.VISIBLE);
binding.btnBackward.setOnClickListener(v -> paginateStories(finalModels.get(currentFeedStoryIndex - 1), context, true, false));
binding.btnForward.setOnClickListener(v -> paginateStories(finalModels.get(currentFeedStoryIndex + 1), context, false, currentFeedStoryIndex == finalModels.size() - 2));
}
binding.imageViewer.setTapListener(simpleOnGestureListener); binding.imageViewer.setTapListener(simpleOnGestureListener);
binding.spotify.setOnClickListener(v -> { binding.spotify.setOnClickListener(v -> {
final Object tag = v.getTag(); final Object tag = v.getTag();
@ -780,4 +780,18 @@ public class StoryViewerFragment extends Fragment {
try { player.release(); } catch (Exception ignored) { } try { player.release(); } catch (Exception ignored) { }
player = null; player = null;
} }
private void paginateStories(Object feedStory, Context context, boolean backward, boolean last) {
if (feedStory != null) {
if (fetching) {
Toast.makeText(context, R.string.be_patient, Toast.LENGTH_SHORT).show();
return;
}
fetching = true;
binding.btnBackward.setVisibility(currentFeedStoryIndex == 1 && backward ? View.INVISIBLE : View.VISIBLE);
binding.btnForward.setVisibility(last ? View.INVISIBLE : View.VISIBLE);
currentFeedStoryIndex = backward ? (currentFeedStoryIndex - 1) : (currentFeedStoryIndex + 1);
resetView();
}
}
} }

4
app/src/main/res/layout/fragment_post_view.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.viewpager2.widget.ViewPager2 xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />

33
app/src/main/res/layout/fragment_story_viewer.xml

@ -116,12 +116,41 @@
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout> </FrameLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnBackward"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="40dp"
android:layout_height="0dp"
android:visibility="visible"
app:icon="@drawable/exo_ic_skip_previous"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/storiesList"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/storiesList" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/storiesList" android:id="@+id/storiesList"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false" android:clipToPadding="false"
app:layout_constraintTop_toBottomOf="@id/story_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btnForward"
app:layout_constraintStart_toEndOf="@id/btnBackward" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnForward"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="40dp"
android:layout_height="0dp"
android:visibility="visible"
app:icon="@drawable/exo_ic_skip_next"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toEndOf="@id/storiesList"
app:layout_constraintTop_toTopOf="@id/storiesList" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

2
app/src/main/res/layout/item_story.xml

@ -5,7 +5,7 @@
android:layout_height="@dimen/story_item_height" android:layout_height="@dimen/story_item_height"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:layout_margin="8dp"
android:layout_margin="4dp"
android:foreground="?android:selectableItemBackground"> android:foreground="?android:selectableItemBackground">
<com.facebook.drawee.view.SimpleDraweeView <com.facebook.drawee.view.SimpleDraweeView

Loading…
Cancel
Save