Integrated Greendroid library and got UI working

This commit is contained in:
Daniel Oeh 2011-12-27 23:02:41 +01:00
parent d63097d696
commit 5b11bc0bbf
8 changed files with 82 additions and 29 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "libs/GreenDroid"]
path = libs/GreenDroid
url = https://github.com/cyrilmottier/GreenDroid.git

View File

@ -12,16 +12,19 @@
<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" > android:label="@string/app_name"
android:theme="@style/Theme.GreenDroid"
android:name=".PodcastApp">
<activity <activity
android:label="@string/app_name" android:label="@string/app_name"
android:name=".PodfetcherActivity" > android:name=".PodfetcherActivity" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".FeedlistActivity"/>
<service android:enabled="true" android:name=".DownloadService" /> <service android:enabled="true" android:name=".DownloadService" />
<service android:enabled="true" android:name=".FeedSyncService" > <service android:enabled="true" android:name=".FeedSyncService" >
<intent-filter> <intent-filter>

View File

@ -9,3 +9,4 @@
# Project target. # Project target.
target=android-10 target=android-10
android.library.reference.1=libs/GreenDroid/GreenDroid

6
res/values/ids.xml Normal file
View File

@ -0,0 +1,6 @@
<resources>
<item type="id" name="action_bar_refresh" />
<item type="id" name="action_bar_add" />
</resources>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="hello">Hello World, PodfetcherActivity!</string>
<string name="app_name">Podfetcher</string> <string name="app_name">Podfetcher</string>
<string name="feeds_label">Feeds</string>
<string name="settings_label">Settings</string>
</resources> </resources>

View File

@ -0,0 +1,18 @@
package de.podfetcher;
import greendroid.app.GDListActivity;
import android.os.Bundle;
import android.view.View;
import greendroid.widget.ActionBarItem.Type;
public class FeedlistActivity extends GDListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addActionBarItem(Type.Add, R.id.action_bar_add);
addActionBarItem(Type.Refresh, R.id.action_bar_refresh);
}
}

View File

@ -1,9 +1,11 @@
package de.podfetcher; package de.podfetcher;
import de.podfetcher.feed.FeedManager; import de.podfetcher.feed.FeedManager;
import de.podfetcher.FeedlistActivity;
import android.app.Application; import android.app.Application;
import greendroid.app.GDApplication;
public class PodcastApp extends Application { public class PodcastApp extends GDApplication {
private static PodcastApp singleton; private static PodcastApp singleton;
@ -11,13 +13,17 @@ public class PodcastApp extends Application {
return singleton; return singleton;
} }
public Class<?> getHomeActivityClass() {
return PodfetcherActivity.class;
}
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
singleton = this; singleton = this;
FeedManager manager = FeedManager.getInstance(); //FeedManager manager = FeedManager.getInstance();
manager.loadDBData(getApplicationContext()); //manager.loadDBData(getApplicationContext());
} }

View File

@ -6,36 +6,51 @@ import org.xml.sax.SAXException;
import de.podfetcher.feed.*; import de.podfetcher.feed.*;
import de.podfetcher.storage.DownloadRequester; import de.podfetcher.storage.DownloadRequester;
import android.app.Activity; import greendroid.app.GDListActivity;
import greendroid.widget.ItemAdapter;
import greendroid.widget.item.TextItem;
import greendroid.widget.item.Item;
import greendroid.widget.ActionBar;
import greendroid.widget.ActionBar.Type;
import greendroid.app.ActionBarActivity;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ListView;
import android.os.Bundle; import android.os.Bundle;
import android.content.Intent;
public class PodfetcherActivity extends Activity { public class PodfetcherActivity extends GDListActivity {
/** Called when the activity is first created. */
public PodfetcherActivity() {
super(ActionBar.Type.Normal);
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final DownloadRequester requester = DownloadRequester.getInstance(); // Add navigation menu
final FeedHandler handler = new FeedHandler(); ItemAdapter adapter = new ItemAdapter(this);
final FeedManager manager = FeedManager.getInstance(); adapter.add(createListItem(R.string.feeds_label, FeedlistActivity.class));
adapter.add(new TextItem("Settings"));
final Button button = (Button)findViewById(R.id.testbutton);
final EditText edittext = (EditText)findViewById(R.id.textedit); setListAdapter(adapter);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final String s = edittext.getText().toString();
manager.addFeed(v.getContext(), s);
edittext.setText("Receiving...");
}
});
} }
private TextItem createListItem(int id, Class<?> _class) {
final TextItem item = new TextItem(getString(id));
item.setTag(_class);
return item;
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
final TextItem item = (TextItem) l.getAdapter().getItem(position);
Intent intent = new Intent(PodfetcherActivity.this, (Class<?>) item.getTag());
intent.putExtra(ActionBarActivity.GD_ACTION_BAR_TITLE, item.text);
startActivity(intent);
}
} }