-
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.
- Loading branch information
Showing
5 changed files
with
121 additions
and
132 deletions.
There are no files selected for viewing
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
31 changes: 16 additions & 15 deletions
31
app/src/main/java/com/example/sergey/shlypa2/screens/game/TeamHintFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,41 @@ | ||
package com.example.sergey.shlypa2.screens.game | ||
|
||
import androidx.lifecycle.ViewModelProviders | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.sergey.shlypa2.R | ||
import com.example.sergey.shlypa2.RvAdapter | ||
import com.example.sergey.shlypa2.extensions.observeSafe | ||
import com.example.sergey.shlypa2.screens.game.adapter.ItemTeamWithScores | ||
import eu.davidea.flexibleadapter.FlexibleAdapter | ||
import kotlinx.android.synthetic.main.fragment_team_hint.* | ||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel | ||
|
||
|
||
class TeamHintFragment : androidx.fragment.app.Fragment() { | ||
class TeamHintFragment : Fragment() { | ||
|
||
|
||
val adapter = RvAdapter() | ||
private val adapter = FlexibleAdapter(emptyList()) | ||
private val viewModel: RoundViewModel by sharedViewModel() | ||
private val playersViewPool = RecyclerView.RecycledViewPool() | ||
|
||
/*override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
}*/ | ||
|
||
lateinit var viewModel: RoundViewModel | ||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
|
||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_team_hint, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
viewModel = ViewModelProviders.of(activity!!).get(RoundViewModel::class.java) | ||
|
||
adapter.setData(viewModel.loadCurrrentBal()) | ||
rvHintTeam_and_Result.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(view.context) | ||
rvHintTeam_and_Result.adapter = adapter | ||
rvScoresSheet.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(view.context) | ||
rvScoresSheet.adapter = adapter | ||
|
||
viewModel.updateCurrentScoresSheet() | ||
viewModel.scoresSheetLiveData.observeSafe(this) { teams -> | ||
adapter.updateDataSet(teams.map { ItemTeamWithScores(it, playersViewPool) }) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.