Skip to content

Commit 3988c06

Browse files
committed
feat: 모두 추가
1 parent d84db04 commit 3988c06

9 files changed

Lines changed: 211 additions & 16 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.seogaemo.hackseoul_android.data
2+
3+
class CreatedAt
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.seogaemo.hackseoul_android.data
2+
3+
data class PipLineBody(
4+
val companyId: String,
5+
val description: String,
6+
val productItemId: String,
7+
val title: String
8+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.seogaemo.hackseoul_android.data
2+
3+
data class ProditemResponse(
4+
val createdAt: CreatedAt,
5+
val modelNumber: String,
6+
val productId: String,
7+
val title: String,
8+
val uid: String
9+
)

app/src/main/java/com/seogaemo/hackseoul_android/network/RetrofitAPI.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.seogaemo.hackseoul_android.network
22

33
import com.seogaemo.hackseoul_android.data.CompanyResponse
4+
import com.seogaemo.hackseoul_android.data.PipLineBody
5+
import com.seogaemo.hackseoul_android.data.ProditemResponse
46
import com.seogaemo.hackseoul_android.data.ProductResponse
57
import com.seogaemo.hackseoul_android.data.SignInRequest
68
import com.seogaemo.hackseoul_android.data.SignInResponse
@@ -21,12 +23,23 @@ interface RetrofitAPI {
2123
@GET("company/{id}")
2224
suspend fun getCompany(
2325
@Header("Authorization") authorization: String,
24-
@Path(value = "id") id : Int
26+
@Path(value = "id") id : String
2527
): Response<CompanyResponse>
2628

2729
@GET("product/{id}")
2830
suspend fun getProduct(
2931
@Header("Authorization") authorization: String,
30-
@Path(value = "id") id : Int
32+
@Path(value = "id") id : String
3133
): Response<ProductResponse>
34+
35+
@GET("blockchain/proditem/{id}")
36+
suspend fun getProdItem(
37+
@Header("Authorization") authorization: String,
38+
@Path(value = "id") id : String
39+
): Response<ProditemResponse>
40+
41+
@POST("blockchain/pipeline")
42+
suspend fun postPipeline(
43+
@Body body: PipLineBody
44+
): Response<Void>
3245
}
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
package com.seogaemo.hackseoul_android.view
22

3+
import android.content.Intent
34
import android.os.Bundle
45
import androidx.activity.enableEdgeToEdge
56
import androidx.appcompat.app.AppCompatActivity
67
import androidx.core.view.ViewCompat
78
import androidx.core.view.WindowInsetsCompat
89
import com.seogaemo.hackseoul_android.R
10+
import com.seogaemo.hackseoul_android.databinding.ActivityHomeBinding
911

1012
class HomeActivity : AppCompatActivity() {
13+
private lateinit var binding: ActivityHomeBinding
1114
override fun onCreate(savedInstanceState: Bundle?) {
1215
super.onCreate(savedInstanceState)
13-
enableEdgeToEdge()
14-
setContentView(R.layout.activity_home)
15-
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
16-
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
17-
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
18-
insets
16+
binding = ActivityHomeBinding.inflate(layoutInflater)
17+
setContentView(binding.root)
18+
19+
binding.loginButton.setOnClickListener {
20+
startActivity(Intent(this@HomeActivity, LoginActivity::class.java))
21+
}
22+
23+
binding.qrButton.setOnClickListener {
24+
startActivity(Intent(this@HomeActivity, MainActivity::class.java))
1925
}
2026
}
2127
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,85 @@
11
package com.seogaemo.hackseoul_android.view
22

3+
import android.content.Context
34
import android.os.Bundle
5+
import android.widget.Toast
6+
import androidx.lifecycle.lifecycleScope
7+
import com.bumptech.glide.Glide
8+
import com.seogaemo.hackseoul_android.data.PipLineBody
9+
import com.seogaemo.hackseoul_android.data.ProductResponse
10+
import com.seogaemo.hackseoul_android.database.SharedPreference
411
import com.seogaemo.hackseoul_android.databinding.ActivityJobHistoryBinding
12+
import com.seogaemo.hackseoul_android.network.RetrofitAPI
13+
import com.seogaemo.hackseoul_android.network.RetrofitClient
514
import com.seogaemo.hackseoul_android.util.BaseActivity
15+
import kotlinx.coroutines.Dispatchers
16+
import kotlinx.coroutines.launch
17+
import kotlinx.coroutines.withContext
618

719
class JobHistoryActivity : BaseActivity() {
820
private lateinit var binding: ActivityJobHistoryBinding
921
override fun onCreate(savedInstanceState: Bundle?) {
1022
super.onCreate(savedInstanceState)
1123
binding = ActivityJobHistoryBinding.inflate(layoutInflater)
1224
setContentView(binding.root)
25+
26+
val id = intent.getStringExtra("id").toString()
27+
28+
lifecycleScope.launch {
29+
getProduct(this@JobHistoryActivity, id)?.let {
30+
binding.titleText.text = it.title
31+
Glide.with(this@JobHistoryActivity)
32+
.load(it.imageUrl)
33+
.centerCrop()
34+
.into(binding.itemImageView)
35+
}
36+
37+
binding.backButton.setOnClickListener {
38+
finish()
39+
}
40+
41+
binding.submitButton.setOnClickListener {
42+
}
43+
}
44+
}
45+
46+
private suspend fun postPipeline(body: PipLineBody): Void? {
47+
return try {
48+
withContext(Dispatchers.IO) {
49+
val retrofitAPI = RetrofitClient.getInstance().create(RetrofitAPI::class.java)
50+
val response = retrofitAPI.postPipeline(body)
51+
if (response.isSuccessful) {
52+
response.body()
53+
} else {
54+
withContext(Dispatchers.Main) {
55+
}
56+
null
57+
}
58+
}
59+
} catch (e: Exception) {
60+
withContext(Dispatchers.Main) {
61+
}
62+
null
63+
}
1364
}
65+
66+
67+
private suspend fun getProduct(context: Context, id: String): ProductResponse? {
68+
return try {
69+
withContext(Dispatchers.IO) {
70+
val retrofitAPI = RetrofitClient.getInstance().create(RetrofitAPI::class.java)
71+
val response = retrofitAPI.getProduct("bearer ${SharedPreference.token}", id)
72+
if (response.isSuccessful) {
73+
response.body()
74+
} else {
75+
76+
null
77+
}
78+
}
79+
} catch (e: Exception) {
80+
81+
null
82+
}
83+
}
84+
1485
}

app/src/main/java/com/seogaemo/hackseoul_android/view/MainActivity.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.seogaemo.hackseoul_android.view
22

33
import android.Manifest
4+
import android.content.Intent
45
import android.content.pm.PackageManager
6+
import android.net.Uri
57
import android.os.Build
68
import android.os.Bundle
79
import android.view.View
@@ -17,6 +19,7 @@ import com.journeyapps.barcodescanner.BarcodeCallback
1719
import com.journeyapps.barcodescanner.BarcodeResult
1820
import com.journeyapps.barcodescanner.DefaultDecoderFactory
1921
import com.seogaemo.hackseoul_android.R
22+
import com.seogaemo.hackseoul_android.database.SharedPreference
2023
import com.seogaemo.hackseoul_android.databinding.ActivityMainBinding
2124
import com.seogaemo.hackseoul_android.util.BaseActivity
2225

@@ -85,7 +88,17 @@ class MainActivity : BaseActivity() {
8588

8689
private fun createRequest(qrCodeText: String) {
8790
if (qrCodeText.startsWith("http://") || qrCodeText.startsWith("https://")) {
88-
91+
val uri = Uri.parse(qrCodeText)
92+
val id = uri.getQueryParameter("id")
93+
if (SharedPreference.isFirst) {
94+
val intent = Intent(this@MainActivity, ProductActivity::class.java)
95+
intent.putExtra("id", id)
96+
startActivity(intent)
97+
} else {
98+
val intent = Intent(this@MainActivity, JobHistoryActivity::class.java)
99+
intent.putExtra("id", id)
100+
startActivity(intent)
101+
}
89102
}
90103
}
91104

app/src/main/java/com/seogaemo/hackseoul_android/view/SplashActivity.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.os.Bundle
66
import android.os.Handler
77
import android.os.Looper
88
import androidx.appcompat.app.AppCompatActivity
9+
import com.seogaemo.hackseoul_android.data.JobHistory
910
import com.seogaemo.hackseoul_android.database.SharedPreference
1011
import com.seogaemo.hackseoul_android.databinding.ActivitySplashBinding
1112

@@ -25,18 +26,23 @@ class SplashActivity : AppCompatActivity() {
2526
val data: Uri? = intent?.data
2627

2728
Handler(Looper.getMainLooper()).postDelayed({
28-
if (SharedPreference.isFirst) {
29-
startActivity(Intent(this@SplashActivity, LoginActivity::class.java))
30-
} else {
31-
if (action == Intent.ACTION_VIEW) {
32-
val id = data?.getQueryParameter("id")
33-
val intent = Intent(this@SplashActivity, ProductActivity::class.java)
29+
30+
if (action == Intent.ACTION_VIEW) {
31+
val id = data?.getQueryParameter("id")
32+
if (SharedPreference.isFirst) {
33+
val intent = Intent(this@SplashActivity, JobHistoryActivity::class.java)
3434
intent.putExtra("id", id)
3535
startActivity(intent)
3636
} else {
37-
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
37+
val intent = Intent(this@SplashActivity, ProductActivity::class.java)
38+
intent.putExtra("id", id)
39+
startActivity(intent)
3840
}
41+
} else {
42+
val intent = Intent(this@SplashActivity, HomeActivity::class.java)
43+
startActivity(intent)
3944
}
45+
4046
finishAffinity()
4147
}, 1500)
4248
}

app/src/main/res/layout/activity_home.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,72 @@
55
android:id="@+id/main"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
8+
android:background="@color/Background_Base_Elevated"
89
tools:context=".view.HomeActivity">
910

11+
<ImageView
12+
android:id="@+id/imageView2"
13+
android:layout_width="wrap_content"
14+
android:layout_height="48dp"
15+
android:src="@drawable/coupang"
16+
app:layout_constraintBottom_toBottomOf="parent"
17+
app:layout_constraintEnd_toEndOf="parent"
18+
app:layout_constraintStart_toStartOf="parent"
19+
app:layout_constraintTop_toTopOf="parent" />
20+
21+
<View
22+
android:layout_marginBottom="8dp"
23+
android:layout_width="match_parent"
24+
android:layout_height="1dp"
25+
android:background="@color/Background_Base_Border"
26+
app:layout_constraintBottom_toTopOf="@+id/login_button" />
27+
28+
<androidx.cardview.widget.CardView
29+
app:cardElevation="0dp"
30+
android:layout_marginBottom="4dp"
31+
android:layout_marginHorizontal="16dp"
32+
android:id="@+id/login_button"
33+
android:layout_width="match_parent"
34+
android:layout_height="44dp"
35+
app:cardBackgroundColor="@color/Background_Accent_Default"
36+
app:cardCornerRadius="4dp"
37+
app:layout_constraintBottom_toTopOf="@+id/qr_button"
38+
app:layout_constraintStart_toStartOf="parent">
39+
40+
<TextView
41+
style="@style/SemiBold15"
42+
android:layout_width="wrap_content"
43+
android:layout_height="wrap_content"
44+
android:layout_gravity="center"
45+
android:text="로그인하기"
46+
android:textColor="@color/Background_Base_Elevated" />
47+
48+
49+
</androidx.cardview.widget.CardView>
50+
51+
<com.google.android.material.card.MaterialCardView
52+
app:cardElevation="0dp"
53+
android:id="@+id/qr_button"
54+
android:layout_marginHorizontal="16dp"
55+
android:layout_marginBottom="8dp"
56+
app:cardCornerRadius="4dp"
57+
android:layout_width="match_parent"
58+
android:layout_height="44dp"
59+
app:cardBackgroundColor="@color/Background_Base_Elevated"
60+
app:layout_constraintBottom_toBottomOf="parent"
61+
app:strokeColor="@color/Background_Base_Border"
62+
app:strokeWidth="1dp">
63+
64+
<TextView
65+
android:layout_gravity="center"
66+
android:layout_marginVertical="10dp"
67+
style="@style/SemiBold15"
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:text="QR 인식하기"
71+
android:textColor="@color/Text_Default_Primary" />
72+
73+
</com.google.android.material.card.MaterialCardView>
74+
75+
1076
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)