Permalink
Browse files

PodcastListActivity inherits from CustomTitleActivity

  • Loading branch information...
1 parent f9f6fac commit 1afa7e3c5fc2b846ec10af829d6fb908168d2fea @tindandelion committed Sep 27, 2012
@@ -1,18 +1,18 @@
package org.dandelion.radiot.accepttest.drivers;
import android.app.Instrumentation;
-import android.app.ListActivity;
import android.widget.ListAdapter;
import com.jayway.android.robotium.solo.Solo;
import org.dandelion.radiot.podcasts.core.PodcastItem;
+import org.dandelion.radiot.podcasts.ui.PodcastListActivity;
import org.dandelion.radiot.podcasts.ui.PodcastVisual;
public class PodcastListUiDriver extends Solo {
- private ListActivity listActivity;
+ private PodcastListActivity activity;
- public PodcastListUiDriver(Instrumentation instrumentation, ListActivity activity) {
+ public PodcastListUiDriver(Instrumentation instrumentation, PodcastListActivity activity) {
super(instrumentation, activity);
- this.listActivity = activity;
+ this.activity = activity;
}
@@ -29,14 +29,14 @@ public PodcastItem selectItemForDownloading(int index) {
}
private PodcastItem clickOnPodcastItem(int index) {
- ListAdapter adapter = listActivity.getListAdapter();
+ ListAdapter adapter = activity.getListAdapter();
PodcastVisual pv = (PodcastVisual) adapter.getItem(index);
clickInList(index);
return pv.podcast;
}
public void makeSamplePodcastWithUrl(String title, String url) {
- ListAdapter adapter = listActivity.getListAdapter();
+ ListAdapter adapter = activity.getListAdapter();
PodcastItem item = ((PodcastVisual) adapter.getItem(0)).podcast;
item.setTitle(title);
item.setAudioUri(url);
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <ListView android:id="@+id/podcast_list"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:cacheColorHint="@color/window_background"
+ android:background="@color/window_background"/>
+</LinearLayout>
@@ -6,13 +6,14 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.widget.ListAdapter;
import android.widget.ListView;
import org.dandelion.radiot.R;
import org.dandelion.radiot.podcasts.PodcastsApp;
import org.dandelion.radiot.podcasts.core.PodcastListLoader;
-import org.dandelion.radiot.util.CustomTitleListActivity;
+import org.dandelion.radiot.util.CustomTitleActivity;
-public class PodcastListActivity extends CustomTitleListActivity {
+public class PodcastListActivity extends CustomTitleActivity {
public static Intent createIntent(Context context, String title, String showName) {
return StartParams.createIntent(context, title, showName);
}
@@ -22,26 +23,23 @@ public static Intent createIntent(Context context, String title, String showName
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setContentView(R.layout.podcast_screen);
StartParams params = StartParams.fromIntent(getIntent());
setTitle(params.title());
- initListView();
-
PodcastListAdapter listAdapter = new PodcastListAdapter(this);
- setListAdapter(listAdapter);
- attachToEngine(params.showName(), listAdapter);
+
+ initListView(listAdapter);
+ attachToLoader(params.showName(), listAdapter);
}
- private void initListView() {
+ private void initListView(PodcastListAdapter adapter) {
ListView listView = getListView();
- setListBackground(listView);
+ listView.setAdapter(adapter);
listView.setOnItemClickListener(createSelectionHandler());
}
- private void setListBackground(ListView listView) {
- final int bgColor = getResources().getColor(R.color.window_background);
-
- listView.setCacheColorHint(bgColor);
- listView.setBackgroundColor(bgColor);
+ private ListView getListView() {
+ return (ListView) findViewById(R.id.podcast_list);
}
private PodcastSelectionHandler createSelectionHandler() {
@@ -50,7 +48,7 @@ private PodcastSelectionHandler createSelectionHandler() {
app.createDownloader(), new DialogErrorDisplayer(this));
}
- protected void attachToEngine(String showName, PodcastListAdapter listAdapter) {
+ protected void attachToLoader(String showName, PodcastListAdapter listAdapter) {
PodcastsApp app = PodcastsApp.getInstance();
loader = app.createLoaderForShow(showName);
loader.attach(new ProgressDisplayer(this), listAdapter);
@@ -93,4 +91,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
}
+
+ public ListAdapter getListAdapter() {
+ return getListView().getAdapter();
+ }
}
@@ -1,29 +0,0 @@
-package org.dandelion.radiot.util;
-
-import android.app.ListActivity;
-import android.os.Bundle;
-import android.view.MenuItem;
-
-public abstract class CustomTitleListActivity extends ListActivity {
-
- private ActivityHelper helper;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- helper = ActivityHelper.create(this);
- helper.onCreate();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- helper.onPostCreate();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- return helper.onOptionsItemSelected(item) ||
- super.onOptionsItemSelected(item);
- }
-}

0 comments on commit 1afa7e3

Please sign in to comment.