Android Open Source - lastfm-android-music-discovery Album Info Fragment






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.album.fragment;
/*  www  . j  a  va 2s.c o m*/
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.text.Html;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.mikeladze.musicdiscovery.R;
import com.mikeladze.musicdiscovery.base.fragment.BaseTabFragment;
import com.mikeladze.musicdiscovery.view.gridview.loader.ImageLoader;

/**
 * This fragment displays the album image and information.
 * 
 * @author Tim Mikeladze
 */
public class AlbumInfoFragment extends BaseTabFragment {
  
  private static final String TITLE = "Info";
  private View v;
  private ImageView imageView;
  private TextView textViewInfo;
  
  @Override
  /**
   * Creates the view
   */
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.fragment_generic_info, container, false);
    
    imageView = (ImageView) v.findViewById(R.id.image);
    textViewInfo = (TextView) v.findViewById(R.id.textview_info);
    
    return v;
  }
  
  @Override
  public String getTitle() {
    return TITLE;
  }
  
  /**
   * Display album info.
   * 
   * @param album the album
   */
  public void displayAlbumInfo(JSONObject album) {
    String s = "No information";
    try {
      
      ImageLoader imageLoader = new ImageLoader(getActivity());
      imageLoader.displayImage(album.getJSONArray("image")
                      .getJSONObject(4)
                      .getString("#text"), imageView);
      
      s = album.getJSONObject("wiki")
            .getString("summary")
            .trim()
            .length() > album.getJSONObject("wiki")
                      .getString("content")
                      .trim()
                      .length() ? album.getJSONObject("wiki")
                                .getString("summary")
                                .trim() : album.getJSONObject("wiki")
                                        .getString("content")
                                        .trim();
    } catch (JSONException e) {
      e.printStackTrace();
    }
    textViewInfo.setText(Html.fromHtml(s));
    Linkify.addLinks(textViewInfo, Linkify.ALL);
  }
}




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