mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-30 08:00: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 Toolbar mToolbar;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ViewPager mViewPager;
|
private ViewPager mViewPager;
|
||||||
|
private View loadingOverlay;
|
||||||
|
|
||||||
public static ConferencesTabBrowseFragment newInstance(int columnCount) {
|
public static ConferencesTabBrowseFragment newInstance(int columnCount) {
|
||||||
ConferencesTabBrowseFragment fragment = new ConferencesTabBrowseFragment();
|
ConferencesTabBrowseFragment fragment = new ConferencesTabBrowseFragment();
|
||||||
|
@ -64,8 +65,10 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
||||||
|
|
||||||
mViewPager = view.findViewById(R.id.viewpager);
|
mViewPager = view.findViewById(R.id.viewpager);
|
||||||
|
|
||||||
|
loadingOverlay = view.findViewById(R.id.loading_overlay);
|
||||||
|
|
||||||
getViewModel().getConferenceGroups()
|
getViewModel().getConferenceGroups()
|
||||||
.observe(this,conferenceGroups -> {
|
.observe(this, conferenceGroups -> {
|
||||||
ConferenceGroupsFragmentPager fragmentPager
|
ConferenceGroupsFragmentPager fragmentPager
|
||||||
= new ConferenceGroupsFragmentPager(this.getContext(), getChildFragmentManager());
|
= new ConferenceGroupsFragmentPager(this.getContext(), getChildFragmentManager());
|
||||||
fragmentPager.setContent(conferenceGroups);
|
fragmentPager.setContent(conferenceGroups);
|
||||||
|
@ -73,8 +76,10 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
||||||
mViewPager.onRestoreInstanceState(getArguments().getParcelable(VIEWPAGER_STATE));
|
mViewPager.onRestoreInstanceState(getArguments().getParcelable(VIEWPAGER_STATE));
|
||||||
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
|
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
|
||||||
tabLayout.setupWithViewPager(mViewPager);
|
tabLayout.setupWithViewPager(mViewPager);
|
||||||
|
setLoadingOverlayVisibility(false);
|
||||||
});
|
});
|
||||||
getViewModel().updateConferences(); // TODO show and dismiss loading-spinner
|
getViewModel().updateConferences().observe(this,
|
||||||
|
loadingFinished -> setLoadingOverlayVisibility(!loadingFinished));
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +95,16 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
||||||
listener = null;
|
listener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setLoadingOverlayVisibility(boolean visible) {
|
||||||
|
if (loadingOverlay != null) {
|
||||||
|
if (visible) {
|
||||||
|
loadingOverlay.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
loadingOverlay.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnInteractionListener {
|
public interface OnInteractionListener {
|
||||||
void onConferenceSelected(long conferenceId);
|
void onConferenceSelected(long conferenceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
||||||
|
|
||||||
private LinearLayoutManager layoutManager;
|
private LinearLayoutManager layoutManager;
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
|
private View loadingOverlay;
|
||||||
|
|
||||||
public static EventsListFragment newInstance(long conferenceId, int columnCount) {
|
public static EventsListFragment newInstance(long conferenceId, int columnCount) {
|
||||||
EventsListFragment fragment = new EventsListFragment();
|
EventsListFragment fragment = new EventsListFragment();
|
||||||
|
@ -75,6 +76,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_events_list, container, false);
|
View view = inflater.inflate(R.layout.fragment_events_list, container, false);
|
||||||
|
loadingOverlay = view.findViewById(R.id.loading_overlay);
|
||||||
Context context = view.getContext();
|
Context context = view.getContext();
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.list);
|
RecyclerView recyclerView = view.findViewById(R.id.list);
|
||||||
if (columnCount <= 1) {
|
if (columnCount <= 1) {
|
||||||
|
@ -89,6 +91,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
||||||
|
|
||||||
Observer<List<PersistentEvent>> listObserver = persistentEvents -> {
|
Observer<List<PersistentEvent>> listObserver = persistentEvents -> {
|
||||||
setEvents(persistentEvents);
|
setEvents(persistentEvents);
|
||||||
|
setLoadingOverlayVisibility(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
|
@ -108,7 +111,9 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
||||||
});
|
});
|
||||||
|
|
||||||
getViewModel().getEventsforConference(conferenceId).observe(this, listObserver);
|
getViewModel().getEventsforConference(conferenceId).observe(this, listObserver);
|
||||||
getViewModel().updateEventsForConference(conferenceId); // TODO show/dismiss loading-spinner
|
getViewModel().updateEventsForConference(conferenceId).observe(this,
|
||||||
|
loadingFinished -> setLoadingOverlayVisibility(!loadingFinished)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
|
@ -161,6 +166,16 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
|
||||||
return true;
|
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 {
|
public interface OnInteractionListener extends OnEventSelectedListener {
|
||||||
void setToolbarTitle(String title);
|
void setToolbarTitle(String title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,7 @@ class Downloader(val recordingApi: RecordingService,
|
||||||
|
|
||||||
private val TAG: String? = Downloader::class.simpleName
|
private val TAG: String? = Downloader::class.simpleName
|
||||||
|
|
||||||
fun updateEventsForConference(conferenceId: Long, listener: ((List<Long>) -> Unit)? = null) {
|
fun updateEventsForConference(conferenceId: Long, listener: ((List<Long>) -> Unit)? = null): MutableLiveData<Boolean> {
|
||||||
if (conferenceId < 0)
|
|
||||||
return
|
|
||||||
val updateFinished = MutableLiveData<Boolean>()
|
val updateFinished = MutableLiveData<Boolean>()
|
||||||
updateFinished.value = false
|
updateFinished.value = false
|
||||||
recordingApi.getConference(conferenceId)
|
recordingApi.getConference(conferenceId)
|
||||||
|
@ -61,7 +59,7 @@ class Downloader(val recordingApi: RecordingService,
|
||||||
}, { t: Throwable? ->
|
}, { t: Throwable? ->
|
||||||
Log.d(TAG, t?.message, t)
|
Log.d(TAG, t?.message, t)
|
||||||
})
|
})
|
||||||
|
return updateFinished
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateRecordingsForEvent(eventId: Long, listener: ((List<Long>) -> Unit)? = null) {
|
fun updateRecordingsForEvent(eventId: Long, listener: ((List<Long>) -> Unit)? = null) {
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.RecyclerView
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
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:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -11,3 +15,7 @@
|
||||||
app:layout_anchorGravity="bottom|end"
|
app:layout_anchorGravity="bottom|end"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
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_anchorGravity="bottom"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||||
|
|
||||||
|
<include layout="@layout/loading_overlay"/>
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</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