forked from antoniolg/Bandhook-Kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Album activity UI according to designs
- Loading branch information
Alexey Verein
committed
Jul 8, 2016
1 parent
fe6dd09
commit 62798aa
Showing
10 changed files
with
244 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/antonioleiva/bandhookkotlin/ui/adapter/TracksAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.antonioleiva.bandhookkotlin.ui.adapter | ||
|
||
import android.support.v7.widget.RecyclerView | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import com.antonioleiva.bandhookkotlin.R | ||
import com.antonioleiva.bandhookkotlin.ui.entity.TrackDetail | ||
import org.jetbrains.anko.find | ||
import org.jetbrains.anko.layoutInflater | ||
import kotlin.properties.Delegates | ||
|
||
/** | ||
* @author alexey@plainvanillagames.com | ||
* | ||
* 06/07/16. | ||
*/ | ||
|
||
class TracksAdapter() : RecyclerView.Adapter<TracksAdapter.ViewHolder>() { | ||
|
||
var items: List<TrackDetail> by Delegates.observable(emptyList()) | ||
{ prop, old, new -> notifyDataSetChanged() } | ||
|
||
override fun getItemCount(): Int { | ||
return items.count() | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.setItem(items[position], position) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder? { | ||
val v = parent.context.layoutInflater.inflate(R.layout.track_item_view, parent, false) | ||
return TracksAdapter.ViewHolder(v) | ||
} | ||
|
||
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
|
||
private val trackNumberTextView: TextView = view.find(R.id.track_number) | ||
private val trackNameTextView: TextView = view.find(R.id.track_name) | ||
private val trackLengthTextView: TextView = view.find(R.id.track_length) | ||
|
||
fun setItem(item: TrackDetail, position: Int) { | ||
val fullMinutes = item.duration / 60 | ||
val restSeconds = item.duration % 60 | ||
val trackLength = String.format("%d:%02d", fullMinutes, restSeconds); | ||
|
||
trackNumberTextView.text = "${position + 1}" | ||
trackNameTextView.text = item.name | ||
trackLengthTextView.text = "$trackLength" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/antonioleiva/bandhookkotlin/ui/entity/TrackDetail.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.antonioleiva.bandhookkotlin.ui.entity | ||
|
||
/** | ||
* @author alexey@plainvanillagames.com | ||
* | ||
* 07/07/16. | ||
*/ | ||
|
||
data class TrackDetail(val name: String, val duration: Int) |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/antonioleiva/bandhookkotlin/ui/entity/mapper/TrackDataMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.antonioleiva.bandhookkotlin.ui.entity.mapper | ||
|
||
import com.antonioleiva.bandhookkotlin.domain.entity.Track | ||
import com.antonioleiva.bandhookkotlin.ui.entity.TrackDetail | ||
|
||
/** | ||
* @author alexey@plainvanillagames.com | ||
* | ||
* 07/07/16. | ||
*/ | ||
|
||
class TrackDataMapper { | ||
fun transform(domainTrack: Track): TrackDetail { | ||
return TrackDetail(domainTrack.name, domainTrack.duration) | ||
} | ||
|
||
fun transform(domainTrack: List<Track>): List<TrackDetail> { | ||
return domainTrack.map { transform(it) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:orientation="vertical" | ||
xmlns:card_view="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<include layout="@layout/includes_toolbar"/> | ||
android:layout_height="match_parent" | ||
> | ||
|
||
<com.antonioleiva.bandhookkotlin.ui.custom.SquareImageView | ||
android:id="@+id/album_image" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fitsSystemWindows="true" | ||
android:background="@android:color/darker_gray" | ||
app:layout_collapseMode="parallax" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/albums" | ||
android:layout_width="match_parent" | ||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_height="wrap_content" | ||
android:text="Album content" | ||
android:layout_width="match_parent" | ||
android:background="@android:color/transparent" | ||
android:layout_marginTop="@dimen/statusbar_height" | ||
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" | ||
/> | ||
|
||
</LinearLayout> | ||
<android.support.v7.widget.CardView | ||
android:layout_below="@id/album_image" | ||
android:id="@+id/card_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
card_view:cardCornerRadius="2dp" | ||
card_view:cardElevation="5sp" | ||
android:layout_marginLeft="8dp" | ||
android:layout_marginRight="8dp" | ||
android:layout_marginBottom="-5dp" | ||
android:layout_marginTop="@dimen/album_breaking_edge_height" | ||
> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/tracks_list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
/> | ||
|
||
</android.support.v7.widget.CardView> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:id="@+id/track_number" | ||
android:layout_width="20dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:layout_marginLeft="40dp" | ||
android:layout_marginRight="16dp" | ||
android:textSize="16sp" | ||
tools:text="1" | ||
android:gravity="end" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/track_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:textSize="16sp" | ||
tools:text="Counting Stars" | ||
android:layout_toRightOf="@id/track_number" | ||
android:layout_toLeftOf="@+id/track_length" | ||
android:ellipsize="end" | ||
/> | ||
|
||
<TextView | ||
android:id="@id/track_length" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="16dp" | ||
android:textSize="16sp" | ||
tools:text="4:18" | ||
android:layout_alignParentRight="true" | ||
/> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters