-
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.
[MIN-52] feat : 스토리 캘린더 뷰 전환 구현 (#25)
- Loading branch information
Showing
24 changed files
with
446 additions
and
16 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
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
70 changes: 70 additions & 0 deletions
70
common-ui/src/main/java/com/najudoryeong/mineme/common_ui/DialogForDatePickerNoDay.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,70 @@ | ||
package com.najudoryeong.mineme.common_ui | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Dialog | ||
import android.content.Context | ||
import android.content.res.Resources | ||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.widget.NumberPicker | ||
import com.najudoryeong.mineme.common_ui.CalendarUtil.Companion.getDateNoDay | ||
import com.najudoryeong.mineme.common_ui.databinding.DialogForDatepickerBinding | ||
import java.util.* | ||
|
||
class DialogForDatePickerNoDay( | ||
context: Context, | ||
private val initDate: Date, | ||
private val onClickPositiveButton: (String) -> Unit | ||
) : Dialog(context) { | ||
private lateinit var binding: DialogForDatepickerBinding | ||
private var calendar: Calendar = Calendar.getInstance() | ||
|
||
init { | ||
calendar.time = initDate | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
binding = DialogForDatepickerBinding.inflate(layoutInflater).apply { | ||
datePicker.init(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),1,null) | ||
|
||
val daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android") | ||
val daySpinner = datePicker.findViewById<NumberPicker>(daySpinnerId) | ||
daySpinner.visibility = View.GONE | ||
positiveButton.setOnClickListener { | ||
onClickPositiveButton.invoke(datePicker.getDateNoDay()) | ||
dismiss() | ||
} | ||
negativeButton.setOnClickListener { | ||
dismiss() | ||
} | ||
} | ||
setContentView(binding.root) | ||
|
||
window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | ||
} | ||
|
||
class Builder(private val context: Context) { | ||
private lateinit var initDate: Date | ||
private var onClickPositiveButton : (String) -> Unit = {} | ||
|
||
|
||
fun setInitDate(initDate: Date) = apply { | ||
this.initDate = initDate | ||
} | ||
|
||
fun setOnClickPositiveButton(onClickPositiveButton: (String) -> Unit) = apply { | ||
this.onClickPositiveButton = onClickPositiveButton | ||
} | ||
|
||
|
||
fun build() = DialogForDatePicker( | ||
context, | ||
initDate, | ||
onClickPositiveButton | ||
) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
52 changes: 52 additions & 0 deletions
52
story/src/main/java/com/najudoryeong/mineme/story/CalendarAdapter.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,52 @@ | ||
package com.najudoryeong.mineme.story | ||
|
||
import android.graphics.Color | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.najudoryeong.mineme.story.databinding.ItemCalendarBinding | ||
import com.najudoryeong.mineme.story.domain.entity.CalendarData | ||
|
||
class CalendarAdapter(private val dataList: Array<CalendarData>) : | ||
RecyclerView.Adapter<CalendarAdapter.ViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
return ViewHolder( | ||
ItemCalendarBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
Log.d("datasize", dataList.size.toString()) | ||
return dataList.size | ||
} | ||
|
||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val item = dataList[position] | ||
holder.bind(item) | ||
} | ||
|
||
inner class ViewHolder(private val binding: ItemCalendarBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun bind(calendarData: CalendarData) { | ||
|
||
if (calendarData.day.toIntOrNull() == null) { | ||
binding.image.visibility = View.GONE | ||
} else { | ||
binding.date.setTextColor(Color.parseColor("#FFFFFF")) | ||
if (calendarData.data != null) { | ||
binding.imgUrl = calendarData.data.imageUrl | ||
} | ||
} | ||
binding.date.text = calendarData.day | ||
} | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
story/src/main/java/com/najudoryeong/mineme/story/domain/entity/CalendarData.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,11 @@ | ||
package com.najudoryeong.mineme.story.domain.entity | ||
|
||
data class CalendarData( | ||
val day : String, | ||
val data :CalendarItemData? | ||
) | ||
|
||
data class CalendarItemData( | ||
val postId: Int, | ||
val imageUrl: String | ||
) |
Oops, something went wrong.