-
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.
- memunculkan list match dalam tablayout tersebut - membuat team model hingga memunculkan list semua team ke dalam fragment teams
- Loading branch information
Showing
37 changed files
with
799 additions
and
147 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
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
50 changes: 0 additions & 50 deletions
50
app/src/main/java/com/example/wijaya_pc/footballapps/MainActivity.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/example/wijaya_pc/footballapps/adapter/MatchPagerAdapter.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,17 @@ | ||
package com.example.wijaya_pc.footballapps.adapter | ||
|
||
import android.support.v4.app.Fragment | ||
import android.support.v4.app.FragmentManager | ||
import android.support.v4.app.FragmentPagerAdapter | ||
import com.example.wijaya_pc.footballapps.feature.match.ListMatchFragment | ||
|
||
class MatchPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { | ||
|
||
override fun getItem(position: Int): Fragment { | ||
return ListMatchFragment.newInstance(position) | ||
} | ||
|
||
override fun getCount(): Int { | ||
return 2 | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/example/wijaya_pc/footballapps/adapter/TeamAdapter.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,40 @@ | ||
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.id.team_badge | ||
import com.example.wijaya_pc.footballapps.R.id.team_name | ||
import com.example.wijaya_pc.footballapps.model.Team | ||
import com.example.wijaya_pc.footballapps.ui.TeamUI | ||
import com.squareup.picasso.Picasso | ||
import org.jetbrains.anko.AnkoContext | ||
import org.jetbrains.anko.find | ||
import org.jetbrains.anko.sdk25.coroutines.onClick | ||
|
||
class TeamAdapter(private val teams: List<Team>, private val listener: (Team) -> Unit) : RecyclerView.Adapter<TeamViewHolder>(){ | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TeamViewHolder { | ||
return TeamViewHolder(TeamUI().createView(AnkoContext.create(parent.context, parent))) | ||
} | ||
|
||
override fun getItemCount(): Int = teams.size | ||
|
||
override fun onBindViewHolder(holder: TeamViewHolder, position: Int) { | ||
holder.bindItem(teams[position], listener) | ||
} | ||
} | ||
|
||
class TeamViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
|
||
private val teamBadge : ImageView = view.find(team_badge) | ||
private val teamName : TextView = view.find(team_name) | ||
|
||
fun bindItem(teams: Team, listener: (Team) -> Unit) { | ||
Picasso.get().load(teams.teamBadge).into(teamBadge) | ||
teamName.text = teams.teamName | ||
itemView.onClick { listener(teams) } | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/example/wijaya_pc/footballapps/feature/main/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,65 @@ | ||
package com.example.wijaya_pc.footballapps.feature.main | ||
|
||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
import com.example.wijaya_pc.footballapps.FavoriteMatchesFragment | ||
import com.example.wijaya_pc.footballapps.feature.match.MatchFragment | ||
import com.example.wijaya_pc.footballapps.R | ||
import com.example.wijaya_pc.footballapps.R.id.* | ||
import com.example.wijaya_pc.footballapps.feature.team.TeamsFragment | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
bottom_navigation.setOnNavigationItemSelectedListener { item -> | ||
when (item.itemId) { | ||
tab_matches -> { | ||
loadMatchFragment() | ||
} | ||
|
||
tab_teams -> { | ||
loadTeamsFragment() | ||
} | ||
|
||
favorites -> { | ||
loadFavoritesFragment() | ||
} | ||
} | ||
true | ||
} | ||
bottom_navigation.selectedItemId = tab_matches | ||
|
||
} | ||
|
||
private fun loadTeamsFragment() { | ||
supportFragmentManager | ||
.beginTransaction() | ||
.replace( | ||
R.id.main_container, | ||
TeamsFragment(), TeamsFragment::class.java.simpleName) | ||
.commit() | ||
} | ||
|
||
private fun loadFavoritesFragment() { | ||
supportFragmentManager | ||
.beginTransaction() | ||
.replace( | ||
R.id.main_container, | ||
FavoriteMatchesFragment(), FavoriteMatchesFragment::class.java.simpleName) | ||
.commit() | ||
} | ||
|
||
private fun loadMatchFragment() { | ||
supportFragmentManager | ||
.beginTransaction() | ||
.replace( | ||
R.id.main_container, | ||
MatchFragment(), MatchFragment::class.java.simpleName) | ||
.commit() | ||
} | ||
|
||
} |
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
Oops, something went wrong.