Android Open Source - fooplayer-android Albums Fragment






From Project

Back to project page fooplayer-android.

License

The source code is released under:

GNU General Public License

If you think the Android project fooplayer-android 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.mauriciogiordano.fooplayer.fragment;
//from w  w w  .  j a va 2s.co m
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;

import com.mauriciogiordano.fooplayer.AlbumsActivity;
import com.mauriciogiordano.fooplayer.R;
import com.mauriciogiordano.fooplayer.TracksActivity;
import com.mauriciogiordano.fooplayer.adapter.AlbumsAdapter;
import com.mauriciogiordano.fooplayer.database.Album;
import com.mauriciogiordano.fooplayer.database.Artist;
import com.mauriciogiordano.fooplayer.network.Network;

import java.util.List;

/**
 * Created by mauricio on 10/31/14.
 */
public class AlbumsFragment extends Fragment {

    private View rootView;
    private AlbumsAdapter albumsAdapter;
    private GridView albumsGrid;
    private AlbumsActivity mainActivity;

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

        mainActivity = (AlbumsActivity) getActivity();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        rootView = inflater.inflate(R.layout.fragment_artists,
                container, false);

        mainActivity.mArtist.loadAlbums(getActivity(), new Artist.AlbumSearchListener() {
            @Override
            public void results(List<Album> albums, Network.Status status, boolean err) {

                if (!err) {
                    albumsAdapter = new AlbumsAdapter(getActivity(), albums);
                    albumsGrid = (GridView) rootView.findViewById(R.id.gridview);

                    albumsGrid.setAdapter(albumsAdapter);

                    albumsGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                            AlbumsAdapter.ViewHolder holder = (AlbumsAdapter.ViewHolder) view.getTag();

                            Intent intent = new Intent(getActivity(), TracksActivity.class);
                            intent.putExtra("album-mbid", holder.album.getMbid());
                            startActivity(intent);
                        }
                    });
                }

            }
        });

        return rootView;
    }
}




Java Source Code List

com.mauriciogiordano.fooplayer.AlbumsActivity.java
com.mauriciogiordano.fooplayer.ApplicationTest.java
com.mauriciogiordano.fooplayer.FooActivity.java
com.mauriciogiordano.fooplayer.TracksActivity.java
com.mauriciogiordano.fooplayer.adapter.AlbumsAdapter.java
com.mauriciogiordano.fooplayer.adapter.ArtistsAdapter.java
com.mauriciogiordano.fooplayer.adapter.TracksAdapter.java
com.mauriciogiordano.fooplayer.config.Constants.java
com.mauriciogiordano.fooplayer.database.Album.java
com.mauriciogiordano.fooplayer.database.Artist.java
com.mauriciogiordano.fooplayer.database.Bean.java
com.mauriciogiordano.fooplayer.database.DatabaseHelper.java
com.mauriciogiordano.fooplayer.database.Track.java
com.mauriciogiordano.fooplayer.fragment.AlbumsFragment.java
com.mauriciogiordano.fooplayer.fragment.ArtistsFragment.java
com.mauriciogiordano.fooplayer.fragment.TracksFragment.java
com.mauriciogiordano.fooplayer.network.Delegate.java
com.mauriciogiordano.fooplayer.network.Endpoints.java
com.mauriciogiordano.fooplayer.network.HttpClientHelper.java
com.mauriciogiordano.fooplayer.network.ImageHelper.java
com.mauriciogiordano.fooplayer.network.Network.java
com.mauriciogiordano.fooplayer.network.YouTubeUtility.java
com.mauriciogiordano.fooplayer.view.TextView.java