Skip to main content

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);




Popular posts from this blog

SalsaNight

Zorgania

The Zorganian Republic has some very strange customs. Couples only wish to have female children as only females can inherit the family's wealth, so if they have a male child they keep having more children until they have a girl. If they have a girl, they stop having children. What is the ratio of girls to boys in Zorgania?
The ratio of girls to boys in Zorgania is 1:1. This might be a little counter-intuitive at first. Here are some ways of tackling this problem. 1. Monte Carlo Simulation: Although, Monte Carlo simulation does not necessarily show why the result is 1:1, it is appropriate because of the very counter-intuitive nature of the problem. At the very least, it helps us see that the result is indeed 1:1. Therefore, this is a good start.
The following R code estimates the probability of a child being a boy in Zorgania. 
couples <-100000 boycount <-0for (i in1:couples){ # 0: boywhile (sample(c(0,1),1) ==0) { boycount=boycount+1 } } probability <- boycount/(co…

Simple Launcher

A simple minimal launcher application for Android devices that shows battery percentage using lzyzsd's CirclProgress library (ArchProgress used in this case) and BroadcastReciever for battery state, Android's clock widgets, a built-in flash light switch and an app list view that can be toggled. Currently, the toggle simply filters all the app that I am working on at present. Future implementation can allow users to select their favorite apps or populate second toggle based on the most used applications.