Skip to content

fix: Fixed the UI glitch that happens when the events fragment is refreshed. #2787

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

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ cache:
- "${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/"
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"

licenses:
- '.+'

before_script:
- bash scripts/prep-key.sh
script:
Expand All @@ -25,7 +29,9 @@ script:
after_success:
- bash scripts/update-apk.sh


branches:
only:
- master
- development

6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ def LOCAL_KEY_PRESENT = project.hasProperty('SIGNING_KEY_FILE') && rootProject.f
android {
dataBinding {
enabled = true


}
compileSdkVersion 28
defaultConfig {
applicationId "com.eventyay.attendee"
minSdkVersion 21
targetSdkVersion 28
versionCode 17
versionName "0.9.1"
versionCode 18
versionName "0.9.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.fossasia.openevent.general
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
Expand Down Expand Up @@ -31,10 +32,10 @@ class MainActivity : AppCompatActivity() {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val hostFragment = supportFragmentManager.findFragmentById(R.id.frameContainer)
if (hostFragment is NavHostFragment)
navController = hostFragment.navController

setupBottomNavigationMenu(navController)

navController.addOnDestinationChangedListener { _, destination, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.graphics.Color
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -53,6 +54,7 @@ import org.fossasia.openevent.general.utils.extensions.setStartPostponedEnterTra
import org.fossasia.openevent.general.utils.extensions.showWithFading
import org.jetbrains.anko.design.longSnackbar
import org.koin.androidx.viewmodel.ext.android.viewModel
import timber.log.Timber

const val BEEN_TO_WELCOME_SCREEN = "beenToWelcomeScreen"
const val EVENTS_FRAGMENT = "eventsFragment"
Expand Down Expand Up @@ -81,6 +83,7 @@ class EventsFragment : Fragment(), BottomIconDoubleClick {
val progressDialog = progressDialog(context, getString(R.string.loading_message))

val token = arguments?.getString(RESET_PASSWORD_TOKEN)

if (token != null)
showResetPasswordAlertDialog(token)

Expand Down Expand Up @@ -116,10 +119,8 @@ class EventsFragment : Fragment(), BottomIconDoubleClick {

eventsViewModel.pagedEvents
.nonNull()
.observe(viewLifecycleOwner, Observer { list ->
eventsListAdapter.submitList(list)
if (!rootView.shimmerEvents.isVisible)
showEmptyMessage(eventsListAdapter.currentList?.isEmpty() ?: true)
.observe( viewLifecycleOwner, Observer {
eventsListAdapter.submitList(it)
})

eventsViewModel.progress
Expand All @@ -130,6 +131,12 @@ class EventsFragment : Fragment(), BottomIconDoubleClick {
showEmptyMessage(false)
showNoInternetScreen(false)
} else {
if(eventsListAdapter.currentList?.isEmpty() != false ){
showEmptyMessage(true)
}
else{
showEmptyMessage(false)
}
rootView.shimmerEvents.stopShimmer()
rootView.swiperefresh.isRefreshing = false
}
Expand All @@ -146,6 +153,7 @@ class EventsFragment : Fragment(), BottomIconDoubleClick {
rootView.notificationToolbar.isVisible = eventsViewModel.isLoggedIn()

eventsViewModel.loadLocation()

if (rootView.locationTextView.text == getString(R.string.enter_location)) {
rootView.emptyEventsText.text = getString(R.string.choose_preferred_location_message)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.fossasia.openevent.general.event

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
Expand All @@ -21,6 +22,7 @@ import org.fossasia.openevent.general.favorite.FavoriteEvent
import org.fossasia.openevent.general.search.location.SAVED_LOCATION
import org.fossasia.openevent.general.utils.extensions.withDefaultSchedulers
import timber.log.Timber
import java.lang.NullPointerException

const val NEW_NOTIFICATIONS = "newNotifications"

Expand All @@ -34,7 +36,6 @@ class EventsViewModel(
) : ViewModel() {

private val compositeDisposable = CompositeDisposable()

val connection: LiveData<Boolean> = mutableConnectionLiveData
private val mutableProgress = MediatorLiveData<Boolean>()
val progress: MediatorLiveData<Boolean> = mutableProgress
Expand All @@ -59,7 +60,6 @@ class EventsViewModel(
mutableProgress.value = false
return
}

sourceFactory = EventsDataSourceFactory(
compositeDisposable,
eventService,
Expand Down Expand Up @@ -89,6 +89,7 @@ class EventsViewModel(
Timber.e(it, "Error fetching events")
mutableMessage.value = resource.getString(R.string.error_fetching_events_message)
})

}
fun isConnected(): Boolean = mutableConnectionLiveData.value ?: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ class EventsDataSource(
eventService.getEventsByLocationPaged(query, requestedPage)
.withDefaultSchedulers()
.subscribe({ response ->
if (response.isEmpty()) mutableProgress.value = false
initialCallback?.onResult(response, null, adjacentPage)
callback?.onResult(response, adjacentPage)
if (response.isEmpty()) {
mutableProgress.value = false
}
}, { error ->
Timber.e(error, "Fail on fetching page of events")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ object AppLinkUtils {
val bundle = Bundle()
bundle.putString(data.argumentKey, data.argumentValue)
navController.navigate(data.destinationId, bundle)

}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"
tools:visibility="visible">
tools:visibility="invisible">
<RelativeLayout
android:layout_width="@dimen/item_image_view_large"
android:layout_height="@dimen/item_image_view_large"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0'
classpath "gradle.plugin.com.github.b3er.local.properties:local-properties-plugin:1.1"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 11 23:14:47 IST 2020
#Mon Oct 05 18:27:13 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip