Android Open Source - HapiPodcastJ Main Activity






From Project

Back to project page HapiPodcastJ.

License

The source code is released under:

GNU General Public License

If you think the Android project HapiPodcastJ 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 info.xuluan.podcast;
//w  w  w. java  2  s  .  c  o m
import info.xuluan.podcastj.R;
import info.xuluan.podcast.service.PlayerService;
import info.xuluan.podcast.service.PodcastService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class MainActivity extends HapiListActivity{
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
    setContentView(R.layout.main_activity);
    startService(new Intent(this, PodcastService.class));
    startService(new Intent(this, PlayerService.class));

        setListAdapter(new SimpleAdapter(this, getData(),
            R.layout.main_item, new String[] { "title" ,"icon"},
                new int[] { R.id.text1, R.id.icon, }));
    }
    
    protected List getData() {
        List<Map> myData = new ArrayList<Map>();

      addItem(myData, getResources().getString(R.string.title_search_channel), R.drawable.search_big_pic , 
          new Intent(this, SearchActivity.class),"");
      
      addItem(myData, getResources().getString(R.string.title_subs), R.drawable.channel_big_pic , 
          new Intent(this, ChannelsActivity.class),"");      
 
      addItem(myData, getResources().getString(R.string.title_episodes), R.drawable.playlist_big_pic , 
          new Intent(this, EpisodesActivity.class),"");       
      
      addItem(myData, getResources().getString(R.string.title_download_list), R.drawable.download_big_pic , 
          new Intent(this, DownloadActivity.class),"");
      
      addItem(myData, getResources().getString(R.string.title_player), R.drawable.player3_big_pic , 
          new Intent(this, PlayerActivity.class),"");        

      addItem(myData, getResources().getString(R.string.title_backup), R.drawable.backup_big_pic , 
          new Intent(this, BackupChannelsActivity.class),"");  
      
      addItem(myData, getResources().getString(R.string.title_pref), R.drawable.settings_big_pic , 
          new Intent(this, Pref.class),"");  

        return myData;
    }

    protected void addItem(List<Map> data, String name,Integer icon, Intent intent, String cmd) {
        Map<String, Object> temp = new HashMap<String, Object>();
        temp.put("title", name);
        temp.put("icon", icon);
        temp.put("intent", intent);
        temp.put("cmd",cmd);
        
        data.add(temp);
    }
  
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Map map = (Map) l.getItemAtPosition(position);

        Intent intent = (Intent) map.get("intent");
        if(intent!=null){
          startActivity(intent);
        }
    }
    
    @Override
    protected void tapHome() {
      //Toast.makeText(this, "Already Home", Toast.LENGTH_SHORT).show();
    SharedPreferences prefsPrivate = getSharedPreferences(Pref.HAPI_PREFS_FILE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor ed = prefsPrivate.edit();
    ed.putInt("homeActivity",1);
        ed.commit();
      startActivity(new Intent(this,HomeActivity.class));
    }
}




Java Source Code List

info.xuluan.podcast.AddChannelActivity.java
info.xuluan.podcast.BackupChannelsActivity.java
info.xuluan.podcast.ChannelActivity.java
info.xuluan.podcast.ChannelDetailsActivity.java
info.xuluan.podcast.ChannelsActivity.java
info.xuluan.podcast.DownloadActivity.java
info.xuluan.podcast.EpisodeDetailsActivity.java
info.xuluan.podcast.EpisodeIcons.java
info.xuluan.podcast.EpisodesActivity.java
info.xuluan.podcast.FlingGestureDetector.java
info.xuluan.podcast.Flingable.java
info.xuluan.podcast.HapiActivity.java
info.xuluan.podcast.HapiListActivity.java
info.xuluan.podcast.HapiPreferenceActivity.java
info.xuluan.podcast.HomeActivity.java
info.xuluan.podcast.MainActivity.java
info.xuluan.podcast.PlayerActivity.java
info.xuluan.podcast.PodcastBaseActivity.java
info.xuluan.podcast.PodcastTab.java
info.xuluan.podcast.Pref.java
info.xuluan.podcast.SearchActivity.java
info.xuluan.podcast.StartupActivity.java
info.xuluan.podcast.TabsHelper.java
info.xuluan.podcast.actionbar.ActionBarHelperBase.java
info.xuluan.podcast.actionbar.ActionBarHelperHoneycomb.java
info.xuluan.podcast.actionbar.ActionBarHelperICS.java
info.xuluan.podcast.actionbar.ActionBarHelper.java
info.xuluan.podcast.actionbar.SimpleMenuItem.java
info.xuluan.podcast.actionbar.SimpleMenu.java
info.xuluan.podcast.fetcher.FeedFetcher.java
info.xuluan.podcast.fetcher.Response.java
info.xuluan.podcast.parser.FeedHandler.java
info.xuluan.podcast.parser.FeedParserHandler.java
info.xuluan.podcast.parser.FeedParserListenerInterface.java
info.xuluan.podcast.parser.FeedParserListener.java
info.xuluan.podcast.parser.FeedParser.java
info.xuluan.podcast.parser.OPMLParserHandler.java
info.xuluan.podcast.parser.SearchItem.java
info.xuluan.podcast.provider.FeedItem.java
info.xuluan.podcast.provider.ItemColumns.java
info.xuluan.podcast.provider.PodcastOpenHelper.java
info.xuluan.podcast.provider.PodcastProvider.java
info.xuluan.podcast.provider.SubscriptionColumns.java
info.xuluan.podcast.provider.Subscription.java
info.xuluan.podcast.service.PlayerService.java
info.xuluan.podcast.service.PodcastService.java
info.xuluan.podcast.utils.DialogMenu.java
info.xuluan.podcast.utils.FileUtils.java
info.xuluan.podcast.utils.IconCursorAdapter.java
info.xuluan.podcast.utils.LabeledFrame.java
info.xuluan.podcast.utils.LockHandler.java
info.xuluan.podcast.utils.Log.java
info.xuluan.podcast.utils.SDCardMgr.java
info.xuluan.podcast.utils.StrUtils.java
info.xuluan.podcast.utils.ZipExporter.java
info.xuluan.podcast.utils.ZipImporter.java