forked from DroidKaigi/conference-app-2019
-
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.
- Loading branch information
Showing
16 changed files
with
497 additions
and
57 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...re/about/src/main/java/io/github/droidkaigi/confsched2019/about/fixeddata/AboutThisApp.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,23 @@ | ||
package io.github.droidkaigi.confsched2019.about.fixeddata | ||
|
||
sealed class AboutThisApp( | ||
open val id: Int, | ||
open val name: Int, | ||
open val description: Int, | ||
open val navigationUrl: String? | ||
) { | ||
data class Item( | ||
override val id: Int, | ||
override val name: Int, | ||
override val description: Int, | ||
override val navigationUrl: String? | ||
) : AboutThisApp(id, name, description, navigationUrl) | ||
|
||
// TODO: Determine headers link | ||
data class HeadItem( | ||
override val id: Int, | ||
override val name: Int, | ||
override val description: Int, | ||
override val navigationUrl: String? | ||
) : AboutThisApp(id, name, description, navigationUrl) | ||
} |
56 changes: 56 additions & 0 deletions
56
...e/about/src/main/java/io/github/droidkaigi/confsched2019/about/fixeddata/AboutThisApps.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,56 @@ | ||
package io.github.droidkaigi.confsched2019.about.fixeddata | ||
|
||
import io.github.droidkaigi.confsched2019.about.R | ||
|
||
class AboutThisApps { | ||
|
||
companion object { | ||
fun getThisApps(): List<AboutThisApp> { | ||
var index = 0 | ||
return listOf( | ||
// Head Item | ||
AboutThisApp.HeadItem( | ||
10000 + index++, | ||
R.string.what_is_droidkaigi, | ||
R.string.description_droidkaigi, | ||
"" | ||
), | ||
// Access Item | ||
AboutThisApp.Item( | ||
10000 + index++, | ||
R.string.access_to_place, | ||
R.string.check_map, | ||
"" | ||
), | ||
// StaffList Item | ||
AboutThisApp.Item( | ||
10000 + index++, | ||
R.string.staff_list, | ||
R.string.check, | ||
"" | ||
), | ||
// Privacy Policy Item | ||
AboutThisApp.Item( | ||
10000 + index++, | ||
R.string.privacy_policy, | ||
R.string.check, | ||
"" | ||
), | ||
// License Item | ||
AboutThisApp.Item( | ||
10000 + index++, | ||
R.string.license, | ||
R.string.check, | ||
"" | ||
), | ||
// App Version Item | ||
AboutThisApp.Item( | ||
10000 + index++, | ||
R.string.app_version, | ||
R.string.version_name, | ||
"" | ||
) | ||
) | ||
} | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
...e/about/src/main/java/io/github/droidkaigi/confsched2019/about/ui/item/AboutHeaderItem.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,33 @@ | ||
package io.github.droidkaigi.confsched2019.about.ui.item | ||
|
||
import android.view.View | ||
import androidx.databinding.DataBindingUtil | ||
import com.xwray.groupie.Item | ||
import com.xwray.groupie.databinding.BindableItem | ||
import com.xwray.groupie.databinding.ViewHolder | ||
import io.github.droidkaigi.confsched2019.about.R | ||
import io.github.droidkaigi.confsched2019.about.databinding.HeaderAboutBinding | ||
import io.github.droidkaigi.confsched2019.about.fixeddata.AboutThisApp | ||
|
||
class AboutHeaderItem( | ||
private val headItem: AboutThisApp.HeadItem | ||
) : BindableItem<HeaderAboutBinding>() { | ||
|
||
override fun createViewHolder(itemView: View): ViewHolder<HeaderAboutBinding> { | ||
return ViewHolder(DataBindingUtil.bind(itemView)!!) | ||
} | ||
|
||
override fun getLayout(): Int = R.layout.header_about | ||
|
||
override fun bind(binding: HeaderAboutBinding, position: Int) { | ||
binding.headItem = headItem | ||
} | ||
|
||
override fun isSameAs(other: Item<*>?): Boolean = | ||
other is AboutHeaderItem | ||
|
||
override fun equals(other: Any?): Boolean = | ||
headItem == (other as? AboutHeaderItem?)?.headItem | ||
|
||
override fun hashCode(): Int = headItem.hashCode() | ||
} |
39 changes: 39 additions & 0 deletions
39
feature/about/src/main/java/io/github/droidkaigi/confsched2019/about/ui/item/AboutItem.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,39 @@ | ||
package io.github.droidkaigi.confsched2019.about.ui.item | ||
|
||
import android.view.View | ||
import androidx.core.content.ContextCompat | ||
import androidx.databinding.DataBindingUtil | ||
import com.xwray.groupie.Item | ||
import com.xwray.groupie.databinding.BindableItem | ||
import com.xwray.groupie.databinding.ViewHolder | ||
import io.github.droidkaigi.confsched2019.about.R | ||
import io.github.droidkaigi.confsched2019.about.databinding.ItemAboutBinding | ||
import io.github.droidkaigi.confsched2019.about.fixeddata.AboutThisApp | ||
|
||
class AboutItem( | ||
private val item: AboutThisApp.Item | ||
) : BindableItem<ItemAboutBinding>() { | ||
|
||
override fun createViewHolder(itemView: View): ViewHolder<ItemAboutBinding> { | ||
return ViewHolder(DataBindingUtil.bind(itemView)!!) | ||
} | ||
|
||
override fun getLayout(): Int = R.layout.item_about | ||
|
||
override fun bind(binding: ItemAboutBinding, position: Int) { | ||
binding.item = item | ||
if (item.navigationUrl.isNullOrEmpty()) { | ||
binding.checkText.setTextColor( | ||
ContextCompat.getColor(binding.root.context, R.color.gray2) | ||
) | ||
} | ||
} | ||
|
||
override fun isSameAs(other: Item<*>?): Boolean = | ||
other is AboutItem | ||
|
||
override fun equals(other: Any?): Boolean = | ||
item == (other as? AboutItem?)?.item | ||
|
||
override fun hashCode(): Int = item.hashCode() | ||
} |
23 changes: 23 additions & 0 deletions
23
feature/about/src/main/java/io/github/droidkaigi/confsched2019/about/ui/item/AboutSection.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,23 @@ | ||
package io.github.droidkaigi.confsched2019.about.ui.item | ||
|
||
import com.xwray.groupie.Item | ||
import com.xwray.groupie.Section | ||
import io.github.droidkaigi.confsched2019.about.fixeddata.AboutThisApp | ||
|
||
class AboutSection : Section() { | ||
|
||
fun updateAboutThisApps( | ||
aboutThisApps: List<AboutThisApp> | ||
) { | ||
val headItem = aboutThisApps.first { it is AboutThisApp.HeadItem } as AboutThisApp.HeadItem | ||
val header = AboutHeaderItem( | ||
headItem | ||
) | ||
val list = mutableListOf<Item<*>>(header) | ||
aboutThisApps.filter { it is AboutThisApp.Item } | ||
.mapTo(list) { | ||
AboutItem(it as AboutThisApp.Item) | ||
} | ||
update(list) | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
.../src/main/java/io/github/droidkaigi/confsched2019/about/ui/widget/DottedItemDecoration.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,79 @@ | ||
package io.github.droidkaigi.confsched2019.about.ui.widget | ||
|
||
import android.content.Context | ||
import android.graphics.* | ||
import android.view.View | ||
import androidx.core.content.ContextCompat | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
class DottedItemDecoration private constructor( | ||
private val color: Int, | ||
private val paddingLeft: Int, | ||
private val paddingRight: Int, | ||
private val width: Int, | ||
private val gap: Int | ||
) : RecyclerView.ItemDecoration() { | ||
|
||
companion object { | ||
fun from( | ||
context: Context, | ||
colorRes: Int, | ||
paddingLeftRes: Int, | ||
paddingRightRes: Int, | ||
widthRes: Int, | ||
gapRes: Int | ||
): DottedItemDecoration { | ||
val color = ContextCompat.getColor(context, colorRes) | ||
val paddingLeftPx = context.resources.getDimensionPixelSize(paddingLeftRes) | ||
val paddingRightPx = context.resources.getDimensionPixelSize(paddingRightRes) | ||
val widthPx = context.resources.getDimensionPixelSize(widthRes) | ||
val gapPx = context.resources.getDimensionPixelSize(gapRes) | ||
return DottedItemDecoration( | ||
color, | ||
paddingLeftPx, | ||
paddingRightPx, | ||
widthPx, | ||
gapPx | ||
) | ||
} | ||
} | ||
|
||
private val paint: Paint = Paint() | ||
|
||
init { | ||
paint.apply { | ||
color = this@DottedItemDecoration.color | ||
style = Paint.Style.STROKE | ||
strokeWidth = this@DottedItemDecoration.width.toFloat() | ||
pathEffect = DashPathEffect( | ||
floatArrayOf( | ||
this@DottedItemDecoration.gap.toFloat(), | ||
this@DottedItemDecoration.gap.toFloat() | ||
), | ||
0f) | ||
} | ||
} | ||
|
||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { | ||
super.getItemOffsets(outRect, view, parent, state) | ||
if (parent.getChildAdapterPosition(view) < 1) return | ||
|
||
outRect.bottom = width | ||
} | ||
|
||
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) { | ||
val left = paddingLeft.toFloat() | ||
val right = (parent.width - paddingRight).toFloat() | ||
|
||
val childCount = parent.childCount | ||
val path = Path() | ||
for (i in 0 until childCount) { | ||
val child = parent.getChildAt(i) | ||
val top = (child.bottom + width / 2).toFloat() | ||
|
||
path.moveTo(left, top) | ||
path.lineTo(right, top) | ||
} | ||
c.drawPath(path, paint) | ||
} | ||
} |
29 changes: 11 additions & 18 deletions
29
feature/about/src/main/res/drawable/dotted_line_gray3.xml
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,19 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > | ||
<item | ||
android:bottom="-2dp" | ||
android:left="-2dp" | ||
android:right="-2dp" | ||
android:top="0dp"> | ||
|
||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle" > | ||
<stroke | ||
android:width="1dp" | ||
android:color="@color/gray3" | ||
android:dashWidth="3dp" | ||
android:dashGap="3dp" /> | ||
</shape> | ||
</item> | ||
</layer-list> | ||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="line"> | ||
<stroke | ||
android:width="1dp" | ||
android:color="@color/gray3" | ||
android:dashWidth="5dp" | ||
android:dashGap="5dp" /> | ||
<size | ||
android:width="1dp"/> | ||
</shape> |
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
Oops, something went wrong.