Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ Bind it with a `PlutoView` instance.
pluto.setCustomIndicator(findViewById(R.id.custom_indicator));
```

> Minimum Supported Version is (17)
> Target Sdk Version is (28)


# License

Expand Down
18 changes: 16 additions & 2 deletions pluto/src/main/java/com/opensooq/pluto/PlutoView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.opensooq.pluto.base.PlutoAdapter
import com.opensooq.pluto.listeners.OnSlideChangeListener
import com.opensooq.pluto.listeners.OnSnapPositionChangeListener
import com.opensooq.pluto.listeners.SnapOnScrollListener
import java.lang.IllegalArgumentException
import java.lang.ref.WeakReference
import java.util.*
import kotlin.Experimental.Level
Expand All @@ -36,6 +37,7 @@ class PlutoView @JvmOverloads constructor(context: Context,
private var cycleTimer: Timer? = null
private var cycleTask: TimerTask? = null
private var plutoAdapter: PlutoAdapter<*, *>? = null
private var linearLayoutManager: LinearLayoutManager? = null

private var resumingTimer: Timer? = null
var isCycling: Boolean = false
Expand All @@ -58,8 +60,8 @@ class PlutoView @JvmOverloads constructor(context: Context,

private val mh = IncomingHandler(this)
private fun setupAdapter() {
val linearLayoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
linearLayoutManager.initialPrefetchItemCount = 4
linearLayoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
linearLayoutManager?.initialPrefetchItemCount = 4
rvSlider?.apply {
layoutManager = linearLayoutManager
adapter = plutoAdapter
Expand Down Expand Up @@ -173,6 +175,17 @@ class PlutoView @JvmOverloads constructor(context: Context,
}
}

/**
* Change the Layout Direction
*/
fun isRtl(isRtl: Boolean) {
if (linearLayoutManager == null) {
throw IllegalArgumentException("Pluto Adapter Not Setup Yet call setupAdapter()")
}

linearLayoutManager?.reverseLayout = isRtl
}

fun setOnSlideChangeListener(onSlideChangeListener: OnSlideChangeListener) {
this.onSlideChangeListener = onSlideChangeListener

Expand Down Expand Up @@ -373,6 +386,7 @@ class PlutoView @JvmOverloads constructor(context: Context,
mh.removeCallbacksAndMessages(null)
rvSlider?.adapter = null
indicator?.destroySelf()
linearLayoutManager = null
onScrollListener?.let { rvSlider?.removeOnScrollListener(it) }
onScrollListener = null
onSlideChangeListener = null
Expand Down
1 change: 0 additions & 1 deletion pluto/src/main/res/layout/layout_view_slider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:id="@+id/rvSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
custom:layout_constraintEnd_toEndOf="parent"
custom:layout_constraintStart_toStartOf="parent"
custom:layout_constraintTop_toTopOf="parent"/>
Expand Down