Skip to content

Commit 65f1614

Browse files
authored
Merge pull request #57 from GaJaMap/feat/#56
Feat/#56
2 parents 843701f + 8cb0081 commit 65f1614

27 files changed

Lines changed: 392 additions & 91 deletions

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'org.jetbrains.kotlin.android'
44
id 'kotlin-kapt'
55
id 'kotlin-parcelize'
6+
id 'com.geekorum.gms.oss-licenses-plugin'
67
}
78

89
Properties properties = new Properties()
@@ -54,6 +55,7 @@ android {
5455
}
5556

5657
dependencies {
58+
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.1'
5759
def lifecycle_version = "2.2.0"
5860

5961
implementation 'androidx.core:core-ktx:1.7.0'

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
<category android:name="android.intent.category.LAUNCHER" />
3636
</intent-filter>
37-
3837
</activity>
3938
<activity
4039
android:name=".ui.view.TermsActivity"
@@ -60,9 +59,7 @@
6059

6160
<activity
6261
android:name=".ui.view.LoginActivity"
63-
android:exported="true">
64-
65-
</activity>
62+
android:exported="true"></activity>
6663
<activity
6764
android:name=".ui.view.EditListActivity"
6865
android:exported="false">
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.pg.gajamap.ui.adapter
2+
3+
import android.content.Context
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.BaseAdapter
8+
import android.widget.TextView
9+
import com.pg.gajamap.R
10+
11+
class CustomerDialogAdapter(private val context: Context, private val items: Array<String>) : BaseAdapter() {
12+
13+
companion object {
14+
private const val KAKAO_TYPE = 0
15+
private const val NAVER_TYPE = 1
16+
}
17+
18+
override fun getCount(): Int {
19+
return items.size
20+
}
21+
22+
override fun getItem(position: Int): Any {
23+
return items[position]
24+
}
25+
26+
override fun getItemId(position: Int): Long {
27+
return position.toLong()
28+
}
29+
30+
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
31+
val item = getItem(position) as String
32+
val inflater = LayoutInflater.from(context)
33+
34+
val view: View = when {
35+
item.contains("카카오") -> {
36+
inflater.inflate(R.layout.kako_dialog_item, parent, false)
37+
}
38+
item.contains("네이버") -> {
39+
inflater.inflate(R.layout.naver_dialog_item, parent, false)
40+
}
41+
else -> {
42+
throw IllegalArgumentException("Unknown item type: $item")
43+
}
44+
}
45+
46+
return view
47+
}
48+
49+
override fun getItemViewType(position: Int): Int {
50+
val item = getItem(position) as String
51+
return when {
52+
item.contains("카카오") -> KAKAO_TYPE
53+
item.contains("네이버") -> NAVER_TYPE
54+
else -> throw IllegalArgumentException("Unknown item type: $item")
55+
}
56+
}
57+
58+
override fun getViewTypeCount(): Int {
59+
return 2
60+
}
61+
}

app/src/main/java/com/pg/gajamap/ui/adapter/CustomerListAdapter.kt

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.pg.gajamap.ui.adapter
22

3+
import android.app.AlertDialog
4+
import android.content.ActivityNotFoundException
35
import android.content.Context
46
import android.content.Intent
57
import android.net.Uri
@@ -49,28 +51,64 @@ class CustomerListAdapter(private var dataList: List<Client>, private val contex
4951
}
5052

5153
binding.itemProfileCarBtn.setOnClickListener {
54+
val items = arrayOf("카카오 내비", "네이버 내비")
55+
56+
val adapter = CustomerDialogAdapter(context, items)
57+
5258
val position = absoluteAdapterPosition
53-
if (NaviClient.instance.isKakaoNaviInstalled(context)) {
54-
context.startActivity(
55-
NaviClient.instance.navigateIntent(
56-
//위도 경도를 장소이름으로 바꿔주기
57-
Location(
58-
dataList[position].clientName,
59-
dataList[position].location.longitude.toString(),
60-
dataList[position].location.latitude.toString()
61-
),
62-
NaviOption(coordType = CoordType.WGS84)
63-
)
64-
)
65-
} else {
66-
// 카카오내비 설치 페이지로 이동
67-
context.startActivity(
68-
Intent(
69-
Intent.ACTION_VIEW,
70-
Uri.parse(Constants.WEB_NAVI_INSTALL)
71-
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
72-
)
59+
60+
val dialogBuilder = AlertDialog.Builder(context)
61+
dialogBuilder.setTitle("내비게이션 선택")
62+
dialogBuilder.setAdapter(adapter) { _, which ->
63+
when (which) {
64+
0 -> {
65+
66+
if (NaviClient.instance.isKakaoNaviInstalled(context)) {
67+
context.startActivity(
68+
NaviClient.instance.navigateIntent(
69+
//위도 경도를 장소이름으로 바꿔주기
70+
Location(
71+
dataList[position].clientName,
72+
dataList[position].location.longitude.toString(),
73+
dataList[position].location.latitude.toString()
74+
),
75+
NaviOption(coordType = CoordType.WGS84)
76+
)
77+
)
78+
} else {
79+
// 카카오내비 설치 페이지로 이동
80+
context.startActivity(
81+
Intent(
82+
Intent.ACTION_VIEW,
83+
Uri.parse(Constants.WEB_NAVI_INSTALL)
84+
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
85+
)
86+
}
87+
}
88+
89+
1 -> {
90+
try {
91+
val url =
92+
"nmap://navigation?dlat=" + dataList[position].location.latitude.toString() + "&dlng=" + dataList[position].location.longitude.toString() + "&dname=" + dataList[position].clientName + "&appname=com.pg.gajamap"
93+
94+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
95+
intent.addCategory(Intent.CATEGORY_BROWSABLE)
96+
97+
context.startActivity(intent)
98+
} catch (e: ActivityNotFoundException) {
99+
context.startActivity(
100+
Intent(
101+
Intent.ACTION_VIEW,
102+
Uri.parse("market://details?id=com.nhn.android.nmap")
103+
)
104+
)
105+
}
106+
}
107+
}
73108
}
109+
110+
val dialog = dialogBuilder.create()
111+
dialog.show()
74112
}
75113
}
76114

app/src/main/java/com/pg/gajamap/ui/adapter/ViewPagerAdapter.kt

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.pg.gajamap.ui.adapter
22

3+
import android.app.AlertDialog
4+
import android.content.ActivityNotFoundException
35
import android.content.Context
46
import android.content.Intent
57
import android.net.Uri
@@ -19,22 +21,28 @@ import com.pg.gajamap.data.model.ViewPagerData
1921
import com.pg.gajamap.databinding.ItemViewpagerBinding
2022
import com.pg.gajamap.ui.view.CustomerInfoActivity
2123

22-
class ViewPagerAdapter (private val itemList: ArrayList<ViewPagerData>, private val context: Context): RecyclerView.Adapter<ViewPagerAdapter.PagerViewHolder>() {
2324

24-
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : PagerViewHolder{
25-
val binding=ItemViewpagerBinding.inflate(LayoutInflater.from(parent.context),parent,false)
25+
class ViewPagerAdapter(
26+
private val itemList: ArrayList<ViewPagerData>,
27+
private val context: Context
28+
) : RecyclerView.Adapter<ViewPagerAdapter.PagerViewHolder>() {
29+
30+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PagerViewHolder {
31+
val binding =
32+
ItemViewpagerBinding.inflate(LayoutInflater.from(parent.context), parent, false)
2633
return PagerViewHolder(binding)
2734
}
2835

2936
override fun getItemCount(): Int = itemList.size
3037

31-
override fun onBindViewHolder(holder: PagerViewHolder, position: Int){
38+
override fun onBindViewHolder(holder: PagerViewHolder, position: Int) {
3239
holder.bind(itemList[position])
3340
}
3441

35-
inner class PagerViewHolder(private val binding: ItemViewpagerBinding) : RecyclerView.ViewHolder(binding.root) {
42+
inner class PagerViewHolder(private val binding: ItemViewpagerBinding) :
43+
RecyclerView.ViewHolder(binding.root) {
3644

37-
fun bind(item: ViewPagerData){
45+
fun bind(item: ViewPagerData) {
3846

3947
binding.clCardPhoneBtn.setOnClickListener {
4048
val intent = Intent(Intent.ACTION_DIAL)
@@ -43,31 +51,64 @@ class ViewPagerAdapter (private val itemList: ArrayList<ViewPagerData>, private
4351
}
4452

4553
binding.clCardCarBtn.setOnClickListener {
46-
if (NaviClient.instance.isKakaoNaviInstalled(context)) {
47-
// 카카오내비 앱으로 길 안내 - WGS84
48-
Log.d("latilongti",item.longitude.toString())
49-
context.startActivity(
50-
NaviClient.instance.navigateIntent(
51-
//위도 경도를 장소이름으로 바꿔주기
52-
Location(item.name, item.longitude.toString(), item.latitude.toString()),
53-
NaviOption(coordType = CoordType.WGS84)
54-
)
55-
)
56-
} else {
57-
// 카카오내비 설치 페이지로 이동
58-
context.startActivity(
59-
Intent(
60-
Intent.ACTION_VIEW,
61-
Uri.parse(Constants.WEB_NAVI_INSTALL)
62-
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
63-
)
54+
val items = arrayOf("카카오 내비", "네이버 내비")
55+
56+
val adapter = CustomerDialogAdapter(context, items)
57+
58+
val dialogBuilder = AlertDialog.Builder(context)
59+
dialogBuilder.setTitle("내비게이션 선택")
60+
dialogBuilder.setAdapter(adapter) { _, which ->
61+
when (which) {
62+
0 -> {
63+
if (NaviClient.instance.isKakaoNaviInstalled(context)) {
64+
Log.d("latilongti", item.longitude.toString())
65+
context.startActivity(
66+
NaviClient.instance.navigateIntent(
67+
Location(
68+
item.name,
69+
item.longitude.toString(),
70+
item.latitude.toString()
71+
),
72+
NaviOption(coordType = CoordType.WGS84)
73+
)
74+
)
75+
} else {
76+
context.startActivity(
77+
Intent(
78+
Intent.ACTION_VIEW,
79+
Uri.parse(Constants.WEB_NAVI_INSTALL)
80+
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
81+
)
82+
}
83+
}
84+
1 -> {
85+
try {
86+
val url =
87+
"nmap://navigation?dlat=" + item.latitude.toString() + "&dlng=" + item.longitude.toString() + "&dname=" + item.name + "&appname=com.pg.gajamap"
88+
89+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
90+
intent.addCategory(Intent.CATEGORY_BROWSABLE)
91+
92+
context.startActivity(intent)
93+
} catch (e: ActivityNotFoundException) {
94+
context.startActivity(
95+
Intent(
96+
Intent.ACTION_VIEW,
97+
Uri.parse("market://details?id=com.nhn.android.nmap")
98+
)
99+
)
100+
}
101+
}
102+
}
64103
}
104+
105+
val dialog = dialogBuilder.create()
106+
dialog.show()
65107
}
66108

67-
if(item.profileImg == "null"){
109+
if (item.profileImg == "null") {
68110
Glide.with(itemView).load(R.drawable.profile_img_origin).into(binding.ivCardProfile)
69-
}
70-
else{
111+
} else {
71112
Glide.with(itemView).load(item.profileImg).into(binding.ivCardProfile)
72113
}
73114
binding.tvCardName.text = item.name
@@ -77,10 +118,9 @@ class ViewPagerAdapter (private val itemList: ArrayList<ViewPagerData>, private
77118
binding.itemViewpager.setOnClickListener {
78119
intentToData(position)
79120
}
80-
if(item.distance == null) {
121+
if (item.distance == null) {
81122
binding.tvCardDistance.text = "- "
82-
}
83-
else {
123+
} else {
84124
binding.tvCardDistance.text = String.format("%.1f ", item.distance?.times(0.001))
85125
}
86126
}

0 commit comments

Comments
 (0)