parent
b31a18e48c
commit
427e44f3bd
2 changed files with 35 additions and 13 deletions
|
@ -13,6 +13,7 @@ import android.os.Parcelable;
|
|||
import android.provider.MediaStore;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
|
@ -44,9 +45,11 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
|
||||
public class MediaActivity extends SimpleActivity
|
||||
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener {
|
||||
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener,
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = MediaActivity.class.getSimpleName();
|
||||
@BindView(R.id.media_grid) GridView mGridView;
|
||||
@BindView(R.id.media_holder) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
|
||||
private static List<Medium> mMedia;
|
||||
private static String mPath;
|
||||
|
@ -66,6 +69,10 @@ public class MediaActivity extends SimpleActivity
|
|||
ButterKnife.bind(this);
|
||||
mIsGetImageIntent = getIntent().getBooleanExtra(Constants.GET_IMAGE_INTENT, false);
|
||||
mIsGetVideoIntent = getIntent().getBooleanExtra(Constants.GET_VIDEO_INTENT, false);
|
||||
mToBeDeleted = new ArrayList<>();
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
mPath = getIntent().getStringExtra(Constants.DIRECTORY);
|
||||
mMedia = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,9 +100,12 @@ public class MediaActivity extends SimpleActivity
|
|||
}
|
||||
|
||||
private void initializeGallery() {
|
||||
mToBeDeleted = new ArrayList<>();
|
||||
mPath = getIntent().getStringExtra(Constants.DIRECTORY);
|
||||
mMedia = getMedia();
|
||||
final List<Medium> newMedia = getMedia();
|
||||
if (newMedia.toString().equals(mMedia.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMedia = newMedia;
|
||||
if (isDirEmpty())
|
||||
return;
|
||||
|
||||
|
@ -347,4 +357,10 @@ public class MediaActivity extends SimpleActivity
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
initializeGallery();
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black">
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/media_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<GridView
|
||||
android:id="@+id/media_grid"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -17,4 +22,5 @@
|
|||
android:stretchMode="columnWidth"
|
||||
android:verticalSpacing="1dp"/>
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
|
Loading…
Reference in a new issue