-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SectionIndicator for viewing section while fast scrolling
- Loading branch information
Showing
30 changed files
with
871 additions
and
186 deletions.
There are no files selected for viewing
This file contains 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
30 changes: 30 additions & 0 deletions
30
Application/src/main/java/com/example/recyclerviewfastscroller/data/ColorData.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.recyclerviewfastscroller.data; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* Data object representing a color | ||
*/ | ||
public class ColorData { | ||
|
||
private final int mColorInt; | ||
private final ColorGroup mColorGroup; | ||
|
||
public ColorData(int colorInt, @NonNull ColorGroup colorGroup) { | ||
mColorInt = colorInt; | ||
mColorGroup = colorGroup; | ||
} | ||
|
||
public int getIntValue() { | ||
return mColorInt; | ||
} | ||
|
||
public ColorGroup getColorGroup() { | ||
return mColorGroup; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("#%06X", (0xFFFFFF & mColorInt)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Application/src/main/java/com/example/recyclerviewfastscroller/data/ColorDataSet.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.example.recyclerviewfastscroller.data; | ||
|
||
import android.graphics.Color; | ||
|
||
/** | ||
* Dummy dataset of N {@link ColorData} objects | ||
*/ | ||
public class ColorDataSet { | ||
|
||
private static final int DATA_SET_SIZE = 100; | ||
private static final float NUM_HUES = 359; | ||
private static final ColorData[] mColors = new ColorData[DATA_SET_SIZE]; | ||
|
||
public ColorDataSet() { | ||
this(new ColorGroupCalculator()); | ||
} | ||
|
||
private ColorDataSet(ColorGroupCalculator colorGroupCalculator) { | ||
for (int i = 0; i < mColors.length; i++) { | ||
mColors[i] = generateNewColor(i, mColors.length, colorGroupCalculator); | ||
} | ||
} | ||
|
||
private ColorData generateNewColor(int position, int numColors, ColorGroupCalculator colorGroupCalculator) { | ||
float positionBasedHue = position * (NUM_HUES / numColors); | ||
int color = Color.HSVToColor(new float[] {positionBasedHue, 1, 1}); | ||
return new ColorData(color, colorGroupCalculator.getColorGroup(positionBasedHue)); | ||
} | ||
|
||
public int getSize() { | ||
return mColors.length; | ||
} | ||
|
||
public ColorData get(int position) { | ||
return mColors[position]; | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
Application/src/main/java/com/example/recyclerviewfastscroller/data/ColorGroup.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example.recyclerviewfastscroller.data; | ||
|
||
import android.graphics.Color; | ||
|
||
/** | ||
* Coarse groupings of colors by hue | ||
*/ | ||
public enum ColorGroup { | ||
RED_UPPER (345, 360, "Red"), | ||
PINK (300, RED_UPPER.mMinimumHue, "Pink"), | ||
PURPLE (260, PINK.mMinimumHue, "Purple"), | ||
BLUE (175, PURPLE.mMinimumHue, "Blue"), | ||
GREEN (70, BLUE.mMinimumHue, "Green"), | ||
YELLOW (50, GREEN.mMinimumHue, "Yellow"), | ||
ORANGE (25, YELLOW.mMinimumHue, "Orange"), | ||
RED_LOWER (0, ORANGE.mMinimumHue, "Red"), | ||
; | ||
|
||
private final int mMinimumHue, mMaximumHue; | ||
private final int mIntegerRepresentation; | ||
private final String mName; | ||
|
||
ColorGroup(int minimumHue, int maximumHue, String groupName) { | ||
mMinimumHue = minimumHue; | ||
mMaximumHue = maximumHue; | ||
mName = groupName; | ||
mIntegerRepresentation = Color.HSVToColor(new float[] { (maximumHue + minimumHue) / 2, 1, 1}); | ||
} | ||
|
||
public String getName() { | ||
return mName; | ||
} | ||
|
||
public boolean containsHue(int hue) { | ||
return (hue >= mMinimumHue && hue < mMaximumHue); | ||
} | ||
|
||
public int getAsColor() { | ||
return mIntegerRepresentation; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ication/src/main/java/com/example/recyclerviewfastscroller/data/ColorGroupCalculator.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.recyclerviewfastscroller.data; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* Allow for finding a color group based on a hue | ||
*/ | ||
class ColorGroupCalculator { | ||
|
||
@NonNull | ||
public ColorGroup getColorGroup(float hue) { | ||
for (ColorGroup group : ColorGroup.values()) { | ||
if (group.containsHue((int) hue)) { | ||
return group; | ||
} | ||
} | ||
|
||
throw new NullPointerException("Could not classify hue into Color Group!"); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.