summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/activity/MiroGuideChannelViewActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/danoeh/antennapod/activity/MiroGuideChannelViewActivity.java')
-rw-r--r--src/de/danoeh/antennapod/activity/MiroGuideChannelViewActivity.java198
1 files changed, 0 insertions, 198 deletions
diff --git a/src/de/danoeh/antennapod/activity/MiroGuideChannelViewActivity.java b/src/de/danoeh/antennapod/activity/MiroGuideChannelViewActivity.java
deleted file mode 100644
index 96c8385ce..000000000
--- a/src/de/danoeh/antennapod/activity/MiroGuideChannelViewActivity.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package de.danoeh.antennapod.activity;
-
-import android.annotation.SuppressLint;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.support.v7.app.ActionBarActivity;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.*;
-import de.danoeh.antennapod.BuildConfig;
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.adapter.MiroGuideItemlistAdapter;
-import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
-import de.danoeh.antennapod.feed.Feed;
-import de.danoeh.antennapod.miroguide.conn.MiroGuideException;
-import de.danoeh.antennapod.miroguide.conn.MiroGuideService;
-import de.danoeh.antennapod.miroguide.model.MiroGuideChannel;
-import de.danoeh.antennapod.preferences.UserPreferences;
-import de.danoeh.antennapod.storage.DBReader;
-import de.danoeh.antennapod.storage.DownloadRequestException;
-import de.danoeh.antennapod.storage.DownloadRequester;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * Displays information about one channel and lets the user add this channel to
- * his library.
- */
-public class MiroGuideChannelViewActivity extends ActionBarActivity {
- private static final String TAG = "MiroGuideChannelViewActivity";
-
- public static final String EXTRA_CHANNEL_ID = "id";
- public static final String EXTRA_CHANNEL_URL = "url";
-
- private RelativeLayout layoutContent;
- private ProgressBar progLoading;
- private TextView txtvTitle;
- private TextView txtVDescription;
- private ListView listEntries;
-
- private long channelId;
- private String channelUrl;
- private MiroGuideChannel channel;
- private volatile List<Feed> feeds;
-
- @Override
- protected void onPause() {
- super.onPause();
- channelLoader.cancel(true);
- }
-
- @SuppressLint("NewApi")
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- setTheme(UserPreferences.getTheme());
- super.onCreate(savedInstanceState);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- setContentView(R.layout.miroguide_channelview);
-
- layoutContent = (RelativeLayout) findViewById(R.id.layout_content);
- progLoading = (ProgressBar) findViewById(R.id.progLoading);
- txtvTitle = (TextView) findViewById(R.id.txtvTitle);
- txtVDescription = (TextView) findViewById(R.id.txtvDescription);
- listEntries = (ListView) findViewById(R.id.itemlist);
-
- channelId = getIntent().getLongExtra(EXTRA_CHANNEL_ID, -1);
- channelUrl = getIntent().getStringExtra(EXTRA_CHANNEL_URL);
-
- if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
- channelLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- } else {
- channelLoader.execute();
- }
-
- }
-
- /**
- * Is used to load channel information asynchronously.
- */
- private AsyncTask<Void, Void, Void> channelLoader = new AsyncTask<Void, Void, Void>() {
- private static final String TAG = "ChannelLoader";
- private Exception exception;
-
- @Override
- protected Void doInBackground(Void... params) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Starting background task");
- feeds = DBReader.getFeedList(MiroGuideChannelViewActivity.this);
- MiroGuideService service = new MiroGuideService();
- try {
- channel = service.getChannel(channelId);
- } catch (MiroGuideException e) {
- e.printStackTrace();
- exception = e;
- }
- return null;
- }
-
- @SuppressLint("NewApi")
- @Override
- protected void onPostExecute(Void result) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Loading finished");
- if (exception == null) {
- txtvTitle.setText(channel.getName());
- txtVDescription.setText(channel.getDescription());
-
- MiroGuideItemlistAdapter listAdapter = new MiroGuideItemlistAdapter(
- MiroGuideChannelViewActivity.this, 0,
- channel.getItems());
- listEntries.setAdapter(listAdapter);
- progLoading.setVisibility(View.GONE);
- layoutContent.setVisibility(View.VISIBLE);
- supportInvalidateOptionsMenu();
- } else {
- finish();
- }
- }
-
- };
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.channelview, menu);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
- boolean channelLoaded = channel != null;
- boolean beingDownloaded = channelLoaded
- && DownloadRequester.getInstance().isDownloadingFile(
- channel.getDownloadUrl());
- boolean notAdded = channelLoaded
- && !((feedExists(
- channel.getDownloadUrl()) || beingDownloaded));
- menu.findItem(R.id.add_feed).setVisible(notAdded);
- menu.findItem(R.id.visit_website_item).setVisible(
- channelLoaded && channel.getWebsiteUrl() != null);
- return true;
- }
-
- @SuppressLint("NewApi")
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- NavUtils.navigateUpFromSameTask(this);
- return true;
- case R.id.visit_website_item:
- Uri uri = Uri.parse(channel.getWebsiteUrl());
- startActivity(new Intent(Intent.ACTION_VIEW, uri));
- return true;
- case R.id.add_feed:
- try {
- DownloadRequester.getInstance().downloadFeed(
- this,
- new Feed(channel.getDownloadUrl(), new Date(), channel
- .getName()));
- } catch (DownloadRequestException e) {
- e.printStackTrace();
- DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
- e.getMessage());
- }
- Toast toast = Toast.makeText(this, R.string.miro_feed_added,
- Toast.LENGTH_LONG);
- toast.show();
- supportInvalidateOptionsMenu();
- return true;
- default:
- return false;
- }
- }
-
- private boolean feedExists(String downloadUrl) {
- if (feeds == null) {
- return false;
- }
-
- for (Feed feed : feeds) {
- if (feed.getDownload_url().equals(downloadUrl)) {
- return true;
- }
- }
- return false;
- }
-
-}