mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
use kotlin android extensions for viewbinding in activity and fragment
This commit is contained in:
@@ -35,6 +35,6 @@ class MainActivity : QkActivity() {
|
||||
})
|
||||
.check()
|
||||
|
||||
supportFragmentManager.beginTransaction().replace(R.id.content_frame, ConversationListFragment()).commit()
|
||||
supportFragmentManager.beginTransaction().replace(R.id.contentFrame, ConversationListFragment()).commit()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,21 +2,17 @@ package com.moez.QKSMS.ui.conversations
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.*
|
||||
import android.widget.ProgressBar
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.data.sync.SyncManager
|
||||
import com.moez.QKSMS.ui.base.QkFragment
|
||||
import kotlinx.android.synthetic.main.conversation_list_fragment.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class ConversationListFragment : QkFragment() {
|
||||
|
||||
@Inject lateinit var viewModel: ConversationListViewModel
|
||||
|
||||
private var progress: ProgressBar? = null
|
||||
private var conversationList: RecyclerView? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
getAppComponent()?.inject(this)
|
||||
@@ -26,11 +22,8 @@ class ConversationListFragment : QkFragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val view = inflater.inflate(R.layout.conversation_list_fragment, container, false)
|
||||
|
||||
progress = view.findViewById(R.id.conversation_progress)
|
||||
|
||||
conversationList = view.findViewById(R.id.conversation_list)
|
||||
conversationList?.layoutManager = LinearLayoutManager(context)
|
||||
conversationList?.adapter = ConversationAdapter(context, viewModel.conversations)
|
||||
conversationList.layoutManager = LinearLayoutManager(context)
|
||||
conversationList.adapter = ConversationAdapter(context, viewModel.conversations)
|
||||
|
||||
return view
|
||||
}
|
||||
@@ -43,9 +36,9 @@ class ConversationListFragment : QkFragment() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.load_conversations -> { // TODO: This is for testing, remove this
|
||||
progress?.visibility = View.VISIBLE
|
||||
progress.visibility = View.VISIBLE
|
||||
SyncManager.copyToRealm(context) {
|
||||
progress?.visibility = View.GONE
|
||||
progress.visibility = View.GONE
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.moez.QKSMS.R
|
||||
|
||||
class ConversationViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
val title: TextView = view.findViewById(R.id.conversation_title)
|
||||
val snippet: TextView = view.findViewById(R.id.conversation_snippet)
|
||||
val title: TextView = view.findViewById(R.id.title)
|
||||
val snippet: TextView = view.findViewById(R.id.snippet)
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class MessageListActivity : QkActivity() {
|
||||
val fragment = MessageListFragment()
|
||||
messagesComponent.inject(fragment)
|
||||
|
||||
supportFragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit()
|
||||
supportFragmentManager.beginTransaction().replace(R.id.contentFrame, fragment).commit()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,18 +2,16 @@ package com.moez.QKSMS.ui.messages
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.*
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.ui.base.QkFragment
|
||||
import kotlinx.android.synthetic.main.message_list_fragment.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageListFragment : QkFragment() {
|
||||
|
||||
@Inject lateinit var viewModel: MessageListViewModel
|
||||
|
||||
private var messageList: RecyclerView? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
@@ -22,12 +20,10 @@ class MessageListFragment : QkFragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
val view = inflater.inflate(R.layout.message_list_fragment, container, false)
|
||||
|
||||
messageList = view.findViewById(R.id.message_list)
|
||||
|
||||
val layoutManager = LinearLayoutManager(context)
|
||||
layoutManager.stackFromEnd = true
|
||||
messageList?.layoutManager = layoutManager
|
||||
messageList?.adapter = MessageAdapter(context, viewModel.messages)
|
||||
messageList.layoutManager = layoutManager
|
||||
messageList.adapter = MessageAdapter(context, viewModel.messages)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ import com.moez.QKSMS.R
|
||||
|
||||
class MessageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
val body: TextView = view.findViewById(R.id.message_body)
|
||||
val body: TextView = view.findViewById(R.id.body)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user