Android Open Source - android-pkpass-viewer Ticket Back Fragment






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;
//from   w  ww  .  ja  va 2  s  .  c  o m
import java.io.IOException;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;

import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Space;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.manso.mytickets.services.PassReadingService;

public class TicketBackFragment extends Fragment {

  public static TicketBackFragment newInstance(String ticketPath) {
    TicketBackFragment ticketBack = new TicketBackFragment();
    
    Bundle args = new Bundle();
    args.putString("ticketPath", ticketPath);
    ticketBack.setArguments(args);
    
    return ticketBack;
  }

  
  private LinearLayout linearLayout;
  private PassReadingService passReadingService;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {        
    
    String path = this.getArguments().getString("ticketPath");
    try {
      this.passReadingService = new PassReadingService(path, this.getActivity());
    } catch (ParseException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }    
    
    View view = inflater.inflate(R.layout.fragment_ticket_back, container, false);    
    this.linearLayout = (LinearLayout) view.findViewById(R.id.containerLayout);
    
    this.drawBackFields();
    
    return view;
  }
  
  private void drawBackFields() {    
    
    JSONObject eventTicket = this.passReadingService.getJSONObject("eventTicket");
    JSONArray backFields = (JSONArray) eventTicket.get("backFields");
    
    for (Object obj : backFields) {
      JSONObject jsonBackfield = (JSONObject)obj;
      
      TextView title = new TextView(this.getActivity());
      title.setTypeface(null, Typeface.BOLD);
      title.setText(jsonBackfield.get("label").toString());
      
      TextView body = new TextView(this.getActivity());
      body.setText(jsonBackfield.get("value").toString());
      
      this.linearLayout.addView(title);
      this.linearLayout.addView(body);
      Space space = new Space(this.getActivity());
      this.linearLayout.addView(space);
    }
  }

}




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