Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now able to parse local file and display in list view
Need to cleanup code though
- Loading branch information
Showing
6 changed files
with
126 additions
and
18 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
package org.hicapacity.techhui; | ||
|
||
import android.app.Activity; | ||
import android.app.ListActivity; | ||
import android.os.Bundle; | ||
import android.widget.TextView; | ||
import android.view.View; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ListView; | ||
import android.widget.Toast; | ||
|
||
/** | ||
* @author Jason Axelson | ||
* | ||
*/ | ||
public class CommunityActivity extends Activity { | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
public class CommunityActivity extends ListActivity { | ||
public void onCreate(Bundle icicle) { | ||
super.onCreate(icicle); | ||
String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", | ||
"WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" }; | ||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, | ||
android.R.layout.simple_list_item_1, values); | ||
setListAdapter(adapter); | ||
} | ||
|
||
TextView textview = new TextView(this); | ||
textview.setText("This is the community tab"); | ||
setContentView(textview); | ||
@Override | ||
protected void onListItemClick(ListView l, View v, int position, long id) { | ||
String item = (String) getListAdapter().getItem(position); | ||
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.hicapacity.techhui; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import android.content.res.AssetManager; | ||
|
||
/** | ||
* @author Jason Axelson | ||
* | ||
*/ | ||
public class FileScheduleRetriever implements ScheduleRetriever { | ||
AssetManager mManager; | ||
|
||
public FileScheduleRetriever(AssetManager manager) { | ||
mManager = manager; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public List<ScheduleElement> getElements() throws IOException { | ||
BufferedReader br = null; | ||
br = new BufferedReader(new InputStreamReader(mManager.open("data.txt"))); | ||
System.out.println(br.readLine()); | ||
ArrayList<ScheduleElement> scheduleList = new ArrayList<ScheduleElement>(); | ||
String line; | ||
while ((line = br.readLine()) != null) { | ||
System.out.println(line); | ||
ScheduleElement scheduleElement = ScheduleElement.parseFromString(line); | ||
scheduleList.add(scheduleElement); | ||
} | ||
return scheduleList; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.hicapacity.techhui; | ||
|
||
/** | ||
* @author Jason Axelson | ||
* | ||
*/ | ||
public class ScheduleElement { | ||
private String mTitle; | ||
private String mTime; | ||
|
||
public ScheduleElement(String title, String time) { | ||
mTime = title; | ||
mTime = time; | ||
} | ||
|
||
public static ScheduleElement parseFromString(String input) { | ||
return new ScheduleElement("fake time", input); | ||
} | ||
|
||
public String getShortDescription() { | ||
String string = mTime + mTitle; | ||
return string.substring(0, 20); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public String toString() { | ||
return this.getShortDescription(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.hicapacity.techhui; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Jason Axelson | ||
* | ||
*/ | ||
public interface ScheduleRetriever { | ||
|
||
/** | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public List<ScheduleElement> getElements() throws IOException; | ||
} |