StockQuotes - siddartha1992/NetApps GitHub Wiki

Purpose

Android Network application for retrieving a financial stock quote from google finance. Displays the corresponding stock value and a chart describing the trend.

Source Code Organization

The project is split into four different classes.

  • MainActivity.java – Main class responsible for updating the GUI, and retrieving values from the text edits. Starts http request process when submit button is clicked.
  • HTTPRequestSender.java – An Asynctask class used for getting requesting HTTPGet command. This class is run on a different thread so that the GUI is not blocked when the information is being retrieved from the server.
  • DataParse.java – An asynchtask class used for parsing raw HTML data into meaning full data that could be displayed on the GUI. Also gets the image from a different server and updates it on the Image View of the GUI.
  • Data.java – A class which stores a string and a Bitmap. Used to pass the values between different functions rather than defining these functions global.

Flow of Program

When the application is clicked, the user is required to enter company X stock name. This name is passed into the HTTPRequestSender class and a HTTPGET is used to receive a raw HTML data. On the “onpostexecute()” of this task, the DataParse Class is invoked which parses the raw HTML data into meaningful data to be displayed on the GUI. Additionally, it gets a chart from a different source. On the “onpostexecute()” of the DataParse class, the data and the image is updated on the GUI. Since this program is written using Asynchtask, the GUI is not affected while the data is being fetched or parsed. Meanwhile the Data object is used to parse the image and text data between function calls. The exit button on the GUI could be used to clear the GUI screen. The data is displayed on a linear listview and the image is displayed on an image view.