Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
luis.falmeida committed Jul 22, 2021
2 parents f8e99ca + da9acb5 commit 2075067
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# CircleIndicator

This design is a circular indicator to be used in the recycler view,
just like those used in ViewPagers, and was based in the lib [CircleIndicator](https://github.com/ongakuer/CircleIndicator).

The main goals of this personal project were:
* Isolate code referring to recyclerview.
* Migrate Java code to Kotlin, following the Clean Code guidelines as much as possible.
* Allow control of height and width of selected and deselected indicators alone.

<img src="circle_indicator.gif" width="280">

Usages:

### Part 1 - XML Example of usage:

```
<?xml version="1.0" encoding="utf-8"?>
<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"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_image_generic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.luisfalmeida.circleindicator.circleindicator.CircleIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/white"
app:ci_width="12dp"
app:ci_height="4dp"
app:ci_deselected_width="4dp"
app:ci_deselected_height="4dp"
app:ci_drawable="@drawable/ic_dot_black"
app:ci_drawable_unselected="@drawable/ic_dot_gray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rv_image_generic"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
```

### Part 2: Create recyclerview and circleIndicator

```
val recyclerView = findViewById(R.id.rv_image_gallery)
val circleIndicator = findViewById(R.id.indicator)
```

### Part 3: Create and attach Snap Helper

```
pagerSnapHelper = PagerSnapHelper()
pagerSnapHelper.attachToRecyclerView(recyclerView)
```

### Part 4: Set recyclerview

```
recyclerView.apply {
this.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
adapter = imagesAdapter
circleIndicator.attachToRecyclerView(this, pagerSnapHelper)
}
```

### Properties

| Properties | Default Value |
| ---------- | ------------- |
app:ci_width | 5dp
app:ci_height | 5dp
app:ci_deselected_width | 4dp
app:ci_deselected_height | 4dp
app:ci_margin | 5dp
app:ci_drawable | R.drawable.white_radius
app:ci_drawable_unselected | R.drawable.white_radius
app:ci_animator | R.animator.scale_with_alpha
app:ci_animator_reverse | 0
app:ci_orientation | horizontal
app:ci_gravity | center

This is an ongoing project, if you have any criticisms or suggestions, please leave an issue here, or contact me via email: luis.almeida.filipe@gmail.com


Binary file added circle_indicator.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2075067

Please sign in to comment.