mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-19 12:26:13 -04:00
ZIM list updates once download is complete in Android #278
This commit is contained in:
parent
124480687e
commit
6d18e80f4b
@ -77,6 +77,7 @@ import org.kiwix.kiwixmobile.library.LibraryAdapter;
|
||||
import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity;
|
||||
import org.kiwix.kiwixmobile.utils.LanguageUtils;
|
||||
import org.kiwix.kiwixmobile.utils.ShortcutUtils;
|
||||
import org.kiwix.kiwixmobile.utils.files.FileReader;
|
||||
import org.kiwix.kiwixmobile.utils.files.FileSearch;
|
||||
import org.kiwix.kiwixmobile.utils.files.FileUtils;
|
||||
import org.kiwix.kiwixmobile.utils.files.FileWriter;
|
||||
@ -143,6 +144,12 @@ public class ZimFileSelectFragment extends Fragment
|
||||
checkPermissions();
|
||||
}
|
||||
|
||||
public void addBook(String path) {
|
||||
mFiles.add(FileSearch.fileToBook(path));
|
||||
mRescanAdapter.notifyDataSetChanged();
|
||||
bookDao.saveBooks(mFiles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
FragmentActivity faActivity = (FragmentActivity) super.getActivity();
|
||||
|
@ -121,9 +121,9 @@ public class DownloadFragment extends Fragment {
|
||||
if (progress == 100) {
|
||||
ImageView pause = (ImageView) viewGroup.findViewById(R.id.pause);
|
||||
pause.setEnabled(false);
|
||||
String fileName = mDownloadFiles.get(mKeys[position]);
|
||||
{
|
||||
Snackbar completeSnack = Snackbar.make(mainLayout, getResources().getString(R.string.download_complete_snackbar), Snackbar.LENGTH_LONG);
|
||||
String fileName = mDownloadFiles.get(mKeys[position]);
|
||||
completeSnack.setAction(getResources().getString(R.string.open), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -131,6 +131,8 @@ public class DownloadFragment extends Fragment {
|
||||
}
|
||||
}).setActionTextColor(getResources().getColor(R.color.white)).show();
|
||||
}
|
||||
ZimFileSelectFragment zimFileSelectFragment = (ZimFileSelectFragment) zimManageActivity.mSectionsPagerAdapter.getItem(0);
|
||||
zimFileSelectFragment.addBook(fileName);
|
||||
mDownloads.remove(mKeys[position]);
|
||||
mDownloadFiles.remove(mKeys[position]);
|
||||
downloadAdapter.notifyDataSetChanged();
|
||||
|
@ -195,7 +195,7 @@ public class FileSearch {
|
||||
return files.toArray(arr);
|
||||
}
|
||||
|
||||
private synchronized LibraryNetworkEntity.Book fileToBook(String filePath) {
|
||||
public static synchronized LibraryNetworkEntity.Book fileToBook(String filePath) {
|
||||
LibraryNetworkEntity.Book book = null;
|
||||
|
||||
if (ZimContentProvider.zimFileName != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user