Skip to content

Commit

Permalink
Merge pull request #5 from thiagokimo/dev
Browse files Browse the repository at this point in the history
Adds support to set your random seed into the Number component.
Adds library into Jitpack.io
  • Loading branch information
thiagokimo authored Sep 5, 2017
2 parents 6253bf9 + 1fa6e8f commit 85178d7
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 186 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

62 changes: 0 additions & 62 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,40 @@ The demo app has a very clean MVP architecture based in the idea of [this post](

Gradle:

Add the JitPack repository to your build file:

``` groovy
repositories {
maven {
url "https://jitpack.io"
}
}
```

Add the dependency in the form:

``` groovy
dependencies {
compile 'com.github.thiagokimo:faker:1.4.3'
compile 'com.github.thiagokimo:faker:VERSION'
}
```

Maven:

If you use Maven, add this into your build file:

``` xml
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
```

``` xml
<dependency>
<groupId>com.github.thiagokimo</groupId>
<artifactId>faker</artifactId>
<version>1.4.3</version>
<version>VERSION</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
buildToolsVersion '26.0.0'

defaultConfig {
applicationId "io.kimo.faker"
Expand Down
10 changes: 1 addition & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:3.0.0-beta4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {

version = VERSION_NAME
group = GROUP

repositories {
jcenter()
}
}

def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}
8 changes: 3 additions & 5 deletions faker-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
buildToolsVersion '26.0.1'

defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
versionName "1.4.4"
versionCode 10

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand All @@ -34,5 +34,3 @@ dependencies {
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
}

apply from: '../maven_push.gradle'
3 changes: 0 additions & 3 deletions faker-core/gradle.properties

This file was deleted.

4 changes: 4 additions & 0 deletions faker-core/src/main/java/io/kimo/lib/faker/api/NumberAPI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package io.kimo.lib.faker.api;

import java.util.Random;

public interface NumberAPI {

void setSeed(Random random);

int digit();
int positiveDigit();
int negativeDigit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

public class NumberComponent extends FakerNumericComponent implements NumberAPI {

private Random mRandom = new Random();

public NumberComponent(Context context) {
super(context);
}
Expand All @@ -19,24 +21,33 @@ public Number randomNumber() {

switch (method % 6) {
case 0:
return new Integer(digit());
return digit();
case 1:
return new Integer(positiveDigit());
return positiveDigit();
case 2:
return new Integer(negativeDigit());
return negativeDigit();
case 3:
return new Integer(number());
return number();
case 4:
return new Integer(positiveNumber());
return positiveNumber();
case 5:
return new Integer(negativeNumber());
return negativeNumber();
default:
return new Integer(0);
return 0;
}
}

private int randomNumberInRangePositiveOrNegative(int min, int max) {
return new Random().nextInt((max - min) + 1) + min;
return mRandom.nextInt((max - min) + 1) + min;
}

@Override
public void setSeed(Random random) {
mRandom = random;
}

public Random getSeed() {
return mRandom;
}

@Override
Expand All @@ -57,7 +68,7 @@ public int negativeDigit() {
@Override
public int number() {

int randomSignal = (int) Math.random() * 10;
int randomSignal = (int) (Math.random() * 10);

if(randomSignal % 2 == 0) {
return number(randomNumberInRangePositiveOrNegative(1, 9));
Expand Down
13 changes: 0 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
VERSION_NAME=1.4.3
VERSION_CODE=9
GROUP=com.github.thiagokimo
POM_DESCRIPTION=Provides fake data to your Android apps
POM_URL=https://github.com/thiagokimo/Faker
POM_SCM_URL=https://github.com/thiagokimo/Faker
POM_SCM_CONNECTION=scm:[email protected]/thiagokimo/Faker.git
POM_SCM_DEV_CONNECTION=scm:[email protected]/thiagokimo/Faker.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=Kimo
POM_DEVELOPER_NAME=Thiago Moreira Rocha
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Aug 26 00:54:05 WEST 2015
#Tue Sep 05 15:21:03 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
10 changes: 3 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ case "`uname`" in
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
Expand All @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down Expand Up @@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Expand Down

0 comments on commit 85178d7

Please sign in to comment.