Multiple selection on long tap.

parent 12ac6833
......@@ -10,8 +10,10 @@ import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.File;
......@@ -167,6 +169,7 @@ public class FolderActivity extends AppCompatActivity {
// OnClick listener
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
......@@ -189,6 +192,27 @@ public class FolderActivity extends AppCompatActivity {
}
}
});
// OnLongClick listener
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View grid_item,
int position, long arg3) {
// Get layout
ViewGroup layout = (ViewGroup) grid_item;
// Get "check" ImageView
ImageView check = (ImageView) layout.getChildAt(2);
// Toggle "check"
if(check.getVisibility() == View.VISIBLE){
check.setVisibility(View.GONE);
}else {
check.setVisibility(View.VISIBLE);
}
return true;
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
......
......@@ -44,6 +44,7 @@ class GridViewAdapterImages extends ArrayAdapter<File> {
holder = new ViewHolder();
holder.image = row.findViewById(R.id.inside_imageview);
holder.overlay = row.findViewById(R.id.outside_imageview);
holder.check = row.findViewById(R.id.check_imageview);
row.setTag(holder);
} else {
holder = (ViewHolder) row.getTag();
......@@ -60,6 +61,8 @@ class GridViewAdapterImages extends ArrayAdapter<File> {
holder.image.getLayoutParams().width = pxWidth/columns;
holder.overlay.getLayoutParams().height = pxWidth/(columns+5);
holder.overlay.getLayoutParams().width = pxWidth/(columns+5);
holder.check.getLayoutParams().height = pxWidth/(columns+5);
holder.check.getLayoutParams().width = pxWidth/(columns+5);
// Get current file
File item = (File) data.get(position);
......@@ -87,5 +90,6 @@ class GridViewAdapterImages extends ArrayAdapter<File> {
private static class ViewHolder {
ImageView image;
ImageView overlay;
ImageView check;
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,
2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M11,16.5L6.5,12L7.91,
10.59L11,13.67L16.59,8.09L18,9.5L11,16.5Z" />
</vector>
\ No newline at end of file
......@@ -4,6 +4,8 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M10,16.5L16,12L10,7.5V16.5Z" />
android:fillColor="#FFFFFF"
android:pathData="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,
16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,
0 12,2M10,16.5L16,12L10,7.5V16.5Z" />
</vector>
\ No newline at end of file
......@@ -19,4 +19,14 @@
android:layout_alignStart="@id/inside_imageview"
android:contentDescription="@string/desc_folder"/>
<ImageView
android:id="@+id/check_imageview"
android:src="@drawable/ic_check"
android:visibility="invisible"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_alignTop="@id/inside_imageview"
android:layout_alignEnd="@id/inside_imageview"
android:contentDescription="@string/desc_check"/>
</RelativeLayout>
\ No newline at end of file
......@@ -12,6 +12,7 @@
<string name="desc_folder">Folder thumbnail</string>
<string name="desc_image">Image thumbnail</string>
<string name="desc_full_image">Full image</string>
<string name="desc_check">Check</string>
<string name="title_activity_folder">Folder</string>
<string name="title_activity_image">Image</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment