mark the selected items
This commit is contained in:
parent
a68ad87b4b
commit
ceecb21fa1
8 changed files with 22 additions and 6 deletions
|
@ -26,6 +26,7 @@ import java.util.regex.Pattern;
|
|||
public class PhotosActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener {
|
||||
private List<String> photos;
|
||||
private int selectedItemsCnt;
|
||||
private GridView gridView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -34,8 +35,8 @@ public class PhotosActivity extends AppCompatActivity implements AdapterView.OnI
|
|||
|
||||
photos = new ArrayList<>();
|
||||
final String path = getIntent().getStringExtra(Constants.DIRECTORY);
|
||||
final GridView gridView = (GridView) findViewById(R.id.photos_grid);
|
||||
final PhotosAdapter adapter = new PhotosAdapter(this, getPhotos(path));
|
||||
gridView = (GridView) findViewById(R.id.photos_grid);
|
||||
gridView.setAdapter(adapter);
|
||||
gridView.setOnItemClickListener(this);
|
||||
gridView.setMultiChoiceModeListener(this);
|
||||
|
@ -45,6 +46,7 @@ public class PhotosActivity extends AppCompatActivity implements AdapterView.OnI
|
|||
}
|
||||
|
||||
private List<String> getPhotos(final String path) {
|
||||
photos.clear();
|
||||
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
final String[] args = new String[]{path + "%"};
|
||||
|
|
|
@ -8,11 +8,10 @@ import android.widget.BaseAdapter;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.simplemobiletools.gallery.R;
|
||||
|
||||
public class PhotosAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final List<String> photos;
|
||||
|
@ -36,7 +35,7 @@ public class PhotosAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
String path = photos.get(position);
|
||||
Glide.with(context).load(path).centerCrop().crossFade().into(holder.photoThumbnail);
|
||||
Glide.with(context).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.photoThumbnail);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
4
app/src/main/res/drawable/selected_mask.xml
Normal file
4
app/src/main/res/drawable/selected_mask.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/activated_item_foreground"/>
|
||||
</selector>
|
4
app/src/main/res/drawable/selected_pressed_mask.xml
Normal file
4
app/src/main/res/drawable/selected_pressed_mask.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/pressed_item_foreground"/>
|
||||
</selector>
|
5
app/src/main/res/drawable/selector.xml
Normal file
5
app/src/main/res/drawable/selector.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/selected_pressed_mask" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/selected_mask" android:state_activated="true"/>
|
||||
</selector>
|
|
@ -5,9 +5,9 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black"
|
||||
android:choiceMode="multipleChoiceModal"
|
||||
android:columnWidth="@dimen/photo_tmb_size"
|
||||
android:horizontalSpacing="1dp"
|
||||
android:numColumns="auto_fit"
|
||||
android:stretchMode="columnWidth"
|
||||
android:choiceMode="multipleChoiceModal"
|
||||
android:verticalSpacing="1dp"/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/tmb_background">
|
||||
android:foreground="@drawable/selector">
|
||||
|
||||
<com.simplemobiletools.gallery.MyImageView
|
||||
android:id="@+id/photo_thumbnail"
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="tmb_background">#ff222222</color>
|
||||
<color name="actionbar_grey">#66000000</color>
|
||||
<color name="pressed_item_foreground">#11000000</color>
|
||||
<color name="activated_item_foreground">#44000000</color>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue