Skip to content

Commit

Permalink
Changed layout, to an awesome one, with Roboto font
Browse files Browse the repository at this point in the history
  • Loading branch information
ylogx committed Jul 20, 2014
1 parent 7fb6bb6 commit ddcbd15
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 56 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="11"
android:minSdkVersion="14"
android:targetSdkVersion="19" />

<application
Expand Down
65 changes: 38 additions & 27 deletions res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#222222"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
Expand All @@ -12,42 +13,52 @@
android:layout_height="match_parent"
android:orientation="vertical" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="30dp" >
<TextView
android:id="@+id/textview_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_alignParentLeft="true"
/>
android:id="@+id/textview_word"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_weight="33"
android:gravity="center"
android:text="Word"
android:textColor="@android:color/holo_blue_light"
android:textIsSelectable="true"
android:textSize="40sp"
android:textStyle="bold"
android:typeface="monospace" />

<TextView
android:id="@+id/textview_meaning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
android:id="@+id/textview_meaning"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_weight="60"
android:gravity="center"
android:text="Meaning"
android:textColor="@android:color/holo_blue_dark"
android:textSize="22sp"
android:textStyle="bold"
android:typeface="monospace" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal"
android:padding="30dp" >
<Button

<Button
android:id="@+id/button_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Random Next"
android:layout_centerInParent="true"
android:onClick="nextRandom"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:onClick="nextRandom"
android:padding="@dimen/activity_horizontal_margin"
android:text="Random Next"
android:textSize="22sp" />

</RelativeLayout>

</LinearLayout>
Expand Down
31 changes: 3 additions & 28 deletions src/com/example/wordpowermadeeasy/WordEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class WordEngine {
try {
this.word_map = readXml();
WordEngine.count += 1;
Log.d("Count",WordEngine.count);
System.out.println("Count ");
System.out.println(WordEngine.count);
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand All @@ -48,38 +49,13 @@ public WordPair getRandomWord(){
}

public Map<String,String> readXml() throws XmlPullParserException, IOException {

// XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
// factory.setNamespaceAware(true);
// XmlPullParser xpp = factory.newPullParser();

// FileInputStream fis = new FileInputStream("word-list.xml");
// InputStreamReader isr = new InputStreamReader(fis);
// isr.read(new char[fis.available()]);
// xpp.setInput(isr);
// int eventType = xpp.getEventType();

XmlResourceParser xrp = context.getResources().getXml(R.xml.word_list);

xrp.next();
int eventType = xrp.getEventType();
// xpp.setInput(new StringReader ("<foo>Hello World!</foo>"));
String word = null,meaning = null;
Map<String,String> word_pair_map = new HashMap<String,String>();
while (eventType != XmlPullParser.END_DOCUMENT) {

// if(eventType == XmlPullParser.START_DOCUMENT) {
// System.out.println("Start Document");
// } else if(eventType == XmlPullParser.END_DOCUMENT) {
// System.out.println("End Document");
// } else if(eventType == XmlPullParser.START_TAG) {
// System.out.println("Start tag "+xrp.getName());
// } else if(eventType == XmlPullParser.END_TAG) {
// System.out.println("End tag "+xrp.getName());
// } else if(eventType == XmlPullParser.TEXT) {
// System.out.println("Text "+xrp.getText());
// }

if (eventType == XmlPullParser.START_TAG
&& xrp.getName().equalsIgnoreCase("pair")){
//NOTE: In our xml file meaning comes before word and that matters
Expand All @@ -103,12 +79,11 @@ public Map<String,String> readXml() throws XmlPullParserException, IOException {
// Log.i("W","Word: "+word);
}
}//end if elif
Log.d("Pair",word+meaning);
}//end if START_TAG
else if (eventType == XmlPullParser.END_TAG && xrp.getName().equalsIgnoreCase("pair")){
if (word != null && meaning != null && word.length() != 0 && meaning.length() != 0){
if (word_pair_map.get(word) == null){
Log.d("map",word+meaning);
// Log.d("map",word+meaning);
word_pair_map.put(word,meaning);
}
}
Expand Down

0 comments on commit ddcbd15

Please sign in to comment.