GithubHelp home page GithubHelp logo

luckywheel's Introduction

Screenshot

Example Image

Usage

Include LuckyWheel widget in your layout:

<rubikstudio.library.LuckyWheelView
    android:layout_centerInParent="true"
    app:lkwBackgroundColor="#FF9800"
    app:lkwTopTextColor="#263238"
    app:lkwCenterImage="@drawable/wheel2"
    app:lkwCursor="@drawable/ic_cursor"
    android:id="@+id/luckyWheel"
    android:layout_width="300dp"
    android:layout_height="300dp" />

You also have the option to add the following parameters:

...
        app:lkwEdgeColor="#e2e5eb"
        app:lkwEdgeWidth="25"
        app:lkwTopTextPadding="10dp"
        app:lkwTopTextSize="12sp"
        app:lkwSecondaryTextSize="25sp" />

And in your code :

LuckyWheelView luckyWheelView = (LuckyWheelView) findViewById(R.id.luckyWheel);
List<LuckyItem> data = new ArrayList<>();
for (int i=0; i<12; i++) {
    LuckyItem luckyItem = new LuckyItem();
    luckyItem1.topText = "Item " + i;
    luckyItem1.icon = R.drawable.test;
    luckyItem1.color = 0xffFFF3E0;
    data.add(luckyItem);
}

luckyWheelView.setData(data);
luckyWheelView.setRound(10);

// start
luckyWheelView.startLuckyWheelWithTargetIndex(index);

// listener after finish lucky wheel
luckyWheelView.setLuckyRoundItemSelectedListener(new LuckyWheelView.LuckyRoundItemSelectedListener() {
    @Override
    public void LuckyRoundItemSelected(int index) {
        // do something with index
    }
});

#Custom LuckyWheel

You can setting these properties of the lucky wheel view with xml :

    app:lkwBackgroundColor="#FF9800"
    app:lkwTopTextColor="#263238"
    app:lkwCenterImage="@drawable/wheel2"
    app:lkwCursor="@drawable/ic_cursor"

Or with code like:

    luckyWheelView.setLuckyWheelBackgrouldColor(0xff0000ff);
    luckyWheelView.setLuckyWheelTextColor(0xffcc0000);
    luckyWheelView.setLuckyWheelCenterImage(getResources().getDrawable(R.drawable.icon));
    luckyWheelView.setLuckyWheelCursorImage(R.drawable.ic_cursor);

#Sample Check out the sample application to see it in action!

Contributing

Contributions welcome via Github pull requests.

luckywheel's People

Contributors

buutqn avatar kagile avatar nvkien avatar peterbetos avatar thanhniencung 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  avatar  avatar

luckywheel's Issues

How to add click event for items?

I want to get position while clicking on items (segment which are drawn using Arc). Is there any possibility to do that?
@peterbetos Is there any possibility to get click event of arcs from canvas?

Add Images TO Slice

I need to add custom images from URL using glide or retrofit to slice images.
I was highlight it.
pls explain how can i do.

abcd

Thanks.

Icon Roatation

when we rotate the wheel spinner it will also rotate the icon where we set in the main xml layout ..
is that possible wheel is just rotate and the icon is fixed on that place .?

How to set topText vertically?

I have implemented your library in Android. But unable to show the text in vertically as currently it is showing horizontally.

Can you please tell me details code logic how to show text vertically?

Index position issue

in spin index position is not accurate some time for 1st item it gives index 1 and some time it give 0 as index position.

Inconsistent versioning?

I'm having an issue with my app using this library. Recently, it appears the PieRotateListener had a second method added to it. Fine.

However, the listener does not trigger on done when using startLuckyWheelWithTargetIndex.

My source locally looks like:

        float targetAngle = ((360f * mRoundOfNumber * rotationAssess) + 270f - getAngleOfIndexTarget(indexResult) - (360f / mLuckyItemList.size()) / 2);
        animate()
                .setInterpolator(new DecelerateInterpolator())
                .setDuration(mRoundOfNumber * 1000 + 900L)
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        isRunning = true;
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        setRotation(getRotation() % 360f);
                        if (mPieRotateListener != null && predeterminedNumber > -1) {
                            mPieRotateListener.rotateDone(predeterminedNumber);
                        }
                    }

Your source of the same line doesn't mention the predeterminedNumber, instead triggering with the index of what was completed.

What's going on? I can't even get the older version of the library that used to work right with the way this library is versioned. There really should be versions cut and not just have users use the master snapshot in Gradle.

Not working at all in Java Project

There is no startLuckyWheelWithTargetIndex(index) method as you show in the example.
The wheel starts the animation only if the user rotates it by touching.
setLuckyRoundItemSelectedListener()'s overridden methods do nothing at all. luckyRoundItemSelected() or onLuckyWheelRotationStart() don't get called anytime whether the wheel starts or stops.
Also there is a problem in passing icons to the items, R.drawable.icon doesn't work and produces null exceptions.
Is this not compatible to Java as you've written it in Kotlin?
Thanks in advance.

How can I play a sound for each spin?

new Thread(() -> {
MediaPlayer mMediaPlayer;

mMediaPlayer = MediaPlayer.create(getContext(), R.raw.tick);

mMediaPlayer.start();
                }).start();

Where should I put it?

LICENSE

Hi,

This is a great implementation of lucky wheel, and I would like to use it for my work and even contribute to it. In this regard, is it possible for you to add a license to this project ?

Pavan

Disabling the touch listener on the wheel?

I have tried to disable the listener to the LuckyWheel to false, also its clickability to false, bu the user is still able to touch the wheel and have it spinning. How can I disable it?

Can we customise the circle?

Hi, i have seen your library, i have one question can we Can we customise the circle as per the below image? i mean the inner circles and there colors with this library.

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.