mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-11 08:27:50 -04:00
Optimizing refresh. Issue #538 @GeVic comment..
This commit is contained in:
parent
1f8d6d6ca9
commit
cec66926e6
@ -40,6 +40,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import androidx.test.espresso.idling.CountingIdlingResource;
|
import androidx.test.espresso.idling.CountingIdlingResource;
|
||||||
@ -80,6 +81,7 @@ public class LibraryFragment extends BaseFragment
|
|||||||
public static final CountingIdlingResource IDLING_RESOURCE =
|
public static final CountingIdlingResource IDLING_RESOURCE =
|
||||||
new CountingIdlingResource("Library Fragment Idling Resource");
|
new CountingIdlingResource("Library Fragment Idling Resource");
|
||||||
public static final List<Book> downloadingBooks = new ArrayList<>();
|
public static final List<Book> downloadingBooks = new ArrayList<>();
|
||||||
|
private static final String EXTRA_BOOKS_ONLINE = "books_online";
|
||||||
public static DownloadService mService = new DownloadService();
|
public static DownloadService mService = new DownloadService();
|
||||||
private static NetworkBroadcastReceiver networkBroadcastReceiver;
|
private static NetworkBroadcastReceiver networkBroadcastReceiver;
|
||||||
private static boolean isReceiverRegistered = false;
|
private static boolean isReceiverRegistered = false;
|
||||||
@ -98,6 +100,7 @@ public class LibraryFragment extends BaseFragment
|
|||||||
LibraryPresenter presenter;
|
LibraryPresenter presenter;
|
||||||
@Inject
|
@Inject
|
||||||
SharedPreferenceUtil sharedPreferenceUtil;
|
SharedPreferenceUtil sharedPreferenceUtil;
|
||||||
|
private LinkedList<Book> books;
|
||||||
private boolean mBound;
|
private boolean mBound;
|
||||||
private DownloadServiceConnection mConnection = new DownloadServiceConnection();
|
private DownloadServiceConnection mConnection = new DownloadServiceConnection();
|
||||||
private ZimManageActivity activity;
|
private ZimManageActivity activity;
|
||||||
@ -151,7 +154,7 @@ public class LibraryFragment extends BaseFragment
|
|||||||
IDLING_RESOURCE.decrement();
|
IDLING_RESOURCE.decrement();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.books = books;
|
||||||
Log.i("kiwix-showBooks", "Contains:" + books.size());
|
Log.i("kiwix-showBooks", "Contains:" + books.size());
|
||||||
libraryAdapter.setAllBooks(books);
|
libraryAdapter.setAllBooks(books);
|
||||||
if (activity.searchView != null) {
|
if (activity.searchView != null) {
|
||||||
@ -331,6 +334,22 @@ public class LibraryFragment extends BaseFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putSerializable(EXTRA_BOOKS_ONLINE, books);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewStateRestored(savedInstanceState);
|
||||||
|
if ((savedInstanceState != null && savedInstanceState.containsKey(EXTRA_BOOKS_ONLINE))) {
|
||||||
|
//noinspection unchecked
|
||||||
|
books = (LinkedList<Book>) savedInstanceState.getSerializable(EXTRA_BOOKS_ONLINE);
|
||||||
|
showBooks(books);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DownloadServiceConnection {
|
class DownloadServiceConnection {
|
||||||
final DownloadServiceInterface downloadServiceInterface;
|
final DownloadServiceInterface downloadServiceInterface;
|
||||||
|
|
||||||
@ -369,6 +388,8 @@ public class LibraryFragment extends BaseFragment
|
|||||||
permissionButton.setVisibility(GONE);
|
permissionButton.setVisibility(GONE);
|
||||||
networkText.setVisibility(GONE);
|
networkText.setVisibility(GONE);
|
||||||
libraryList.setVisibility(View.VISIBLE);
|
libraryList.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
stopScanningContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user