EPL-NPT


After missing couple of English Premier League Games due to the time difference between what I was used to and Nepal, I thought it would be wise to create an app that kept track of all Premier League fixtures in Nepal time.  

Step 1: Extracting, Parsing and Storing

Since I wanted the fixtures to be available offline, I had to find a way to extract and store the data. After trying several implementations, I decided to use a csv file that I found online. I used CSVReader to parse through the csv file and added required html tags to change everything into web pages.The plan was to use WebView in android to display the fixtures.

For example, the follwing java code prints a full webpage for the month of October.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Calendar;

import au.com.bytecode.opencsv.CSVReader;

public class exceltohtml {
 public static void main(String[] args) throws FileNotFoundException {
  CSVReader reader = new CSVReader(new FileReader("file.csv"), '\t');
  String month = "Dec";
  String[] nextLine;
  String a = "";
  boolean test = true;

  String html = "<!DOCTYPE html><html>";
  try {
   while ((nextLine = reader.readNext()) != null) {
    if (nextLine[0].contains(month)) {
     if (!a.equals(nextLine[0])) {
      html = html + "<p></p></table><h2><b>" + nextLine[0] + "</b></h2><table cellpadding=\\\"5\\\" cellspacing=\\\"3\\\"><tbody><tr> <td><b>Fixtures</b></td><td><b>Kick-off</b></td></tr>";
     }
     
     html = html + "<tr><td>" + nextLine[2] + " vs " + nextLine[3] + "</td><td>" + nextLine[4] + "</td></tr>";
     a = nextLine[0];
    }

   }
   System.out.print(html + "</tbody></table></html>");
   
   

  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

 }
} 

Step 2: Rest of the app






Feature#1:

Allows users to select their default team. The default team name was stored in a SharedPreference variable. With a simple if/else implementation, the user gets a custom wallpaper. Also, their team name in fixtures page is typefaced bold and underlines.  

To store:
1
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("default_team", selected).commit();

To retrieve:
1
String team = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("default_team", "--");

Feature#2:

Generates current month fixtures by default.
1
2
Calendar cal = Calendar.getInstance();
int thismonth = cal.get(Calendar.MONTH);