Skip to content

Commit

Permalink
#248 [FEAT] : Banner - youtube playlist, instagram 으로 연결
Browse files Browse the repository at this point in the history
- Spring Playlist : 유튜브 플레이리스트로 이동
- About Charo : charo__official 인스타 프로필로 이동
  • Loading branch information
HJinhee committed Apr 10, 2022
1 parent c7c65d1 commit d1f6497
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.charo.android.presentation.ui.home

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.charo.android.R
import com.charo.android.databinding.ActivityBannerAboutCharoBinding
import com.charo.android.domain.model.home.BannerAboutCharo
import com.charo.android.presentation.util.Define

class BannerAboutCharoActivity : AppCompatActivity() {
class BannerAboutCharoActivity : AppCompatActivity(), View.OnClickListener {
private lateinit var binding: ActivityBannerAboutCharoBinding

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -22,6 +27,31 @@ class BannerAboutCharoActivity : AppCompatActivity() {
binding.vpBannerAboutCharo.orientation = ViewPager2.ORIENTATION_HORIZONTAL
binding.dotsIndicator.setViewPager2(binding.vpBannerAboutCharo)

binding.ivInsta.setOnClickListener(this)
binding.tvInstaId.setOnClickListener(this)
binding.tvInstaContext.setOnClickListener(this)
}

private fun openInsta(){
val InstagramPageID = Define().INSTA_CHARO_ID
val uri = Uri.parse("http://instagram.com/_u/$InstagramPageID")

val Instagram_Intent = Intent(Intent.ACTION_VIEW, uri)
Instagram_Intent.setPackage("com.instagram.android")

kotlin.runCatching {
startActivity(Instagram_Intent)
}.onFailure{
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/$InstagramPageID")))
}
}

override fun onClick(v: View?) {
when(v) {
binding.ivInsta, binding.tvInstaId, binding.tvInstaContext -> {
openInsta()
}
}
}

private inner class BannerViewPagerAdapter(fa : FragmentActivity) : FragmentStateAdapter(fa){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,79 @@
package com.charo.android.presentation.ui.home

import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.charo.android.R
import android.view.View
import com.charo.android.databinding.ActivityBannerSpringPlaylistBinding
import com.charo.android.presentation.util.Define

class BannerSpringPlaylistActivity : AppCompatActivity() {
class BannerSpringPlaylistActivity : AppCompatActivity(), View.OnClickListener {

private lateinit var binding: ActivityBannerSpringPlaylistBinding
private lateinit var define: Define

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityBannerSpringPlaylistBinding.inflate(layoutInflater)
setContentView(binding.root)

define = Define()
initListener()

}

private fun initListener(){
binding.tvBtnGoPlaylist.setOnClickListener(this)
binding.clPlaylistPoolside.setOnClickListener(this)
binding.clPlaylistOpenseason.setOnClickListener(this)
binding.clPlaylistLastnightonearth.setOnClickListener(this)
binding.clPlaylistMalibu.setOnClickListener(this)
binding.clPlaylistThing.setOnClickListener(this)
binding.clPlaylistPride.setOnClickListener(this)
binding.clPlaylistYellowhearts.setOnClickListener(this)
binding.clPlaylistSayyou.setOnClickListener(this)
binding.clPlaylistTomorrowtonight.setOnClickListener(this)
binding.clPlaylistSpeechless.setOnClickListener(this)
binding.clPlaylist1245.setOnClickListener(this)
binding.clPlaylistThickandthin.setOnClickListener(this)
binding.clPlaylistSomeonethat.setOnClickListener(this)
binding.clPlaylistIlysb.setOnClickListener(this)
binding.clPlaylistNoises.setOnClickListener(this)
}

private fun openYoutue(youtubeId : String){
val uri = Uri.parse("https://www.youtube.com/$youtubeId")

val Instagram_Intent = Intent(Intent.ACTION_VIEW, uri)
Instagram_Intent.setPackage("com.google.android.youtube")

kotlin.runCatching {
startActivity(Instagram_Intent)
}.onFailure{
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/$youtubeId")))
}
}

override fun onClick(v: View?) {
when(v) {
binding.tvBtnGoPlaylist -> openYoutue(define.YOUTUBE_PLAYLIST_ALL)
binding.clPlaylistPoolside -> openYoutue(define.YOUTUBE_PLAYLIST_POOLSIDE)
binding.clPlaylistOpenseason -> openYoutue(define.YOUTUBE_PLAYLIST_OPENSEASON)
binding.clPlaylistLastnightonearth -> openYoutue(define.YOUTUBE_PLAYLIST_LASTNIGHTONEARTH)
binding.clPlaylistMalibu -> openYoutue(define.YOUTUBE_PLAYLIST_MALIBU)
binding.clPlaylistThing -> openYoutue(define.YOUTUBE_PLAYLIST_THING)
binding.clPlaylistPride -> openYoutue(define.YOUTUBE_PLAYLIST_PRIDE)
binding.clPlaylistYellowhearts -> openYoutue(define.YOUTUBE_PLAYLIST_YELLOWHEARTS)
binding.clPlaylistSayyou -> openYoutue(define.YOUTUBE_PLAYLIST_SAYYOU)
binding.clPlaylistTomorrowtonight -> openYoutue(define.YOUTUBE_PLAYLIST_TOMORROWTONIGHT)
binding.clPlaylistSpeechless -> openYoutue(define.YOUTUBE_PLAYLIST_SPEECHLESS)
binding.clPlaylist1245 -> openYoutue(define.YOUTUBE_PLAYLIST_1245)
binding.clPlaylistThickandthin -> openYoutue(define.YOUTUBE_PLAYLIST_THICKANDTHIN)
binding.clPlaylistSomeonethat -> openYoutue(define.YOUTUBE_PLAYLIST_SOMEONETHAT)
binding.clPlaylistIlysb -> openYoutue(define.YOUTUBE_PLAYLIST_ILYSB)
binding.clPlaylistNoises -> openYoutue(define.YOUTUBE_PLAYLIST_NOISES)
}
}

}
19 changes: 19 additions & 0 deletions app/src/main/java/com/charo/android/presentation/util/Define.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,23 @@ class Define {
val LOCATION_FLAG_MID_SEC : String = "location_flag_2"
val LOCATION_FLAG_END : String = "location_flag_3"

//외부 앱 실행
val INSTA_CHARO_ID : String = "charo__official"
val YOUTUBE_PLAYLIST_ALL : String = "watch?v=xm-AhIVL_h0&list=PLs3lyuoGquKDe-eh5zPVAGIvtrWI9nFMd"
val YOUTUBE_PLAYLIST_POOLSIDE : String = "watch?v=xm-AhIVL_h0&list=TLPQMjkwMzIwMjL7krhnOXW4sA&index=1"
val YOUTUBE_PLAYLIST_OPENSEASON : String = "watch?v=AXiMS5XW6kA"
val YOUTUBE_PLAYLIST_LASTNIGHTONEARTH : String = "watch?v=xg_Y7Or_hWM"
val YOUTUBE_PLAYLIST_MALIBU : String = "watch?v=aLa0bFGF9SY"
val YOUTUBE_PLAYLIST_THING : String = "watch?v=3nc-qD-6Rn0"
val YOUTUBE_PLAYLIST_PRIDE : String = "watch?v=d5ITypP0dZk"
val YOUTUBE_PLAYLIST_YELLOWHEARTS : String = "watch?v=FDWTP4_5eps"
val YOUTUBE_PLAYLIST_SAYYOU : String = "watch?v=0yW7w8F2TVA"
val YOUTUBE_PLAYLIST_TOMORROWTONIGHT : String = "watch?v=OfG97e-4YXE"
val YOUTUBE_PLAYLIST_SPEECHLESS : String = "watch?v=7UoP9ABJXGE"
val YOUTUBE_PLAYLIST_1245 : String = "watch?v=GhWnG7YhcEE"
val YOUTUBE_PLAYLIST_THICKANDTHIN : String = "watch?v=ZpUxgAXCK2E"
val YOUTUBE_PLAYLIST_SOMEONETHAT : String = "watch?v=LQC3dBWS_FE"
val YOUTUBE_PLAYLIST_ILYSB : String = "watch?v=SSTp0rknOgA"
val YOUTUBE_PLAYLIST_NOISES : String = "watch?v=-nQessUrdk0"

}
45 changes: 30 additions & 15 deletions app/src/main/res/layout/activity_banner_spring_playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_poolside"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_poolside"
Expand Down Expand Up @@ -154,8 +155,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_openseason"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_openseason"
Expand Down Expand Up @@ -188,8 +190,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_lastnightonearth"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_lastnightonearth"
Expand Down Expand Up @@ -222,8 +225,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_malibu"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_malibu"
Expand Down Expand Up @@ -256,8 +260,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_thing"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_thing"
Expand Down Expand Up @@ -290,8 +295,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_pride"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_pride"
Expand Down Expand Up @@ -324,8 +330,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_yellowhearts"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_yellowhearts"
Expand Down Expand Up @@ -358,8 +365,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_sayyou"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_sayyou"
Expand Down Expand Up @@ -392,8 +400,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_tomorrowtonight"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_tomorrowtonight"
Expand Down Expand Up @@ -426,8 +435,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_speechless"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_speechless"
Expand Down Expand Up @@ -460,8 +470,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_1245"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_1245"
Expand Down Expand Up @@ -494,8 +505,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_thickandthin"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_thickandthin"
Expand Down Expand Up @@ -528,8 +540,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_someonethat"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_someonethat"
Expand Down Expand Up @@ -562,8 +575,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_ilysb"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_ilysb"
Expand Down Expand Up @@ -596,8 +610,9 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_playlist_noises"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/iv_playlist_noises"
Expand Down

0 comments on commit d1f6497

Please sign in to comment.