~trb143/openlp/release7c

« back to all changes in this revision

Viewing changes to app/src/main/java/org/openlp/android2/fragments/live/LiveListFragment.kt

  • Committer: Tim Bentley
  • Date: 2018-02-10 12:31:28 UTC
  • Revision ID: tim.bentley@gmail.com-20180210123128-7btcmfskb9awzigb
Add next previous

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        val localBroadcastManager = LocalBroadcastManager.getInstance(OpenLPApp.instance!!.applicationContext)
64
64
        localBroadcastManager.registerReceiver(object : BroadcastReceiver() {
65
65
            override fun onReceive(context: Context, intent: Intent) {
66
 
                getLiveList(OpenLPApp.instance!!.applicationContext)
 
66
                getLiveList(OpenLPApp.instance!!.applicationContext, EndPoints.LIVE_TEXT)
67
67
            }
68
68
        }, IntentFilter(Constants.REQUEST_REFRESH))
69
69
 
70
70
        localBroadcastManager.registerReceiver(object : BroadcastReceiver() {
71
71
            override fun onReceive(context: Context, intent: Intent) {
72
 
                //handleSomethingHappened()
 
72
                getLiveList(OpenLPApp.instance!!.applicationContext, EndPoints.LIVE_NEXT)
73
73
            }
74
74
        }, IntentFilter(Constants.REQUEST_NEXT))
75
75
 
76
76
        localBroadcastManager.registerReceiver(object : BroadcastReceiver() {
77
77
            override fun onReceive(context: Context, intent: Intent) {
78
 
               // handleSomethingHappened()
 
78
                getLiveList(OpenLPApp.instance!!.applicationContext, EndPoints.LIVE_PREVIOUS)
79
79
            }
80
80
        }, IntentFilter(Constants.REQUEST_PREVIOUS))
81
81
 
85
85
    override fun onResume() {
86
86
        info("onResume")
87
87
        super.onResume()
88
 
        getLiveList(OpenLPApp.instance!!.applicationContext)
 
88
        getLiveList(OpenLPApp.instance!!.applicationContext, EndPoints.LIVE_TEXT)
89
89
    }
90
90
 
91
91
    private fun updateView(response: JSONObject) {
101
101
        recyclerView.adapter = LiveAdapter(liveItems, this)
102
102
    }
103
103
 
104
 
    private fun getLiveList(applicationContext: Context) {
 
104
    private fun getLiveList(applicationContext: Context, endPoint: String) {
105
105
        info("getLiveList Called")
106
106
        //creating volley string request for the blank interface
107
107
        val stringRequest = object : StringRequest(Request.Method.GET,
108
 
                EndPoints.getUrlwithVersion(EndPoints.LIVE_TEXT, Poll.version),
 
108
                EndPoints.getUrlwithVersion(endPoint, Poll.version),
109
109
                Response.Listener<String> { response ->
110
110
                    updateView(JSONObject(response))
111
111
                },
134
134
        val stringRequest = object : StringRequest(Request.Method.GET,
135
135
                EndPoints.getUrlwithVersion(EndPoints.LIVE_SET, Poll.version) + request,
136
136
                Response.Listener<String> { response ->
137
 
                    getLiveList(OpenLPApp.instance!!.applicationContext)
 
137
                    getLiveList(OpenLPApp.instance!!.applicationContext, EndPoints.LIVE_TEXT)
138
138
                },
139
139
                object : Response.ErrorListener {
140
140
                    override fun onErrorResponse(volleyError: VolleyError) {