Browse Source

Fixes selection on multi-link that doesn't work and cause crash

Fixes 19,20
tags/release-v2.6
Schoumi 2 years ago
parent
commit
38d953486c

+ 6
- 4
app/src/main/java/fr/mobdev/goblim/MultiLinkAdapter.java View File

@@ -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

+ 4
- 2
app/src/main/java/fr/mobdev/goblim/activity/MultiLinkActivity.java View File

@@ -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;
}

+ 9
- 8
app/src/main/res/layout/link_item.xml View File

@@ -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…
Cancel
Save