Skip to content

Commit

Permalink
List just artist's albums instead of albums and songs
Browse files Browse the repository at this point in the history
  • Loading branch information
rivaldi8 committed Apr 11, 2017
1 parent 8056465 commit 644b45b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 280 deletions.
247 changes: 0 additions & 247 deletions app/src/main/java/com/naman14/timber/adapters/ArtistSongAdapter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.naman14.timber.R;
import com.naman14.timber.adapters.ArtistSongAdapter;
import com.naman14.timber.dataloaders.ArtistSongLoader;
import com.naman14.timber.models.Song;
import com.naman14.timber.adapters.AlbumAdapter;
import com.naman14.timber.adapters.ArtistAlbumAdapter;
import com.naman14.timber.dataloaders.ArtistAlbumLoader;
import com.naman14.timber.models.Album;
import com.naman14.timber.utils.Constants;
import com.naman14.timber.widgets.DividerItemDecoration;

import java.util.ArrayList;

public class ArtistMusicFragment extends Fragment {

public static RecyclerView songsRecyclerview;
public static RecyclerView albumsRecyclerView;
long artistID = -1;
ArtistSongAdapter mSongAdapter;
AlbumAdapter albumAdapter;

public static ArtistMusicFragment newInstance(long id) {
ArtistMusicFragment fragment = new ArtistMusicFragment();
Expand All @@ -58,28 +58,21 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View rootView = inflater.inflate(
R.layout.fragment_artist_music, container, false);

songsRecyclerview = (RecyclerView) rootView.findViewById(R.id.recycler_view_songs);
albumsRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view_albums);

setUpSongs();
setUpAlbums();


return rootView;
}


private void setUpSongs() {
songsRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
private void setUpAlbums() {
albumsRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));

ArrayList<Song> songList;
songList = ArtistSongLoader.getSongsForArtist(getActivity(), artistID);

// adding one dummy song to top of arraylist
//there will be albums header at this position in recyclerview
songList.add(0, new Song(-1, -1, -1, "dummy", "dummy", "dummy", -1, -1));

mSongAdapter = new ArtistSongAdapter(getActivity(), songList, artistID);
songsRecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
songsRecyclerview.setAdapter(mSongAdapter);
ArrayList<Album> albumList = ArtistAlbumLoader.getAlbumsForArtist(getActivity(), artistID);
ArtistAlbumAdapter albumAdapter = new ArtistAlbumAdapter(getActivity(), albumList);
albumsRecyclerView.setAdapter(albumAdapter);
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_artist_music.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/recycler_view_songs"
android:id="@+id/recycler_view_albums"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
20 changes: 9 additions & 11 deletions app/src/main/res/layout/item_artist_album.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="104dp"
android:layout_height="150dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="?selectableItemBackgroundBorderless"
android:paddingLeft="25dp"
app:cardUseCompatPadding="true"
android:id="@+id/root_view"
style="?attr/cardStyle">

<RelativeLayout
android:layout_width="104dp"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
<com.naman14.timber.widgets.SquareImageView
android:id="@+id/album_art"
android:layout_width="104dp"
android:layout_height="104dp"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:transitionName="transition_album_art"/>

android:transitionName="transition_album_art" />

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -34,7 +32,7 @@

<TextView
android:id="@+id/album_title"
android:layout_width="104dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:ellipsize="end"
Expand All @@ -44,7 +42,7 @@

<TextView
android:id="@+id/album_details"
android:layout_width="104dp"
android:layout_width="match_parent"
android:ellipsize="end"
android:singleLine="true"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 644b45b

Please sign in to comment.