Skip to content

Commit

Permalink
Migrate to design support library, add view pager for artist bio and …
Browse files Browse the repository at this point in the history
…albums
  • Loading branch information
Alexey Verein committed Jul 8, 2016
1 parent f649049 commit 575438c
Show file tree
Hide file tree
Showing 20 changed files with 374 additions and 320 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ dependencies {
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile "com.android.support:palette-v7:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile "de.greenrobot:eventbus:2.4.0"
compile "com.squareup.picasso:picasso:2.5.0"
compile "com.squareup.okhttp:okhttp:2.2.0"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</activity>

<activity
android:name=".ui.screens.detail.DetailActivity"
android:name=".ui.screens.detail.ArtistActivity"
android:parentActivityName=".ui.screens.main.MainActivity"/>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ArtistMapper {
artist.bio?.content)

private fun artistHasQualityInfo(it: LastFmArtist): Boolean {
return !it.mbid.isEmpty() && it.images.size > 0
return it.mbid != null && !it.mbid.isEmpty() && it.images.size > 0
}

private fun getImage(images: List<LastFmImage>): String {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.antonioleiva.bandhookkotlin.ui.adapter

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import java.util.*

/**
* @author tpom6oh@gmail.com
*
* 01/07/16.
*/

class ArtistDetailPagerAdapter(fragmentManager: FragmentManager): FragmentPagerAdapter(fragmentManager)
{
val fragments = LinkedHashMap<Fragment, String>()

override fun getItem(position: Int): Fragment? {
return fragments.keys.elementAt(position)
}

override fun getCount(): Int {
return fragments.keys.size
}

fun addFragment(fragment: Fragment, title: String) {
fragments.put(fragment, title)
}

override fun getPageTitle(position: Int): CharSequence {
return fragments.values.elementAt(position)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import com.antonioleiva.bandhookkotlin.domain.interactor.base.Bus
import com.antonioleiva.bandhookkotlin.domain.interactor.base.InteractorExecutor
import com.antonioleiva.bandhookkotlin.domain.interactor.event.ArtistDetailEvent
import com.antonioleiva.bandhookkotlin.ui.entity.mapper.ArtistDetailDataMapper
import com.antonioleiva.bandhookkotlin.ui.view.DetailView
import com.antonioleiva.bandhookkotlin.ui.view.ArtistView

class DetailPresenter(
override val view: DetailView,
class ArtistPresenter(
override val view: ArtistView,
override val bus: Bus,
val artistDetailInteractor: GetArtistDetailInteractor,
val interactorExecutor: InteractorExecutor,
val mapper: ArtistDetailDataMapper) : Presenter<DetailView> {
val mapper: ArtistDetailDataMapper) : Presenter<ArtistView> {

fun init(id: String) {
val interactor = artistDetailInteractor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.antonioleiva.bandhookkotlin.ui.screens.detail


import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.antonioleiva.bandhookkotlin.R
import com.antonioleiva.bandhookkotlin.ui.adapter.ImageTitleAdapter
import com.antonioleiva.bandhookkotlin.ui.entity.ImageTitle

/**
* @author alexey@plainvanillagames.com
*
* 01/07/16.
*/

class AlbumsFragment: Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

val view = inflater.inflate(R.layout.fragment_albums, container, false)

if (view != null) {
setUpRecyclerView(view)
return view
}
return super.onCreateView(inflater, container, savedInstanceState)
}

private fun setUpRecyclerView(view: View) {
val recyclerView = view.findViewById(R.id.albums_view) as RecyclerView
val adapter = ImageTitleAdapter();
mockAdapterContent(adapter)
recyclerView.adapter = adapter;
}

private fun mockAdapterContent(adapter: ImageTitleAdapter) {
val imageTile = ImageTitle("0", "The Dark Side of the Moon",
"http://a.fastcompany.net/multisite_files/fastcompany/imagecache/inline-large/inline/2014/12/3039377-inline-i-3-the-dark-side-of-the-moon-cover-pf-dark-side-copy.jpg");
adapter.items = listOf(imageTile, imageTile, imageTile, imageTile, imageTile, imageTile)
}
}
Loading

0 comments on commit 575438c

Please sign in to comment.