Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: fix instantiatable error (fixes #3779) #3794

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
"submission" -> (v as TextView).setText(R.string.no_submissions)
"teams" -> (v as TextView).setText(R.string.no_teams)
"chatHistory" -> (v as TextView).setText(R.string.no_chats)
"feedback" -> (v as TextView).setText(R.string.no_feedback)
else -> (v as TextView).setText(R.string.no_data_available_please_check_and_try_again)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.ole.planet.myplanet.model.RealmFeedback
import org.ole.planet.myplanet.model.RealmUserModel
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.ui.feedback.FeedbackFragment.OnFeedbackSubmittedListener
import org.ole.planet.myplanet.base.BaseRecyclerFragment.Companion.showNoData

class FeedbackListFragment : Fragment(), OnFeedbackSubmittedListener {
private lateinit var fragmentFeedbackListBinding: FragmentFeedbackListBinding
Expand All @@ -25,6 +26,7 @@ class FeedbackListFragment : Fragment(), OnFeedbackSubmittedListener {
fragmentFeedbackListBinding = FragmentFeedbackListBinding.inflate(inflater, container, false)
mRealm = DatabaseService(requireActivity()).realmInstance
userModel = UserProfileDbHandler(requireContext()).userModel

fragmentFeedbackListBinding.fab.setOnClickListener {
val feedbackFragment = FeedbackFragment()
feedbackFragment.setOnFeedbackSubmittedListener(this)
Expand All @@ -33,15 +35,13 @@ class FeedbackListFragment : Fragment(), OnFeedbackSubmittedListener {
}
}

mRealm.executeTransactionAsync(
Realm.Transaction { },
Realm.Transaction.OnSuccess {
feedbackList = mRealm.where(RealmFeedback::class.java)
.equalTo("owner", userModel?.name).findAllAsync()
feedbackList?.addChangeListener { results ->
updatedFeedbackList(results)
}
})
feedbackList = mRealm.where(RealmFeedback::class.java)
.equalTo("owner", userModel?.name).findAllAsync()

feedbackList?.addChangeListener { results ->
updatedFeedbackList(results)
}

return fragmentFeedbackListBinding.root
}

Expand All @@ -53,6 +53,11 @@ class FeedbackListFragment : Fragment(), OnFeedbackSubmittedListener {
if (userModel?.isManager() == true) list = mRealm.where(RealmFeedback::class.java).findAll()
val adapterFeedback = AdapterFeedback(requireActivity(), list)
fragmentFeedbackListBinding.rvFeedback.adapter = adapterFeedback

val itemCount = feedbackList?.size ?: 0
showNoData(fragmentFeedbackListBinding.tvMessage, itemCount, "feedback")

updateTextViewsVisibility(itemCount)
}

override fun onDestroy() {
Expand All @@ -74,11 +79,25 @@ class FeedbackListFragment : Fragment(), OnFeedbackSubmittedListener {
updatedFeedbackList(updatedList)
})
}

private fun updatedFeedbackList(updatedList: RealmResults<RealmFeedback>?) {
activity?.runOnUiThread {
val adapterFeedback = updatedList?.let { AdapterFeedback(requireActivity(), it) }
fragmentFeedbackListBinding.rvFeedback.adapter = adapterFeedback
adapterFeedback?.notifyDataSetChanged()

val itemCount = updatedList?.size ?: 0
showNoData(fragmentFeedbackListBinding.tvMessage, itemCount, "feedback")
updateTextViewsVisibility(itemCount)
}
}

private fun updateTextViewsVisibility(itemCount: Int) {
val visibility = if (itemCount == 0) View.GONE else View.VISIBLE
fragmentFeedbackListBinding.tvTitle.visibility = visibility
fragmentFeedbackListBinding.tvType.visibility = visibility
fragmentFeedbackListBinding.tvPriority.visibility = visibility
fragmentFeedbackListBinding.tvStatus.visibility = visibility
fragmentFeedbackListBinding.tvOpenDate.visibility = visibility
}
}
11 changes: 7 additions & 4 deletions app/src/main/res/layout/fragment_feedback_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">


<TextView
android:id="@+id/tv_title"
android:layout_width="0dp"
Expand All @@ -41,7 +40,6 @@
android:textColor="@color/md_black_1000"
android:textSize="@dimen/text_size_mid" />


<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand All @@ -59,7 +57,6 @@
android:textSize="@dimen/text_size_mid" />
</LinearLayout>


<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -112,4 +109,10 @@
android:src="@drawable/ic_add"
android:contentDescription="@string/add" />

</FrameLayout>
<TextView
android:visibility="gone"
android:id="@+id/tvMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@
<string name="planet_name">كوكب %s</string>
<string name="no_submissions">التقديمات غير متاحة</string>
<string name="no_chats">لا توجد محادثات سابقة</string>
<string name="no_feedback">لا توجد تعليقات متاحة</string>
<string name="empty_text"></string>
<string name="message_placeholder">%s</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@
<string name="planet_name">%s Planeta</string>
<string name="no_submissions">envíos no disponibles</string>
<string name="no_chats">no hay chats anteriores</string>
<string name="no_feedback">No hay comentarios aquí</string>
<string name="empty_text"></string>
<string name="message_placeholder">%s</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@
<string name="planet_name">%s planète</string>
<string name="no_submissions">soumissions non disponibles</string>
<string name="no_chats">aucune discussion précédente</string>
<string name="no_feedback">aucun commentaire disponible</string>
<string name="empty_text"></string>
<string name="message_placeholder">%s</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ne/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@
<string name="planet_name">%s ग्रह</string>
<string name="no_submissions">पेशाहरू उपलब्ध छैनन्</string>
<string name="no_chats">अघिल्ला कुराकानीहरू छैनन्</string>
<string name="no_feedback">कुनै प्रतिक्रिया उपलब्ध छैन</string>
<string name="empty_text"></string>
<string name="message_placeholder">%s</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-so/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@
<string name="planet_name">%s Meerah</string>
<string name="no_submissions">soo gudbin lama heli karo</string>
<string name="no_chats">ma jiraan wada sheekaysi hore</string>
<string name="no_feedback">wax jawaab celin ah lama hayo</string>
<string name="empty_text"></string>
<string name="message_placeholder">%s</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@
<string name="planet_name">%s\'s Planet</string>
<string name="no_submissions">submissions not available</string>
<string name="no_chats">no previous chats</string>
<string name ="no_feedback">no feedback available</string>
<string name="empty_text"></string>
<string name="message_placeholder">%s</string>

Expand Down