Android Open Source - android-pkpass-viewer Random Name Generator






From Project

Back to project page android-pkpass-viewer.

License

The source code is released under:

MIT License

If you think the Android project android-pkpass-viewer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.manso.mytickets.utils;
//from  w w w . j  a v  a 2s .  co m
import java.util.HashSet;
import java.util.Set;

public class RandomNameGenerator {
  final String lexicon = "ABCDEFGHIJKLMNOPQRSTUVWXYZ12345674890";

  final java.util.Random rand = new java.util.Random();

  final Set<String> identifiers = new HashSet<String>();

  public String randomName() {
      StringBuilder builder = new StringBuilder();
      while(builder.toString().length() == 0) {
          int length = rand.nextInt(5)+5;
          
          for(int i = 0; i < length; i++) {          
              builder.append(lexicon.charAt(rand.nextInt(lexicon.length())));
          }
          
          if(identifiers.contains(builder.toString())) { 
              builder = new StringBuilder();
          }
      }
      return builder.toString();
  }
}




Java Source Code List

com.manso.mytickets.HandleIntentAsyncTask.java
com.manso.mytickets.TicketBackFragment.java
com.manso.mytickets.TicketFrontFragment.java
com.manso.mytickets.ViewTicketFrontActivity.java
com.manso.mytickets.services.EventTicketPassStrategy.java
com.manso.mytickets.services.IPassStrategy.java
com.manso.mytickets.services.ManifestService.java
com.manso.mytickets.services.PassReadingService.java
com.manso.mytickets.services.PassStorageService.java
com.manso.mytickets.services.PassStrategyService.java
com.manso.mytickets.services.PassTypes.java
com.manso.mytickets.utils.BarcodeEncoder.java
com.manso.mytickets.utils.FileReader.java
com.manso.mytickets.utils.ImageUtils.java
com.manso.mytickets.utils.RandomNameGenerator.java
com.manso.mytickets.utils.Sha1.java