This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.cyrilmottier.android.anapp"> | |
| <!-- ... --> | |
| <application | |
| android:icon="@drawable/ic_launcher" | |
| android:label="@string/config_app_name" | |
| android:theme="@style/Theme.AnApp" > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.cyrilmottier.android.resourcesadditions; | |
| import android.content.res.Resources; | |
| import android.content.res.XmlResourceParser; | |
| import android.os.Bundle; | |
| import org.xmlpull.v1.XmlPullParser; | |
| import org.xmlpull.v1.XmlPullParserException; | |
| /** | |
| * @author Cyril Mottier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.cyrilmottier.android.citybikes.provider; | |
| import android.net.Uri; | |
| import com.cyrilmottier.android.avelov.BuildConfig; | |
| /** | |
| * @author Cyril Mottier | |
| */ | |
| public class CityBikesContract { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <bitmap xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:src="@drawable/rainbow_stripes_pattern" | |
| android:tileMode="repeat" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ColorRes | |
| private val RAINBOW_COLORS = intArrayOf( | |
| R.color.pink, | |
| R.color.orange, | |
| R.color.yellow, | |
| R.color.green, | |
| R.color.emerald_green, | |
| R.color.azur_blue, | |
| R.color.blue, | |
| R.color.cerulean_blue, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val colorCount = RAINBOW_COLORS.size | |
| val colors = IntArray(colorCount * 2) | |
| val stops = FloatArray(colorCount * 2) | |
| for (i in 0 until colorCount) { | |
| colors[i * 2] = ContextCompat.getColor(context, RAINBOW_COLORS[i]) | |
| colors[i * 2 + 1] = colors[i * 2] | |
| stops[i * 2] = i / colorCount.toFloat() | |
| stops[i * 2 + 1] = (i + 1) / colorCount.toFloat() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return object : Drawable() { | |
| private val paint = Paint() | |
| init { | |
| val scaledWidth = RAINBOW_WIDTH * context.resources.displayMetrics.density | |
| val y1 = (Math.sin(2 * RAINBOW_ANGLE) / 2 * scaledWidth).toFloat() | |
| val x1 = (scaledWidth - Math.tan(RAINBOW_ANGLE) * y1).toFloat() | |
| paint.shader = LinearGradient( | |
| 0f, 0f, | |
| x1, y1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val colorCount = RAINBOW_COLORS.size | |
| val colors = IntArray(colorCount * 2) | |
| val stops = FloatArray(colorCount * 2) | |
| for (i in 0 until colorCount) { | |
| colors[i * 2] = ContextCompat.getColor(context, RAINBOW_COLORS[i]) | |
| colors[i * 2 + 1] = colors[i * 2] | |
| stops[i * 2] = (i / colorCount.toFloat() + RAINBOW_EPSILON).coerceAtLeast(0f) | |
| stops[i * 2 + 1] = ((i + 1) / colorCount.toFloat() - RAINBOW_EPSILON).coerceAtMost(1f) | |
| } |
OlderNewer