mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 12:38:00 +01:00
add pull to refresh to the directories view
This commit is contained in:
parent
cda29dd904
commit
b31a18e48c
2 changed files with 34 additions and 13 deletions
|
@ -14,6 +14,7 @@ import android.provider.MediaStore;
|
||||||
import android.support.design.widget.CoordinatorLayout;
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.SparseBooleanArray;
|
import android.util.SparseBooleanArray;
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
|
@ -45,8 +46,10 @@ import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MainActivity extends SimpleActivity
|
public class MainActivity extends SimpleActivity
|
||||||
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener {
|
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener,
|
||||||
|
SwipeRefreshLayout.OnRefreshListener {
|
||||||
@BindView(R.id.directories_grid) GridView mGridView;
|
@BindView(R.id.directories_grid) GridView mGridView;
|
||||||
|
@BindView(R.id.directories_holder) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
|
|
||||||
private static final int STORAGE_PERMISSION = 1;
|
private static final int STORAGE_PERMISSION = 1;
|
||||||
private static final int PICK_MEDIA = 2;
|
private static final int PICK_MEDIA = 2;
|
||||||
|
@ -79,9 +82,12 @@ public class MainActivity extends SimpleActivity
|
||||||
mIsGetImageContentIntent = isGetImageContentIntent(intent);
|
mIsGetImageContentIntent = isGetImageContentIntent(intent);
|
||||||
mIsGetVideoContentIntent = isGetVideoContentIntent(intent);
|
mIsGetVideoContentIntent = isGetVideoContentIntent(intent);
|
||||||
mIsSetWallpaperIntent = isSetWallpaperIntent(intent);
|
mIsSetWallpaperIntent = isSetWallpaperIntent(intent);
|
||||||
|
|
||||||
mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent ||
|
mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent ||
|
||||||
mIsSetWallpaperIntent;
|
mIsSetWallpaperIntent;
|
||||||
|
|
||||||
|
mToBeDeleted = new ArrayList<>();
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||||
|
mDirs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -155,8 +161,11 @@ public class MainActivity extends SimpleActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeGallery() {
|
private void initializeGallery() {
|
||||||
mToBeDeleted = new ArrayList<>();
|
final List<Directory> newDirs = getDirectories();
|
||||||
mDirs = getDirectories();
|
if (newDirs.toString().equals(mDirs.toString())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mDirs = newDirs;
|
||||||
|
|
||||||
final DirectoryAdapter adapter = new DirectoryAdapter(this, mDirs);
|
final DirectoryAdapter adapter = new DirectoryAdapter(this, mDirs);
|
||||||
mGridView.setAdapter(adapter);
|
mGridView.setAdapter(adapter);
|
||||||
|
@ -533,4 +542,10 @@ public class MainActivity extends SimpleActivity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
initializeGallery();
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,21 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/black">
|
android:background="@android:color/black">
|
||||||
|
|
||||||
<GridView
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/directories_grid"
|
android:id="@+id/directories_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:choiceMode="multipleChoiceModal"
|
|
||||||
android:columnWidth="@dimen/dir_tmb_size"
|
|
||||||
android:horizontalSpacing="1dp"
|
|
||||||
android:numColumns="auto_fit"
|
|
||||||
android:stretchMode="columnWidth"
|
|
||||||
android:verticalSpacing="1dp"/>
|
|
||||||
|
|
||||||
|
<GridView
|
||||||
|
android:id="@+id/directories_grid"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:choiceMode="multipleChoiceModal"
|
||||||
|
android:columnWidth="@dimen/dir_tmb_size"
|
||||||
|
android:horizontalSpacing="1dp"
|
||||||
|
android:numColumns="auto_fit"
|
||||||
|
android:stretchMode="columnWidth"
|
||||||
|
android:verticalSpacing="1dp"/>
|
||||||
|
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|
Loading…
Reference in a new issue