-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from kevinmf1/main
add PlayerPedia to repo
- Loading branch information
Showing
64 changed files
with
2,133 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "com.vinz.playerpedia" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
applicationId = "com.vinz.playerpedia" | ||
minSdk = 24 | ||
targetSdk = 33 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation("androidx.core:core-ktx:1.9.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("com.google.android.material:material:1.9.0") | ||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
|
||
// glide | ||
implementation("com.github.bumptech.glide:glide:4.16.0") | ||
|
||
// navigation | ||
val nav_version = "2.6.0" | ||
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version") | ||
implementation("androidx.navigation:navigation-ui-ktx:$nav_version") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
Kotlin/PlayerPedia/app/src/androidTest/java/com/vinz/playerpedia/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.vinz.playerpedia | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.vinz.playerpedia", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<queries> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<data android:scheme="https" /> | ||
</intent> | ||
</queries> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.PlayerPedia" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".activity.PlayerDataActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.DetailActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
58 changes: 58 additions & 0 deletions
58
Kotlin/PlayerPedia/app/src/main/java/com/vinz/playerpedia/activity/DetailActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.vinz.playerpedia.activity | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.bumptech.glide.Glide | ||
import com.vinz.playerpedia.data.PlayerWordData | ||
import com.vinz.playerpedia.databinding.ActivityDetailBinding | ||
|
||
class DetailActivity : AppCompatActivity() { | ||
|
||
private lateinit var binding: ActivityDetailBinding | ||
|
||
@Suppress("DEPRECATION") | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityDetailBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val player = intent.getParcelableExtra<PlayerWordData>("player") as PlayerWordData | ||
|
||
Glide.with(this) | ||
.load(player.playerWordImageResourceId) | ||
.into(binding.ivPlayer) | ||
|
||
binding.tvPlayerName.text = player.playerWordName | ||
binding.tvPlayerClub.text = player.playerWordClub | ||
binding.tvPlayerPosition.text = player.playerWordPosition | ||
binding.tvPlayerNationally.text = player.playerWordNationality | ||
binding.tvPlayerDescription.text = player.playerWordDescription | ||
|
||
binding.btnBack.setOnClickListener { | ||
onBackPressed() | ||
} | ||
|
||
binding.btnSearchGoogle.setOnClickListener { | ||
val playerName = player.playerWordName | ||
|
||
// Buat URL pencarian Google dengan data player.playerWordName | ||
val searchQuery = "https://www.google.com/search?q=${playerName}" | ||
|
||
// Buat intent untuk membuka browser dengan URL pencarian Google | ||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(searchQuery)) | ||
|
||
// Periksa apakah ada aplikasi browser yang dapat menangani intent ini | ||
if (intent.resolveActivity(this.packageManager) != null) { | ||
startActivity(intent) | ||
} else { | ||
// Jika tidak ada aplikasi browser yang dapat menangani intent ini | ||
// Tampilkan pesan kesalahan atau lakukan tindakan lain sesuai kebutuhan Anda | ||
// Misalnya, tampilkan pesan toast bahwa tidak ada browser yang tersedia. | ||
Toast.makeText(this, "Tidak ada browser yang tersedia.", Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
Kotlin/PlayerPedia/app/src/main/java/com/vinz/playerpedia/activity/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.vinz.playerpedia.activity | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import androidx.navigation.findNavController | ||
import androidx.recyclerview.widget.GridLayoutManager | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.vinz.playerpedia.R | ||
import com.vinz.playerpedia.adapter.PlayerAdapter | ||
import com.vinz.playerpedia.data.PlayerDummyData | ||
import com.vinz.playerpedia.data.PlayerWordStart | ||
import com.vinz.playerpedia.databinding.ActivityMainBinding | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
private lateinit var binding : ActivityMainBinding | ||
|
||
private lateinit var playerAdapter: PlayerAdapter | ||
private lateinit var recyclerView: RecyclerView | ||
|
||
private var isLinearLayoutManager = true | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityMainBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
recyclerView = binding.rvWords | ||
recyclerView.setHasFixedSize(true) | ||
recyclerView.layoutManager = LinearLayoutManager(this) | ||
playerAdapter = PlayerAdapter(PlayerDummyData.playerDummy) | ||
recyclerView.adapter = playerAdapter | ||
|
||
binding.btnChangeView.setOnClickListener { | ||
isLinearLayoutManager = !isLinearLayoutManager | ||
setLayout() | ||
} | ||
|
||
playerAdapter.setOnItemClickCallback(object : PlayerAdapter.OnItemClickCallback { | ||
override fun onItemClicked(data: PlayerWordStart) { | ||
// Tambahkan kode untuk membuka detail makanan | ||
showSelectedWord(data) | ||
} | ||
}) | ||
} | ||
|
||
private fun setLayout() { | ||
if (isLinearLayoutManager) { | ||
recyclerView.layoutManager = LinearLayoutManager(this) | ||
binding.btnChangeView.setImageResource(R.drawable.ic_grid) | ||
} else { | ||
recyclerView.layoutManager = GridLayoutManager(this, 2) | ||
binding.btnChangeView.setImageResource(R.drawable.ic_list) | ||
} | ||
} | ||
|
||
private fun showSelectedWord(player: PlayerWordStart) { | ||
val intent = Intent(this, PlayerDataActivity::class.java) | ||
val playerLetterToFind = player.playerLetter | ||
intent.putExtra("playerData", playerLetterToFind) | ||
startActivity(intent) | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
Kotlin/PlayerPedia/app/src/main/java/com/vinz/playerpedia/activity/PlayerDataActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.vinz.playerpedia.activity | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.navigation.findNavController | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.vinz.playerpedia.R | ||
import com.vinz.playerpedia.adapter.PlayerDataAdapter | ||
import com.vinz.playerpedia.data.PlayerDummyData | ||
import com.vinz.playerpedia.data.PlayerWordData | ||
import com.vinz.playerpedia.databinding.ActivityPlayerDataBinding | ||
|
||
class PlayerDataActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityPlayerDataBinding | ||
|
||
private lateinit var playerDataAdapter: PlayerDataAdapter | ||
private lateinit var recyclerView: RecyclerView | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityPlayerDataBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val playerLetter = intent.getStringExtra("playerData") | ||
|
||
val filteredPlayers = PlayerDummyData.playerDummy.filter { playerWordStart -> | ||
playerWordStart.playerLetter == playerLetter | ||
} | ||
|
||
recyclerView = binding.rvPlayerName | ||
recyclerView.setHasFixedSize(true) | ||
recyclerView.layoutManager = LinearLayoutManager(this) | ||
playerDataAdapter = PlayerDataAdapter(filteredPlayers[0].playerWordList) | ||
recyclerView.adapter = playerDataAdapter | ||
|
||
playerDataAdapter.setOnItemClickCallback(object : PlayerDataAdapter.OnItemClickCallback { | ||
override fun onItemClicked(data: PlayerWordData) { | ||
// Tambahkan kode untuk membuka detail makanan | ||
showSelectedPlayer(data) | ||
} | ||
}) | ||
|
||
binding.btnBack.setOnClickListener { | ||
onBackPressed() | ||
} | ||
} | ||
|
||
private fun showSelectedPlayer(player: PlayerWordData) { | ||
val intent = Intent(this, DetailActivity::class.java) | ||
intent.putExtra("player", player) | ||
startActivity(intent) | ||
} | ||
} |
Oops, something went wrong.