Easy in use android library for creating wheel of fortune. With this library you can add a wheel of fortune to your app at the few lines of code.
<com.github.matvapps.wheeloffortune.WOFView
android:id="@+id/fortune_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>wofView = (WOFView) findViewById(R.id.fortune_view);wofView.addSector(R.drawable.wheel_of_fortune_image_1);Or use full sector description:
wofView.addSector(int fillColor,
int strokeColor,
float strokeSize,
int imageID));wofView.setRotationListener(rotationListener);public class MainActivity extends AppCompatActivity {
WOFView wofView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wofView = (WOFView) findViewById(R.id.fortune_view);
for (int i = 0; i < 10; i++) {
// add icon that will be used in sector
wofView.addSector(R.drawable.ic_launcher);
}
wofView.setRotationListener(new CircleView.RotationListener() {
@Override
public void rotationStart() {
}
@Override
public void rotationEnd(int sectorIndex) {
// sectorIndex - index of sector winner
// show index in toast
Toast.makeText(MainActivity.this, sectorIndex + "", Toast.LENGTH_SHORT).show();
}
});
}
}wofView.setSpeedRotate(float speed); // (optional) rotating speed - turnover per second
wofView.setTimeRotate(float time); // (optional) rotating time - seconds
wofView.startRotate();// start wheel rotatingCreate fortune colors resources:
<color name="fortune_color_1">#7ad408</color>
<color name="fortune_color_2">#00be3f</color>
<color name="fortune_color_3">#11b9d6</color>
<color name="fortune_color_4">#0948d9</color>
<color name="fortune_color_5">#5207c8</color>
<color name="fortune_color_6">#b201c5</color>
<color name="fortune_color_7">#dc0039</color>
<color name="fortune_color_8">#d90d0a</color>
<color name="fortune_color_9">#ee6805</color>
<color name="fortune_color_10">#fad006</color>Create array from resources:
<array name="fortune_colors">
<item>@color/fortune_color_1</item>
<item>@color/fortune_color_2</item>
<item>@color/fortune_color_3</item>
<item>@color/fortune_color_4</item>
<item>@color/fortune_color_5</item>
<item>@color/fortune_color_6</item>
<item>@color/fortune_color_7</item>
<item>@color/fortune_color_8</item>
<item>@color/fortune_color_9</item>
<item>@color/fortune_color_10</item>
</array>Set color array in code:
wofView.setFillColors(getResources().getIntArray(R.array.fortune_colors);wofView.setBackgroundImageID(R.drawable.fortune_back);wofView.setOuterImageID(R.drawable.fortune_outer);wofView.setMarkerImageID(R.drawable.fortune_marker);app:wof_background="@drawable/fortune_back"app:wof_outer="@drawable/fortune_outer"app:wof_marker="@drawable/fortune_marker"Download via Gradle:
compile 'com.github.matvapps:wheeloffortune:0.0.1'or Maven:
<dependency>
<groupId>com.github.matvapps</groupId>
<artifactId>WheelOfFortune</artifactId>
<version>0.0.1</version>
<type>pom</type>
</dependency>Take a look at the sample project for more information.
Copyright 2017 github.com/matvapps
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.

