-
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.
Detail Player,Player team list,overview team,model Player
- Loading branch information
1 parent
b8fe0d9
commit c8692c2
Showing
16 changed files
with
380 additions
and
39 deletions.
There are no files selected for viewing
51 changes: 49 additions & 2 deletions
51
...c/main/java/com/hariobudiharjo/footballmatchschedule/DetailPlayer/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 |
---|---|---|
@@ -1,18 +1,65 @@ | ||
package com.hariobudiharjo.footballmatchschedule.DetailPlayer | ||
|
||
import android.app.ProgressDialog | ||
import android.os.Bundle | ||
import android.support.design.widget.Snackbar | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log | ||
import com.bumptech.glide.Glide | ||
import com.google.gson.Gson | ||
import com.hariobudiharjo.footballmatchschedule.Model.playerModel | ||
import com.hariobudiharjo.footballmatchschedule.Network.ApiMatch | ||
import com.hariobudiharjo.footballmatchschedule.R | ||
|
||
import kotlinx.android.synthetic.main.activity_detail_player.* | ||
import kotlinx.android.synthetic.main.content_detail_player.* | ||
|
||
class DetailPlayerActivity : AppCompatActivity() { | ||
class DetailPlayerActivity : AppCompatActivity(), DetailPlayerView { | ||
|
||
private var matchs: MutableList<playerModel> = mutableListOf() | ||
lateinit var progress: ProgressDialog | ||
lateinit var presenter: DetailPlayerPresenter | ||
|
||
override fun showLoading() { | ||
progress.show() | ||
} | ||
|
||
override fun hideLoading() { | ||
progress.dismiss() | ||
} | ||
|
||
override fun showDetail(data: MutableList<playerModel>) { | ||
Log.d("DEBUGDETAIL", data.toString()) | ||
Glide.with(this@DetailPlayerActivity).load(data[0].strFanart1).into(ivFanart) | ||
tvWeight.text = data[0].strWeight | ||
tvHeight.text = data[0].strHeight | ||
tvPosition.text = data[0].strPosition | ||
tvDescription.text = data[0].strDescriptionEN | ||
|
||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_detail_player) | ||
setSupportActionBar(toolbar) | ||
|
||
getSupportActionBar()!!.setDisplayHomeAsUpEnabled(true) | ||
|
||
toolbar.setNavigationOnClickListener { | ||
onBackPressed() | ||
} | ||
|
||
|
||
val idplayer = intent.getStringExtra("id") | ||
val request = ApiMatch() | ||
val gson = Gson() | ||
|
||
progress = ProgressDialog(this) | ||
progress.setTitle("Loading") | ||
progress.setMessage("Wait while loading...") | ||
progress.setCancelable(false) | ||
|
||
presenter = DetailPlayerPresenter(this, request, gson) | ||
presenter.getPlayerList(idplayer) | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
.../main/java/com/hariobudiharjo/footballmatchschedule/DetailPlayer/DetailPlayerPresenter.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,37 @@ | ||
package com.hariobudiharjo.footballmatchschedule.DetailPlayer | ||
|
||
import android.util.Log | ||
import com.google.gson.Gson | ||
import com.hariobudiharjo.footballmatchschedule.Model.playerDetailResponse | ||
import com.hariobudiharjo.footballmatchschedule.Model.playerModel | ||
import com.hariobudiharjo.footballmatchschedule.Model.playerResponse | ||
import com.hariobudiharjo.footballmatchschedule.Network.ApiMatch | ||
import com.hariobudiharjo.footballmatchschedule.Util.CoroutineContextProvider | ||
import org.jetbrains.anko.doAsync | ||
import org.jetbrains.anko.uiThread | ||
|
||
class DetailPlayerPresenter(private val view: DetailPlayerView, | ||
private val apiRepository: ApiMatch, | ||
private val gson: Gson, | ||
private val contextPool: CoroutineContextProvider = CoroutineContextProvider()) { | ||
private var matchs: MutableList<playerModel> = mutableListOf() | ||
|
||
fun getPlayerList(idPlayer: String) { | ||
|
||
Log.d("DEBUGDETAIL", "MASUK PAK EKO") | ||
view.showLoading() | ||
doAsync { | ||
val data = gson.fromJson(apiRepository | ||
.doRequest("https://www.thesportsdb.com/api/v1/json/1/lookupplayer.php?id=$idPlayer"), | ||
playerDetailResponse::class.java) | ||
matchs.clear() | ||
matchs.addAll(data.players) | ||
Log.d("DEBUG", matchs.toString()) | ||
|
||
uiThread { | ||
view.showDetail(matchs) | ||
view.hideLoading() | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/hariobudiharjo/footballmatchschedule/DetailPlayer/DetailPlayerView.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,9 @@ | ||
package com.hariobudiharjo.footballmatchschedule.DetailPlayer | ||
|
||
import com.hariobudiharjo.footballmatchschedule.Model.playerModel | ||
|
||
interface DetailPlayerView { | ||
fun showLoading() | ||
fun hideLoading() | ||
fun showDetail(data: MutableList<playerModel>) | ||
} |
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
52 changes: 51 additions & 1 deletion
52
...java/com/hariobudiharjo/footballmatchschedule/DetailTeam/PlayerTeam/PlayerTeamFragment.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
35 changes: 35 additions & 0 deletions
35
...ava/com/hariobudiharjo/footballmatchschedule/DetailTeam/PlayerTeam/PlayerTeamPresenter.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,35 @@ | ||
package com.hariobudiharjo.footballmatchschedule.DetailTeam.PlayerTeam | ||
|
||
import android.util.Log | ||
import com.google.gson.Gson | ||
import com.hariobudiharjo.footballmatchschedule.Model.playerModel | ||
import com.hariobudiharjo.footballmatchschedule.Model.playerResponse | ||
import com.hariobudiharjo.footballmatchschedule.Network.ApiMatch | ||
import com.hariobudiharjo.footballmatchschedule.Util.CoroutineContextProvider | ||
import org.jetbrains.anko.doAsync | ||
import org.jetbrains.anko.uiThread | ||
|
||
class PlayerTeamPresenter(private val view: PlayerTeamView, | ||
private val apiRepository: ApiMatch, | ||
private val gson: Gson, | ||
private val contextPool: CoroutineContextProvider = CoroutineContextProvider()) { | ||
private var matchs: MutableList<playerModel> = mutableListOf() | ||
|
||
fun getPlayerList(idTeam: String) { | ||
view.showLoading() | ||
doAsync { | ||
val data = gson.fromJson(apiRepository | ||
.doRequest("https://www.thesportsdb.com/api/v1/json/1/lookup_all_players.php?id=$idTeam"), | ||
playerResponse::class.java) | ||
matchs.clear() | ||
matchs.addAll(data.player) | ||
Log.d("DEBUG", matchs.toString()) | ||
|
||
uiThread { | ||
view.showDetail(matchs) | ||
view.hideLoading() | ||
} | ||
} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...ain/java/com/hariobudiharjo/footballmatchschedule/DetailTeam/PlayerTeam/PlayerTeamView.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,10 @@ | ||
package com.hariobudiharjo.footballmatchschedule.DetailTeam.PlayerTeam | ||
|
||
import com.hariobudiharjo.footballmatchschedule.Model.playerModel | ||
import com.hariobudiharjo.footballmatchschedule.Model.teamModel | ||
|
||
interface PlayerTeamView { | ||
fun showLoading() | ||
fun hideLoading() | ||
fun showDetail(data: MutableList<playerModel>) | ||
} |
Oops, something went wrong.