123 |
124 |
125 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/db/DbFavoriteMatch.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.db
2 |
3 | import android.content.Context
4 | import android.database.sqlite.SQLiteDatabase
5 | import com.dizcoding.kadesubmission2.db.table.FavoriteMatch
6 | import org.jetbrains.anko.db.*
7 |
8 | class DbFavoriteMatch(ctx: Context) : ManagedSQLiteOpenHelper(ctx, "FavoriteMatch.db", null, 1) {
9 | companion object {
10 | private var instance: DbFavoriteMatch? = null
11 |
12 | @Synchronized
13 | fun getInstance(ctx: Context): DbFavoriteMatch {
14 | if (instance == null) {
15 | instance = DbFavoriteMatch(ctx.applicationContext)
16 | }
17 | return instance as DbFavoriteMatch
18 | }
19 | }
20 |
21 | override fun onCreate(db: SQLiteDatabase) {
22 | // Ok, lets try make a database
23 | db.createTable(
24 | FavoriteMatch.TABLE_NAME, true,
25 | FavoriteMatch.ID to INTEGER + PRIMARY_KEY + AUTOINCREMENT,
26 | FavoriteMatch.dateEvent to TEXT,
27 | FavoriteMatch.dateEventLocal to TEXT,
28 | FavoriteMatch.idAwayTeam to TEXT,
29 | FavoriteMatch.idEvent to TEXT + UNIQUE,
30 | FavoriteMatch.idHomeTeam to TEXT,
31 | FavoriteMatch.idLeague to TEXT,
32 | FavoriteMatch.idSoccerXML to TEXT,
33 | FavoriteMatch.intAwayScore to TEXT,
34 | FavoriteMatch.intAwayShots to TEXT,
35 | FavoriteMatch.intHomeScore to TEXT,
36 | FavoriteMatch.intHomeShots to TEXT,
37 | FavoriteMatch.intRound to TEXT,
38 | FavoriteMatch.intSpectators to TEXT,
39 | FavoriteMatch.strAwayFormation to TEXT,
40 | FavoriteMatch.strAwayGoalDetails to TEXT,
41 | FavoriteMatch.strAwayLineupDefense to TEXT,
42 | FavoriteMatch.strAwayLineupForward to TEXT,
43 | FavoriteMatch.strAwayLineupGoalkeeper to TEXT,
44 | FavoriteMatch.strAwayLineupMidfield to TEXT,
45 | FavoriteMatch.strAwayLineupSubstitutes to TEXT,
46 | FavoriteMatch.strAwayRedCards to TEXT,
47 | FavoriteMatch.strAwayTeam to TEXT,
48 | FavoriteMatch.strAwayYellowCards to TEXT,
49 | FavoriteMatch.strBanner to TEXT,
50 | FavoriteMatch.strCircuit to TEXT,
51 | FavoriteMatch.strCity to TEXT,
52 | FavoriteMatch.strCountry to TEXT,
53 | FavoriteMatch.strDate to TEXT,
54 | FavoriteMatch.strDescriptionEN to TEXT,
55 | FavoriteMatch.strEvent to TEXT,
56 | FavoriteMatch.strEventAlternate to TEXT,
57 | FavoriteMatch.strFanart to TEXT,
58 | FavoriteMatch.strFilename to TEXT,
59 | FavoriteMatch.strHomeFormation to TEXT,
60 | FavoriteMatch.strHomeGoalDetails to TEXT,
61 | FavoriteMatch.strHomeLineupDefense to TEXT,
62 | FavoriteMatch.strHomeLineupForward to TEXT,
63 | FavoriteMatch.strHomeLineupGoalkeeper to TEXT,
64 | FavoriteMatch.strHomeLineupMidfield to TEXT,
65 | FavoriteMatch.strHomeLineupSubstitutes to TEXT,
66 | FavoriteMatch.strHomeRedCards to TEXT,
67 | FavoriteMatch.strHomeTeam to TEXT,
68 | FavoriteMatch.strHomeYellowCards to TEXT,
69 | FavoriteMatch.strLeague to TEXT,
70 | FavoriteMatch.strLocked to TEXT,
71 | FavoriteMatch.strMap to TEXT,
72 | FavoriteMatch.strPoster to TEXT,
73 | FavoriteMatch.strResult to TEXT,
74 | FavoriteMatch.strSeason to TEXT,
75 | FavoriteMatch.strSport to TEXT,
76 | FavoriteMatch.strTVStation to TEXT,
77 | FavoriteMatch.strThumb to TEXT,
78 | FavoriteMatch.strTime to TEXT,
79 | FavoriteMatch.strTimeLocal to TEXT,
80 | FavoriteMatch.strTweet1 to TEXT,
81 | FavoriteMatch.strTweet2 to TEXT,
82 | FavoriteMatch.strTweet3 to TEXT,
83 | FavoriteMatch.strVideo to TEXT
84 | )
85 | }
86 |
87 | override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
88 | db.dropTable(FavoriteMatch.TABLE_NAME, true)
89 | }
90 | }
91 |
92 | val Context.dbFavoriteMatch: DbFavoriteMatch get() = DbFavoriteMatch.getInstance(applicationContext)
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/db/table/FavoriteMatch.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.db.table
2 |
3 | data class FavoriteMatch(
4 | val ID : Long?,
5 | val dateEvent : String?,
6 | val dateEventLocal : String?,
7 | val idAwayTeam : String?,
8 | val idEvent : String?,
9 | val idHomeTeam : String?,
10 | val idLeague : String?,
11 | val idSoccerXML : String?,
12 | val intAwayScore : String?,
13 | val intAwayShots : String?,
14 | val intHomeScore : String?,
15 | val intHomeShots : String?,
16 | val intRound : String?,
17 | val intSpectators : String?,
18 | val strAwayFormation : String?,
19 | val strAwayGoalDetails : String?,
20 | val strAwayLineupDefense : String?,
21 | val strAwayLineupForward : String?,
22 | val strAwayLineupGoalkeeper : String?,
23 | val strAwayLineupMidfield : String?,
24 | val strAwayLineupSubstitutes : String?,
25 | val strAwayRedCards : String?,
26 | val strAwayTeam : String?,
27 | val strAwayYellowCards : String?,
28 | val strBanner : String?,
29 | val strCircuit : String?,
30 | val strCity : String?,
31 | val strCountry : String?,
32 | val strDate : String?,
33 | val strDescriptionEN : String?,
34 | val strEvent : String?,
35 | val strEventAlternate : String?,
36 | val strFanart : String?,
37 | val strFilename : String?,
38 | val strHomeFormation : String?,
39 | val strHomeGoalDetails : String?,
40 | val strHomeLineupDefense : String?,
41 | val strHomeLineupForward : String?,
42 | val strHomeLineupGoalkeeper : String?,
43 | val strHomeLineupMidfield : String?,
44 | val strHomeLineupSubstitutes : String?,
45 | val strHomeRedCards : String?,
46 | val strHomeTeam : String?,
47 | val strHomeYellowCards : String?,
48 | val strLeague : String?,
49 | val strLocked : String?,
50 | val strMap : String?,
51 | val strPoster : String?,
52 | val strResult : String?,
53 | val strSeason : String?,
54 | val strSport : String?,
55 | val strTVStation : String?,
56 | val strThumb : String?,
57 | val strTime : String?,
58 | val strTimeLocal : String?,
59 | val strTweet1 : String?,
60 | val strTweet2 : String?,
61 | val strTweet3 : String?,
62 | val strVideo : String?
63 | ){
64 | companion object{
65 | const val TABLE_NAME: String = "favorite_match"
66 | const val ID: String = "ID_"
67 | const val dateEvent: String = "dateEvent"
68 | const val dateEventLocal: String = "dateEventLocal"
69 | const val idAwayTeam: String = "idAwayTeam"
70 | const val idEvent: String ="idEvent"
71 | const val idHomeTeam: String = "idHomeTeam"
72 | const val idLeague: String ="idLeague"
73 | const val idSoccerXML: String ="idSoccerXML"
74 | const val intAwayScore: String ="intAwayScore"
75 | const val intAwayShots: String ="intAwayShots"
76 | const val intHomeScore: String ="intHomeScore"
77 | const val intHomeShots: String ="intHomeShots"
78 | const val intRound: String ="intRound"
79 | const val intSpectators: String ="intSpectators"
80 | const val strAwayFormation: String ="strAwayFormation"
81 | const val strAwayGoalDetails: String = "strAwayGoalDetails"
82 | const val strAwayLineupDefense: String ="strAwayLineupDefense"
83 | const val strAwayLineupForward: String ="strAwayLineupForward"
84 | const val strAwayLineupGoalkeeper: String ="strAwayLineupGoalkeeper"
85 | const val strAwayLineupMidfield: String ="strAwayLineupMidfield"
86 | const val strAwayLineupSubstitutes: String ="strAwayLineupSubstitutes"
87 | const val strAwayRedCards: String ="strAwayRedCards"
88 | const val strAwayTeam: String ="strAwayTeam"
89 | const val strAwayYellowCards: String = "strAwayYellowCards"
90 | const val strBanner: String ="strBanner"
91 | const val strCircuit: String = "strCircuit"
92 | const val strCity: String ="strCity"
93 | const val strCountry: String = "strCountry"
94 | const val strDate: String ="strDate"
95 | const val strDescriptionEN: String ="strDescriptionEN"
96 | const val strEvent: String ="strEvent"
97 | const val strEventAlternate: String ="strEventAlternate"
98 | const val strFanart: String ="strFanart"
99 | const val strFilename: String ="strFilename"
100 | const val strHomeFormation: String ="strHomeFormation"
101 | const val strHomeGoalDetails: String = "strHomeGoalDetails"
102 | const val strHomeLineupDefense: String ="strHomeLineupDefense"
103 | const val strHomeLineupForward: String ="strHomeLineupForward"
104 | const val strHomeLineupGoalkeeper: String ="strHomeLineupGoalkeeper"
105 | const val strHomeLineupMidfield: String ="strHomeLineupMidfield"
106 | const val strHomeLineupSubstitutes: String ="strHomeLineupSubstitutes"
107 | const val strHomeRedCards: String ="strHomeRedCards"
108 | const val strHomeTeam: String ="strHomeTeam"
109 | const val strHomeYellowCards: String = "strHomeYellowCards"
110 | const val strLeague: String ="strLeague"
111 | const val strLocked: String ="strLocked"
112 | const val strMap: String = "strMap"
113 | const val strPoster: String ="strPoster"
114 | const val strResult: String ="strResult"
115 | const val strSeason: String ="strSeason"
116 | const val strSport: String ="strSport"
117 | const val strTVStation: String ="strTVStation"
118 | const val strThumb: String ="strThumb"
119 | const val strTime: String ="strTime"
120 | const val strTimeLocal: String ="strTimeLocal"
121 | const val strTweet1: String ="strTweet1"
122 | const val strTweet2: String ="strTweet2"
123 | const val strTweet3: String ="strTweet3"
124 | const val strVideo: String ="strVideo"
125 | }
126 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/activity/Pencarian.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.activity
2 |
3 | import android.content.Intent
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.view.Menu
7 | import android.view.MenuItem
8 | import android.view.View
9 | import android.widget.Toast
10 | import androidx.appcompat.widget.SearchView
11 | import androidx.recyclerview.widget.LinearLayoutManager
12 | import androidx.recyclerview.widget.RecyclerView
13 | import com.dizcoding.kadesubmission2.R
14 | import com.dizcoding.kadesubmission2.adapter.MatchAdapter
15 | import com.dizcoding.kadesubmission2.api.TheSportDbApi
16 | import com.dizcoding.kadesubmission2.interfaceclass.FragmentNavigationListener
17 | import com.dizcoding.kadesubmission2.model.*
18 | import kotlinx.android.synthetic.main.activity_pencarian.*
19 | import kotlinx.android.synthetic.main.main_activity.*
20 | import kotlinx.android.synthetic.main.main_activity.toolbar
21 | import org.jetbrains.anko.intentFor
22 | import org.jetbrains.anko.toast
23 | import retrofit2.Call
24 | import retrofit2.Callback
25 | import retrofit2.Response
26 |
27 | class Pencarian : AppCompatActivity(), SearchView.OnQueryTextListener, FragmentNavigationListener {
28 |
29 | private var dataTeams: AllTeamResponse = AllTeamResponse(listOf())
30 | private var dataPencarian = MatchResponse(listOf())
31 | private var listIdLiga = mutableListOf()
32 | private lateinit var adapter: MatchAdapter
33 |
34 | override fun onCreate(savedInstanceState: Bundle?) {
35 | super.onCreate(savedInstanceState)
36 | setContentView(R.layout.activity_pencarian)
37 | setSupportActionBar(toolbar)
38 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
39 | }
40 |
41 | override fun onSupportNavigateUp(): Boolean {
42 | finish()
43 | return super.onSupportNavigateUp()
44 | }
45 |
46 | private fun refreshData(dataTeams: AllTeamResponse, data: MatchResponse) {
47 | adapter = MatchAdapter(dataTeams, data, this)
48 | rvMatchSearch.adapter = adapter
49 | rvMatchSearch.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)
50 | adapter.notifyDataSetChanged()
51 | }
52 |
53 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
54 | menuInflater.inflate(R.menu.action_menu, menu)
55 | val searchItem: MenuItem = menu!!.findItem(R.id.searchMenu)
56 | val searchView: SearchView = searchItem.actionView as SearchView
57 | searchView.setOnQueryTextListener(this)
58 | return super.onCreateOptionsMenu(menu)
59 | }
60 |
61 | override fun onQueryTextSubmit(query: String?): Boolean {
62 | query?.let { toast("Mencari " + it) }
63 | query?.let { cariPertandingan(it) }
64 | return false
65 | }
66 |
67 | override fun onQueryTextChange(newText: String?): Boolean {
68 | return false
69 | }
70 |
71 | private fun cariPertandingan(query: String) {
72 | TheSportDbApi().services.cariPertandingan(query).enqueue(object : Callback {
73 | override fun onFailure(call: Call, t: Throwable) {
74 | toast("Failure get cari pertandingan : " + t.message)
75 | }
76 |
77 | override fun onResponse(
78 | call: Call,
79 | response: Response
80 | ) {
81 | var listEvent = response.body()!!.event
82 | listEvent = if (listEvent.isNullOrEmpty()) {
83 | listOf()
84 | } else {
85 | listEvent.filter { it.strSport == "Soccer" }
86 | }
87 | dataPencarian = MatchResponse(listEvent)
88 | addLigaList(dataPencarian.events)
89 | }
90 | })
91 |
92 | }
93 |
94 | private fun addLigaList(events: List) {
95 | if (!events.isNullOrEmpty()) {
96 | events.forEach {
97 | if (cekLigaList(it.idLeague)) {
98 | listIdLiga.add(it.idLeague)
99 | }
100 | }
101 | }
102 | if (!listIdLiga.isNullOrEmpty()) {
103 | listIdLiga.forEach {
104 | getAllTeams(it)
105 | }
106 | }
107 | }
108 |
109 | private fun getAllTeams(id_liga: String) {
110 | TheSportDbApi().services.allTeams(id_liga).enqueue(object : Callback {
111 | override fun onFailure(call: Call, t: Throwable) {
112 | toast("Failure get All Teams : " + t.message)
113 | }
114 |
115 | override fun onResponse(
116 | call: Call,
117 | response: Response
118 | ) {
119 | dataTeams = response.body()!!
120 | if (!dataTeams.teams.isNullOrEmpty()) {
121 | if (!dataPencarian.events.isNullOrEmpty()) {
122 | noData.visibility = View.GONE
123 | refreshData(AllTeamResponse(dataTeams.teams), dataPencarian)
124 | }
125 | }
126 |
127 | }
128 | })
129 |
130 | }
131 |
132 | private fun cekLigaList(idLiga: String): Boolean {
133 | val listliga = listIdLiga.filter { it == idLiga }
134 | return listliga.isEmpty()
135 | }
136 |
137 | override fun onMatchItemSelected(data: Event) {
138 | val intent = Intent(applicationContext, DetailMatchActivity::class.java)
139 | intent.putExtra("id", data.idEvent)
140 | startActivity(intent)
141 | }
142 |
143 | override fun openFragment() {}
144 | override fun loadData(v: View) {}
145 | override fun refreshNextMatch(v: View) {}
146 | override fun refreshPrevMatch(v: View) {}
147 | override fun pagerAdapterDetails(data: Leagues) {}
148 | override fun pagerAdapterSelected(data: Leagues) {}
149 |
150 |
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/activity/Favorit.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.activity
2 |
3 | import android.content.Intent
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.view.View
7 | import androidx.recyclerview.widget.LinearLayoutManager
8 | import androidx.recyclerview.widget.RecyclerView
9 | import com.dizcoding.kadesubmission2.R
10 | import com.dizcoding.kadesubmission2.adapter.MatchAdapter
11 | import com.dizcoding.kadesubmission2.api.TheSportDbApi
12 | import com.dizcoding.kadesubmission2.db.dbFavoriteMatch
13 | import com.dizcoding.kadesubmission2.db.table.FavoriteMatch
14 | import com.dizcoding.kadesubmission2.interfaceclass.FragmentNavigationListener
15 | import com.dizcoding.kadesubmission2.model.*
16 | import kotlinx.android.synthetic.main.activity_favorit.*
17 | import org.jetbrains.anko.db.classParser
18 | import org.jetbrains.anko.db.select
19 | import org.jetbrains.anko.toast
20 | import retrofit2.Call
21 | import retrofit2.Callback
22 | import retrofit2.Response
23 |
24 | class Favorit : AppCompatActivity(), FragmentNavigationListener {
25 |
26 |
27 | private var dataTeams: AllTeamResponse = AllTeamResponse(listOf())
28 | private var dataPertandingan = MatchResponse(listOf())
29 | private var listIdLiga = mutableListOf()
30 | private lateinit var adapter: MatchAdapter
31 |
32 |
33 | override fun onCreate(savedInstanceState: Bundle?) {
34 | super.onCreate(savedInstanceState)
35 | setContentView(R.layout.activity_favorit)
36 | setSupportActionBar(toolbar)
37 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
38 | loadData()
39 | }
40 |
41 | private fun loadData() {
42 | dbFavoriteMatch.use {
43 | val result = select(FavoriteMatch.TABLE_NAME)
44 | val favorite = result.parseList(classParser())
45 | dataPertandingan = MatchResponse(convertToTeam(favorite))
46 | addLigaList(dataPertandingan.events)
47 | }
48 |
49 | }
50 |
51 | private fun convertToTeam(favorite: List): List {
52 | var eventList: MutableList = mutableListOf()
53 |
54 | favorite.forEach {
55 | eventList.add(
56 | Event(
57 | it.dateEvent.toString(),
58 | it.dateEventLocal.toString(),
59 | it.idAwayTeam.toString(),
60 | it.idEvent.toString(),
61 | it.idHomeTeam.toString(),
62 | it.idLeague.toString(),
63 | it.idSoccerXML.toString(),
64 | it.intAwayScore.toString(),
65 | it.intAwayShots.toString(),
66 | it.intHomeScore.toString(),
67 | it.intHomeShots.toString(),
68 | it.intRound.toString(),
69 | it.intSpectators.toString(),
70 | it.strAwayFormation.toString(),
71 | it.strAwayGoalDetails.toString(),
72 | it.strAwayLineupDefense.toString(),
73 | it.strAwayLineupForward.toString(),
74 | it.strAwayLineupGoalkeeper.toString(),
75 | it.strAwayLineupMidfield.toString(),
76 | it.strAwayLineupSubstitutes.toString(),
77 | it.strAwayRedCards.toString(),
78 | it.strAwayTeam.toString(),
79 | it.strAwayYellowCards.toString(),
80 | it.strBanner.toString(),
81 | it.strCircuit.toString(),
82 | it.strCity.toString(),
83 | it.strCountry.toString(),
84 | it.strDate.toString(),
85 | it.strDescriptionEN.toString(),
86 | it.strEvent.toString(),
87 | it.strEventAlternate.toString(),
88 | it.strFanart.toString(),
89 | it.strFilename.toString(),
90 | it.strHomeFormation.toString(),
91 | it.strHomeGoalDetails.toString(),
92 | it.strHomeLineupDefense.toString(),
93 | it.strHomeLineupForward.toString(),
94 | it.strHomeLineupGoalkeeper.toString(),
95 | it.strHomeLineupMidfield.toString(),
96 | it.strHomeLineupSubstitutes.toString(),
97 | it.strHomeRedCards.toString(),
98 | it.strHomeTeam.toString(),
99 | it.strHomeYellowCards.toString(),
100 | it.strLeague.toString(),
101 | it.strLocked.toString(),
102 | it.strMap.toString(),
103 | it.strPoster.toString(),
104 | it.strResult.toString(),
105 | it.strSeason.toString(),
106 | it.strSport.toString(),
107 | it.strTVStation.toString(),
108 | it.strThumb.toString(),
109 | it.strTime.toString(),
110 | it.strTimeLocal.toString(),
111 | it.strTweet1.toString(),
112 | it.strTweet2.toString(),
113 | it.strTweet3.toString(),
114 | it.strVideo.toString()
115 | )
116 | )
117 | }
118 |
119 |
120 | return eventList
121 | }
122 |
123 | private fun addLigaList(events: List) {
124 | if (!events.isNullOrEmpty()) {
125 | events.forEach {
126 | if (cekLigaList(it.idLeague)) {
127 | listIdLiga.add(it.idLeague)
128 | }
129 | }
130 | }
131 | if (!listIdLiga.isNullOrEmpty()) {
132 | listIdLiga.forEach {
133 | getAllTeams(it)
134 | }
135 | }
136 | }
137 |
138 | private fun getAllTeams(id_liga: String) {
139 | TheSportDbApi().services.allTeams(id_liga).enqueue(object : Callback {
140 | override fun onFailure(call: Call, t: Throwable) {
141 | toast("Failure get All Teams : " + t.message)
142 | }
143 |
144 | override fun onResponse(
145 | call: Call,
146 | response: Response
147 | ) {
148 | response.body().let {
149 | if (it != null) {
150 | dataTeams = it
151 | refreshData(dataTeams, dataPertandingan)
152 | }
153 | }
154 | }
155 | })
156 |
157 | }
158 |
159 |
160 | override fun onResume() {
161 | loadData()
162 | // refreshData(dataTeams,dataPertandingan)
163 | super.onResume()
164 | }
165 |
166 |
167 | private fun cekLigaList(idLiga: String): Boolean {
168 | val listliga = listIdLiga.filter { it == idLiga }
169 | return listliga.isEmpty()
170 | }
171 |
172 | private fun refreshData(dataTeams: AllTeamResponse, data: MatchResponse) {
173 | adapter = MatchAdapter(dataTeams, data, this)
174 | rvMatchFavorite.adapter = adapter
175 | rvMatchFavorite.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)
176 | adapter.notifyDataSetChanged()
177 | noData.visibility = View.GONE
178 |
179 | }
180 |
181 | override fun onMatchItemSelected(data: Event) {
182 | val intent = Intent(applicationContext, DetailMatchActivity::class.java)
183 | intent.putExtra("id", data.idEvent)
184 | startActivity(intent)
185 | }
186 |
187 | override fun openFragment() {}
188 | override fun loadData(v: View) {}
189 | override fun refreshNextMatch(v: View) {}
190 | override fun refreshPrevMatch(v: View) {}
191 | override fun pagerAdapterDetails(data: Leagues) {}
192 | override fun pagerAdapterSelected(data: Leagues) {}
193 |
194 | override fun onSupportNavigateUp(): Boolean {
195 | finish()
196 | return super.onSupportNavigateUp()
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/layout/adapter/MatchItemLayout.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.layout.adapter
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.graphics.Typeface
6 | import android.view.Gravity
7 | import android.view.View
8 | import android.widget.ImageView
9 | import android.widget.LinearLayout
10 | import com.dizcoding.kadesubmission2.R
11 | import org.jetbrains.anko.*
12 | import org.jetbrains.anko.cardview.v7.cardView
13 |
14 | class MatchItemLayout : AnkoComponent {
15 | override fun createView(ui: AnkoContext): View = with(ui) {
16 | cardView {
17 | lparams(matchParent, dip(150)) {
18 | margin = dip(5)
19 | radius = dip(5).toFloat()
20 |
21 | }
22 | linearLayout {
23 | lparams(matchParent, matchParent) {
24 | orientation = LinearLayout.VERTICAL
25 | }
26 |
27 | /*Header / Title*/
28 | linearLayout {
29 | lparams(matchParent, matchParent) {
30 | orientation = LinearLayout.VERTICAL
31 | weight = .3.toFloat()
32 | backgroundColor = Color.YELLOW
33 | }
34 | linearLayout {
35 | lparams(matchParent, matchParent) {
36 | weight = .1.toFloat()
37 | }
38 |
39 | textView {
40 | id = R.id.tvEventName
41 | gravity = Gravity.CENTER
42 | textColor = Color.BLACK
43 | typeface = Typeface.DEFAULT_BOLD
44 | textSize = dip(6).toFloat()
45 | }.lparams(matchParent, matchParent)
46 | }
47 | linearLayout {
48 | lparams(matchParent, matchParent) {
49 | weight = .1.toFloat()
50 | }
51 |
52 | textView {
53 | id = R.id.tvLigaName
54 | gravity = Gravity.CENTER
55 | textColor = Color.BLACK
56 | typeface = Typeface.DEFAULT_BOLD
57 | textSize = dip(5).toFloat()
58 | }.lparams(matchParent, matchParent)
59 | }
60 | }
61 | /*Body*/
62 | linearLayout {
63 | lparams(matchParent, matchParent) {
64 | orientation = LinearLayout.HORIZONTAL
65 | weight = .1.toFloat()
66 | padding = dip(5)
67 | }
68 |
69 | /*Home*/
70 | linearLayout {
71 | lparams(matchParent, matchParent) {
72 | orientation = LinearLayout.HORIZONTAL
73 | weight = .1.toFloat()
74 | }
75 | /*Home Image*/
76 | linearLayout {
77 | lparams(matchParent, matchParent) {
78 | weight = .1.toFloat()
79 | orientation = LinearLayout.VERTICAL
80 | }
81 | linearLayout {
82 | lparams(matchParent, matchParent) {
83 | weight = .1.toFloat()
84 | }
85 | imageView {
86 | id = R.id.ivHome
87 | scaleType = ImageView.ScaleType.FIT_CENTER
88 | }.lparams(matchParent, matchParent)
89 | }
90 | linearLayout {
91 | lparams(matchParent, wrapContent)
92 | textView {
93 | id = R.id.tvHomeTeamName
94 | gravity = Gravity.CENTER
95 | textColor = Color.BLACK
96 | typeface = Typeface.DEFAULT_BOLD
97 | textSize = dip(5).toFloat()
98 | }.lparams(matchParent, matchParent)
99 | }
100 |
101 | }
102 | /*Home Score*/
103 | linearLayout {
104 | lparams(matchParent, matchParent) {
105 | weight = .4.toFloat()
106 | orientation = LinearLayout.VERTICAL
107 | }
108 | textView {
109 | id = R.id.tvHomeScore
110 |
111 | gravity = Gravity.CENTER
112 | textColor = Color.BLACK
113 | typeface = Typeface.DEFAULT_BOLD
114 | textSize = dip(8).toFloat()
115 |
116 | }.lparams(matchParent, matchParent)
117 | }
118 |
119 | }
120 | /*Pemisah*/
121 | linearLayout {
122 | lparams(dip(20), matchParent) {
123 | orientation = LinearLayout.VERTICAL
124 | }
125 | textView(":") {
126 | gravity = Gravity.CENTER
127 | textColor = Color.BLACK
128 | typeface = Typeface.DEFAULT_BOLD
129 | textSize = dip(8).toFloat()
130 |
131 | }.lparams(matchParent, matchParent)
132 | }
133 |
134 | /*Away*/
135 | linearLayout {
136 | lparams(matchParent, matchParent) {
137 | orientation = LinearLayout.HORIZONTAL
138 | weight = .1.toFloat()
139 | }
140 | /*Away Score*/
141 | linearLayout {
142 | lparams(matchParent, matchParent) {
143 | weight = .4.toFloat()
144 | orientation = LinearLayout.VERTICAL
145 | }
146 | textView {
147 | id = R.id.tvAwayScore
148 | gravity = Gravity.CENTER
149 | textColor = Color.BLACK
150 | typeface = Typeface.DEFAULT_BOLD
151 | textSize = dip(8).toFloat()
152 |
153 | }.lparams(matchParent, matchParent)
154 | }
155 | /*Away Image*/
156 | linearLayout {
157 | lparams(matchParent, matchParent) {
158 | weight = .1.toFloat()
159 | orientation = LinearLayout.VERTICAL
160 | }
161 |
162 | linearLayout {
163 | lparams(matchParent, matchParent) {
164 | weight = .1.toFloat()
165 | }
166 | imageView {
167 | id = R.id.ivAway
168 | scaleType = ImageView.ScaleType.FIT_CENTER
169 | }.lparams(matchParent, matchParent)
170 | }
171 | linearLayout {
172 | lparams(matchParent, wrapContent)
173 | textView {
174 | id = R.id.tvAwayTeamName
175 | gravity = Gravity.CENTER
176 | textColor = Color.BLACK
177 | typeface = Typeface.DEFAULT_BOLD
178 | textSize = dip(5).toFloat()
179 | }.lparams(matchParent, matchParent)
180 | }
181 | }
182 |
183 | }
184 | }
185 |
186 |
187 | }
188 | }
189 |
190 |
191 | }
192 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.activity
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import androidx.appcompat.app.AppCompatActivity
6 | import android.os.Bundle
7 | import android.view.Menu
8 | import android.view.MenuItem
9 | import android.view.View
10 | import androidx.fragment.app.Fragment
11 |
12 | import com.dizcoding.kadesubmission2.R
13 | import com.dizcoding.kadesubmission2.api.TheSportDbApi
14 | import com.dizcoding.kadesubmission2.fragment.BaseFragment
15 | import com.dizcoding.kadesubmission2.fragment.NextMatchFragment
16 | import com.dizcoding.kadesubmission2.fragment.PrevMatchFragment
17 | import com.dizcoding.kadesubmission2.interfaceclass.FragmentNavigationListener
18 | import com.dizcoding.kadesubmission2.model.*
19 | import kotlinx.android.synthetic.main.main_activity.*
20 | import org.jetbrains.anko.intentFor
21 | import org.jetbrains.anko.toast
22 | import retrofit2.Call
23 | import retrofit2.Callback
24 | import retrofit2.Response
25 |
26 |
27 | class MainActivity : AppCompatActivity(), FragmentNavigationListener {
28 |
29 | private var dataDetailPertandingan: DetailPertandinganResponse =
30 | DetailPertandinganResponse(listOf())
31 | private var dataDetailLiga: DetailLigaResponse = DetailLigaResponse(listOf())
32 | private var dataNextMatch: MatchResponse = MatchResponse(listOf())
33 | private var dataPrevMatch: MatchResponse = MatchResponse(listOf())
34 | private var dataTeams: AllTeamResponse = AllTeamResponse(listOf())
35 |
36 | private lateinit var nextMatchFragment: NextMatchFragment
37 | private lateinit var prefMatchFragment: PrevMatchFragment
38 |
39 |
40 | private var idLiga: String = "4328"
41 | private var idEvent: String = "602262"
42 |
43 | private lateinit var prefMatcView: View
44 | private lateinit var nextMatcView: View
45 | private lateinit var conntext: Context
46 |
47 |
48 | override fun onCreate(savedInstanceState: Bundle?) {
49 | super.onCreate(savedInstanceState)
50 | setContentView(R.layout.main_activity)
51 | setSupportActionBar(toolbar)
52 | conntext = this
53 | nextMatchFragment = NextMatchFragment(this)
54 | prefMatchFragment = PrevMatchFragment(this)
55 | dorApi()
56 | openBaseFragment()
57 | }
58 |
59 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
60 | menuInflater.inflate(R.menu.main_activity_menu, menu)
61 | return super.onCreateOptionsMenu(menu)
62 | }
63 |
64 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
65 | when (item.itemId) {
66 | R.id.searchMenu -> startActivity(intentFor())
67 | R.id.favorit -> startActivity(intentFor())
68 | }
69 | return super.onOptionsItemSelected(item)
70 | }
71 |
72 |
73 | private fun commitFragment(fragment: Fragment) {
74 | val fragmentManager = supportFragmentManager
75 | val fragmentTransaction = fragmentManager.beginTransaction()
76 | fragmentTransaction.replace(R.id.container, fragment)
77 | fragmentTransaction.addToBackStack(null)
78 | fragmentTransaction.commit()
79 | }
80 |
81 | private fun openBaseFragment() {
82 | commitFragment(BaseFragment(supportFragmentManager, this))
83 | }
84 |
85 | override fun openFragment() {
86 |
87 | }
88 |
89 | override fun pagerAdapterDetails(data: Leagues) {
90 | val bundle = Bundle()
91 | bundle.putParcelable("league", data)
92 | startActivity(intentFor("Bundle" to bundle))
93 | }
94 |
95 | override fun pagerAdapterSelected(data: Leagues) {
96 | idLiga = data.id
97 | getAllTeams(idLiga)
98 | nextMatch(idLiga)
99 | prevMatch(idLiga)
100 | }
101 |
102 | override fun refreshNextMatch(v: View) {
103 | nextMatcView = v
104 | nextMatch(idLiga)
105 | }
106 |
107 | override fun refreshPrevMatch(v: View) {
108 | prefMatcView = v
109 | prevMatch(idLiga)
110 | }
111 |
112 | override fun loadData(v: View) {
113 |
114 | }
115 |
116 | override fun onMatchItemSelected(data: Event) {
117 | val intent = Intent(applicationContext, DetailMatchActivity::class.java)
118 | intent.putExtra("id", data.idEvent)
119 | startActivity(intent)
120 | }
121 |
122 | // Dor API
123 | private fun dorApi() {
124 | getAllTeams(idLiga)
125 | detailLiga(idLiga)
126 | detailPertandingan(idEvent)
127 | }
128 |
129 | private fun detailLiga(id_liga: String) {
130 | TheSportDbApi().services.detailLiga(id_liga).enqueue(object : Callback {
131 | override fun onFailure(call: Call, t: Throwable) {
132 | toast("Failure get Detail Liga : " + t.message)
133 | }
134 |
135 | override fun onResponse(
136 | call: Call,
137 | response: Response
138 | ) {
139 | response.body().let {
140 | if (it != null) {
141 | dataDetailLiga = it
142 | }
143 | }
144 | }
145 | })
146 |
147 | }
148 |
149 | private fun nextMatch(id_liga: String) {
150 | TheSportDbApi().services.nextMatch(id_liga).enqueue(object : Callback {
151 | override fun onFailure(call: Call, t: Throwable) {
152 | toast("Failure get Next Match : " + t.message)
153 | }
154 |
155 | override fun onResponse(
156 | call: Call,
157 | response: Response
158 | ) {
159 | response.body().let {
160 | if (it != null) {
161 | dataNextMatch = it
162 | nextMatchFragment.refreshData(dataTeams, dataNextMatch, nextMatcView)
163 | }
164 | }
165 | }
166 | })
167 |
168 | }
169 |
170 | private fun prevMatch(id_liga: String) {
171 | TheSportDbApi().services.prevMatch(id_liga).enqueue(object : Callback {
172 | override fun onFailure(call: Call, t: Throwable) {
173 | toast("Failure get Prev Match : " + t.message)
174 | }
175 |
176 | override fun onResponse(
177 | call: Call,
178 | response: Response
179 | ) {
180 | response.body().let {
181 | if (it != null) {
182 | dataPrevMatch = it
183 | prefMatchFragment.refreshData(dataTeams, dataPrevMatch, prefMatcView)
184 | }
185 | }
186 | }
187 | })
188 |
189 | }
190 |
191 | private fun detailPertandingan(id_event: String) {
192 | TheSportDbApi().services.detailPertandingan(id_event)
193 | .enqueue(object : Callback {
194 | override fun onFailure(call: Call, t: Throwable) {
195 | toast("Failure get detail pertandingan : " + t.message)
196 | }
197 |
198 | override fun onResponse(
199 | call: Call,
200 | response: Response
201 | ) {
202 | response.body().let {
203 | if (it != null) {
204 | dataDetailPertandingan = it
205 | }
206 | }
207 | }
208 | })
209 |
210 | }
211 |
212 | private fun getAllTeams(id_liga: String) {
213 | TheSportDbApi().services.allTeams(id_liga).enqueue(object : Callback {
214 | override fun onFailure(call: Call, t: Throwable) {
215 | toast("Failure get All Teams : " + t.message)
216 | }
217 |
218 | override fun onResponse(
219 | call: Call,
220 | response: Response
221 | ) {
222 | dataTeams = AllTeamResponse(listOf())
223 | response.body().let {
224 | if (it != null) {
225 | dataTeams = it
226 | prefMatchFragment.refreshData(dataTeams, dataPrevMatch, prefMatcView)
227 | nextMatchFragment.refreshData(dataTeams, dataNextMatch, nextMatcView)
228 | }
229 | }
230 |
231 | }
232 | })
233 |
234 | }
235 |
236 | }
237 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dizcoding/kadesubmission2/activity/DetailMatchActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dizcoding.kadesubmission2.activity
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.view.Menu
6 | import android.view.MenuItem
7 | import androidx.core.content.ContextCompat
8 | import com.dizcoding.kadesubmission2.R
9 | import com.dizcoding.kadesubmission2.api.TheSportDbApi
10 | import com.dizcoding.kadesubmission2.db.dbFavoriteMatch
11 | import com.dizcoding.kadesubmission2.db.table.FavoriteMatch
12 | import com.dizcoding.kadesubmission2.model.AllTeamResponse
13 | import com.dizcoding.kadesubmission2.model.DetailPertandinganResponse
14 | import com.dizcoding.kadesubmission2.model.Event
15 | import com.dizcoding.kadesubmission2.model.Team
16 | import com.dizcoding.kadesubmission2.tools.Utils
17 | import kotlinx.android.synthetic.main.detail_match_activity.*
18 | import org.jetbrains.anko.db.classParser
19 | import org.jetbrains.anko.db.insert
20 | import org.jetbrains.anko.db.select
21 | import org.jetbrains.anko.db.delete
22 | import org.jetbrains.anko.toast
23 | import retrofit2.Call
24 | import retrofit2.Callback
25 | import retrofit2.Response
26 |
27 | class DetailMatchActivity : AppCompatActivity() {
28 | private var dataDetailPertandingan: DetailPertandinganResponse =
29 | DetailPertandinganResponse(listOf())
30 | private var event: Event? = null
31 | private var home: Team? = null
32 | private var away: Team? = null
33 | private var menuItem: Menu? = null
34 |
35 | private var favorit: Boolean = false
36 | private var isMenuReady: Boolean = false
37 |
38 | private lateinit var idEvent: String
39 | private lateinit var dataMatch: FavoriteMatch
40 |
41 | override fun onCreate(savedInstanceState: Bundle?) {
42 | super.onCreate(savedInstanceState)
43 | setContentView(R.layout.detail_match_activity)
44 | setSupportActionBar(toolbar)
45 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
46 | idEvent = intent.getStringExtra("id")
47 | isFavorit()
48 | detailPertandingan(idEvent)
49 |
50 | }
51 |
52 | override fun onSupportNavigateUp(): Boolean {
53 | finish()
54 | return super.onSupportNavigateUp()
55 | }
56 |
57 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
58 | menuInflater.inflate(R.menu.detail_match_menu, menu)
59 | menuItem = menu
60 | setIcon()
61 | return super.onCreateOptionsMenu(menu)
62 | }
63 |
64 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
65 | when (item.itemId) {
66 | R.id.favorit -> {
67 | if (isMenuReady) {
68 | if (favorit) hapus() else simpan()
69 | favorit = !favorit
70 | setIcon()
71 | }
72 | }
73 | }
74 | return super.onOptionsItemSelected(item)
75 | }
76 |
77 | private fun setDataMatch(event: Event) {
78 | dataMatch = FavoriteMatch(
79 | 0, event.dateEvent
80 | , event.dateEventLocal
81 | , event.idAwayTeam
82 | , event.idEvent
83 | , event.idHomeTeam
84 | , event.idLeague
85 | , event.idSoccerXML
86 | , event.intAwayScore
87 | , event.intAwayShots
88 | , event.intHomeScore
89 | , event.intHomeShots
90 | , event.intRound
91 | , event.intSpectators
92 | , event.strAwayFormation
93 | , event.strAwayGoalDetails
94 | , event.strAwayLineupDefense
95 | , event.strAwayLineupForward
96 | , event.strAwayLineupGoalkeeper
97 | , event.strAwayLineupMidfield
98 | , event.strAwayLineupSubstitutes
99 | , event.strAwayRedCards
100 | , event.strAwayTeam
101 | , event.strAwayYellowCards
102 | , event.strBanner
103 | , event.strCircuit
104 | , event.strCity
105 | , event.strCountry
106 | , event.strDate
107 | , event.strDescriptionEN
108 | , event.strEvent
109 | , event.strEventAlternate
110 | , event.strFanart
111 | , event.strFilename
112 | , event.strHomeFormation
113 | , event.strHomeGoalDetails
114 | , event.strHomeLineupDefense
115 | , event.strHomeLineupForward
116 | , event.strHomeLineupGoalkeeper
117 | , event.strHomeLineupMidfield
118 | , event.strHomeLineupSubstitutes
119 | , event.strHomeRedCards
120 | , event.strHomeTeam
121 | , event.strHomeYellowCards
122 | , event.strLeague
123 | , event.strLocked
124 | , event.strMap
125 | , event.strPoster
126 | , event.strResult
127 | , event.strSeason
128 | , event.strSport
129 | , event.strTVStation
130 | , event.strThumb
131 | , event.strTime
132 | , event.strTimeLocal
133 | , event.strTweet1
134 | , event.strTweet2
135 | , event.strTweet3
136 | , event.strVideo
137 | )
138 | }
139 |
140 | private fun simpan() {
141 | dbFavoriteMatch.use {
142 | insert(
143 | FavoriteMatch.TABLE_NAME,
144 | FavoriteMatch.dateEvent to dataMatch.dateEvent,
145 | FavoriteMatch.dateEventLocal to dataMatch.dateEventLocal,
146 | FavoriteMatch.idAwayTeam to dataMatch.idAwayTeam,
147 | FavoriteMatch.idEvent to dataMatch.idEvent,
148 | FavoriteMatch.idHomeTeam to dataMatch.idHomeTeam,
149 | FavoriteMatch.idLeague to dataMatch.idLeague,
150 | FavoriteMatch.idSoccerXML to dataMatch.idSoccerXML,
151 | FavoriteMatch.intAwayScore to dataMatch.intAwayScore,
152 | FavoriteMatch.intAwayShots to dataMatch.intAwayShots,
153 | FavoriteMatch.intHomeScore to dataMatch.intHomeScore,
154 | FavoriteMatch.intHomeShots to dataMatch.intHomeShots,
155 | FavoriteMatch.intRound to dataMatch.intRound,
156 | FavoriteMatch.intSpectators to dataMatch.intSpectators,
157 | FavoriteMatch.strAwayFormation to dataMatch.strAwayFormation,
158 | FavoriteMatch.strAwayGoalDetails to dataMatch.strAwayGoalDetails,
159 | FavoriteMatch.strAwayLineupDefense to dataMatch.strAwayLineupDefense,
160 | FavoriteMatch.strAwayLineupForward to dataMatch.strAwayLineupForward,
161 | FavoriteMatch.strAwayLineupGoalkeeper to dataMatch.strAwayLineupGoalkeeper,
162 | FavoriteMatch.strAwayLineupMidfield to dataMatch.strAwayLineupMidfield,
163 | FavoriteMatch.strAwayLineupSubstitutes to dataMatch.strAwayLineupSubstitutes,
164 | FavoriteMatch.strAwayRedCards to dataMatch.strAwayRedCards,
165 | FavoriteMatch.strAwayTeam to dataMatch.strAwayTeam,
166 | FavoriteMatch.strAwayYellowCards to dataMatch.strAwayYellowCards,
167 | FavoriteMatch.strBanner to dataMatch.strBanner,
168 | FavoriteMatch.strCircuit to dataMatch.strCircuit,
169 | FavoriteMatch.strCity to dataMatch.strCity,
170 | FavoriteMatch.strCountry to dataMatch.strCountry,
171 | FavoriteMatch.strDate to dataMatch.strDate,
172 | FavoriteMatch.strDescriptionEN to dataMatch.strDescriptionEN,
173 | FavoriteMatch.strEvent to dataMatch.strEvent,
174 | FavoriteMatch.strEventAlternate to dataMatch.strEventAlternate,
175 | FavoriteMatch.strFanart to dataMatch.strFanart,
176 | FavoriteMatch.strFilename to dataMatch.strFilename,
177 | FavoriteMatch.strHomeFormation to dataMatch.strHomeFormation,
178 | FavoriteMatch.strHomeGoalDetails to dataMatch.strHomeGoalDetails,
179 | FavoriteMatch.strHomeLineupDefense to dataMatch.strHomeLineupDefense,
180 | FavoriteMatch.strHomeLineupForward to dataMatch.strHomeLineupForward,
181 | FavoriteMatch.strHomeLineupGoalkeeper to dataMatch.strHomeLineupGoalkeeper,
182 | FavoriteMatch.strHomeLineupMidfield to dataMatch.strHomeLineupMidfield,
183 | FavoriteMatch.strHomeLineupSubstitutes to dataMatch.strHomeLineupSubstitutes,
184 | FavoriteMatch.strHomeRedCards to dataMatch.strHomeRedCards,
185 | FavoriteMatch.strHomeTeam to dataMatch.strHomeTeam,
186 | FavoriteMatch.strHomeYellowCards to dataMatch.strHomeYellowCards,
187 | FavoriteMatch.strLeague to dataMatch.strLeague,
188 | FavoriteMatch.strLocked to dataMatch.strLocked,
189 | FavoriteMatch.strMap to dataMatch.strMap,
190 | FavoriteMatch.strPoster to dataMatch.strPoster,
191 | FavoriteMatch.strResult to dataMatch.strResult,
192 | FavoriteMatch.strSeason to dataMatch.strSeason,
193 | FavoriteMatch.strSport to dataMatch.strSport,
194 | FavoriteMatch.strTVStation to dataMatch.strTVStation,
195 | FavoriteMatch.strThumb to dataMatch.strThumb,
196 | FavoriteMatch.strTime to dataMatch.strTime,
197 | FavoriteMatch.strTimeLocal to dataMatch.strTimeLocal,
198 | FavoriteMatch.strTweet1 to dataMatch.strTweet1,
199 | FavoriteMatch.strTweet2 to dataMatch.strTweet2,
200 | FavoriteMatch.strTweet3 to dataMatch.strTweet3,
201 | FavoriteMatch.strVideo to dataMatch.strVideo
202 | )
203 | }
204 | }
205 |
206 | private fun hapus() {
207 | dbFavoriteMatch.use {
208 | delete(
209 | FavoriteMatch.TABLE_NAME,
210 | "(idEvent = {id})",
211 | "id" to idEvent
212 | )
213 | }
214 | }
215 |
216 | private fun isFavorit() {
217 | dbFavoriteMatch.use {
218 | val result =
219 | select(FavoriteMatch.TABLE_NAME).whereArgs("idEvent ={id}", "id" to idEvent)
220 | val favorite = result.parseList(classParser())
221 | if (favorite.isNotEmpty()) favorit = true
222 | }
223 | }
224 |
225 | private fun setIcon() {
226 | if (favorit)
227 | menuItem?.getItem(0)?.icon =
228 | ContextCompat.getDrawable(this, R.drawable.ic_favorite_border_black_24dp)
229 | else
230 | menuItem?.getItem(0)?.icon =
231 | ContextCompat.getDrawable(this, R.drawable.ic_favorite_black_24dp)
232 | }
233 |
234 | private fun loadContent() {
235 | home?.strTeamBadge?.let { Utils().picShow(it, ivHomeBadge) }
236 | tvHomeScore.text = event?.intHomeScore ?: "-"
237 | tvHomeName.text = event?.strHomeTeam ?: "-"
238 |
239 | away?.strTeamBadge?.let { Utils().picShow(it, ivAwayBadge) }
240 | tvAwayScore.text = event?.intAwayScore ?: "-"
241 | tvAwayName.text = event?.strAwayTeam ?: "-"
242 |
243 | // body header
244 | strEvent.text = event?.strEvent ?: "-"
245 | strLeague.text = event?.strLeague ?: "-"
246 |
247 | // home content
248 | home?.strTeamLogo?.let { Utils().picShow(it, ivHomeLogo) }
249 | tvHomeTeamName.text = event?.strHomeTeam ?: "-"
250 | tvHomeFormation.text = event?.strHomeFormation ?: "-"
251 | tvHomeShots.text = event?.intHomeShots ?: "-"
252 | tvHomeScoreDetail.text = event?.intHomeScore ?: "-"
253 |
254 | // away content
255 | away?.strTeamLogo?.let { Utils().picShow(it, ivAwayLogo) }
256 | tvAwayTeamName.text = event?.strAwayTeam ?: "-"
257 | tvAwayFormation.text = event?.strAwayFormation ?: "-"
258 | tvAwayShots.text = event?.intAwayShots ?: "-"
259 | tvAwayScoreDetail.text = event?.intAwayScore ?: "-"
260 | }
261 |
262 | private fun detailPertandingan(id_event: String) {
263 | TheSportDbApi().services.detailPertandingan(id_event).enqueue(object :
264 | Callback {
265 | override fun onFailure(call: Call, t: Throwable) {
266 | toast("Failure get detail pertandingan : " + t.message)
267 | }
268 |
269 | override fun onResponse(
270 | call: Call,
271 | response: Response
272 | ) {
273 | response.body().let {
274 | if (it != null) {
275 | dataDetailPertandingan = it
276 | event = dataDetailPertandingan.events[0]
277 | getAllTeams(dataDetailPertandingan.events[0].idLeague)
278 | }
279 | }
280 |
281 | }
282 | })
283 |
284 | }
285 |
286 | private fun getAllTeams(id_liga: String) {
287 | TheSportDbApi().services.allTeams(id_liga).enqueue(object : Callback {
288 | override fun onFailure(call: Call, t: Throwable) {
289 | toast("Failure get cari pertandingan : " + t.message)
290 | }
291 |
292 | override fun onResponse(
293 | call: Call,
294 | response: Response
295 | ) {
296 | val datas = response.body()
297 | val event = dataDetailPertandingan.events
298 | val hme = datas?.teams?.filter { it.idTeam == event[0].idHomeTeam }
299 | val awy = datas?.teams?.filter { it.idTeam == event[0].idAwayTeam }
300 | home = hme?.get(0)
301 | away = awy?.get(0)
302 | setDataMatch(event[0])
303 | loadContent()
304 | isMenuReady = true
305 | setIcon()
306 | // kalau sudah sampai sini, baru icon di tampilkan.
307 | }
308 | })
309 |
310 | }
311 | }
312 |
--------------------------------------------------------------------------------
/app/src/main/assets/league.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"English Premier League",
4 | "id":"4328",
5 | "logo": "1_english_premier_league.png",
6 | "description" :"The Premier League (often referred to as the English Premier League (EPL) outside England), is the top level of the English football league system. Contested by 20 clubs, it operates on a system of promotion and relegation with the English Football League (EFL).\nThe Premier League is a corporation in which the member clubs act as shareholders. Seasons run from August to May with each team playing 38 matches (playing each other home and away). Most games are played on Saturday and Sunday afternoons. The Premier League has featured 47 English and two Welsh clubs since its inception, making it a cross-border league.\n The competition was formed as the FA Premier League on 20 February 1992 following the decision of clubs in the Football League First Division to break away from the Football League, founded in 1888, and take advantage of a lucrative television rights deal. The deal was worth £1 billion a year domestically as of 2013–14, with BSkyB and BT Group securing the domestic rights to broadcast 116 and 38 games respectively. The league generates €2.2 billion per year in domestic and international television rights. In 2014–15, teams were apportioned revenues of £1.6 billion, rising sharply to £2.4 billion in 2016–17.\n The Premier League is the most-watched sports league in the world, broadcast in 212 territories to 643 million homes and a potential TV audience of 4.7 billion people. In the 2014–15 season, the average Premier League match attendance exceeded 36,000, second highest of any professional football league behind the Bundesliga's 43,500. Most stadium occupancies are near capacity. The Premier League ranks second in the UEFA coefficients of leagues based on performances in European competitions over the past five seasons, as of 2018.\n Forty-nine clubs have competed since the inception of the Premier League in 1992. Six of them have won the title: Manchester United (13), Chelsea (5), Arsenal (3), Manchester City (3), Blackburn Rovers (1), and Leicester City (1). Following the 2003–04 season, Arsenal acquired the nickname \"The Invincibles\" as they became, and still remain, the only club to complete a Premier League campaign without losing a single game. The record of most points in a season is 100 by Manchester City in 2017–18."
7 | },
8 | {
9 | "name":"French Ligue 1",
10 | "id":"4334",
11 | "logo": "2_french_ligue_1.png",
12 | "description" :"Ligue 1 (French pronunciation: ; League 1, formerly known as Division 1), is the French professional league for association football clubs. It is the country's primary football competition and serves as the top division of the French football league system. Ligue 1 is one of two divisions making up the Ligue de Football Professionnel, the other being Ligue 2. Contested by 20 clubs, it operates on a system of promotion and relegation with Ligue 2. Seasons run from August to May, with teams playing 38 games each totaling 380 games in the season. Most games are played on Saturdays and Sundays, with a few games played during weekday evenings. Play is regularly suspended the last weekend before Christmas for two weeks before returning in the second week of January. Ligue 1 is one of the top national leagues, currently ranked sixth in Europe behind the Spanish La Liga, English Premier League, the German Bundesliga, the Portuguese Primeira Liga and the Italian Serie A.\n Ligue 1 was inaugurated on 11 September 1932 under the name National before switching to Division 1 after a year of existence. The name lasted until 2002 before switching to its current name. The current champions are Paris Saint-Germain, who won the 4th title of their history in the 2013–14 season.\n Ligue 1 is generally regarded as competently run, with good planning of fixtures, complete and consistently enforced rules, timely resolution of issues, and adequate escalation procedures of judicial disputes to national or international institutions. The league has faced three significant corruption scandals in its history (Antibes in 1933, Red Star in the 1950s, and Marseille in 1993) and has preserved its reputation every time through swift and appropriately severe punishment of the guilty parties."
13 | },
14 | {
15 | "name":"German Bundesliga",
16 | "id":"4331",
17 | "logo": "3_german_bundesliga.png",
18 | "description" :"The Fußball-Bundesliga (English: Football Federal League), commonly known as the Bundesliga, is a professional association football league in Germany and the football league with the highest average stadium attendance worldwide. At the top of the German football league system, the Bundesliga is Germany's primary football competition. The Bundesliga is contested by 18 teams and operates on a system of promotion and relegation with the 2. Bundesliga. Seasons run from August to May. Most games are played on Saturdays and Sundays, with a few games played during weekdays. All of the Bundesliga clubs qualify for the DFB-Pokal. The winner of the Bundesliga qualifies for the DFL-Supercup.\n A total of 53 clubs have competed in the Bundesliga since its founding. FC Bayern Munich has won the Bundesliga the most, winning the title 23 times. However, the Bundesliga has seen other champions with Borussia Dortmund, Hamburger SV, Werder Bremen, Borussia Mönchengladbach and VfB Stuttgart most prominent among them. The Bundesliga is one of the top national leagues, currently ranked 3rd in Europe according to UEFA's league coefficient ranking, based on recent European performances. The Bundesliga is the number one football league in the world in terms of average attendance; out of all sports, its average of 45,134 fans per game during the 2011–12 season was the second highest of any sports league in the world. The Bundesliga is broadcast on television in over 200 countries.\n The Bundesliga was founded in 1962 in Dortmund and the first season started in 1963. The structure and organisation of the Bundesliga along with Germany's other football leagues have undergone frequent changes right up to the present day. The Bundesliga was originally founded by the Deutscher Fußball-Bund (English: German Football Association), but is now operated by the Deutsche Fußball Liga (English: German Football League)."
19 | },
20 | {
21 | "name":"Italian Serie A",
22 | "id":"4332",
23 | "logo": "4_italian_serie_a.png",
24 | "description" :"Serie A, also called Serie A TIM due to sponsorship by Telecom Italia, is a professional league competition for football clubs located at the top of the Italian football league system and has been operating for over eighty years since the 1929–30 season. It had been organized by Lega Calcio until 2010, but a new league, the Lega Serie A, was created for the 2010–11 season. Serie A is regarded as one of the best football leagues in the world. Serie A was considered the best league in the world in the '90s, and has produced the highest number of European Cup finalists: Italian clubs have reached the final of the competition on a record twenty-six different occasions, winning the title twelve times. Serie A is ranked 4th among European leagues according to UEFA's league coefficient behind the Spanish La Liga, English Premier League and German Bundesliga, which is based on the performance of Italian clubs in the Champions League and the Europa League. It also ranked 5th in world according to the first trends of the 2011 IFFHS rating.\n In its current format, the Italian Football Championship was revised from having regional and interregional rounds, to a single-tier league from the 1929–30 season onwards. The championship titles won prior to 1929 are officially recognised by FIGC with the same weighting as titles that were subsequently awarded. However, the 1945–46 season, when the league was played over two geographical groups due to the ravages of WWII, is not statistically considered, even if its title is fully official.\n The league hosts three of the world's most famous clubs as Juventus, Milan and Internazionale, all founding members of the G-14, a group which represented the largest and most prestigious European football clubs; Serie A was the only league to produce three founding members. More players have won the coveted Ballon d'Or award while playing at a Serie A club than any other league in the world. Ahead of Spain's La Liga. Although the actual number of Ballon d'Or won by players in these two leagues is equal at 18 each. Including the FIFA Ballon d'Or. Milan is the second club with the most official international titles in the world (18). Juventus, Italy's most successful club of the 20th century and the most successful Italian team, is tied for fourth in Europe and eighth in the world in the same ranking. The club is the only one in the world to have won all possible official continental competitions and the world title. Internazionale, following their achievements in the 2009–10 season, became the first Italian team to have achieved The Treble."
25 | },
26 | {
27 | "name":"Spanish La Liga",
28 | "id":"4335",
29 | "logo": "5_spanish_la_liga.png",
30 | "description" :"The Primera División, commonly known as La Liga and as La Liga Santander for sponsorship reasons, is the top professional association football division of the Spanish football league system. Administrated by the Liga de Fútbol Profesional (LFP), La Liga is contested by 20 teams, with the three lowest-placed teams relegated to the Segunda División and replaced by the top two teams in that division plus the winner of a play-off.\n A total of 60 teams have competed in La Liga since its inception. Nine teams have been crowned champions, with Real Madrid winning the title a record 32 times and Barcelona 24 times. Real Madrid dominated the championship from the 1950s through the 1980s. From the 1990s onwards, Barcelona (14 titles) and Real Madrid (7 titles) both dominated, though La Liga also saw other champions, including Atlético Madrid, Valencia, and Deportivo de La Coruña. In more recent years, Atlético Madrid has joined a coalition of now three teams dominating La Liga alongside Real Madrid and Barcelona.\n According to UEFA's league coefficient, La Liga has been the top league in Europe over the last five years, and has produced the continent's top-rated club more times (18) than any other league, double that of second-placed Serie A. Its clubs have won the most UEFA Champions League (16), UEFA Europa League (10), UEFA Super Cup (13), and FIFA Club World Cup (5) titles, and its players have accumulated the highest number of (FIFA) Ballon d'Or awards (19).\n La Liga is one of the most popular professional sports leagues in the world, with an average attendance of 26,741 for league matches in the 2014–15 season. This is the sixth-highest of any domestic professional sports league in the world and the fourth-highest of any professional association football league in the world, behind the Bundesliga, the Premier League, and the Indian Super League."
31 | },
32 | {
33 | "name":"American Mayor League",
34 | "id":"4346",
35 | "logo": "6_american_mayor_league.png",
36 | "description" :"Major League Soccer (MLS) is a professional soccer league representing the sport's highest level in both the United States and Canada. MLS constitutes one of the major professional sports leagues of the United States and Canada. The league is composed of 20 teams—17 in the U.S. and 3 in Canada. The MLS regular season runs from March to October, with each team playing 34 games; the team with the best record is awarded the Supporters' Shield. The post season includes twelve teams competing in the MLS Cup Playoffs through November and December, culminating in the championship game, the MLS Cup. MLS teams also play in other competitions against teams from other divisions and countries, such as the U.S. Open Cup, the Canadian Championship, and the CONCACAF Champions League. MLS is sanctioned by the United States Soccer Federation (U.S. Soccer).\n Major League Soccer was founded in 1993 as part of the United States' successful bid to host the 1994 FIFA World Cup. The first season took place in 1996 with ten teams. MLS experienced financial and operational struggles in its first few years: The league lost millions of dollars, teams played in mostly empty American football stadiums, and two teams folded in 2002. Since then, MLS has expanded to 20 teams, owners built soccer-specific stadiums, average attendance at MLS matches exceeds that of the National Basketball Association (NBA) and the National Hockey League (NHL), MLS secured national TV contracts, and the league is now profitable.\n Instead of operating as an association of independently owned teams, MLS is a single entity in which each team is owned and controlled by the league's investors. The investor-operators control their teams as owners control teams in other leagues, and are commonly (but inaccurately) referred to as the team's owners. The league's closed membership makes it one of the world's few soccer leagues that does not use promotion and relegation, which is uncommon in North America. MLS headquarters are in New York City."
37 | },
38 | {
39 | "name":"Protugeuese Premiera Liga",
40 | "id":"4344",
41 | "logo": "7_portugeuese_premiera_liga.png",
42 | "description" :"The Primeira Liga (First League; Portuguese pronunciation: ), formerly called Primeira Divisão), is the top professional association football division of the Portuguese football league system.\n The Primeira Liga is contested by 18 clubs, but only five of them have won the title. Founded in 1934, the league is in its 81st edition (counting four experimental leagues in the 1930s). It has been dominated by the \"Big Three\": Benfica, Porto and Sporting CP. These three clubs have won a total of 78 titles, with Belenenses and Boavista winning the other two."
43 | },
44 | {
45 | "name":"Australian A League",
46 | "id":"4356",
47 | "logo": "8_australian_a_league.png",
48 | "description" :"The A-League is a professional men's soccer league, run by Football Federation Australia (FFA). At the top of the Australian league system, it is the country's primary competition for the sport. The A-League was established in 2004 as a successor to the National Soccer League (NSL) and competition commenced in August 2005. The league is currently contested by ten teams; nine based in Australia and one based in New Zealand. It is known as the Hyundai A-League (HAL) through a sponsorship arrangement with the Hyundai Motor Company.\n Seasons run from October to May and include a 27-round regular season and an end-of-season finals series playoff tournament involving the highest-placed teams, culminating in a grand final match. The winner of the regular season tournament is dubbed 'premier' and the winner of the grand final is 'champion'. This differs from the other major football codes in Australia, where 'premier' refers to the winner of the grand final and the winner of the regular season is the 'minor premier'. The A-League's non-standard terminology is reflective of the increased prestige associated with winning the regular season in association football compared to other football codes in Australia. Successful A-League clubs gain qualification into the continental competition, the Asian Football Confederation Champions League (ACL).\n Since the league's inaugural season, a total of six clubs have been crowned A-League Premiers and five clubs have been crowned A-League Champions. The current premiers and champions are Brisbane Roar, who won both titles in 2013–14."
49 | },
50 | {
51 | "name":"Scotish Premier League",
52 | "id":"4330",
53 | "logo": "9_scotish_premier_league.png",
54 | "description" :"The Scottish Premiership is the top division of the Scottish Professional Football League, the league competition for professional football clubs in Scotland. The Scottish Premiership was established in July 2013, after the Scottish Professional Football League was formed by a merger of the Scottish Premier League and Scottish Football League. Teams receive three points for a win and one point for a draw. No points are awarded for a loss. Teams are ranked by total points, then goal difference, and then goals scored. At the end of each season, the club with the most points is crowned league champion. If points are equal, the goal difference and then goals scored determine the winner."
55 | },
56 | {
57 | "name":"English League 1",
58 | "id":"4396",
59 | "logo": "10_english_league_1.png",
60 | "description" :"Football League One (often referred to as League One for short or Sky Bet League 1) is the second-highest division of the Football League and the third tier in the English football league system\n Football League One was introduced for the 2004–05 season. It was previously known as the Football League Second Division and prior to the advent of the Premier League, the Football League Third Division.\n At present (2014–15 season), Oldham Athletic hold the longest tenure in League One, last being out of the division in the 1996–97 season when they were relegated from the Championship. There are currently six former Premier League clubs competing in the League One, namely Barnsley, Bradford City, Coventry City, Oldham Athletic, Sheffield United and Swindon Town.\n There are 24 clubs in Football League One. Each club plays every other club twice (once at home and once away). Three points are awarded for a win, one for a draw and zero for a loss. At the end of the season a table of the final League standings is determined, based on the following criteria in this order: points obtained, goal difference, goals scored, an aggregate of the results between two or more clubs (ranked using the previous three criteria) and, finally, a series of one or more play-off matches.\n At the end of each season the top two clubs, together with the winner of the play-offs between the clubs which finished in 3rd–6th position, are promoted to Football League Championship and are replaced by the three clubs that finished at the bottom of that division.\n Similarly, the four clubs that finished at the bottom of Football League One are relegated to Football League Two and are replaced by the top three clubs and the club that won the 4th–7th place play-offs in that division.\n Sky Sports currently show live League One matches with highlights shown on BBC One on their programme called The Football League Show, which also broadcasts highlights of Football League Championship and Football League Two matches. The show is available on the red button the following Sunday until midday and is available on iPlayer all the following week. Highlights of all games in the Football League are also available to view separately on the Sky Sports website. In Sweden, TV4 Sport has the rights of broadcasting from the league. A couple of league matches during the season of 09/10 including play-off matches and the play-off final to the Championship were shown. In Australia, Setanta Sports Australia broadcasts live Championship matches. In the USA and surrounding countries including Cuba, some Football League Championship, Football League One and Football League Two games are shown on beIN Sport."
61 | }
62 | ]
--------------------------------------------------------------------------------
/app/src/main/res/layout/detail_match_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
18 |
19 |
20 |
21 |
22 |
27 |
28 |
34 |
40 |
46 |
52 |
53 |
59 |
64 |
69 |
70 |
75 |
80 |
85 |
86 |
87 |
88 |
98 |
99 |
102 |
103 |
104 |
110 |
115 |
121 |
122 |
123 |
129 |
135 |
141 |
147 |
148 |
149 |
158 |
171 |
184 |
185 |
194 |
207 |
220 |
221 |
233 |
234 |
235 |
236 |
237 |
238 |
248 |
249 |
252 |
253 |
258 |
264 |
270 |
275 |
276 |
282 |
288 |
294 |
300 |
305 |
310 |
315 |
321 |
327 |
333 |
339 |
345 |
351 |
356 |
361 |
366 |
371 |
376 |
381 |
382 |
383 |
384 |
394 |
395 |
407 |
419 |
431 |
443 |
444 |
456 |
468 |
479 |
490 |
501 |
512 |
513 |
514 |
524 |
525 |
537 |
549 |
561 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
--------------------------------------------------------------------------------