-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- membuat detail dari player
- Loading branch information
Showing
26 changed files
with
597 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/example/wijaya_pc/footballapps/adapter/PlayerAdapter.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,44 @@ | ||
package com.example.wijaya_pc.footballapps.adapter | ||
|
||
import android.support.v7.widget.RecyclerView | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import com.example.wijaya_pc.footballapps.R | ||
import com.example.wijaya_pc.footballapps.R.id.* | ||
import com.example.wijaya_pc.footballapps.model.Player | ||
import com.example.wijaya_pc.footballapps.ui.PlayerUI | ||
import com.squareup.picasso.Picasso | ||
import org.jetbrains.anko.AnkoContext | ||
import org.jetbrains.anko.find | ||
import org.jetbrains.anko.sdk15.coroutines.onClick | ||
|
||
class PlayerAdapter(private val players: List<Player>, private val listener: (Player) -> Unit) : RecyclerView.Adapter<PlayerViewHolder>() { | ||
override fun onCreateViewHolder(parent: ViewGroup, position: Int): PlayerViewHolder { | ||
return PlayerViewHolder(PlayerUI().createView(AnkoContext.create(parent.context, parent))) | ||
} | ||
|
||
override fun getItemCount(): Int = players.size | ||
|
||
override fun onBindViewHolder(holder: PlayerViewHolder, position: Int) { | ||
holder.bindItem(players[position], listener) | ||
} | ||
|
||
} | ||
|
||
class PlayerViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
|
||
private val playerPhoto : ImageView = view.find(player_photo) | ||
private val playerName : TextView = view.find(player_name) | ||
private val playerPosition : TextView = view.find(player_position) | ||
|
||
fun bindItem(players: Player, listener: (Player) -> Unit) { | ||
Picasso.get().load(players.playerPhoto).placeholder(R.drawable.default_player).into(playerPhoto) | ||
|
||
playerName.text = players.playerName | ||
playerPosition.text = players.playerPosition | ||
|
||
itemView.onClick { listener(players) } | ||
} | ||
} |
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
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
96 changes: 96 additions & 0 deletions
96
app/src/main/java/com/example/wijaya_pc/footballapps/feature/player/DetailPlayerActivity.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,96 @@ | ||
package com.example.wijaya_pc.footballapps.feature.player | ||
|
||
import android.media.Image | ||
import android.os.Bundle | ||
import android.os.PersistableBundle | ||
import android.support.v7.app.AppCompatActivity | ||
import android.view.Menu | ||
import android.view.MenuItem | ||
import android.widget.ImageView | ||
import android.widget.ProgressBar | ||
import android.widget.ScrollView | ||
import android.widget.TextView | ||
import com.example.wijaya_pc.footballapps.R | ||
import com.example.wijaya_pc.footballapps.R.id.* | ||
import com.example.wijaya_pc.footballapps.api.ApiRepository | ||
import com.example.wijaya_pc.footballapps.invisible | ||
import com.example.wijaya_pc.footballapps.model.Player | ||
import com.example.wijaya_pc.footballapps.presenter.DetailPlayerPresenter | ||
import com.example.wijaya_pc.footballapps.ui.DetailPlayerUI | ||
import com.example.wijaya_pc.footballapps.view.DetailPlayerView | ||
import com.example.wijaya_pc.footballapps.visible | ||
import com.google.gson.Gson | ||
import com.squareup.picasso.Picasso | ||
import org.jetbrains.anko.find | ||
import org.jetbrains.anko.setContentView | ||
import org.jetbrains.anko.toast | ||
|
||
class DetailPlayerActivity : AppCompatActivity(), DetailPlayerView { | ||
|
||
private lateinit var detailView: ScrollView | ||
private lateinit var progressBar: ProgressBar | ||
|
||
private lateinit var detailPresenter: DetailPlayerPresenter | ||
|
||
private lateinit var playerID: String | ||
private lateinit var playerName: String | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
DetailPlayerUI().setContentView(this) | ||
|
||
val intent = intent | ||
playerID = intent.getStringExtra("id") | ||
playerName = intent.getStringExtra("name") | ||
|
||
supportActionBar?.title = playerName | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
|
||
detailView = find(player_detail_sv) | ||
progressBar = find(player_detail_progress) | ||
|
||
val request = ApiRepository() | ||
val gson = Gson() | ||
detailPresenter = DetailPlayerPresenter(this, request, gson) | ||
|
||
detailPresenter.getPlayerDetails(playerID) | ||
|
||
} | ||
|
||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return when (item.itemId) { | ||
android.R.id.home -> { | ||
finish() | ||
true | ||
} | ||
else -> super.onOptionsItemSelected(item) | ||
} | ||
} | ||
|
||
override fun showLoading() { | ||
progressBar.visible() | ||
} | ||
|
||
override fun hideLoading() { | ||
progressBar.invisible() | ||
} | ||
|
||
override fun showPlayerDetail(data: Player) { | ||
val playerThumb : ImageView = find(player_detail_photo) | ||
Picasso.get().load(data.playerThumb).placeholder(R.drawable.default_player).into(playerThumb) | ||
|
||
val playerWeight : TextView = find(player_detail_weight) | ||
playerWeight.text = data.playerWeight | ||
|
||
val playerHeight : TextView = find(player_detail_height) | ||
playerHeight.text = data.playerHeight | ||
|
||
val playerPosition : TextView = find(player_detail_position) | ||
playerPosition.text = data.playerPosition | ||
|
||
val playerDesc : TextView = find(player_detail_description) | ||
playerDesc.text = data.playerDescription | ||
} | ||
|
||
} |
Oops, something went wrong.