Skip to content

Commit

Permalink
Merge branch 'master' into 3784-new-chat-not-showing
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Jul 8, 2024
2 parents 9c82213 + 8f4c631 commit e175c40
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 165 deletions.
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 @@ -25,7 +25,7 @@ import org.ole.planet.myplanet.model.RealmSubmission
import org.ole.planet.myplanet.model.RealmUserModel
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.ui.exam.TakeExamFragment
import org.ole.planet.myplanet.utilities.CameraUtils.CapturePhoto
import org.ole.planet.myplanet.utilities.CameraUtils.capturePhoto
import org.ole.planet.myplanet.utilities.CameraUtils.ImageCaptureCallback
import org.ole.planet.myplanet.utilities.Constants
import org.ole.planet.myplanet.utilities.Constants.showBetaFeature
Expand Down Expand Up @@ -164,7 +164,7 @@ class CourseStepFragment : BaseContainerFragment(), ImageCaptureCallback {
takeExam.arguments = b
homeItemClickListener?.openCallFragment(takeExam)
context?.let { it1 ->
CapturePhoto(it1, object : ImageCaptureCallback {
capturePhoto(it1, object : ImageCaptureCallback {
override fun onImageCapture(fileUri: String?) {
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.ole.planet.myplanet.model.RealmExamQuestion
import org.ole.planet.myplanet.model.RealmSubmission
import org.ole.planet.myplanet.model.RealmSubmission.Companion.createSubmission
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.utilities.CameraUtils.CapturePhoto
import org.ole.planet.myplanet.utilities.CameraUtils.capturePhoto
import org.ole.planet.myplanet.utilities.CameraUtils.ImageCaptureCallback
import org.ole.planet.myplanet.utilities.JsonParserUtils.getStringAsJsonArray
import org.ole.planet.myplanet.utilities.JsonUtils.getString
Expand Down Expand Up @@ -210,7 +210,7 @@ class TakeExamFragment : BaseExamFragment(), View.OnClickListener, CompoundButto
try {
if (isCertified && !isMySurvey) {
context?.let { it1 ->
CapturePhoto(it1, object : ImageCaptureCallback {
capturePhoto(it1, object : ImageCaptureCallback {
override fun onImageCapture(fileUri: String?) {
}
})
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
}
}
Loading

0 comments on commit e175c40

Please sign in to comment.