Android Open Source - Jupiter-Broadcasting-Holo Show Activity






From Project

Back to project page Jupiter-Broadcasting-Holo.

License

The source code is released under:

Copyright (c) 2011 Shane Quigley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Soft...

If you think the Android project Jupiter-Broadcasting-Holo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jupiter.broadcasting.live.holo;
//from  www . j  ava2s.co  m
/*
 * Copyright (c) 2012 Shane Quigley
 *
 * This software is MIT licensed see link for details
 * http://www.opensource.org/licenses/MIT
 *
 * @author Shane Quigley
 * @hacked Adam Szabo
 */

import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.Hashtable;


public class ShowActivity extends ActionBarActivity {
    private DrawerLayout mDrawerLayout;
    private ListView mDrawerList;
    private ActionBarDrawerToggle mDrawerToggle;
    private CharSequence mDrawerTitle;
    private CharSequence mTitle;
    public Hashtable<String, String> audioFeedTable;
    public Hashtable<String, String> videoFeedTable;
    public String[] shows;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);


        sharedPref.getBoolean("pref_sync_audio", false);
        shows = new String[]{getString(R.string.allshows),
                "BSD Now",
                "Coder Radio",
                "Faux Show",
                "Linux Action Show",
                "LINUX Unplugged",
                "Plan B",
                "SciByte",
                "Tech Talk Today",
                "Techsnap",
                "Unfilter"};

        audioFeedTable = new Hashtable<String, String>();
        audioFeedTable.put(getString(R.string.allshows), "http://feeds.feedburner.com/JupiterBroadcasting");
        audioFeedTable.put("Coder Radio", "http://feeds.feedburner.com/coderradiomp3");
        audioFeedTable.put("Faux Show", "http://www.jupiterbroadcasting.com/feeds/FauxShowMP3.xml");
        audioFeedTable.put("Linux Action Show", "http://feeds.feedburner.com/TheLinuxActionShow");
        audioFeedTable.put("LINUX Unplugged", "http://feeds.feedburner.com/linuxunplugged");
        audioFeedTable.put("SciByte", "http://feeds.feedburner.com/scibyteaudio");
        audioFeedTable.put("Techsnap", "http://feeds.feedburner.com/techsnapmp3");
        audioFeedTable.put("Unfilter", "http://www.jupiterbroadcasting.com/feeds/unfilterMP3.xml");
        audioFeedTable.put("Plan B", "http://feeds.feedburner.com/planbmp3");
        audioFeedTable.put("BSD Now", "http://feeds.feedburner.com/BsdNowMp3");
        audioFeedTable.put("Tech Talk Today", "http://feedpress.me/t3mp3");

        videoFeedTable = new Hashtable<String, String>();
        videoFeedTable.put(getString(R.string.allshows), "http://feeds2.feedburner.com/AllJupiterVideos");
        videoFeedTable.put("Coder Radio", "http://feeds.feedburner.com/coderradiovideo");
        videoFeedTable.put("LINUX Unplugged", "http://feeds.feedburner.com/linuxunvid");
        videoFeedTable.put("SciByte", "http://feeds.feedburner.com/scibytelarge");
        videoFeedTable.put("Plan B", "http://feeds.feedburner.com/PlanBVideo");
        videoFeedTable.put("Tech Talk Today", "http://feedpress.me/t3mob");


        if (sharedPref.getBoolean("pref_sync_video", false)) {
            //load low quality video feeds
            videoFeedTable.put("Techsnap", "http://feeds.feedburner.com/techsnapmobile");
            videoFeedTable.put("Linux Action Show", "http://feeds.feedburner.com/linuxactionshowipodvid");
            videoFeedTable.put("Faux Show", "http://www.jupiterbroadcasting.com/feeds/FauxShowMobile.xml");
            videoFeedTable.put("BSD Now", "http://feeds.feedburner.com/BsdNowMobile");
            videoFeedTable.put("Unfilter", "http://www.jupiterbroadcasting.com/feeds/unfilterMob.xml");

        } else {
            //if set, load high quality videos
            videoFeedTable.put("Techsnap", "http://feeds.feedburner.com/techsnaphd");
            videoFeedTable.put("Linux Action Show", "http://feeds.feedburner.com/linuxashd");
            videoFeedTable.put("Faux Show", "http://www.jupiterbroadcasting.com/feeds/FauxShowHD.xml");
            videoFeedTable.put("BSD Now", "http://feeds.feedburner.com/BsdNowHd");
            videoFeedTable.put("Unfilter", "http://www.jupiterbroadcasting.com/feeds/unfilterHD.xml");
        }

        supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.main);


        mTitle = mDrawerTitle = getTitle();

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerList = (ListView) findViewById(R.id.showlist);

        // set a custom shadow that overlays the main content when the drawer opens
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
        // set up the drawer's list view with shows
        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
                R.layout.drawer_list_item, shows));

        mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

        // enable ActionBar app icon to behave as action to toggle nav drawer (Not working for some reason)
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);

        mDrawerToggle = new ActionBarDrawerToggle(
                this,                  /* host Activity */
                mDrawerLayout,         /* DrawerLayout object */
                R.drawable.ic_drawer,  /* nav drawer image to replace 'Up' caret */
                R.string.drawer_open,  /* "open drawer" description for accessibility */
                R.string.drawer_close  /* "close drawer" description for accessibility */
        ) {
            public void onDrawerClosed(View view) {
                getSupportActionBar().setTitle(mTitle);

            }

            public void onDrawerOpened(View drawerView) {
                getSupportActionBar().setTitle(mDrawerTitle);

            }
        };
        //set the drawer icon to be clickable
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        //first start opens the drawer
        if (savedInstanceState == null) {
            mDrawerLayout.openDrawer(mDrawerList);
        }
    }

    private class DrawerItemClickListener implements ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position); //start fragment to download items for the selected show
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        return super.onPrepareOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // The action bar home/up action should open or close the drawer.
        // ActionBarDrawerToggle will take care of this.
        if (item.getItemId() == android.R.id.home) {

            if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
                mDrawerLayout.closeDrawer(mDrawerList);
            } else {
                mDrawerLayout.openDrawer(mDrawerList);
            }
        }
        return super.onOptionsItemSelected(item);
    }

    private void selectItem(int position) {
        // update the main content by replacing fragments

        Fragment fragment = new EpisodeListFragment();
        Bundle args = new Bundle();
        String afeed = audioFeedTable.get(shows[position]);
        String vfeed = videoFeedTable.get(shows[position]);
        args.putInt("SHOW_ID", position);
        args.putString("SHOW_AUDIO", afeed);
        args.putString("SHOW_VIDEO", vfeed);
        args.putString("SHOW_NAME", shows[position]);
        fragment.setArguments(args);

        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        //ft.setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_out);
        ft.replace(R.id.episodelist, fragment).commit();

        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        setTitle(shows[position]);
        mDrawerLayout.closeDrawer(mDrawerList);
    }

    @Override
    public void setTitle(CharSequence title) {
        mTitle = title;
        getSupportActionBar().setTitle(mTitle);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        mDrawerToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mDrawerToggle.onConfigurationChanged(newConfig);
    }
}




Java Source Code List

com.google.sample.castcompanionlibrary.cast.BaseCastManager.java
com.google.sample.castcompanionlibrary.cast.CastMediaRouterCallback.java
com.google.sample.castcompanionlibrary.cast.DataCastManager.java
com.google.sample.castcompanionlibrary.cast.DeviceSelectionListener.java
com.google.sample.castcompanionlibrary.cast.VideoCastManager.java
com.google.sample.castcompanionlibrary.cast.callbacks.BaseCastConsumerImpl.java
com.google.sample.castcompanionlibrary.cast.callbacks.DataCastConsumerImpl.java
com.google.sample.castcompanionlibrary.cast.callbacks.IBaseCastConsumer.java
com.google.sample.castcompanionlibrary.cast.callbacks.IDataCastConsumer.java
com.google.sample.castcompanionlibrary.cast.callbacks.IVideoCastConsumer.java
com.google.sample.castcompanionlibrary.cast.callbacks.VideoCastConsumerImpl.java
com.google.sample.castcompanionlibrary.cast.dialog.video.VideoMediaRouteControllerDialogFragment.java
com.google.sample.castcompanionlibrary.cast.dialog.video.VideoMediaRouteControllerDialog.java
com.google.sample.castcompanionlibrary.cast.dialog.video.VideoMediaRouteDialogFactory.java
com.google.sample.castcompanionlibrary.cast.exceptions.CastException.java
com.google.sample.castcompanionlibrary.cast.exceptions.NoConnectionException.java
com.google.sample.castcompanionlibrary.cast.exceptions.OnFailedListener.java
com.google.sample.castcompanionlibrary.cast.exceptions.TransientNetworkDisconnectionException.java
com.google.sample.castcompanionlibrary.cast.player.IMediaAuthListener.java
com.google.sample.castcompanionlibrary.cast.player.IMediaAuthService.java
com.google.sample.castcompanionlibrary.cast.player.IVideoCastController.java
com.google.sample.castcompanionlibrary.cast.player.MediaAuthStatus.java
com.google.sample.castcompanionlibrary.cast.player.OnVideoCastControllerListener.java
com.google.sample.castcompanionlibrary.cast.player.VideoCastControllerActivity.java
com.google.sample.castcompanionlibrary.cast.player.VideoCastControllerFragment.java
com.google.sample.castcompanionlibrary.notification.VideoCastNotificationService.java
com.google.sample.castcompanionlibrary.remotecontrol.RemoteControlClientCompat.java
com.google.sample.castcompanionlibrary.remotecontrol.RemoteControlHelper.java
com.google.sample.castcompanionlibrary.remotecontrol.VideoIntentReceiver.java
com.google.sample.castcompanionlibrary.utils.LogUtils.java
com.google.sample.castcompanionlibrary.utils.Utils.java
com.google.sample.castcompanionlibrary.widgets.IMiniController.java
com.google.sample.castcompanionlibrary.widgets.MiniController.java
jupiter.broadcasting.live.holo.CatalogueAdapter.java
jupiter.broadcasting.live.holo.Catalogue.java
jupiter.broadcasting.live.holo.EpisodeAdapter.java
jupiter.broadcasting.live.holo.EpisodeListFragment.java
jupiter.broadcasting.live.holo.Home.java
jupiter.broadcasting.live.holo.JBApplication.java
jupiter.broadcasting.live.holo.JBPlayer.java
jupiter.broadcasting.live.holo.MySpinnerAdapter.java
jupiter.broadcasting.live.holo.SettingsActivity.java
jupiter.broadcasting.live.holo.ShowActivity.java
jupiter.broadcasting.live.holo.ShowNotesView.java
jupiter.broadcasting.live.holo.list.BitmapLruCache.java
jupiter.broadcasting.live.holo.list.FadeImageView.java
jupiter.broadcasting.live.holo.parser.RssHandler.java
jupiter.broadcasting.live.holo.parser.SaxRssParser.java