Archived
Reorganized gui code to maximize code reusage - added BaseDnsActivity which is an abstract class which all Activities extend. As of now it contains code that handles footer buttons and starts other activities.
This commit is contained in:
1 parent
d0ae3bc2b5
commit
022f48de8b
8 files changed
+75
-57
No files matched your search
+2
-1
@@ -15,7 +15,8 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".ui.ProgramList"></activity>
|
||||
<activity android:name=".ui.JoinUsActivity"></activity>
|
||||
<activity android:name=".ui.ProgramListActivity"></activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -18,7 +18,7 @@
|
||||
android:layout_alignParentBottom="true" />
|
||||
|
||||
<!-- Program list -->
|
||||
<ListView android:id="@android:id/list"
|
||||
<ListView android:id="@+id/event_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/header"
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<!-- Header -->
|
||||
<include layout="@layout/header"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_alignParentTop="true"/>
|
||||
|
||||
<!-- Footer -->
|
||||
<include layout="@layout/footer"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_alignParentBottom="true" />
|
||||
|
||||
<!-- Bli med-tekst -->
|
||||
<TextView
|
||||
android:id="@+id/join_us_textview"
|
||||
android:layout_marginTop="10px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_below="@id/header"
|
||||
android:layout_above="@id/footer"
|
||||
android:layout_marginLeft="20dip"
|
||||
android:text="@string/join_us" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
<!-- Header -->
|
||||
<include layout="@layout/header"
|
||||
android:id="@+id/header"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_alignParentTop="true"/>
|
||||
@@ -24,17 +23,5 @@
|
||||
android:layout_below="@id/header"
|
||||
android:layout_above="@id/footer"
|
||||
android:src="@drawable/partest" />
|
||||
|
||||
<!-- Bli med-tekst -->
|
||||
<TextView
|
||||
android:id="@+id/join_us_textview"
|
||||
android:layout_marginTop="10px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_below="@id/header"
|
||||
android:layout_above="@id/footer"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="20dip"
|
||||
android:text="@string/join_us" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.studentersamfundet.app.ui;
|
||||
|
||||
import com.studentersamfundet.app.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
public abstract class BaseDnsActivity extends Activity {
|
||||
public void clickHandler(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION
|
||||
| Intent.FLAG_ACTIVITY_NO_HISTORY
|
||||
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
|
||||
if (v.getId() == R.id.program_button) {
|
||||
intent.setClass(this, ProgramListActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
} else if (v.getId() == R.id.bli_med_button) {
|
||||
intent.setClass(this, JoinUsActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,15 @@
|
||||
package com.studentersamfundet.app.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.studentersamfundet.app.R;
|
||||
|
||||
public class DnsActivity extends Activity {
|
||||
public class DnsActivity extends BaseDnsActivity {
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
View tmp = this.findViewById(R.id.join_us_textview);
|
||||
tmp.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void clickHandler(View v) {
|
||||
if (v.getId() == R.id.program_button) {
|
||||
startActivity(new Intent(this, ProgramList.class));
|
||||
} else if (v.getId() == R.id.bli_med_button) {
|
||||
View j = this.findViewById(R.id.bli_med_button);
|
||||
ImageView p = (ImageView)this.findViewById(R.id.paragraph);
|
||||
View t = this.findViewById(R.id.join_us_textview);
|
||||
|
||||
j.setClickable(false);
|
||||
p.setVisibility(View.INVISIBLE);
|
||||
t.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed () {
|
||||
View t = this.findViewById(R.id.join_us_textview);
|
||||
if (t.getVisibility() == View.VISIBLE) {
|
||||
View j = this.findViewById(R.id.bli_med_button);
|
||||
ImageView p = (ImageView)this.findViewById(R.id.paragraph);
|
||||
j.setClickable(true);
|
||||
t.setVisibility(View.INVISIBLE);
|
||||
p.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.studentersamfundet.app.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.studentersamfundet.app.R;
|
||||
|
||||
public class JoinUsActivity extends BaseDnsActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.join_us);
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -2,13 +2,13 @@ package com.studentersamfundet.app.ui;
|
||||
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.studentersamfundet.app.R;
|
||||
import com.studentersamfundet.app.Utils;
|
||||
import com.studentersamfundet.app.XmlParser;
|
||||
|
||||
public class ProgramList extends ListActivity {
|
||||
public class ProgramListActivity extends BaseDnsActivity {
|
||||
public static final String feedURL = "http://folk.uio.no/larsjeng/test.xml";
|
||||
public static final String localURL = "/data/com.studentersamfundet.app/files/dns_events";
|
||||
public static FeedFetcher feed = new FeedFetcher();
|
||||
@@ -31,9 +31,6 @@ public class ProgramList extends ListActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.event_list);
|
||||
|
||||
View v = this.findViewById(R.id.program_button);
|
||||
v.setClickable(false);
|
||||
|
||||
// Do we have intarwebs?
|
||||
// YAY = Fetch the feed.
|
||||
// NAY = Inform about no connection.
|
||||
@@ -48,8 +45,10 @@ public class ProgramList extends ListActivity {
|
||||
toast.show();
|
||||
}
|
||||
|
||||
ListView list = (ListView)findViewById(R.id.event_list);
|
||||
|
||||
ListAdapter adapter = createAdapter();
|
||||
setListAdapter(adapter);
|
||||
list.setAdapter(adapter);
|
||||
}
|
||||
|
||||
protected ListAdapter createAdapter() {
|
||||
Reference in new issue
Block a user