Android Open Source - lastfm-android-music-discovery Base Fragment Activity






From Project

Back to project page lastfm-android-music-discovery.

License

The source code is released under:

Apache License

If you think the Android project lastfm-android-music-discovery 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 com.mikeladze.musicdiscovery.base.activity;
/*w w  w . j a v a2  s .  com*/
import android.app.ActionBar;
import android.app.SearchManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.SearchView;

import com.mikeladze.musicdiscovery.R;

/**
 * This is a base fragment activity used through out the app. Takes care of creating the
 * actionbar.
 * 
 * @author Tim Mikeladze
 */
public abstract class BaseFragmentActivity extends FragmentActivity {
  
  protected ActionBar actionBar;
  
  @Override
  /**
   * Creates the activity. Requests action bar and indeterminate progress. 
   */
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    
    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
  }
  
  @Override
  /**
   * The options menu is used for the "Search" icon.
   */
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
                          .getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    
    return true;
  }
  
  @Override
  /**
   * Navigation using the app icon in top left corner.
   */
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        finish();
    }
    return true;
  }
}




Java Source Code List

com.mikeladze.musicdiscovery.album.activity.AlbumActivity.java
com.mikeladze.musicdiscovery.album.adapter.LastFMTrack.java
com.mikeladze.musicdiscovery.album.adapter.OnTrackClickListener.java
com.mikeladze.musicdiscovery.album.adapter.TrackListAdapter.java
com.mikeladze.musicdiscovery.album.fragment.AlbumInfoFragment.java
com.mikeladze.musicdiscovery.album.fragment.AlbumTracksFragment.java
com.mikeladze.musicdiscovery.artist.activity.ArtistActivity.java
com.mikeladze.musicdiscovery.artist.fragment.ArtistAlbumsFragment.java
com.mikeladze.musicdiscovery.artist.fragment.ArtistInfoFragment.java
com.mikeladze.musicdiscovery.artist.fragment.SimilarArtistsFragment.java
com.mikeladze.musicdiscovery.base.activity.BaseFragmentActivity.java
com.mikeladze.musicdiscovery.base.adapter.SectionsPagerAdapter.java
com.mikeladze.musicdiscovery.base.fragment.BaseTabFragment.java
com.mikeladze.musicdiscovery.base.fragment.ImageGridViewFragment.java
com.mikeladze.musicdiscovery.http.LastFMResult.java
com.mikeladze.musicdiscovery.http.RestClient.java
com.mikeladze.musicdiscovery.main.activity.MainActivity.java
com.mikeladze.musicdiscovery.main.fragment.HypedArtistsFragment.java
com.mikeladze.musicdiscovery.main.fragment.TopArtistsFragment.java
com.mikeladze.musicdiscovery.search.activity.SearchResultsActivity.java
com.mikeladze.musicdiscovery.search.adapter.SearchResultsAdapter.java
com.mikeladze.musicdiscovery.util.IntentUtils.java
com.mikeladze.musicdiscovery.view.gridview.DynamicImageView.java
com.mikeladze.musicdiscovery.view.gridview.ImageGridAdapter.java
com.mikeladze.musicdiscovery.view.gridview.loader.FileCache.java
com.mikeladze.musicdiscovery.view.gridview.loader.ImageLoader.java
com.mikeladze.musicdiscovery.view.gridview.loader.MemoryCache.java
com.mikeladze.musicdiscovery.view.gridview.loader.Utils.java