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