Skip to content

Commit

Permalink
Detail Activity
Browse files Browse the repository at this point in the history
  • Loading branch information
salvator627 committed Sep 11, 2023
1 parent ead4416 commit 0051513
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 43 deletions.
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
}

android {
Expand Down Expand Up @@ -30,6 +31,10 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
viewBinding {
enabled = true
}

}

dependencies {
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
Expand All @@ -13,6 +13,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.Games"
tools:targetApi="31">
<activity
android:name=".DetailActivity2"
android:exported="false" />
<activity
android:name=".DetailActivity"
android:exported="false" />
Expand Down
45 changes: 45 additions & 0 deletions app/src/main/java/com/example/games/DetailActivity2.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.example.games


import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.example.games.databinding.ActivityDetail2Binding

class DetailActivity2 : AppCompatActivity() {

private lateinit var binding: ActivityDetail2Binding

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

val data = intent.getParcelableExtra<PostResponse>("data")
if (data!=null){
binding.textView3.text = data.title
binding.tvDev.text = data.developer
binding.tvDescription.text = data.short_description
binding.tvPlatform.text = "Platform : ${data.platform}"
binding.tvRelase.text = "Release Date : ${data.release_date}"
binding.tvGenre.text = "Genre : ${data.genre}"
binding.apply {
Glide.with(this@DetailActivity2)
.load(data.thumbnail)
.transition(DrawableTransitionOptions.withCrossFade())
.centerCrop()
.into(imageView2)
}
binding.apply {
Glide.with(this@DetailActivity2)
.load(data.thumbnail)
.transition(DrawableTransitionOptions.withCrossFade())
.centerCrop()
.circleCrop()
.into(ivProfile)
}

}
}
}
7 changes: 4 additions & 3 deletions app/src/main/java/com/example/games/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import android.content.Intent
import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.games.detail.DetailActivity
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand Down Expand Up @@ -39,7 +37,10 @@ class MainActivity : AppCompatActivity() {

adapter.setOnItemclickcallback(object : GameAdapter.onItemclick{
override fun onItemclicked(data: PostResponse) {
Toast.makeText(this@MainActivity, "hello ${data.title}", Toast.LENGTH_SHORT).show()
val intent = Intent(this@MainActivity,DetailActivity2::class.java)
intent.putExtra("data",data)
startActivity(intent)

}

})
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/com/example/games/PostResponse.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.example.games

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize


@Parcelize
data class PostResponse(
val id: Int,
val title: String,
val developer: String,
val thumbnail: String
)
val thumbnail: String,
val short_description: String,
val platform: String,
val release_date: String,
val genre: String
):Parcelable
17 changes: 0 additions & 17 deletions app/src/main/java/com/example/games/detail/DetailActivity.kt

This file was deleted.

20 changes: 0 additions & 20 deletions app/src/main/res/layout/activity_detail.xml

This file was deleted.

145 changes: 145 additions & 0 deletions app/src/main/res/layout/activity_detail2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:backgroundTint="@color/rvback"
android:background="@color/rvback"
tools:context=".DetailActivity2">

<ImageView
android:id="@+id/imageView2"
android:layout_width="415dp"
android:layout_height="174dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:srcCompat="@tools:sample/avatars" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#FFFFFF"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.131"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.396" />

<TextView
android:id="@+id/tvDev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#B6B6B6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/textView3"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/textView3"
app:layout_constraintTop_toBottomOf="@+id/textView3"
app:layout_constraintVertical_bias="0.0" />

<ImageView
android:id="@+id/ivProfile"
android:layout_width="156dp"
android:layout_height="166dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.109"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.176"
tools:srcCompat="@tools:sample/avatars" />

<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="394dp"
android:layout_height="252dp"
android:layout_marginStart="2dp"
android:layout_marginTop="32dp"
android:backgroundTint="@color/cvback"
app:cardCornerRadius="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.728">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tvDescription"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#B6B6B6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.271"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.214" />

<TextView
android:id="@+id/tvPlatform"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#B6B6B6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/tvDescription"
app:layout_constraintTop_toBottomOf="@+id/tvDescription"
app:layout_constraintVertical_bias="0.08" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About Game"
android:textColor="#B6B6B6"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/tvDescription"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.047"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.551" />

<TextView
android:id="@+id/tvRelase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#B6B6B6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/tvPlatform"
app:layout_constraintTop_toBottomOf="@+id/tvPlatform"
app:layout_constraintVertical_bias="0.121" />

<TextView
android:id="@+id/tvGenre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#B6B6B6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/tvRelase"
app:layout_constraintTop_toBottomOf="@+id/tvRelase"
app:layout_constraintVertical_bias="0.195" />
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 0051513

Please sign in to comment.