I put together the answer above to create a general layout for my card-list loader activities. Here's the layout file card_scroll_with_progress_layout.xml
:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<com.google.android.glass.widget.CardScrollView
android:id="@+id/card_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</FrameLayout>
Then in the onCreate I get the progress bar and set it rolling:
View rootLayout = getLayoutInflater()
.inflate(R.layout.card_scroll_with_progress_layout, null);
mProgressBar = (ProgressBar)rootLayout.findViewById(R.id.progress_bar);
mProgressBar.setVisibility(View.VISIBLE);
mCardScrollView = (CardScrollView)rootLayout
.findViewById(R.id.card_scroll_view);
mCardScrollView.setAdapter(mAdapter);
setContentView(rootLayout);
Later on in my loader callback I hide the progress bar and activate the card scroll view:
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (loader.getId() == mLoaderId) {
mAdapter.swapCursor(data);
mProgressBar.setVisibility(View.GONE);
mCardScrollView.activate();
}
}
This seems to be working well as a paradigm for handling various json loading into a list of cards in the GDK.