Skip to content

์†์ปคํ†ค_๐Ÿ’ƒํฅ๋ถ€์ž๋“ค๐Ÿ•บ | ๋ฐฉ๋ฐฉ์ฝ•์ฝ• | ๋ฐฉ๊ตฌ์„ ์ฝ˜์„œํŠธ ์ •๋ณด ํ”Œ๋žซํผ

Notifications You must be signed in to change notification settings

BangBangCockCock/BangBangCockCock_Android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

57 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๋ฐฉ๋ฐฉ์ฝ•์ฝ• ๐Ÿ“ฑ _ ๐Ÿ•บํฅ๋ถ€์ž๋“ค๐Ÿ’ƒ

๐Ÿ‘‰๐Ÿป ์ง‘์—์„œ ๋ฐฉ๋ฐฉ๋›ฐ๊ณ  ์ž…์žฅ์€ ์ฝ•!(ํ„ฐ์น˜ํ•œ๋ฒˆ)



"์ฃ„์†กํ•ด์š”, ์ œ๊ฐ€ ๋ฐฉ๊ตฌ์„์— ์„ ์•ฝ์ด ์žˆ์–ด์„œ,,"

๊ฑฐ๋ฆฌ๋‘๊ธฐ ์‹ค์ฒœํ•˜๊ณ , ๊ณต์—ฐ์€ 1000๋ฐฐ๋กœ ์ฆ๊ธฐ์ž

( ์•„๋ฌด๋ฆฌ ์ฝ”๋กœ๋‚˜๊ฐ€ ์™€๋„ ๐Ÿ”ฅํฅ๐Ÿ”ฅ์„ ์ฃผ์ฒดํ• ์ˆ˜ ์—†๋Š” ์‚ฌ๋žŒ๋“ค์„ ์œ„ํ•œ ๋ฐฉ๊ตฌ์„ ์ฝ˜์„œํŠธ ์ •๋ณด ํ”Œ๋žซํผ )



๐Ÿ”ฅ ๊ตฌํ˜„ ํ™”๋ฉด

tablayout1

---

๐Ÿ”ฅ ์‹œํ˜„์˜์ƒ

Register



๐Ÿ”ฅ ํŒจํ‚ค์ง€

Screen Shot 2020-06-07 at 9 26 20 AM


ํฌ๊ฒŒ adapter, viewholder,ui ,network,data, util ๋กœ ๋‚˜๋ˆด์Šต๋‹ˆ๋‹ค!


adapter - recycler view ๊ด€๋ จ adapter

viewholder - recycler view ๊ด€๋ จ viewholder

ui - fragment ์™€ activity ๋กœ ๊ตฌ์„ฑ

network - ์„œ๋ฒ„ ์—ฐ๊ฒฐ์„ ์œ„ํ•œ ํŒŒ์ผ

data - recycler data ์™€ server response data

util - horizantal Decoration , vertical Decoration ( RecyclerView ๋ฅผ ์œ„ํ•œ decoration)


๐Ÿ”ฅ ๊ตฌํ˜„๋ฐฉ์‹


Main

โœ”๏ธ TabLayout์„ ์ด์šฉํ•œ ViewPager ์ƒ์„ฑ

๐Ÿ“Œ Adapter

package com.example.bangbangcockcock_android.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.example.bangbangcockcock_android.HomeFragment
import com.example.bangbangcockcock_android.ui.fragment.*

class MainTabAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm,
    BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
) {
    override fun getCount(): Int =5

    override fun getItem(position: Int): Fragment {
        return when(position)
        {
            0-> HomeFragment()
            1-> Category1Fragment()
            2-> Category2Fragment()
            3-> Category3Fragment()
            else-> Category4Fragment()
        }
    }

    override fun getPageTitle(position: Int): CharSequence? {
        val title = when(position)
        {
            0-> "์ „์ฒด"
            1-> "์•„์ด๋Œ"
            2-> "์ฝ”๋กœ๋‚˜ํŽ€๋”ฉ"
            3->"ํ–‰์‚ฌ"
            else -> "๋ฝ/์ธ๋””"
        }
        return title
    }
}

๐Ÿ“Œ MainActivity

 fun initViewPager()
    {

        val pagerAdapter = MainTabAdapter(supportFragmentManager)
        val pager = findViewById<ViewPager>(R.id.viewPager)
        pager.adapter = pagerAdapter
        val tab = findViewById<TabLayout>(R.id.tab)
        tab.setSelectedTabIndicatorColor(Color.parseColor("#f9320c"));
        tab.setupWithViewPager(pager)
    }

โœ”๏ธ CoordinatorLayout + CollapsingToolbarLayout ์‘์šฉํ•œ ํƒญ ์Šคํฌ๋กค ๋ทฐ


Register


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">



    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:fillViewport="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">



        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/lab3_appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">


            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                android:id="@+id/cl_banner">

        <ImageView
                android:id="@+id/iv_poster"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/main_img_tumbnail"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.0" />



            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/rl_banner_title"
                android:paddingLeft="16dp"
                android:paddingRight="16dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintBottom_toBottomOf="@id/cl_banner"
                android:layout_marginBottom="40dp">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="ํฌํŠธ๋‚˜์ดํŠธ ๋ผ์ด๋ธŒ"
                    android:layout_alignParentLeft="true"
                    android:textColor="#2e2e2e"
                    android:textSize="20sp"
                    android:textStyle="bold"
                    />

                <Button
                    android:layout_width="40dp"
                    android:layout_height="20dp"
                    android:text="D-7"
                    android:textSize="14sp"
                    android:id="@+id/btn_dday"
                    android:layout_centerVertical="true"
                    android:layout_alignParentRight="true"
                    android:lineSpacingExtra="6sp"
                    android:textColor="@color/white"
                    android:background="@drawable/btn_dday"
                    android:layout_gravity="center_vertical"/>



            </RelativeLayout>


            <TextView
                android:id="@+id/textView_date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:lineSpacingExtra="7sp"
                android:textColor="#2e2e2e"
                android:textSize="15sp"
                app:layout_constraintTop_toBottomOf="@id/rl_banner_title"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginLeft="16dp"
                android:text="20.06.06" />

            <TextView
                android:id="@+id/tv_tag"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:lineSpacingExtra="7sp"
                android:textColor="@color/blue"
                android:layout_marginLeft="10dp"
                android:textSize="15sp"
                app:layout_constraintTop_toBottomOf="@id/rl_banner_title"
                app:layout_constraintLeft_toRightOf="@id/textView_date"
                android:layout_toRightOf="@id/textView_date"
                android:text="#์ฝ˜์„œํŠธ" />


            </androidx.constraintlayout.widget.ConstraintLayout>


            <androidx.appcompat.widget.Toolbar
                android:id="@+id/lab3_toolbar"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:layout_margin="8dp"
                app:layout_collapseMode="pin"/>

    </com.google.android.material.appbar.CollapsingToolbarLayout>



        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tab"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="#ffffff"
            app:tabSelectedTextColor="@color/black"
            app:tabTextColor="#c2c2c2"
            app:tabMode="fixed"
            android:layout_gravity="bottom"
            app:layout_collapseMode="pin"
            app:tabGravity="fill"/>

        </com.google.android.material.appbar.AppBarLayout>
        <androidx.viewpager.widget.ViewPager
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/viewPager"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


</androidx.coordinatorlayout.widget.CoordinatorLayout>



    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginTop="20dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:id="@+id/rl_banner">


        <ImageView
            android:id="@+id/img_main_logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/logo"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />

        <ImageView
            android:id="@+id/img_calender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginRight="16dp"
            android:layout_alignParentRight="true"
            android:background="@drawable/main_btn_calendar"/>
    </RelativeLayout>




</FrameLayout>

โœ”๏ธ ๋‹ค์–‘ํ•œ RecyclerView ๊ตฌํ˜„


Calendar

ezgif com-video-to-gif (1)

  • ๊ด€์‹ฌ์žˆ๋Š” ๊ณต์—ฐ์— ์ข‹์•„์š”๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋‹ฌ๋ ฅ์— ํ‘œ์‹œ๋จ
  • Calendar ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
    implementation 'com.michalsvec:single-row-calednar:1.0.0'
  1. ๊ธฐ๋ณธ : special calendar item
  2. ์ผ์ •์ด ํฌํ•จ๋œ ๋‚  : special selected calendar item
  3. SingleRowCalendar
<com.michalsvec.singlerowcalendar.calendar.SingleRowCalendar
    android:id="@+id/main_single_row_calendar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="30dp"
    android:layout_marginEnd="16dp"
    app:deselection="false"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvDate"
    app:longPress="false"
    app:multiSelection="false" />
  1. CalendarViewManager ๋“ฑ๋ก
val myCalendarViewManager = object : CalendarViewManager {  
    override fun setCalendarViewResourceId(                 
        position: Int,                                      
        date: Date,                                         
        isSelected: Boolean                                 
    ): Int {                                                
        // return item layout files, which you have created 
    }                                                       
                                                            
    override fun bindDataToCalendarView(                    
        holder: SingleRowCalendarAdapter.CalendarViewHolder,
        date: Date,                                         
        position: Int,                                      
        isSelected: Boolean                                 
    ) {                                                     
        // bind data to calendar item views                 
    }                                                       
}  
  1. CalendarSelectionManager ๋“ฑ๋ก
val mySelectionManager = object : CalendarSelectionManager {             
    override fun canBeItemSelected(position: Int, date: Date): Boolean { 
        // return true if item can be selected                           
    }                                                                    
}
  1. CalendarChangesObserver ๋“ฑ๋ก
val myCalendarChangesObserver = object : CalendarChangesObserver {

    override fun whenWeekMonthYearChanged(weekNumber: String,monthNumber: String,monthName:
    String,year: String,date: Date) { 
        super.whenWeekMonthYearChanged(weekNumber, monthNumber, monthName, year, date)                 
    }                                                                                                
    
    override fun whenSelectionChanged(isSelected: Boolean, position: Int, date: Date) {               
        super.whenSelectionChanged(isSelected, position, date)
    }       
    
    override fun whenCalendarScrolled(dx: Int, dy: Int) {                                             
        super.whenCalendarScrolled(dx, dy)                                                             
    }                                                                                                
    
    override fun whenSelectionRestored() {                                                             
        super.whenSelectionRestored()                                                                 
    }       
    
    override fun whenSelectionRefreshed() {                                                          
        super.whenSelectionRefreshed()                                                                 
    }   
  1. ๋‚ ์งœ ์ดˆ๊ธฐํ™”
val singleRowCalendar = main_single_row_calendar.apply {        
    calendarViewManager = myCalendarViewManager                
    calendarChangesObserver = myCalendarChangesObserver        
    calendarSelectionManager = mySelectionManager              
    futureDaysCount = 30                                       
    includeCurrentDate = true                                  
    init()                                                     
}   

์„œ๋ฒ„ ์—ฐ๊ฒฐ

package com.example.bangbangcockcock_android.network

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object RequestToServer {
    var retrofit = Retrofit.Builder()
        .baseUrl("http://3.34.151.159:3000") .addConverterFactory(GsonConverterFactory.create()) .build()
    var service: RequestInterface = retrofit.create(RequestInterface::class.java)
}

package com.example.bangbangcockcock_android.network

import com.example.bangbangcockcock_android.data.responseBanner
import com.example.bangbangcockcock_android.data.responseCategory
import retrofit2.Call
import retrofit2.Response
import retrofit2.http.GET

interface RequestInterface {

    @GET("/main/banner")
    fun getBanner() : Call<responseBanner>

    @GET("/main/filter/1")
    fun getConcert() : Call<responseCategory>

    @GET("/main/filter/2")
    fun getCorona() : Call<responseCategory>

    @GET("/main/filter/3")
    fun getFestival() : Call<responseCategory>

    @GET("/main/filter/4")
    fun getIdol() : Call<responseCategory>

    @GET("/main/filter/5")
    fun getRock() : Call<responseCategory>

}

 val requestToServer= RequestToServer
                requestToServer.service.getConcert()
                    .enqueue(
                        object : Callback<responseCategory> {
                            override fun onFailure(call: Call<responseCategory>, t: Throwable) {
                                Log.d("ํ†ต์‹ ์‹คํŒจ", "${t}")
                            }

                            override fun onResponse(
                                call: Call<responseCategory>,
                                response:retrofit2.Response<responseCategory>
                            ) {
                                if (response.isSuccessful) {
                                    Adapter  = CategoryRecyclerAdapter(view!!.context,response.body()!!.data)
                                    rv_category1.adapter = Adapter
                                    rv_category1.addItemDecoration(VerticalItemDecorator(28))
                                    rv_category1.addItemDecoration(HorizontalItemDecorator(16))

                                }

                            }
                        }
                    )

About

์†์ปคํ†ค_๐Ÿ’ƒํฅ๋ถ€์ž๋“ค๐Ÿ•บ | ๋ฐฉ๋ฐฉ์ฝ•์ฝ• | ๋ฐฉ๊ตฌ์„ ์ฝ˜์„œํŠธ ์ •๋ณด ํ”Œ๋žซํผ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages