Skip to content

matrixxun/RandomData

 
 

Repository files navigation

RandomData

Your test/mock screens would look much better with some real data. RandomData automatically fills your structures with generated, random names, numbers, images, etc. RandomData uses data libraries, validating algorithms and keeps track of a context to make sure that every bit of generated data is consistent and makes sense. Did you notice that a female name always comes with a picture of a woman? :)

Before you start, make sure to check out https://www.pexels.com/ - very nice site with free stock photos :)

Screenshot Screenshot2

Setup

Add JitPack to your main build.gradle:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Add RandomData to your project's dependencies:

dependencies {
    compile 'com.github.ZieIony:RandomData:926c64a3ca'
}

Usage

Prepare a data class:

public class User{
    Drawable avatar;
    String name, subtext, date;
}

Setup RandomData with generators you need:

RandomData randomData = new RandomData();
randomData.addGenerators(new Generator[]{
    new StringNameGenerator(Gender.Both)),
    new TextGenerator().withMatcher(f -> f.getName().equals("subtext")),
    new DrawableAvatarGenerator(this),
    new StringDateGenerator()
});

Fill your objects with data. There's no need to initialize arrays:

User[] items = new User[10];
randomData.fill(items);

FAQ

1. Where did you get these nice recycler rows from?

It's Carbon. RandomData helps me with carbon.components package.

2. I need a generator you don't have

Open an issue and describe your generator. I'll try to add it.

3. I've coded a generator. Can I make a pull request?

Sure thing!

About

Random data generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%