Skip to content

Commit

Permalink
add ContentLoadingProgressBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay committed Nov 30, 2017
1 parent 9cb0bb0 commit 2a9ce82
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v4.widget.ContentLoadingProgressBar;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
Expand Down Expand Up @@ -87,6 +88,7 @@ public class DaguerreActivity extends AppCompatActivity
private RecyclerView mNavRecyclerView;
private AlbumsItemAdapter mAlbumsItemAdapter;
private DrawerLayout mDrawerLayout;
private ContentLoadingProgressBar mContentLoadingProgressBar;

@Override
protected void onSaveInstanceState(Bundle outState) {
Expand Down Expand Up @@ -114,6 +116,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mDrawerLayout.addDrawerListener(toggle);
toggle.syncState();

mContentLoadingProgressBar = findViewById(R.id.content_progress_bar);

if (savedInstanceState != null) {
// 恢复数据
String take_photo_file = savedInstanceState.getString("take_photo_file", null);
Expand All @@ -122,8 +126,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
}



max = intent.getIntExtra(Daguerre.INTENT_EXTRA_KEY_MAX, 1);

int spanCount = intent.getIntExtra(Daguerre.INTENT_EXTRA_KEY_SPAN_COUNT, 3);
Expand Down Expand Up @@ -163,7 +165,7 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView parent, Recycle
|| ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// empty code
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE},
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
REQUEST_READ_EXTERNAL_STORAGE_PERMISSION);
}
}
Expand Down Expand Up @@ -266,6 +268,7 @@ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAlbumsItemAdapter.setData(mAlbums);
mAlbumsItemAdapter.notifyDataSetChanged();
}
mContentLoadingProgressBar.hide();
}

/**
Expand All @@ -288,6 +291,7 @@ public void onLoaderReset(Loader<Cursor> loader) {
mResources.clear();
mAdapter.notifyDataSetChanged();
}

@Override
public void onListItemClick(View itemView) {
int adapterPosition = mRecyclerView.getChildViewHolder(itemView).getAdapterPosition();
Expand Down
25 changes: 18 additions & 7 deletions daguerre/src/main/res/layout/daguerre_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,29 @@
tools:openDrawer="start">



<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<android.support.v4.widget.ContentLoadingProgressBar
android:id="@+id/content_progress_bar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>

<android.support.v7.widget.RecyclerView
android:clipToPadding="false"
android:id="@+id/nav_recycler_view"
android:background="?android:windowBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"/>
android:layout_gravity="start"
android:background="?android:windowBackground"
android:clipToPadding="false"/>

</android.support.v4.widget.DrawerLayout>
1 change: 1 addition & 0 deletions daguerre/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<style name="Daguerre.Activity.Theme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#FA8CBE</item>
<item name="colorPrimaryDark">#FA8CBE</item>
<item name="colorAccent">#FA8CBE</item>
<item name="actionModeBackground">?colorPrimary</item>
<item name="daguerreCheckButtonColor">@android:color/white</item>
<item name="daguerreActionDrawableColor">@android:color/white</item>
Expand Down

0 comments on commit 2a9ce82

Please sign in to comment.