Skip to content

Commit

Permalink
leagues list
Browse files Browse the repository at this point in the history
  • Loading branch information
andremw96 committed Oct 29, 2018
1 parent df11f18 commit f476f40
Show file tree
Hide file tree
Showing 39 changed files with 199 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.support.test.espresso.Espresso
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.Espresso.pressBack
import android.support.test.espresso.action.ViewActions.click
Expand All @@ -12,7 +11,7 @@ import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import android.support.v7.widget.RecyclerView
import com.example.wijaya_pc.eplmatchschedule.R.id.*
import com.example.wijaya_pc.footballapps.R.id.*
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wijaya_pc.eplmatchschedule">
package="com.example.wijaya_pc.footballapps">

<uses-permission android:name="android.permission.INTERNET"/>

Expand All @@ -12,15 +12,15 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".MainActivity">
<activity android:name="com.example.wijaya_pc.footballapps.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity android:name=".DetailActivity">
<activity android:name="com.example.wijaya_pc.footballapps.DetailActivity">
</activity>
</application>

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.os.Bundle
import android.support.v4.content.ContextCompat
Expand All @@ -9,18 +9,18 @@ import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.ScrollView
import android.widget.TextView
import com.example.wijaya_pc.eplmatchschedule.R.drawable.ic_add_to_favorites
import com.example.wijaya_pc.eplmatchschedule.R.drawable.ic_added_to_favorites
import com.example.wijaya_pc.eplmatchschedule.R.id.*
import com.example.wijaya_pc.eplmatchschedule.R.menu.detail_menu
import com.example.wijaya_pc.eplmatchschedule.api.ApiRepository
import com.example.wijaya_pc.eplmatchschedule.database.database
import com.example.wijaya_pc.eplmatchschedule.model.FavoriteMatches
import com.example.wijaya_pc.eplmatchschedule.model.Match
import com.example.wijaya_pc.eplmatchschedule.model.Team
import com.example.wijaya_pc.eplmatchschedule.presenter.DetailPresenter
import com.example.wijaya_pc.eplmatchschedule.ui.DetailMatchUI
import com.example.wijaya_pc.eplmatchschedule.view.DetailView
import com.example.wijaya_pc.footballapps.R.drawable.ic_add_to_favorites
import com.example.wijaya_pc.footballapps.R.drawable.ic_added_to_favorites
import com.example.wijaya_pc.footballapps.R.id.*
import com.example.wijaya_pc.footballapps.R.menu.detail_menu
import com.example.wijaya_pc.footballapps.api.ApiRepository
import com.example.wijaya_pc.footballapps.database.database
import com.example.wijaya_pc.footballapps.model.FavoriteMatches
import com.example.wijaya_pc.footballapps.model.Match
import com.example.wijaya_pc.footballapps.model.Team
import com.example.wijaya_pc.footballapps.presenter.DetailPresenter
import com.example.wijaya_pc.footballapps.ui.DetailMatchUI
import com.example.wijaya_pc.footballapps.view.DetailView
import com.google.gson.Gson
import com.squareup.picasso.Picasso
import org.jetbrains.anko.ctx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.content.Context
import android.os.Bundle
Expand All @@ -9,10 +9,10 @@ import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.wijaya_pc.eplmatchschedule.R.color.colorAccent
import com.example.wijaya_pc.eplmatchschedule.adapter.FavoriteMatchesAdapter
import com.example.wijaya_pc.eplmatchschedule.database.database
import com.example.wijaya_pc.eplmatchschedule.model.FavoriteMatches
import com.example.wijaya_pc.footballapps.R.color.colorAccent
import com.example.wijaya_pc.footballapps.adapter.FavoriteMatchesAdapter
import com.example.wijaya_pc.footballapps.database.database
import com.example.wijaya_pc.footballapps.model.FavoriteMatches
import org.jetbrains.anko.*
import org.jetbrains.anko.db.classParser
import org.jetbrains.anko.db.select
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.example.wijaya_pc.eplmatchschedule.R.id.*
import com.example.wijaya_pc.footballapps.R.id.*
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ProgressBar
import com.example.wijaya_pc.eplmatchschedule.R.color.colorAccent
import com.example.wijaya_pc.eplmatchschedule.adapter.MatchAdapter
import com.example.wijaya_pc.eplmatchschedule.api.ApiRepository
import com.example.wijaya_pc.eplmatchschedule.model.Match
import com.example.wijaya_pc.eplmatchschedule.presenter.MainPresenter
import com.example.wijaya_pc.eplmatchschedule.view.MainView
import android.widget.*
import com.example.wijaya_pc.footballapps.R.color.colorAccent
import com.example.wijaya_pc.footballapps.adapter.MatchAdapter
import com.example.wijaya_pc.footballapps.api.ApiRepository
import com.example.wijaya_pc.footballapps.model.League
import com.example.wijaya_pc.footballapps.model.Match
import com.example.wijaya_pc.footballapps.presenter.MainPresenter
import com.example.wijaya_pc.footballapps.view.MainView
import com.google.gson.Gson
import org.jetbrains.anko.*
import org.jetbrains.anko.design.tabItem
import org.jetbrains.anko.design.tabLayout
import org.jetbrains.anko.recyclerview.v7.recyclerView
import org.jetbrains.anko.support.v4.ctx
import org.jetbrains.anko.support.v4.onRefresh
Expand All @@ -29,10 +31,12 @@ class MatchFragment() : Fragment(), AnkoComponent<Context>, MainView {
private lateinit var listMatch: RecyclerView
private lateinit var swipeRefresh: SwipeRefreshLayout
private lateinit var progressBar: ProgressBar
private lateinit var spinner: Spinner

private var matches: MutableList<Match> = mutableListOf()
private var leagues: MutableList<League> = mutableListOf()
private lateinit var presenter: MainPresenter
private lateinit var adapter: MatchAdapter
private lateinit var matchAdapter: MatchAdapter

companion object {
private const val leagueID = "4328"
Expand All @@ -50,24 +54,27 @@ class MatchFragment() : Fragment(), AnkoComponent<Context>, MainView {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

/*val spinnerItems = leagues
val spinnerAdapter = ArrayAdapter(ctx, android.R.layout.simple_spinner_dropdown_item, spinnerItems)
spinner.adapter = spinnerAdapter*/

listMatch.layoutManager = LinearLayoutManager(ctx)
adapter = MatchAdapter(matches) {
matchAdapter = MatchAdapter(matches) {
ctx.startActivity<DetailActivity>(
"id" to "${it.matchId}",
"homeTeamId" to "${it.idHomeTeam}",
"awayTeamId" to "${it.idAwayTeam}"
)

/* val intent = Intent(ctx, DetailActivity::class.java)
intent.putExtra(DetailActivity.matchParcel, it)
startActivity(intent)*/
}
listMatch.adapter = adapter
listMatch.adapter = matchAdapter

val request = ApiRepository()
val gson = Gson()
presenter = MainPresenter(this, request, gson)

presenter.getLeagueList()


if (arguments?.getInt(ARG_SECTION_NUMBER) == 0) {
presenter.getLast15MatchesList(leagueID)

Expand Down Expand Up @@ -96,6 +103,21 @@ class MatchFragment() : Fragment(), AnkoComponent<Context>, MainView {
leftPadding = dip(16)
rightPadding = dip(16)

tabLayout {
id = R.id.tab_match
lparams(width = matchParent)

tabItem {

}.lparams(width = wrapContent, height = wrapContent)

tabItem {

}.lparams(width = wrapContent, height = wrapContent)
}

spinner = spinner()

swipeRefresh = swipeRefreshLayout {
setColorSchemeResources(
colorAccent,
Expand Down Expand Up @@ -134,6 +156,13 @@ class MatchFragment() : Fragment(), AnkoComponent<Context>, MainView {
swipeRefresh.isRefreshing = false
matches.clear()
matches.addAll(data)
adapter.notifyDataSetChanged()
matchAdapter.notifyDataSetChanged()
}

override fun showLeagueList(data: List<League>) {
leagues.clear()
leagues.addAll(data)

// val leagueAdapter = ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, leagues)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule
package com.example.wijaya_pc.footballapps

import android.view.View
import java.text.SimpleDateFormat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.example.wijaya_pc.eplmatchschedule.adapter
package com.example.wijaya_pc.footballapps.adapter

import android.os.Build
import android.support.annotation.RequiresApi
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.example.wijaya_pc.eplmatchschedule.R.id.*
import com.example.wijaya_pc.eplmatchschedule.model.FavoriteMatches
import com.example.wijaya_pc.eplmatchschedule.ui.MatchUI
import com.example.wijaya_pc.footballapps.R.id.*
import com.example.wijaya_pc.footballapps.model.FavoriteMatches
import com.example.wijaya_pc.footballapps.ui.MatchUI
import org.jetbrains.anko.AnkoContext
import org.jetbrains.anko.find
import org.jetbrains.anko.sdk25.coroutines.onClick
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.example.wijaya_pc.eplmatchschedule.adapter
package com.example.wijaya_pc.footballapps.adapter

import android.os.Build
import android.support.annotation.RequiresApi
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.example.wijaya_pc.eplmatchschedule.R.id.*
import com.example.wijaya_pc.eplmatchschedule.dateToSimpleString
import com.example.wijaya_pc.eplmatchschedule.model.Match
import com.example.wijaya_pc.eplmatchschedule.ui.MatchUI
import com.example.wijaya_pc.footballapps.R.id.*
import com.example.wijaya_pc.footballapps.dateToSimpleString
import com.example.wijaya_pc.footballapps.model.Match
import com.example.wijaya_pc.footballapps.ui.MatchUI
import org.jetbrains.anko.AnkoContext
import org.jetbrains.anko.find

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule.api
package com.example.wijaya_pc.footballapps.api

import java.net.URL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.wijaya_pc.eplmatchschedule.api
package com.example.wijaya_pc.footballapps.api

import android.net.Uri
import com.example.wijaya_pc.eplmatchschedule.BuildConfig
import com.example.wijaya_pc.footballapps.BuildConfig

object TheSportDBApi {

Expand All @@ -20,4 +19,8 @@ object TheSportDBApi {
fun getTeam(teamID: String?): String {
return BuildConfig.BASE_URL + "api/v1/json/${BuildConfig.TSDB_API_KEY}" + "/lookupteam.php?id=" + teamID
}

fun getLeague() : String {
return BuildConfig.BASE_URL + "api/v1/json/${BuildConfig.TSDB_API_KEY}" + "/all_leagues.php?"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule.coroutine
package com.example.wijaya_pc.footballapps.coroutine

import kotlinx.coroutines.experimental.android.UI
import kotlin.coroutines.experimental.CoroutineContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule.coroutine
package com.example.wijaya_pc.footballapps.coroutine

import kotlinx.coroutines.experimental.Unconfined
import kotlin.coroutines.experimental.CoroutineContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.wijaya_pc.eplmatchschedule.database
package com.example.wijaya_pc.footballapps.database

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import com.example.wijaya_pc.eplmatchschedule.model.FavoriteMatches
import com.example.wijaya_pc.footballapps.model.FavoriteMatches
import org.jetbrains.anko.db.*

class MyDatabaseFavoriteMatchHelper(ctx: Context) : ManagedSQLiteOpenHelper(ctx, "FavoriteMatch.db", null, 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.wijaya_pc.eplmatchschedule.model
package com.example.wijaya_pc.footballapps.model

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.wijaya_pc.footballapps.model

import com.google.gson.annotations.SerializedName

data class League (
@SerializedName("idLeague")
var leagueId : String?,

@SerializedName("strLeague")
var leagueName : String?
)
Loading

0 comments on commit f476f40

Please sign in to comment.