Skip to content

Commit

Permalink
actions: less warnings is more (fixes #3342) (#3345)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Apr 3, 2024
1 parent ad64e66 commit cb80227
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 36 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1463
versionName "0.14.63"
versionCode 1464
versionName "0.14.64"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,10 @@ open class RealmMyLibrary : RealmObject() {

@JvmStatic
fun getMyLibIds(realm: Realm?, userId: String?): JsonArray {
val myLibraries: RealmResults<RealmMyLibrary>? = realm?.where(RealmMyLibrary::class.java)?.contains("userId", userId)?.findAll()
val myLibraries: RealmResults<RealmMyLibrary>? =
userId?.let {
realm?.where(RealmMyLibrary::class.java)?.contains("userId", it)?.findAll()
}
val ids = JsonArray()
for (lib in myLibraries ?: emptyList()) {
ids.add(lib.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ class CommunityTabFragment : Fragment() {
val settings = requireActivity().getSharedPreferences(SyncActivity.PREFS_NAME, Context.MODE_PRIVATE)
val sParentcode = settings.getString("parentCode", "")
val user = UserProfileDbHandler(requireActivity()).userModel
fragmentTeamDetailBinding.viewPager2?.adapter = CommunityPagerAdapter(requireActivity(), user?.planetCode + "@" + sParentcode, false)
fragmentTeamDetailBinding.viewPager2?.let {
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, it) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2?.adapter as CommunityPagerAdapter).getPageTitle(position)
}.attach()
}
fragmentTeamDetailBinding.viewPager2.adapter = CommunityPagerAdapter(requireActivity(), user?.planetCode + "@" + sParentcode, false)
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, fragmentTeamDetailBinding.viewPager2) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2.adapter as CommunityPagerAdapter).getPageTitle(position)
}.attach()
fragmentTeamDetailBinding.title.text = user?.planetCode
fragmentTeamDetailBinding.subtitle.text = TimeUtils.getFormatedDateWithTime(Date().time)
fragmentTeamDetailBinding.llActionButtons.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ class HomeCommunityDialogFragment : BottomSheetDialogFragment() {
val sPlanetcode = settings.getString("planetCode", "")
val sParentcode = settings.getString("parentCode", "")
val user = UserProfileDbHandler(requireActivity()).userModel
fragmentTeamDetailBinding.viewPager2?.adapter = CommunityPagerAdapter(requireActivity(), user?.planetCode + "@" + sParentcode, true)
fragmentTeamDetailBinding.viewPager2?.let {
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, it) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2?.adapter as CommunityPagerAdapter).getPageTitle(position)
}.attach()
}

fragmentTeamDetailBinding.viewPager2.adapter = CommunityPagerAdapter(requireActivity(), user?.planetCode + "@" + sParentcode, true)
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, fragmentTeamDetailBinding.viewPager2) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2.adapter as CommunityPagerAdapter).getPageTitle(position)
}.attach()
fragmentTeamDetailBinding.title.text = user?.planetCode
fragmentTeamDetailBinding.title.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))
fragmentTeamDetailBinding.subtitle.setTextColor(ContextCompat.getColor(requireContext(), R.color.md_black_1000))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa
return
}
else -> {
mRealm.where(c as Class<RealmObject>).contains("userId", userId, Case.INSENSITIVE)
.findAll()
userId?.let {
mRealm.where(c as Class<RealmObject>).contains("userId", it, Case.INSENSITIVE).findAll()
}
}
}) as List<RealmObject>
setCountText(dbMycourses.size, c, view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ class TeamDetailFragment : Fragment() {
val user = UserProfileDbHandler(requireContext()).userModel!!
mRealm = DatabaseService(requireActivity()).realmInstance
team = mRealm.where(RealmMyTeam::class.java).equalTo("_id", requireArguments().getString("id")).findFirst()
fragmentTeamDetailBinding.viewPager2?.adapter = TeamPagerAdapter(requireActivity(), team, isMyTeam)
fragmentTeamDetailBinding.viewPager2?.let {
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, it) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2?.adapter as TeamPagerAdapter).getPageTitle(position)
}.attach()
}
fragmentTeamDetailBinding.viewPager2.adapter = TeamPagerAdapter(requireActivity(), team, isMyTeam)
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, fragmentTeamDetailBinding.viewPager2) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2.adapter as TeamPagerAdapter).getPageTitle(position)
}.attach()

if (!isMyTeam) {
fragmentTeamDetailBinding.llActionButtons.visibility = View.GONE
} else {
Expand All @@ -47,18 +46,16 @@ class TeamDetailFragment : Fragment() {
.setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int ->
team?.leave(user, mRealm)
Utilities.toast(activity, getString(R.string.left_team))
fragmentTeamDetailBinding.viewPager2?.adapter = TeamPagerAdapter(requireActivity(), team, false)
fragmentTeamDetailBinding.viewPager2?.let {
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, it) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2?.adapter as TeamPagerAdapter).getPageTitle(position)
}.attach()
}
fragmentTeamDetailBinding.viewPager2.adapter = TeamPagerAdapter(requireActivity(), team, false)
TabLayoutMediator(fragmentTeamDetailBinding.tabLayout, fragmentTeamDetailBinding.viewPager2) { tab, position ->
tab.text = (fragmentTeamDetailBinding.viewPager2.adapter as TeamPagerAdapter).getPageTitle(position)
}.attach()
fragmentTeamDetailBinding.llActionButtons.visibility = View.GONE
}.setNegativeButton(R.string.no, null).show()
}
fragmentTeamDetailBinding.btnAddDoc.setOnClickListener {
MainApplication.showDownload = true
fragmentTeamDetailBinding.viewPager2?.currentItem = 6
fragmentTeamDetailBinding.viewPager2.currentItem = 6
MainApplication.showDownload = false
if (MainApplication.listener != null) {
MainApplication.listener?.onAddDocument()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ class EditAchievementFragment : BaseContainerFragment(), DatePickerDialog.OnDate
setUserInfo()
setAchievementInfo()
aRealm.commitTransaction()
val fragmentManager = fragmentManager
fragmentManager?.popBackStack()
val fragmentManager = parentFragmentManager
fragmentManager.popBackStack()
}
fragmentEditAchievementBinding.btnCancel.setOnClickListener {
val fragmentManager = fragmentManager
fragmentManager?.popBackStack()
val fragmentManager = parentFragmentManager
fragmentManager.popBackStack()
}
fragmentEditAchievementBinding.btnAchievement.setOnClickListener {
showAddachievementAlert(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class WebViewActivity : AppCompatActivity() {
private fun setListeners() {
activityWebViewBinding.contentWebView.wv.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView, newProgress: Int) {
this@WebViewActivity.setProgress(newProgress)
activityWebViewBinding.contentWebView.pBar.progress = newProgress
Utilities.log("Url " + view.url)
if (view.url?.endsWith("/eng/") == true) {
finish()
Expand Down

0 comments on commit cb80227

Please sign in to comment.