Skip to content

Commit

Permalink
Merge pull request #44 from kevinmf1/main
Browse files Browse the repository at this point in the history
add PlayerPedia to repo
  • Loading branch information
HarshwardhanPatil07 authored Oct 12, 2023
2 parents d954f04 + 4cddcec commit 0fa19b3
Show file tree
Hide file tree
Showing 64 changed files with 2,133 additions and 6 deletions.
7 changes: 1 addition & 6 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
| Moh Faizan | <a href="https://github.com/faizanusmani06"> Moh Faizan</a>|
| Praneesh Sharma | <a href="https://github.com/Praneesh-Sharma"> Praneesh Sharma </a>|
| Naman Bagdiya | <a href="https://github.com/NamanOG"> NamanOG </a>|

| Kevin Malik Fajar | <a href="https://github.com/kevinmf1"> Kevin Malik Fajar </a>|
| Jeelwin | <a href="https://github.com/jeelwin"> Jeelwin </a>|


| Marina J | <a href="https://github.com/marinajcs"> marinajcs </a>|

| Diapk Kurkute| <a href="https://github.com/dipak-01"> dipak-01 </a>|


15 changes: 15 additions & 0 deletions Kotlin/PlayerPedia/.gitignore
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
1 change: 1 addition & 0 deletions Kotlin/PlayerPedia/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
61 changes: 61 additions & 0 deletions Kotlin/PlayerPedia/app/build.gradle.kts
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")

}
21 changes: 21 additions & 0 deletions Kotlin/PlayerPedia/app/proguard-rules.pro
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
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)
}
}
42 changes: 42 additions & 0 deletions Kotlin/PlayerPedia/app/src/main/AndroidManifest.xml
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>
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()
}
}
}
}
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)
}

}
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)
}
}
Loading

0 comments on commit 0fa19b3

Please sign in to comment.