• Stars
    star
    3,555
  • Rank 11,896 (Top 0.3 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android Library that lights items for tutorials or walk-throughs etc...

Spotlight

alt text

Build Status Download License API

Gradle

dependencies {
    implementation 'com.github.takusemba:spotlight:x.x.x'
}

Usage

val spotlight = Spotlight.Builder(this)
    .setTargets(firstTarget, secondTarget, thirdTarget ...)
    .setBackgroundColor(R.color.spotlightBackground)
    .setDuration(1000L)
    .setAnimation(DecelerateInterpolator(2f))
    .setContainer(viewGroup)
    .setOnSpotlightListener(object : OnSpotlightListener {
      override fun onStarted() {
        Toast.makeText(this@MainActivity, "spotlight is started", Toast.LENGTH_SHORT).show()
      }
      override fun onEnded() {
        Toast.makeText(this@MainActivity, "spotlight is ended", Toast.LENGTH_SHORT).show()
      }
    })
    .build()         

If you want to show Spotlight immediately, you have to wait until views are laid out.

// with core-ktx method.
view.doOnPreDraw { Spotlight.Builder(this)...start() }


Target

Create a Target to add Spotlight.

Target is a spot to be casted by Spotlight. You can add multiple targets to Spotlight.

val target = Target.Builder()
    .setAnchor(100f, 100f)
    .setShape(Circle(100f))
    .setEffect(RippleEffect(100f, 200f, argb(30, 124, 255, 90)))
    .setOverlay(layout)
    .setOnTargetListener(object : OnTargetListener {
      override fun onStarted() {
        makeText(this@MainActivity, "first target is started", LENGTH_SHORT).show()
      }
      override fun onEnded() {
        makeText(this@MainActivity, "first target is ended", LENGTH_SHORT).show()
      }
    })
    .build()


Start/Finish Spotlight

val spotlight = Spotlight.Builder(this)...start()

spotlight.finish()

Next/Previous/Show Target

val spotlight = Spotlight.Builder(this)...start()

spotlight.next()

spotlight.previous()

spotlight.show(2)

Custom Shape

Shape defines how your target will look like. Circle and RoundedRectangle shapes are already implemented, but if you want your custom shape, it's arhivable by implementing Shape interface.

class CustomShape(
    override val duration: Long,
    override val interpolator: TimeInterpolator
) : Shape {

  override fun draw(canvas: Canvas, point: PointF, value: Float, paint: Paint) {
    // draw your shape here.
  }
}

Custom Effect

Effect allows you to decorates your target. RippleEffect and FlickerEffect shapes are already implemented, but if you want your custom effect, it's arhivable by implementing Effect interface.

class CustomEffect(
    override val duration: Long,
    override val interpolator: TimeInterpolator,
    override val repeatMode: Int
) : Effect {

  override fun draw(canvas: Canvas, point: PointF, value: Float, paint: Paint) {
    // draw your effect here.
  }
}

Sample

Clone this repo and check out the app module.

Author

Licence

Copyright 2017 Taku Semba.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

MultiSnapRecyclerView

Android library for multiple snapping of RecyclerView
Kotlin
2,503
star
2

RtmpPublisher

Rtmp client on Android. Live Video Streaming.
Java
611
star
3

JetHub

Sample App with Jetpack components(LiveData, Navigation, ViewModel) + MVVM + coroutine + single activity
Kotlin
431
star
4

CropMe

Extremely Smooth and Easy Cropping library for you
Kotlin
408
star
5

docker-nginx-rtmp

docker file for RTMP on nginx
XSLT
48
star
6

AudioThief

Let you gain and release AudioFocus.
Kotlin
41
star
7

RtmpPlayer

RTMP player on Android
Kotlin
33
star
8

Tindest

This is a Tinder-like app
Swift
29
star
9

HlsPlayer

HLS Player on Android
Kotlin
21
star
10

go-hls-hosting

generates LIVE, CHASE playlists from your given VOD playlist, then publish their playlists individually.
Go
19
star
11

SampleDrmExoPlayer

Kotlin
18
star
12

QuicPlayer

media player using QUIC protocol
Kotlin
18
star
13

exoplayer-practice-guide-sample

「ExoPlayer実践ガイド」 のサンプルアプリ
Kotlin
18
star
14

AutoBuilder

Auto builder generation with Annotation Processing
Java
13
star
15

DribbbleKotlinApp

this is a dribbble app written in kotlin
Kotlin
11
star
16

RetrofitDownloader

Download files using Retrofit
Java
8
star
17

grpc-android

client side for grpc
Java
8
star
18

DribbbleMvp

Android architecture MVP
Java
7
star
19

SpringSample

Kotlin
4
star
20

EspressoDemo

Espresso demo
Java
4
star
21

camembert

API server with protocol buffers
Go
4
star
22

ksudoku

sudoku solver in kotlin
Kotlin
3
star
23

ProcessLifecycleOwnerSample

sample app using ProcessLifecycleOwner
Kotlin
2
star
24

DribbbleSwiftApp

this is a iOS App written in Swift
Swift
2
star
25

AudioFocusServiceApp

AudioFocusServiceApp allow you to control audio focus via Service
Kotlin
2
star
26

Ekuity

A command-line tool written in Kotlin for calculating equity
Kotlin
2
star
27

grpc-go

grpc written in golang
Go
1
star
28

gouda

json request vs proto request
Java
1
star
29

grpc-proto

proto file for grpc
Java
1
star
30

DribbbleAndroidApp

this is a Dribbble App written in Android java
Java
1
star
31

KotlinAndroidProjectSample

AndroidProject Sample in Kotlin
Kotlin
1
star
32

portfolio

My Portfolio powered by Hugo
HTML
1
star
33

TakuSemba

My Profile Repository
1
star