Fixes selection on multi-link that doesn't work and cause crash
Fixes 19,20pull/1/head
parent
ead2d6ce21
commit
38d953486c
|
@ -69,9 +69,9 @@ public class MultiLinkAdapter extends RecyclerView.Adapter<MultiLinkViewHolder>{
|
|||
box = (CheckBox) v.findViewById(R.id.selected);
|
||||
}
|
||||
if(box.isChecked() && !selecteds.contains(holder.index)) {
|
||||
selecteds.add(holder.index);
|
||||
} else {
|
||||
selecteds.remove(holder.index);
|
||||
selecteds.set(holder.index,holder.index);
|
||||
} else if (!box.isChecked() && selecteds.contains(holder.index)) {
|
||||
selecteds.set(holder.index,-1);
|
||||
}
|
||||
selectionListener.onSelectionChanged();
|
||||
}
|
||||
|
@ -95,7 +95,9 @@ public class MultiLinkAdapter extends RecyclerView.Adapter<MultiLinkViewHolder>{
|
|||
holder.progress.setVisibility(View.VISIBLE);
|
||||
holder.thumb.setVisibility(View.GONE);
|
||||
}
|
||||
holder.box.setChecked(selecteds.contains(position));
|
||||
|
||||
holder.box.setChecked(selecteds.get(position) != -1);
|
||||
holder.index = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -210,7 +210,8 @@ public class MultiLinkActivity extends AppCompatActivity {
|
|||
List<Integer> selected = adapter.getSelecteds();
|
||||
List<String> urls = new ArrayList<>();
|
||||
for(Integer index : selected) {
|
||||
urls.add(deleteUrls.get(index));
|
||||
if(index != -1)
|
||||
urls.add(deleteUrls.get(index));
|
||||
}
|
||||
NetworkManager.getInstance(listener).deleteMultiple(MultiLinkActivity.this, urls);
|
||||
}
|
||||
|
@ -230,7 +231,8 @@ public class MultiLinkActivity extends AppCompatActivity {
|
|||
List<Integer> selected = adapter.getSelecteds();
|
||||
String output = baseUrl;
|
||||
for(Integer index : selected) {
|
||||
output += sharedHashs.get(index)+",";
|
||||
if(index != -1)
|
||||
output += sharedHashs.get(index)+",";
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,6 @@
|
|||
android:layout_margin="5dp"
|
||||
>
|
||||
|
||||
<CheckBox
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:id="@+id/selected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
android:layout_centerVertical="true"
|
||||
|
@ -29,4 +21,13 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
/>
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:id="@+id/selected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue