Skip to content

Commit

Permalink
- update activity untuk search match
Browse files Browse the repository at this point in the history
  • Loading branch information
andremw96 committed Nov 1, 2018
1 parent c827a27 commit b08a4da
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class MatchViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private val matchAwayTeam: TextView = view.find(match_away_team)

fun bindItem(matches: Match, listener: (Match) -> Unit) {
val matchDateTime = dateTimeToSimpleString(toGMTFormat(dateToSimpleString(matches.matchDate), matches.matchTime))
val match_time = if (matches.matchTime == null) "00:00:00" else matches.matchTime

val matchDateTime = dateTimeToSimpleString(toGMTFormat(dateToSimpleString(matches.matchDate), match_time))

//matchDate.text = dateToSimpleString(matches.matchDate)
//matchTime.text = timeToSimpleString(timeToGMT(matches.matchTime))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SearchMatchActivity : AppCompatActivity(), SearchMatchView {
private lateinit var recyclerView: RecyclerView
private lateinit var searchView : SearchView
private lateinit var progressBar : ProgressBar
private lateinit var swipeRefresh : SwipeRefreshLayout

private var matches: MutableList<Match> = mutableListOf()

Expand All @@ -47,6 +48,7 @@ class SearchMatchActivity : AppCompatActivity(), SearchMatchView {
toolbar = find(R.id.toolbar_search)
recyclerView = find(R.id.rv_search)
progressBar = find(R.id.progress_bar_search)
swipeRefresh = find(R.id.swipe_refresh_search)

setSupportActionBar(toolbar)
supportActionBar?.title = "Search Match"
Expand Down Expand Up @@ -111,6 +113,7 @@ class SearchMatchActivity : AppCompatActivity(), SearchMatchView {
}

override fun showSearchMatchList(data: List<Match>) {
swipeRefresh.isRefreshing = false
matches.clear()
matches.addAll(data)
matchAdapter.notifyDataSetChanged()
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/java/com/example/wijaya_pc/footballapps/ui/MatchUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,45 @@ class MatchUI : AnkoComponent<ViewGroup> {
orientation = LinearLayout.VERTICAL

cardView {
radius = dip(4).toFloat()

linearLayout {
lparams(width = matchParent)
lparams(width = matchParent) {
bottomMargin = dip(5)
}
orientation = LinearLayout.VERTICAL

textView {
id = R.id.match_date
textSize = 12f
textColor = Color.GREEN
gravity = Gravity.CENTER_HORIZONTAL
}
}.lparams(width = matchParent)

textView {
id = R.id.match_time
textSize = 12f
textColor = Color.RED
gravity = Gravity.CENTER_HORIZONTAL
}
}.lparams(width = matchParent)
}


linearLayout {
lparams(width = matchParent)
lparams(width = matchParent) {
topMargin = dip(10)
}

padding = dip(16)
orientation = LinearLayout.HORIZONTAL
gravity = Gravity.CENTER

// home team
textView {
id = R.id.match_home_team
textSize = 16f
gravity = Gravity.START
}.lparams(width = dip(0), weight = 1F)
}.lparams(width = dip(0), weight = 1F) {
gravity = Gravity.CENTER_VERTICAL
}

// home team score
textView {
Expand Down Expand Up @@ -84,7 +89,9 @@ class MatchUI : AnkoComponent<ViewGroup> {
id = R.id.match_away_team
textSize = 16f
gravity = Gravity.END
}.lparams(width = dip(0), weight = 1F)
}.lparams(width = dip(0), weight = 1F) {
gravity = Gravity.CENTER_VERTICAL
}
}
}.lparams(width = matchParent) {
topMargin = dip(8)
Expand Down
31 changes: 21 additions & 10 deletions app/src/main/res/layout/activity_search_match.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -14,16 +14,27 @@
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/rv_search"

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/rv_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<ProgressBar
android:id="@+id/progress_bar_search"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</android.support.v4.widget.SwipeRefreshLayout>



<ProgressBar
android:id="@+id/progress_bar_search"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>


</android.support.constraint.ConstraintLayout>
</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/menu/search_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
android:icon="@android:drawable/ic_menu_search"
android:title="@string/search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView" />
app:showAsAction="always|collapseActionView" />

</menu>

0 comments on commit b08a4da

Please sign in to comment.