Android Open Source - android-pkpass-viewer Pass Storage Service






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.services;
//w ww . ja v  a  2  s .c  o m
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.json.simple.parser.ParseException;

import android.content.Context;

import com.manso.mytickets.utils.RandomNameGenerator;

public class PassStorageService {
  Context context;

  public PassStorageService(Context context) {
    super();
    this.context = context;    
  }
  
  public File InflatePkPassInTempDir(InputStream pkpassFile) throws IOException, ParseException {          
    File cacheDir = context.getCacheDir();
    String name = new RandomNameGenerator().randomName();    
    File inflateHere = new File(cacheDir, name);
    inflateHere.mkdir();
    
    byte[] buffer = new byte[1024];
    ZipInputStream zis = new ZipInputStream(pkpassFile);
    ZipEntry ze = zis.getNextEntry();

    while (ze != null) {      
      File newFile = new File(inflateHere, ze.getName());
      FileOutputStream stream = new FileOutputStream(newFile);
      int len;
      while ((len = zis.read(buffer)) > 0) {
        stream.write(buffer, 0, len);
      }            
      stream.close();
      ze = zis.getNextEntry();
    }

    zis.close();
    
    return inflateHere;
  }
}




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