Skip to content

gzeinnumer/PaginationManualJava

Repository files navigation

PaginationManualJava


vm.getNotification().observe(this, resource -> {
    switch (resource.status) {
        case STATUS_1_SUCCESS:
            swipe(binding.swipeRefreshLayout, false);
            list = resource.data;
            emptyState(list != null ? list.size() : 0, binding.rv, binding.imgEmpty);
            params.setTotalData(resource.total);
            adapter.addNewItem(resource.data);
            break;
        case STATUS_2_ERROR:
            swipe(binding.swipeRefreshLayout, false);
            emptyState(list != null ? list.size() : 0, binding.rv, binding.imgEmpty);
            break;
        case STATUS_6_LOADING:
            swipe(binding.swipeRefreshLayout, true);
            emptyState(list != null ? list.size() : 0, binding.rv, binding.imgEmpty);
            break;
    }
});
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    style="@style/swipeRefreshLayoutV1">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv"
            style="@style/LLEmptyStateRV"
            android:visibility="gone"
            tools:itemCount="3"
            tools:listitem="@layout/item_notifikasi"
            tools:visibility="visible" />

        <LinearLayout
            android:id="@+id/imgEmpty"
            style="@style/LLEmptyState"
            android:visibility="gone"
            tools:visibility="visible">

            <ImageView
                style="@style/LLEmptyStateImage"
                android:src="@drawable/img_no_data_v3" />

        </LinearLayout>
    </LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<style name="swipeRefreshLayoutV1">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">0dp</item>
    <item name="android:layout_weight">1</item>
</style>

<style name="LLEmptyStateRV">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">0dp</item>
    <item name="android:layout_weight">1</item>
    <item name="android:overScrollMode">never</item>
</style>

<style name="LLEmptyState">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">0dp</item>
    <item name="android:layout_weight">1</item>
    <item name="android:gravity">center</item>
    <item name="android:orientation">vertical</item>
</style>

<style name="LLEmptyStateImage">
    <item name="android:layout_width">300dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:adjustViewBounds">true</item>
    <item name="android:scaleType">fitCenter</item>
    <item name="android:src">@drawable/img_no_data_v3</item>
</style>

Copyright 2021 M. Fadli Zein

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages