Skip to content

Commit

Permalink
weaken access to some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtom committed May 14, 2019
1 parent 84e91e2 commit ecb5367
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="@drawable/bg_btn_red"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/slider_view">
Expand Down
5 changes: 4 additions & 1 deletion pluto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ext {
gitUrl = 'https://github.com/OpenSooq/Pluto.git'
githubRepository= 'OpenSooq/Pluto'

libraryVersion = '1.3'
libraryVersion = '1.4'

developerId = 'OpenSooq'
developerName = 'OpenSooq'
Expand Down Expand Up @@ -64,3 +64,6 @@ dependencies {
}
apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/installv1.gradle'
apply from: 'https://gist.githubusercontent.com/tamtom/f54a538637178e4818bbc72f24a73e2d/raw/af6f8b6782475230cfff852ae11669c936e739a2/bintrayv1.gradle'
tasks.withType(Javadoc).all {
enabled = false
}
12 changes: 6 additions & 6 deletions pluto/src/main/java/com/opensooq/pluto/PlutoLifeCycleObserver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ import android.arch.lifecycle.OnLifecycleEvent
internal class PlutoLifeCycleObserver : LifecycleObserver {
private var actionHandler: ViewActionHandler? = null
private lateinit var lifecycle: Lifecycle
fun registerActionHandler(handler: ViewActionHandler) {
internal fun registerActionHandler(handler: ViewActionHandler) {
this.actionHandler = handler
}

fun registerLifecycle(lifecycle: Lifecycle) {
internal fun registerLifecycle(lifecycle: Lifecycle) {
this.lifecycle = lifecycle
this.lifecycle.addObserver(this)
}

@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
fun onResume() {
internal fun onResume() {
this.actionHandler?.onResumed()
}

@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
fun stop() {
internal fun stop() {
this.actionHandler?.onDestroy()
}

@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
fun onDestroy() {
internal fun onDestroy() {
this.actionHandler?.onPause()
}

fun unregister() {
internal fun unregister() {
this.actionHandler = null
lifecycle.removeObserver(this)
}
Expand Down
13 changes: 8 additions & 5 deletions pluto/src/main/java/com/opensooq/pluto/PlutoView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.opensooq.pluto.listeners.OnSnapPositionChangeListener
import com.opensooq.pluto.listeners.SnapOnScrollListener
import java.lang.ref.WeakReference
import java.util.*
import kotlin.Experimental.Level

/**
* Created by Omar Altamimi on 28,April,2019
Expand Down Expand Up @@ -382,23 +383,21 @@ class PlutoView @JvmOverloads constructor(context: Context,
}
}

@DontUse
override fun onResumed() {
println("LifeCycle : onResumed()")
if (wasCycling) {
println("LifeCycle : recovering()")
recoverCycle()
}

}

@DontUse
override fun onPause() {

println("LifeCycle : onPause()")
pauseAutoCycle()
}

@DontUse
override fun onDestroy() {
println("LifeCycle : onDestroy()")
destroyPluto()
}

Expand All @@ -407,4 +406,8 @@ class PlutoView @JvmOverloads constructor(context: Context,
private const val DELAY_TIME = 3000L
private const val DEFAULT_DURATION = 4000L
}

@Experimental(level = Level.ERROR)
private annotation class DontUse

}

0 comments on commit ecb5367

Please sign in to comment.