mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 03:54:18 -04:00
Allow MultiSelection in ZimHostActivity
This commit is contained in:
parent
635bc4ee8d
commit
bc3c6c958a
@ -48,7 +48,9 @@ import org.kiwix.kiwixmobile.R;
|
||||
import org.kiwix.kiwixmobile.base.BaseActivity;
|
||||
import org.kiwix.kiwixmobile.main.MainActivity;
|
||||
import org.kiwix.kiwixmobile.wifi_hotspot.HotspotService;
|
||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.SelectionMode;
|
||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BookOnDiskDelegate;
|
||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter;
|
||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
|
||||
|
||||
import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle;
|
||||
@ -77,7 +79,7 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
private static final int LOCATION_SETTINGS_PERMISSION_RESULT = 101;
|
||||
private Intent serviceIntent;
|
||||
private Task<LocationSettingsResponse> task;
|
||||
private ZimHostAdapter booksAdapter;
|
||||
private BooksOnDiskAdapter booksAdapter;
|
||||
HotspotService hotspotService;
|
||||
String ip;
|
||||
boolean bound;
|
||||
@ -97,15 +99,20 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
startServerButton.setText(getString(R.string.stop_server_label));
|
||||
startServerButton.setBackgroundColor(getResources().getColor(R.color.stopServer));
|
||||
}
|
||||
|
||||
booksAdapter = new ZimHostAdapter(
|
||||
BookOnDiskDelegate.BookDelegate bookDelegate =
|
||||
new BookOnDiskDelegate.BookDelegate(sharedPreferenceUtil,
|
||||
bookOnDiskItem -> {
|
||||
open(bookOnDiskItem);
|
||||
return Unit.INSTANCE;
|
||||
},
|
||||
null,
|
||||
null),
|
||||
bookOnDiskItem -> {
|
||||
select(bookOnDiskItem);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
bookDelegate.setSelectionMode(SelectionMode.MULTI);
|
||||
booksAdapter = new BooksOnDiskAdapter(bookDelegate
|
||||
,
|
||||
BookOnDiskDelegate.LanguageDelegate.INSTANCE
|
||||
);
|
||||
|
||||
@ -135,6 +142,9 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
|
||||
startServerButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
|
||||
//Get File Path of All The ZIMs using booksAdapter
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
toggleHotspot();
|
||||
} else {
|
||||
@ -161,6 +171,18 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
finish();
|
||||
}
|
||||
|
||||
public void select(BooksOnDiskListItem.BookOnDisk bookOnDisk) {
|
||||
List<BooksOnDiskListItem> selectedBooks = null;
|
||||
for (int i = 0; i < booksAdapter.getItemCount(); i++) {
|
||||
if (booksAdapter.getItems().get(i).equals(bookOnDisk)) {
|
||||
booksAdapter.getItems().get(i).setSelected(true);
|
||||
selectedBooks.add(booksAdapter.getItems().get(i));
|
||||
}
|
||||
}
|
||||
booksAdapter.setItems(selectedBooks);
|
||||
}
|
||||
|
||||
|
||||
@Override protected void onStart() {
|
||||
super.onStart();
|
||||
bindService();
|
||||
|
Loading…
x
Reference in New Issue
Block a user