-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start adding horizontal days scrollbar in DailyReading
- Loading branch information
Showing
6 changed files
with
142 additions
and
31 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
54 changes: 54 additions & 0 deletions
54
app/src/main/java/net/bible/android/view/activity/readingplan/DailyReadingDayBarAdapter.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,54 @@ | ||
/* | ||
* Copyright (c) 2022 Martin Denham, Tuomas Airaksinen and the And Bible contributors. | ||
* | ||
* This file is part of And Bible (http://github.com/AndBible/and-bible). | ||
* | ||
* And Bible is free software: you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* And Bible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with And Bible. | ||
* If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
package net.bible.android.view.activity.readingplan | ||
|
||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import net.bible.android.activity.databinding.ReadingDayBarBoxBinding | ||
import net.bible.android.view.activity.readingplan.model.DayBarItem | ||
|
||
class DailyReadingDayBarAdapter : ListAdapter<DayBarItem, DailyReadingDayBarAdapter.ViewHolder>(DIFF_CALLBACK) { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
inner class ViewHolder(val binding: ReadingDayBarBoxBinding) : RecyclerView.ViewHolder(binding.root) | ||
|
||
companion object { | ||
const val TAG = "DailyReadingDayBarAdapt" | ||
val DIFF_CALLBACK: DiffUtil.ItemCallback<DayBarItem> = object: DiffUtil.ItemCallback<DayBarItem>() { | ||
override fun areItemsTheSame(oldItem: DayBarItem, newItem: DayBarItem):Boolean { | ||
// User properties may have changed if reloaded from the DB, but ID is fixed | ||
return oldItem.dayNumber == newItem.dayNumber | ||
} | ||
override fun areContentsTheSame(oldItem: DayBarItem, newItem: DayBarItem):Boolean { | ||
// NOTE: if you use equals, your object must properly override Object#equals() | ||
// Incorrectly returning false here will result in too many animations. | ||
return oldItem == newItem | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/net/bible/android/view/activity/readingplan/model/DayBarItem.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,36 @@ | ||
package net.bible.android.view.activity.readingplan.model | ||
|
||
import java.util.Date | ||
|
||
data class DayBarItem ( | ||
val dayNumber: Int, | ||
val date: Date, | ||
/** This day's readings are being shown in daily reading */ | ||
var dayActive: Boolean, | ||
var dayReadPartial: Boolean, | ||
var dayReadComplete: Boolean, | ||
) { | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as DayBarItem | ||
|
||
if (dayNumber != other.dayNumber) return false | ||
if (date != other.date) return false | ||
if (dayActive != other.dayActive) return false | ||
if (dayReadPartial != other.dayReadPartial) return false | ||
if (dayReadComplete != other.dayReadComplete) return false | ||
|
||
return true | ||
} | ||
override fun hashCode(): Int { | ||
var result = dayNumber | ||
result = 31 * result + date.hashCode() | ||
result = 31 * result + dayActive.hashCode() | ||
result = 31 * result + dayReadPartial.hashCode() | ||
result = 31 * result + dayReadComplete.hashCode() | ||
return result | ||
} | ||
} |
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,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="55dp" | ||
android:layout_height="50dp" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
tools:text="Feb 13" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:textSize="18sp" | ||
android:textStyle="bold" | ||
tools:text="222" /> | ||
|
||
</androidx.appcompat.widget.LinearLayoutCompat> |
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