Git Product home page Git Product logo

luckywheel_android's Introduction

LuckyWheel Android

Android custom component that displays a lucky wheel. it features easy customize of colors , text and addition of items and it's very trivial to integrate in your application.

What's new in 0.3.0

  • Fix the image rotation issue

Sample

Lucky wheel.

Overview

The LuckyWheel shows a wheel which can spin, and a marker that indicates the selected item in the wheel. Items may be customized with text, image, or a color.

The wheel starts off stationary. Calling the setTarget() method with an integer parameter will set the wheel to spin to that section when the user taps the wheel in the UI. Calling rotateWheelTo() with an integer parameter will cause the wheel to spin to that section immediately.

The wheel spins for a few seconds, then fires the setLuckyWheelReachTheTarget callback to notify the application it has stopped moving.

Installing

Add it in your root build.gradle at the end of repositories:

  allprojects {
  	repositories {
  		...
  		maven { url 'https://jitpack.io' }
  	}
  }

Step 2. Add the dependency

dependencies {
  	implementation 'com.github.mmoamenn:LuckyWheel_Android:0.3.0'
  }

XML

<com.bluehomestudio.luckywheel.LuckyWheel
        android:id="@+id/lwv"
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:layout_centerInParent="true"
        LuckyWheel:background_color="@color/colorPrimary" />

You must use the following properties in your XML

Choose the background color

LuckyWheel:background_color

Choose wheel image arrow

LuckyWheel:arrow_image

Change item image padding

LuckyWheel:image_padding

Kotlin

Functions to use after reference the Lucky wheel

  • Create wheel sections
val wheelItems: MutableList<WheelItem> = ArrayList()

wheelItems.add(WheelItem(Color.LTGRAY,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 1"))

wheelItems.add(WheelItem(Color.BLUE,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 2"))

wheelItems.add(WheelItem(Color.BLACK,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 3"))

wheelItems.add(WheelItem(Color.GRAY,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name)
,"text 4"))

wheelItems.add(WheelItem(Color.RED,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 5"))

wheelItems.add(WheelItem(Color.BLACK,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 6"))
  • Add sections to wheel
 addWheelItems(wheelItems)
  • Rotate by touch -- set target before user touch wheel
 setTarget(3)
  • Rotate to section -- not need if you will use touch
 rotateWheelTo(2)
  • On target reach listener
 lwv.setLuckyWheelReachTheTarget {
 
 }

Note

Last version before support AndroidX com.github.mmoamenn:LuckyWheel_Android:0.1.2

luckywheel_android's People

Contributors

mflisar avatar mikeblas avatar mmoamenn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

luckywheel_android's Issues

How to add text to each item?

Hello, this is a great library. It can attach image to each element in the wheel. But, how to add text to each item like +2 coins or something like that? And how to stop it like call the stop() function? Thanks in advance.

documentation could use an overview

There are no samples for the wheel, and it's not clear how the wheel is meant to work or be used from the existing documentation. It would be helpful to add a section to the documentation that gives an overview of what the LuckyWheel does and how it can be used.

Failed to resolve dependencies

I'm trying to add the LuckyWheel dependency to my project (I've tried version 0.3.0 too), and I get the following error:

> Could not find com.github.mmoamenn:LuckyWheel_Android:0.1.2. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/github/mmoamenn/LuckyWheel_Android/0.1.2/LuckyWheel_Android-0.1.2.pom - https://repo.maven.apache.org/maven2/com/github/mmoamenn/LuckyWheel_Android/0.1.2/LuckyWheel_Android-0.1.2.pom Required by: project :app

Has the package been removed from the repos? Thanks!

how to use text?

Hey im a beginner on java, android studio. i would really like to know how to use the string function.
It shows me only Bitmap

Image in wheel

I don't want to add an Image or bitmap in Wheel. So what is the solution for this?

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

This is my piece of code for adding items to the lucky wheel :
val b = ArrayList<WheelItem>() val bitmap = BitmapFactory.decodeResource(resources, R.drawable.circle) b.add((WheelItem(Color.parseColor("#FFFFFF"), bitmap, "Test"))) b.add((WheelItem(Color.parseColor("#FFFFFF"), bitmap, "Test"))) luckyWheel.addWheelItems(b)

This is the error I'm getting :

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
at com.bluehomestudio.luckywheel.WheelView.drawImage(WheelView.java:133)
at com.bluehomestudio.luckywheel.WheelView.onDraw(WheelView.java:245)
at android.view.View.draw(View.java:23194)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.widget.ScrollView.draw(ScrollView.java:1869)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5030)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
E/AndroidRuntime: at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.View.draw(View.java:22925)
at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
at android.view.View.draw(View.java:23197)
at com.android.internal.policy.DecorView.draw(DecorView.java:821)
at android.view.View.updateDisplayListIfDirty(View.java:22061)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:689)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:695)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:793)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4670)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4381)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3600)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2328)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9087)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
at android.view.Choreographer.doCallbacks(Choreographer.java:899)
at android.view.Choreographer.doFrame(Choreographer.java:832)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

    I think you forgot to do a null check before trying to draw the bitmap

How to Set Multiline text ?

I want to set Multi line text according to width of each triangle. how is it possible? Please help me for same

I am getting null point exception error when using it on fragment.

Hi,

Good day! hope you are doing well at this moment. Just so you know I am new to android development.

I'm not really sure of this is an issue or I am just missing something on my code. Would you mind taking a look of this?

Here is my MainActivity:

package com.example.foodpicker

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

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

    supportFragmentManager.beginTransaction()
        .replace(R.id.mainViewFragment, SpinnerFragment())
        .commit()
}

}

activity_main.xml

<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">

<FrameLayout
    android:id="@+id/mainViewFragment"
    android:layout_width="326dp"
    android:layout_height="458dp"
    app:layout_constraintBottom_toTopOf="@+id/button"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/spin"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/mainViewFragment" />

</androidx.constraintlayout.widget.ConstraintLayout>


SpinnerFragment
package com.example.foodpicker

import android.graphics.BitmapFactory
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bluehomestudio.luckywheel.LuckyWheel
import com.bluehomestudio.luckywheel.WheelItem

import kotlinx.android.synthetic.main.fragment_spinner.*

/**

  • A simple [Fragment] subclass.
    */
    class SpinnerFragment : Fragment() {

    override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
    ): View {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_spinner, container, false)

     val luckyWheel : LuckyWheel = lwv
    
     val wheelItems: MutableList<WheelItem> = ArrayList()
    
     wheelItems.add(WheelItem(
         Color.LTGRAY,
         BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
         "text 1"))
    
     wheelItems.add(WheelItem(Color.BLUE,
         BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
         "text 2"))
    
     wheelItems.add(WheelItem(Color.BLACK,
         BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
         "text 3"))
    
     wheelItems.add(WheelItem(Color.GRAY,
         BitmapFactory.decodeResource(resources, R.drawable.ic_action_name)
         ,"text 4"))
    
     wheelItems.add(WheelItem(Color.RED,
         BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
         "text 5"))
    
     wheelItems.add(WheelItem(Color.BLACK,
         BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
         "text 6")
     )
    
     luckyWheel.addWheelItems(wheelItems)
    

    }

}


frament_spinner.xml

<com.bluehomestudio.luckywheel.LuckyWheel
    android:id="@+id/lwv"
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:layout_centerInParent="true"
    app:background_color="@color/colorPrimary" />

And after doing those code I was stuck on this failure:

2020-05-20 16:39:46.751 9412-9412/com.example.foodpicker E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.foodpicker, PID: 9412
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at com.bluehomestudio.luckywheel.WheelView.onDraw(WheelView.java:232)
at android.view.View.draw(View.java:21594)
at android.view.View.updateDisplayListIfDirty(View.java:20471)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21326)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.draw(View.java:21597)
at com.android.internal.policy.DecorView.draw(DecorView.java:815)
at android.view.View.updateDisplayListIfDirty(View.java:20471)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:580)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:586)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:659)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3871)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3671)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2993)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1930)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7988)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1154)
at android.view.Choreographer.doCallbacks(Choreographer.java:977)
at android.view.Choreographer.doFrame(Choreographer.java:893)
at android.view.Choreographer$FrameHandler.handleMessage(Choreographer.java:1082)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)


Your help will be greatly appreciated!

Thanks!

Unknown attribute

Unknown attribute LuckyWheel:background_color.

<com.bluehomestudio.luckywheel.LuckyWheel
android:id="@+id/lwv"
android:layout_width="310dp"
android:layout_height="310dp"
android:layout_centerInParent="true"
android:layout_marginTop="56dp"
LuckyWheel:background_color="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/turnText" />

Interesting

thanks for the lib, what if I got 5k wheelItems ? (5k participants)
i see it crash or it freeze a lot, do you have any solution ? maybe change the type instead of a wheel a spinner and each second it show a textView ?

documentation has many typos

The documentation has many grammatical errors and is difficult to understand as a result. Most sections aren't more than a sentence fragment, and it leaves out many useful details.

I suggest that it be re-written to clean up the obvious errors and add more detail to its usage.

README.md instructions result in broken code

Steps to Repro:

  1. In Android Studio, create a new "Empty Activity" project
  2. Per the LuckyWheel README.md, add the dependencies to the Gradle scripts
  3. Open the activity_main.xml layout resource and add the XML block from the LuckyWheel README.md instructions

BUG: The build fails with the message "app\src\main\res\layout\activity_main.xml:18: AAPT: error: unbound prefix."

It seems like the fix is to remove the background_color attribute, so the XML block looks like this:

<com.bluehomestudio.luckywheel.LuckyWheel
        android:id="@+id/lwv"
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:layout_centerInParent="true" />

but that means that we can't access LuckyWheel attributes in the XML settings. My guess is that a new XML namespace must be imported, but the README.md doesn't mention that before recommending the qualified XML attributes, and doesn't explain how to do the import.

Maybe the README.md should be changed to not mention the broken properties. Or, maybe it should offer complete instructions that show how to make them work correctly.

LuckyWheel crashes when it has no WheelItems to draw

Steps to reproduce:

  1. In Android Studio, create a new "Empty Activity" project
  2. Per the LuckyWheel README.md, add the dependencies to the Gradle scripts
  3. Open the activity_main.xml layout resource and add this XML block:
<com.bluehomestudio.luckywheel.LuckyWheel
        android:id="@+id/lwv"
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:layout_centerInParent="true" />
  1. With no other changes, build and run the application.

BUG: The application starts, then immediately crashes with this call stack:

D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.wheeltest1, PID: 20695
    java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
        at com.bluehomestudio.luckywheel.WheelView.onDraw(WheelView.java:240)
        at android.view.View.draw(View.java:19123)
        at android.view.View.updateDisplayListIfDirty(View.java:18073)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1975)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.updateDisplayListIfDirty(View.java:18064)
        at android.view.View.draw(View.java:18851)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
        at android.view.View.draw(View.java:19126)
        at com.android.internal.policy.DecorView.draw(DecorView.java:785)
        at android.view.View.updateDisplayListIfDirty(View.java:18073)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:643)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:649)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:757)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:2980)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2794)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2347)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:658)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

The problem is that the LuckyWheel doesn't check to see if the list of WheelItems is empty. While that's not a great use case, sometimes in development not all steps are completed. The control would offer developers a better experience if it was able to draw itself without crashing when it contained no WheelItems. Perhaps just a circle would be fine -- and maybe log a warning that there were no items in the control to be drawn.

int android.graphics.Bitmap.getWidth()' on a null object reference

After adding the list, the following error occurred when starting this project:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.bluehomestudio.luckywheel.WheelView.drawImage(WheelView.java:133) at com.bluehomestudio.luckywheel.WheelView.onDraw(WheelView.java:245) at android.view.View.draw(View.java:21612) at android.view.View.updateDisplayListIfDirty(View.java:20481) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.updateDisplayListIfDirty(View.java:20472) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.updateDisplayListIfDirty(View.java:20472) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.draw(View.java:21615) at android.view.View.updateDisplayListIfDirty(View.java:20481) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.updateDisplayListIfDirty(View.java:20472) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.updateDisplayListIfDirty(View.java:20472) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.updateDisplayListIfDirty(View.java:20472) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.updateDisplayListIfDirty(View.java:20472) at android.view.View.draw(View.java:21341) at android.view.ViewGroup.drawChild(ViewGroup.java:4417) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4177) at android.view.View.draw(View.java:21615) at com.android.internal.policy.DecorView.draw(DecorView.java:844) at android.view.View.updateDisplayListIfDirty(View.java:20481) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:575) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:581) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:654) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3735) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3530) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2867) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1820) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7782) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1031) at android.view.Choreographer.doCallbacks(Choreographer.java:854) at android.view.Choreographer.doFrame(Choreographer.java:789) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1016) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7562) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Android studio version:2021.2.1

Animation spinning until data fetched

How could I start an infinite spinning wheel and when my data is fetched, I can set a finalized location that the spinner should stop at and will slowly stop to that location?

Kotlin integration

I want to integrate the library with Kotlin but in my activity_main.xml file the class LuckyWheel is not found. How can i load it there?

imagesize

how to set imagesize bitmap ?

thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.