Giter Club home page Giter Club logo

faker's Introduction

Faker

Android Arsenal Build Status

Faker provides fake data to your Android MPVs. Now it's very handy to make screenshots of your apps without worrying with Google Play copyright infringments, e.g this app. Faker helps you to populate your views with random data quickly and painlessly.

Screenshots

Demo

The sample application (the source is in the app folder) has been published on Google Play to facilitate the access:

Get it on Google Play

The demo app has a very clean MVP architecture based in the idea of this post. Feel free to give me suggestions.

Setup

Gradle:

Add the JitPack repository to your build file:

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

Add the dependency in the form:

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

Maven:

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

<repository>
    <id>jitpack.io</id>
	<url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.thiagokimo</groupId>
    <artifactId>faker</artifactId>
    <version>VERSION</version>
</dependency>

Usage

The "lazy" way

Faker.with(context)
      .fill(rootView);

Faker will figure out all views inside the one you passed to it and fill it with proper data. Just like that!

By default faker will fill TextViews with lorem ipsum, ImageViews with a random color, CompoundButtons with a random state (check or uncheck) and ProgressBars with a random progress value.

The specific way

Faker.with(context)
      .NameOfTheComponent
      .componentMethod();

Targeting views

If you want Faker to fill specific views inside your ViewGroup you can pass your target views like the example below

Faker.with(context)
      .targetViews(collection-of-ids)
      .fill(rootView);

Check out all examples here.

Components

Faker is organized in components that provides you specific types of data. Here is a list of the current components:

  • Lorem - The old good lorem ispum words, sentences and paragraphs.
  • Name - Firsts, lasts, full and complete names and profession/titles.
  • Number - It gives you numbers ¬¬
  • Phone - Phone masks \o/
  • Internet - It provides you random emails and domains.
  • Url - Gives you (valid) urls that you might use somewhere.
  • Color - Generates attractive colors thanks to lzyzsd!
  • Address - Gives random cities, countries, zipcodes, states and so on.

Contribuiting

  1. Fork it
  2. Create your feature/bug-fix branch(git checkout -b my-new-feature-or-fix)
  3. Commit your changes (git commit -am 'Add some feature/fix')
  4. Do your pull-request

Make sure you write tests for your code. Only code with passing tests will be accepted.

Components

You can add more components or improve the existing ones. For new components, make sure you also add an example in the demo app.

Localization

You can help providing localized data to Faker components.

License

Copyright 2011, 2012 Thiago Rocha

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.

faker's People

Contributors

sandromachado avatar thiagokimo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

faker's Issues

Support for Random

Is there any constructor for Faker that uses a Random? I want to use this library, but it would be nice to have a constructor that passes a Random, so we can set a seed.

Incorrect use of double checking singleton idiom

The current Faker.with(Context) is broken if used by multiple threads. The mFaker needs to be declared as volatile, or someone may get an partially initialized instance of it. Also if anyone accesses the static fields like Lorem, they may get incomplete instances if they do not synchronize of Faker.class first.

https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java

As a whole nothing seems to be trying to be thread safe in this library other than Faker.with(), which does so incorrectly. Probably need to look into each class and see if they can be made thread safe. The methods that act on Views don't need to be, but the generic data generation methods should be thread safe.

An example. LoremComponent, would be thread safe if loremWords was declared final, since the final will make sure anyone that gets an instance of it will see the list fully constructed. And if FakerCoreComponent had the context declared as final.

Could you provide a no-op version of the same library?

Faker is super useful to pre-fill values when I'm in debug variant of my app. So I use it with debugImplementation rather than implementation. Now the issue is that in release mode it throws me errors that the Faker class is missing (Obviously, since it's not included!). It would be nice to have a no-op version of the same library to use in releaseImplementation mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.