mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-26 22:20:24 +00:00
add loading-overlay
This commit is contained in:
parent
652f370761
commit
7a7aea2612
6 changed files with 63 additions and 10 deletions
|
@ -26,6 +26,7 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
|||
private Toolbar mToolbar;
|
||||
private Context mContext;
|
||||
private ViewPager mViewPager;
|
||||
private View loadingOverlay;
|
||||
|
||||
public static ConferencesTabBrowseFragment newInstance(int columnCount) {
|
||||
ConferencesTabBrowseFragment fragment = new ConferencesTabBrowseFragment();
|
||||
|
@ -64,17 +65,21 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
|||
|
||||
mViewPager = view.findViewById(R.id.viewpager);
|
||||
|
||||
loadingOverlay = view.findViewById(R.id.loading_overlay);
|
||||
|
||||
getViewModel().getConferenceGroups()
|
||||
.observe(this,conferenceGroups -> {
|
||||
.observe(this, conferenceGroups -> {
|
||||
ConferenceGroupsFragmentPager fragmentPager
|
||||
= new ConferenceGroupsFragmentPager(this.getContext(), getChildFragmentManager());
|
||||
= new ConferenceGroupsFragmentPager(this.getContext(), getChildFragmentManager());
|
||||
fragmentPager.setContent(conferenceGroups);
|
||||
mViewPager.setAdapter(fragmentPager);
|
||||
mViewPager.onRestoreInstanceState(getArguments().getParcelable(VIEWPAGER_STATE));
|
||||
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
setLoadingOverlayVisibility(false);
|
||||
});
|
||||
getViewModel().updateConferences(); // TODO show and dismiss loading-spinner
|
||||
getViewModel().updateConferences().observe(this,
|
||||
loadingFinished -> setLoadingOverlayVisibility(!loadingFinished));
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -90,6 +95,16 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
|||
listener = null;
|
||||
}
|
||||
|
||||
private void setLoadingOverlayVisibility(boolean visible) {
|
||||
if (loadingOverlay != null) {
|
||||
if (visible) {
|
||||
loadingOverlay.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
loadingOverlay.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnInteractionListener {
|
||||
void onConferenceSelected(long conferenceId);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
|||
|
||||
private LinearLayoutManager layoutManager;
|
||||
private SearchView searchView;
|
||||
private View loadingOverlay;
|
||||
|
||||
public static EventsListFragment newInstance(long conferenceId, int columnCount) {
|
||||
EventsListFragment fragment = new EventsListFragment();
|
||||
|
@ -75,6 +76,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_events_list, container, false);
|
||||
loadingOverlay = view.findViewById(R.id.loading_overlay);
|
||||
Context context = view.getContext();
|
||||
RecyclerView recyclerView = view.findViewById(R.id.list);
|
||||
if (columnCount <= 1) {
|
||||
|
@ -89,6 +91,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
|||
|
||||
Observer<List<PersistentEvent>> listObserver = persistentEvents -> {
|
||||
setEvents(persistentEvents);
|
||||
setLoadingOverlayVisibility(false);
|
||||
};
|
||||
|
||||
Resources resources = getResources();
|
||||
|
@ -108,7 +111,9 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
|||
});
|
||||
|
||||
getViewModel().getEventsforConference(conferenceId).observe(this, listObserver);
|
||||
getViewModel().updateEventsForConference(conferenceId); // TODO show/dismiss loading-spinner
|
||||
getViewModel().updateEventsForConference(conferenceId).observe(this,
|
||||
loadingFinished -> setLoadingOverlayVisibility(!loadingFinished)
|
||||
);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
|
@ -161,6 +166,16 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
|||
return true;
|
||||
}
|
||||
|
||||
private void setLoadingOverlayVisibility(boolean visible){
|
||||
if(loadingOverlay != null){
|
||||
if(visible){
|
||||
loadingOverlay.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
loadingOverlay.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnInteractionListener extends OnEventSelectedListener {
|
||||
void setToolbarTitle(String title);
|
||||
}
|
||||
|
|
|
@ -47,9 +47,7 @@ class Downloader(val recordingApi: RecordingService,
|
|||
|
||||
private val TAG: String? = Downloader::class.simpleName
|
||||
|
||||
fun updateEventsForConference(conferenceId: Long, listener: ((List<Long>) -> Unit)? = null) {
|
||||
if (conferenceId < 0)
|
||||
return
|
||||
fun updateEventsForConference(conferenceId: Long, listener: ((List<Long>) -> Unit)? = null): MutableLiveData<Boolean> {
|
||||
val updateFinished = MutableLiveData<Boolean>()
|
||||
updateFinished.value = false
|
||||
recordingApi.getConference(conferenceId)
|
||||
|
@ -61,7 +59,7 @@ class Downloader(val recordingApi: RecordingService,
|
|||
}, { t: Throwable? ->
|
||||
Log.d(TAG, t?.message, t)
|
||||
})
|
||||
|
||||
return updateFinished
|
||||
}
|
||||
|
||||
fun updateRecordingsForEvent(eventId: Long, listener: ((List<Long>) -> Unit)? = null) {
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -10,4 +14,8 @@
|
|||
app:layout_anchor="@id/toolbar"
|
||||
app:layout_anchorGravity="bottom|end"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:listitem="@layout/item_conference_cardview"/>
|
||||
tools:listitem="@layout/item_conference_cardview"/>
|
||||
|
||||
<include layout="@layout/loading_overlay"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
@ -38,4 +38,5 @@
|
|||
app:layout_anchorGravity="bottom"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
|
||||
<include layout="@layout/loading_overlay"/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
16
touch/src/main/res/layout/loading_overlay.xml
Normal file
16
touch/src/main/res/layout/loading_overlay.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/loading_overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black_trans80"
|
||||
tools:showIn="@layout/fragment_tab_pager_layout">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"/>
|
||||
</FrameLayout>
|
Loading…
Reference in a new issue