Android Open Source - BusTicketer Bus Utils






From Project

Back to project page BusTicketer.

License

The source code is released under:

Copyright (c) 2013, Nelspike All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Red...

If you think the Android project BusTicketer 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 bus.ticketer.utils;
//  ww w  . ja v  a  2s . co  m
import java.util.ArrayList;

import android.app.Activity;
import android.util.SparseArray;
import android.view.View;
import bus.ticketer.objects.Ticket;
import bus.ticketer.passenger.BusTicketer;

public class BusUtils {
  
  public static BusTimer initializeTimer(Activity context, final View view) {
    BusTicketer app = ((BusTicketer) context.getApplicationContext());
    SparseArray<ArrayList<Ticket>> tickets = app.getTickets();
    int type = Integer.parseInt(app.getTicketType().charAt(1)+"");
    long span = 1000;
    String finalTicketFile = "";
    
    long timeInMinutes = app.getMinutes(type-1) * 1000 * 60;
    ArrayList<Ticket> tXTickets = tickets.get(type);
    String filename = "t"+type+"Ticket-";
    
    for(Ticket t : tXTickets) {
      int id = t.getTicketID();
      if(FileHandler.checkFileExistance(filename+id+".txt")) {
        finalTicketFile = filename+id+".txt";
        new FileWriter(finalTicketFile, new FileHandler().getUsername()).writeToFile();
        break;
      }
    }
    
    return new BusTimer(timeInMinutes, span, view, context, finalTicketFile);
  }
  
  public static void purchaseProcess(Activity context) {
    BusTicketer app = (BusTicketer) context.getApplication();
    FileHandler fHandler = new FileHandler(app.getClientFilename(), "");
    ArrayList<String> fileContents = fHandler.readFromFile();
    SparseArray<ArrayList<Ticket>> tickets = app.getTickets();
    
    for(int i = 1; i <= 3; i++) {
      ArrayList<Ticket> typeTickets = tickets.get(i);
      for(Ticket t : typeTickets) {
        if(!FileHandler.checkFileExistance("t"+i+"Ticket-"+t.getTicketID()+".txt"))
          new FileWriter("t"+i+"Ticket-"+t.getTicketID()+".txt", fileContents.get(0)).createFile();
      }
    }
  }
  
}




Java Source Code List

bus.ticketer.adapters.CentralPagerAdapter.java
bus.ticketer.adapters.DialogAdapter.java
bus.ticketer.adapters.SpinnerAdapter.java
bus.ticketer.connection.ConnectionRunnable.java
bus.ticketer.connection.ConnectionRunnable.java
bus.ticketer.connection.ConnectionRunnable.java
bus.ticketer.connection.ConnectionThread.java
bus.ticketer.connection.ConnectionThread.java
bus.ticketer.connection.ConnectionThread.java
bus.ticketer.filters.MonthInputFilter.java
bus.ticketer.fragments.BuyTicketsFragment.java
bus.ticketer.fragments.ShowTicketsFragment.java
bus.ticketer.inspector.BusInspector.java
bus.ticketer.inspector.MainActivity.java
bus.ticketer.inspector.ResultActivity.java
bus.ticketer.inspector.ScanActivity.java
bus.ticketer.listeners.BusTabListener.java
bus.ticketer.listeners.PurchaseListener.java
bus.ticketer.listeners.RadioGroupListener.java
bus.ticketer.listeners.SwipeListener.java
bus.ticketer.listeners.TicketPurchaseListener.java
bus.ticketer.listeners.ValidationListener.java
bus.ticketer.objects.Ticket.java
bus.ticketer.passenger.BeamActivity.java
bus.ticketer.passenger.BusTicketer.java
bus.ticketer.passenger.CentralActivity.java
bus.ticketer.passenger.MainActivity.java
bus.ticketer.runnable.BuyRunnable.java
bus.ticketer.runnable.ShowRunnable.java
bus.ticketer.runnable.TimerRunnable.java
bus.ticketer.runnable.TimerThread.java
bus.ticketer.utils.BusTimer.java
bus.ticketer.utils.BusUtils.java
bus.ticketer.utils.FileHandler.java
bus.ticketer.utils.FileWriter.java
bus.ticketer.utils.Method.java
bus.ticketer.utils.Method.java
bus.ticketer.utils.Method.java
bus.ticketer.utils.RESTFunction.java
bus.ticketer.utils.RESTFunction.java
bus.ticketer.utils.RESTFunction.java
bus.ticketer.utils.SpinnerAdapter.java
bus.ticketer.validation.MainActivity.java
bus.ticketer.validation.ResultActivity.java