1
0
Fork 0
mirror of https://github.com/KokaKiwi/BarInsta synced 2026-03-05 20:11:36 +00:00

Update Feed view, check description

Changes:

1. Separate out view holders for feed post types.
2. Improve performance for binding.
4. Initiating migration from Glide to Fresco, as performance of Fresco is way better.
3. Prefetch feed view thumbnails to get aspect ratio, to improve layout performance.
4. If auto play is off, the videos in feed are not loaded until play is pressed.
5. Lots of optimizations here and there.
This commit is contained in:
Ammar Githam 2020-08-25 00:05:54 +09:00
parent 0b183c5ab5
commit da98cff507
44 changed files with 4375 additions and 1274 deletions

View file

@ -71,7 +71,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
tools:listitem="@layout/item_feed" />
tools:listitem="@layout/item_feed_photo" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</awais.instagrabber.customviews.RemixDrawerLayout>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:viewBindingIgnore="true">
<include layout="@layout/item_feed_top" />
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/imageViewer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include layout="@layout/item_feed_bottom" />
</LinearLayout>

View file

@ -16,8 +16,9 @@
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="32dp"
android:layout_marginLeft="4dp"
android:layout_height="48dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:srcCompat="@drawable/comments" />
<androidx.appcompat.widget.AppCompatTextView
@ -32,7 +33,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/llVideoViews"
android:id="@+id/videoViewsContainer"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_toEndOf="@id/btnComments"
@ -62,8 +63,8 @@
android:layout_alignRight="@id/btnMute"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:layout_toEndOf="@id/llVideoViews"
android:layout_toRightOf="@id/llVideoViews">
android:layout_toEndOf="@id/videoViewsContainer"
android:layout_toRightOf="@id/videoViewsContainer">
<View
android:layout_width="1dip"
@ -131,7 +132,7 @@
android:padding="12dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="16sp"
tools:text="BOTTOM TEXT HAHA FUNNY MEME" />
tools:text="BOTTOM TEXT" />
</FrameLayout>
</ScrollView>
</RelativeLayout>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<!--<com.github.chrisbanes.photoview.PhotoView-->
<!-- android:id="@+id/imageViewer"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content" />-->
<awais.instagrabber.customviews.drawee.ZoomableDraweeView
android:id="@+id/imageViewer"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@android:color/transparent" />
<include
android:id="@+id/item_feed_bottom"
layout="@layout/item_feed_bottom" />
</LinearLayout>

View file

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:viewBindingIgnore="true">
android:orientation="vertical">
<include layout="@layout/item_feed_top" />
<include
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<FrameLayout
android:layout_width="match_parent"
@ -16,7 +16,7 @@
<androidx.viewpager.widget.ViewPager
android:id="@+id/media_list"
android:layout_width="match_parent"
android:layout_height="200dp" />
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="24dp"
@ -31,8 +31,13 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center"
android:textSize="20sp" />
android:padding="5dp"
android:textColor="@android:color/white"
android:background="@drawable/rounder_corner_semi_black_bg"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
</FrameLayout>
<include layout="@layout/item_feed_bottom" />
<include
android:id="@+id/item_feed_bottom"
layout="@layout/item_feed_bottom" />
</LinearLayout>

View file

@ -1,48 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<awais.instagrabber.customviews.CircularImageView
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/ivProfilePic"
android:layout_width="@dimen/feed_profile_size"
android:layout_height="@dimen/feed_profile_size"
android:adjustViewBounds="true"
app:roundAsCircle="true"
android:background="?selectableItemBackgroundBorderless" />
<RelativeLayout
android:id="@+id/infoContainer"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:animateLayoutChanges="true"
android:background="@null"
android:orientation="vertical"
android:weightSum="2"
android:paddingStart="4dp"
android:paddingLeft="4dp"
android:paddingEnd="4dp"
android:paddingRight="4dp">
android:paddingRight="4dp"
android:weightSum="2">
<awais.instagrabber.customviews.RamboTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="@color/feed_text_primary_color"
android:textSize="18sp"/>
android:textSize="18sp" />
<awais.instagrabber.customviews.RamboTextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="@color/feed_text_primary_color"
android:textSize="18sp" />

View file

@ -1,23 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/videoHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:viewBindingIgnore="true">
android:orientation="vertical">
<include layout="@layout/item_feed_top" />
<include
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/playerView"
<ViewSwitcher
android:id="@+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="240dp"
app:auto_show="true"
app:controller_layout_id="@layout/layout_controls"
app:repeat_toggle_modes="all"
app:use_controller="true" />
android:layout_height="wrap_content">
<include layout="@layout/item_feed_bottom" />
<!--<androidx.appcompat.widget.AppCompatImageView-->
<!-- android:id="@+id/thumbnail"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:adjustViewBounds="true"-->
<!-- android:scaleType="fitCenter"/>-->
<FrameLayout
android:id="@+id/thumbnail_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:actualImageScaleType="fitCenter" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
app:srcCompat="@drawable/exo_controls_play" />
</FrameLayout>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1000" />
</ViewSwitcher>
<include
android:id="@+id/item_feed_bottom"
layout="@layout/item_feed_bottom" />
</LinearLayout>

View file

@ -44,6 +44,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
tools:listitem="@layout/item_feed" />
tools:listitem="@layout/item_feed_photo" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:background="@null"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="@null">
<!-- for users -->
<com.google.android.material.appbar.CollapsingToolbarLayout
@ -86,8 +85,8 @@
android:paddingRight="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="16sp"
tools:text="https://austinhuang.me/"
android:visibility="gone" />
android:visibility="gone"
tools:text="https://austinhuang.me/" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/profileActions"
@ -99,47 +98,47 @@
android:id="@+id/btnFollow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="1dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/follow"
android:textColor="@color/btn_pink_text_color"
android:textSize="16sp"
app:backgroundTint="@color/btn_pink_background"
android:visibility="gone" />
android:visibility="gone"
app:backgroundTint="@color/btn_pink_background" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnRestrict"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="1dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/restrict"
android:textColor="@color/btn_orange_text_color"
android:textSize="16sp"
app:backgroundTint="@color/btn_orange_background"
android:visibility="gone" />
android:visibility="gone"
app:backgroundTint="@color/btn_orange_background" />
<!-- only for invisible private accounts -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnBlock"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="1dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/block"
android:textColor="@color/btn_red_text_color"
android:textSize="16sp"
app:backgroundTint="@color/btn_red_background"
android:visibility="gone" />
android:visibility="gone"
app:backgroundTint="@color/btn_red_background" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
@ -152,47 +151,47 @@
android:id="@+id/btnTagged"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/tagged"
android:textColor="@color/btn_blue_text_color"
android:textSize="16sp"
app:backgroundTint="@color/btn_blue_background"
android:visibility="gone" />
android:visibility="gone"
app:backgroundTint="@color/btn_blue_background" />
<!-- also used as block -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnSaved"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/saved"
android:textColor="@color/btn_orange_text_color"
android:textSize="16sp"
app:backgroundTint="@color/btn_orange_background"
android:visibility="gone" />
android:visibility="gone"
app:backgroundTint="@color/btn_orange_background" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnLiked"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/liked"
android:textColor="@color/btn_lightpink_text_color"
android:textSize="16sp"
app:backgroundTint="@color/btn_lightpink_background"
android:visibility="gone" />
android:visibility="gone"
app:backgroundTint="@color/btn_lightpink_background" />
</androidx.appcompat.widget.LinearLayoutCompat>
@ -219,9 +218,7 @@
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainProfileImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:adjustViewBounds="true"
android:background="?selectableItemBackgroundBorderless" />
android:layout_height="@dimen/profile_picture_size" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainPostCount"
@ -372,15 +369,15 @@
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/locationFullName"
android:layout_below="@id/locInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/locInfo"
android:layout_weight="1"
android:ellipsize="marquee"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:ellipsize="marquee"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="16sp"
@ -413,8 +410,8 @@
android:paddingRight="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="16sp"
tools:text="https://austinhuang.me/"
android:visibility="gone" />
android:visibility="gone"
tools:text="https://austinhuang.me/" />
</RelativeLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>