Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
Updated toolchain of sample app
  • Loading branch information
Faltenreich committed Oct 14, 2020
1 parent 53a67d0 commit 1a7d14a
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 55 deletions.
78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Create your own skeleton view with custom shapes, colors and shimmers.
- **Make your app feel faster:** Immediate visual feedback long before your data has been fetched or requested
- **Support any View:** Apply to any type of View or ViewGroup
- **RecyclerView on speed:** Convenience adapter for the RecyclerView, since it is the main use case
- **ViewPager2 support:** As ViewPager2 uses RecyclerView internally the same concepts apply
- **ViewPager2 support:** Convenience adapter for the ViewPager2, as it uses a RecyclerView under the hood
- **Customization:** Adjust shimmer, color and shape of the skeleton to set you apart from other apps
- **Minimum effort:** A fistful lines of code to use the SkeletonLayout
- **Minimum footprint:** org.jetbrains.kotlin:kotlin-stdlib-jdk7 and androidx.recyclerview:recyclerview are the only dependencies
- **Minimum footprint:** org.jetbrains.kotlin:kotlin-stdlib-jdk7, androidx.recyclerview:recyclerview and androidx.viewpager2.widget.ViewPager2 are the only dependencies

### Getting Started

Expand All @@ -58,6 +58,38 @@ dependencies {
</com.faltenreich.skeletonlayout.SkeletonLayout>
```

##### Kotlin
```kotlin
class MainActivity : AppCompatActivity() {

private lateinit var skeleton: Skeleton

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// Either use an existing Skeletonlayout
skeleton = findViewById(R.id.skeletonLayout)

// or create a new SkeletonLayout from a given View
skeleton = view.createSkeleton()

// or apply a new SkeletonLayout to a RecyclerView
skeleton = recyclerView.applySkeleton(R.layout.list_item_recyclerview)

// or apply a new SkeletonLayout to a ViewPager2
skeleton = viewPager2.applySkeleton(R.layout.list_item_viewpager2)

skeleton.showSkeleton()
}

// Example callback that hides skeleton
private fun onDataLoaded() {
skeleton.showOriginal()
}
}
```

##### Java
```java
public class MainActivity extends AppCompatActivity {
Expand All @@ -75,11 +107,11 @@ public class MainActivity extends AppCompatActivity {
// or create a new SkeletonLayout from a given View
skeleton = SkeletonLayoutUtils.createSkeleton(view);

// or apply a new SkeletonLayout to a RecyclerView (showing 5 items)
skeleton = SkeletonLayoutUtils.applySkeleton(recyclerView, R.layout.list_item, 5);
// or apply a new SkeletonLayout to a RecyclerView
skeleton = SkeletonLayoutUtils.applySkeleton(recyclerView, R.layout.list_item_recyclerview);

// or apply a new SkeletonLayout to a ViewPager2 (showing 3 items)
skeleton = SkeletonLayoutUtils.applySkeleton(viewPager2, R.layout.pager_item, 3);
// or apply a new SkeletonLayout to a ViewPager2
skeleton = SkeletonLayoutUtils.applySkeleton(viewPager2, R.layout.list_item_viewpager2);

skeleton.showSkeleton();
}
Expand All @@ -91,38 +123,6 @@ public class MainActivity extends AppCompatActivity {
}
```

##### Kotlin
```kotlin
class MainActivity : AppCompatActivity() {

private lateinit var skeleton: Skeleton

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// Either use an existing Skeletonlayout
skeleton = findViewById(R.id.skeletonLayout)

// or create a new SkeletonLayout from a given View
skeleton = view.createSkeleton()

// or apply a new SkeletonLayout to a RecyclerView (showing 5 items)
skeleton = recyclerView.applySkeleton(R.layout.list_item, 5)

// or apply a new SkeletonLayout to a ViewPager2 (showing 3 items)
skeleton = viewPager2.applySkeleton(R.layout.pager_item, 3)

skeleton.showSkeleton()
}

// Example callback that hides skeleton
private fun onDataLoaded() {
skeleton.showOriginal()
}
}
```

### Configuration

Property | Type | Description
Expand All @@ -132,7 +132,7 @@ maskCornerRadius | dimension | The x- and y-radius of the oval used to round the
showShimmer | boolean | Animate left-to-right shimmer, if set to true (defaults to true)
shimmerColor | color | Color of the animated shimmer (defaults to #d5d5d5)
shimmerDurationInMillis | integer | Duration in milliseconds for one shimmer animation interval (defaults to 2000)
itemCount | integer | Item count for Skeleton adapter (RecyclerView only, defaults to 3)
itemCount | integer | Item count for Skeleton adapter (RecyclerView and ViewPager2 only, defaults to 3)

### FAQ

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.naz013:ColorSlider:2.0.6'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'com.github.naz013:ColorSlider:2.0.7'
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ class RecyclerViewFragment : MainPagerFragment(R.layout.fragment_recyclerview, "
list.layoutManager = LinearLayoutManager(context)
list.adapter = listAdapter

skeleton = list.applySkeleton(R.layout.list_item, items.size).apply { showSkeleton() }
skeleton = list.applySkeleton(R.layout.list_item_recyclerview, items.size).apply { showSkeleton() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.faltenreich.skeletonlayout.demo.R
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.list_item.*
import kotlinx.android.synthetic.main.list_item_recyclerview.*

class RecyclerViewHolder(
parent: ViewGroup,
private val view: View = LayoutInflater.from(parent.context).inflate(R.layout.list_item, parent, false)
private val view: View = LayoutInflater.from(parent.context).inflate(R.layout.list_item_recyclerview, parent, false)
) : RecyclerView.ViewHolder(view), LayoutContainer {

override val containerView: View?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.faltenreich.skeletonlayout.demo.MainPagerFragment
import com.faltenreich.skeletonlayout.demo.R
import com.faltenreich.skeletonlayout.demo.recyclerview.RecyclerViewListItem
import kotlinx.android.synthetic.main.fragment_viewgroup.*
import kotlinx.android.synthetic.main.list_item.*
import kotlinx.android.synthetic.main.list_item_recyclerview.*

class ViewGroupFragment : MainPagerFragment(R.layout.fragment_viewgroup, "ViewGroup") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ViewPager2Fragment : MainPagerFragment(R.layout.fragment_viewpager2, "View
val listAdapter = ViewPager2Adapter(items)
pager.adapter = listAdapter

skeleton = pager.applySkeleton(R.layout.pager_item, items.size).apply { showSkeleton() }
skeleton = pager.applySkeleton(R.layout.list_item_viewpager2, items.size).apply { showSkeleton() }
mediator = TabLayoutMediator(pager_tabs, pager) { _, _ -> }.apply { attach() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.faltenreich.skeletonlayout.demo.R
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.list_item.*
import kotlinx.android.synthetic.main.list_item_viewpager2.*

class ViewPager2ViewHolder(
parent: ViewGroup,
private val view: View = LayoutInflater.from(parent.context).inflate(R.layout.pager_item, parent, false)
private val view: View = LayoutInflater.from(parent.context).inflate(R.layout.list_item_viewpager2, parent, false)
) : RecyclerView.ViewHolder(view), LayoutContainer {

override val containerView: View?
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_recyclerview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
android:layout_height="match_parent"
android:padding="@dimen/margin"
android:clipToPadding="false"
tools:listitem="@layout/list_item"/>
tools:listitem="@layout/list_item_recyclerview"/>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_viewgroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
app:shimmerColor="@color/colorPrimaryDark"
app:shimmerDurationInMillis="2000">

<include layout="@layout/list_item"/>
<include layout="@layout/list_item_recyclerview"/>

</com.faltenreich.skeletonlayout.SkeletonLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_viewpager2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:layout_weight="1"
android:clipToPadding="false"
android:padding="@dimen/margin"
tools:listitem="@layout/list_item" />
tools:listitem="@layout/list_item_viewpager2" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/pager_tabs"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
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"
Expand All @@ -26,7 +27,6 @@
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginStart="@dimen/padding"
android:layout_marginLeft="@dimen/padding"
android:layout_marginTop="@dimen/padding"
android:contentDescription="@null"
app:layout_constraintEnd_toEndOf="@id/wallpaperView"
Expand All @@ -40,7 +40,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding"
android:layout_marginLeft="@dimen/padding"
android:layout_marginTop="@dimen/padding"
android:gravity="center"
android:textColor="@android:color/black"
Expand Down

0 comments on commit 1a7d14a

Please sign in to comment.