-
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.
(#2) Update notice list UI and model.
- Loading branch information
Showing
62 changed files
with
742 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.mashup | ||
|
||
import android.app.Application | ||
import com.mashup.notices.noticeModule | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.context.startKoin | ||
|
||
class MyApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
startKoin { | ||
androidContext(this@MyApplication) | ||
modules(noticeModule) | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.mashup.data.model | ||
|
||
data class Notice( | ||
val pk: Int, | ||
val team: Team, | ||
val title: String, | ||
val author: User, | ||
val startAt: String, | ||
val duration: String, | ||
val address1: String, | ||
val address2: String, | ||
val description: String, | ||
val attendanceSet: ArrayList<NoticeAttendance> | ||
) |
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,8 @@ | ||
package com.mashup.data.model | ||
|
||
data class NoticeAttendance( | ||
val pk:Int, | ||
val user:User, | ||
val vote: String, | ||
val voteDisplay: String | ||
) |
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,7 @@ | ||
package com.mashup.data.model | ||
|
||
data class Period( | ||
val pk: Int, | ||
val isCurrent: Boolean, | ||
val number: Int | ||
) |
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,6 @@ | ||
package com.mashup.data.model | ||
|
||
data class Team( | ||
val pk: Int, | ||
val name: String | ||
) |
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,10 @@ | ||
package com.mashup.data.model | ||
|
||
data class User( | ||
val pk: Int, | ||
val name: String, | ||
val phoneNumber: String, | ||
val email: String, | ||
val github: String, | ||
val userPeriodTeamSet: ArrayList<UserPeriodTeam> | ||
) |
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,6 @@ | ||
package com.mashup.data.model | ||
|
||
data class UserPeriodTeam( | ||
val period: Period, | ||
val team: Team | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/mashup/notices/NoticeListBindings.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,10 @@ | ||
package com.mashup.notices | ||
|
||
import androidx.databinding.BindingAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.mashup.data.model.Notice | ||
|
||
@BindingAdapter("app:items") | ||
fun setItems(listView: RecyclerView, items: List<Notice>) { | ||
(listView.adapter as NoticeAdapter).submitList(items) | ||
} |
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,8 @@ | ||
package com.mashup.notices | ||
|
||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
|
||
val noticeModule = module { | ||
viewModel { NoticesViewModel() } | ||
} |
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,19 @@ | ||
package com.mashup.notices | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import com.mashup.R | ||
|
||
class NoticesActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.notices_activity) | ||
if (savedInstanceState == null) { | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.container, NoticesFragment.newInstance()) | ||
.commitNow() | ||
} | ||
} | ||
|
||
} |
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,59 @@ | ||
package com.mashup.notices | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.mashup.data.model.Notice | ||
import com.mashup.databinding.NoticeItemBinding | ||
|
||
class NoticeAdapter(private val viewModel: NoticesViewModel) : | ||
ListAdapter<Notice, NoticeAdapter.ViewHolder>(TaskDiffCallback()) { | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val item = getItem(position) | ||
|
||
holder.bind(viewModel, item) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
return ViewHolder.from(parent) | ||
} | ||
|
||
class ViewHolder private constructor(val binding: NoticeItemBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(viewModel: NoticesViewModel, item: Notice) { | ||
|
||
binding.viewmodel = viewModel | ||
binding.notice = item | ||
binding.executePendingBindings() | ||
} | ||
|
||
companion object { | ||
fun from(parent: ViewGroup): ViewHolder { | ||
val layoutInflater = LayoutInflater.from(parent.context) | ||
val binding = NoticeItemBinding.inflate(layoutInflater, parent, false) | ||
|
||
return ViewHolder(binding) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Callback for calculating the diff between two non-null items in a list. | ||
* | ||
* Used by ListAdapter to calculate the minimum number of changes between and old list and a new | ||
* list that's been passed to `submitList`. | ||
*/ | ||
class TaskDiffCallback : DiffUtil.ItemCallback<Notice>() { | ||
override fun areItemsTheSame(oldItem: Notice, newItem: Notice): Boolean { | ||
return oldItem.pk == newItem.pk | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: Notice, newItem: Notice): Boolean { | ||
return oldItem == newItem | ||
} | ||
} |
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,46 @@ | ||
package com.mashup.notices | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.mashup.databinding.NoticesFragmentBinding | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
|
||
class NoticesFragment : Fragment() { | ||
|
||
companion object { | ||
fun newInstance() = NoticesFragment() | ||
} | ||
|
||
private val viewModel: NoticesViewModel by viewModel() | ||
private lateinit var viewDataBinding: NoticesFragmentBinding | ||
private lateinit var listAdapter: NoticeAdapter | ||
|
||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
viewDataBinding = NoticesFragmentBinding.inflate(inflater, container, false).apply { | ||
viewmodel = viewModel | ||
} | ||
return viewDataBinding.root | ||
} | ||
|
||
override fun onActivityCreated(savedInstanceState: Bundle?) { | ||
super.onActivityCreated(savedInstanceState) | ||
viewDataBinding.setLifecycleOwner(this.viewLifecycleOwner) | ||
setupListAdapter() | ||
} | ||
|
||
private fun setupListAdapter() { | ||
val viewModel = viewDataBinding.viewmodel | ||
if (viewModel != null) { | ||
listAdapter = NoticeAdapter(viewModel) | ||
viewDataBinding.tasksList.adapter = listAdapter | ||
} | ||
} | ||
|
||
} |
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 @@ | ||
package com.mashup.notices | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.mashup.data.model.Notice | ||
import com.mashup.data.model.Team | ||
import com.mashup.data.model.User | ||
|
||
class NoticesViewModel : ViewModel() { | ||
private val _items = MutableLiveData<List<Notice>>().apply { value = emptyList() } | ||
val items: LiveData<List<Notice>> = _items | ||
|
||
init { | ||
loadNotice() | ||
} | ||
|
||
private fun loadNotice() { | ||
val user = User(0, "이동근", "010", "ee", "ee", ArrayList()) | ||
val noticeArray = ArrayList<Notice>() | ||
noticeArray.add(Notice( | ||
0, Team(0, "Mash-up"), "전체 회의", user, "2019-10-10", "2시까지", "행신역에서", "", "재밌게 놀아봐요", | ||
ArrayList())) | ||
noticeArray.add(Notice( | ||
0, Team(0, "Mash-up"), "전체 회의", user, "2019-10-10", "2시까지", "행신역에서", "", "재밌게 놀아봐요", | ||
ArrayList())) | ||
noticeArray.add(Notice( | ||
0, Team(0, "Mash-up"), "전체 회의", user, "2019-10-10", "2시까지", "행신역에서", "", "재밌게 놀아봐요", | ||
ArrayList())) | ||
noticeArray.add(Notice( | ||
0, Team(0, "Mash-up"), "전체 회의", user, "2019-10-10", "2시까지", "행신역에서", "", "재밌게 놀아봐요", | ||
ArrayList())) | ||
noticeArray.add(Notice( | ||
0, Team(0, "Mash-up"), "전체 회의", user, "2019-10-10", "2시까지", "행신역에서", "", "재밌게 놀아봐요", | ||
ArrayList())) | ||
noticeArray.add(Notice( | ||
0, Team(0, "Mash-up"), "전체 회의", user, "2019-10-10", "2시까지", "행신역에서", "", "재밌게 놀아봐요", | ||
ArrayList())) | ||
|
||
_items.value = noticeArray | ||
} | ||
|
||
} |
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.mashup.util | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import androidx.constraintlayout.motion.widget.MotionLayout | ||
import com.google.android.material.appbar.AppBarLayout | ||
|
||
class CollapsibleToolbar @JvmOverloads constructor( | ||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 | ||
) : MotionLayout(context, attrs, defStyleAttr), AppBarLayout.OnOffsetChangedListener { | ||
|
||
override fun onOffsetChanged(appBarLayout: AppBarLayout?, verticalOffset: Int) { | ||
progress = -verticalOffset / appBarLayout?.totalScrollRange?.toFloat()!! | ||
} | ||
|
||
override fun onAttachedToWindow() { | ||
super.onAttachedToWindow() | ||
(parent as? AppBarLayout)?.addOnOffsetChangedListener(this) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.