[app] Add loading indicator to repo

This commit is contained in:
tehcneko 2021-02-12 22:29:55 +08:00
parent 19a9b7fd7f
commit 4fb5bea9f0
6 changed files with 67 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import android.os.Handler;
import android.os.Looper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
@ -146,7 +147,7 @@ public class AppListActivity extends BaseActivity {
}
public void onDataReady() {
handler.post(() -> binding.progress.hide());
handler.post(() -> binding.progress.setIndeterminate(false));
String queryStr = searchView != null ? searchView.getQuery().toString() : "";
runOnUiThread(() -> scopeAdapter.getFilter().filter(queryStr));
}

View File

@ -26,6 +26,7 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Filter;
@ -75,6 +76,7 @@ public class RepoActivity extends BaseActivity implements RepoLoader.Listener {
binding.recyclerView.setAdapter(adapter);
binding.recyclerView.setHasFixedSize(true);
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
binding.progress.setVisibilityAfterHide(View.GONE);
RecyclerViewKt.addFastScroller(binding.recyclerView, binding.recyclerView);
RecyclerViewKt.fixEdgeEffect(binding.recyclerView, false, true);
repoLoader.addListener(this);
@ -107,12 +109,25 @@ public class RepoActivity extends BaseActivity implements RepoLoader.Listener {
@Override
public void repoLoaded() {
runOnUiThread(() -> adapter.setData(repoLoader.getOnlineModules()));
runOnUiThread(() -> {
binding.progress.hide();
adapter.setData(repoLoader.getOnlineModules());
});
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_refresh) {
binding.progress.show();
repoLoader.loadRemoteData();
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_modules, menu);
getMenuInflater().inflate(R.menu.menu_repo, menu);
searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setOnQueryTextListener(searchListener);
return super.onCreateOptionsMenu(menu);
@ -168,7 +183,7 @@ public class RepoActivity extends BaseActivity implements RepoLoader.Listener {
public void initData() {
Collection<OnlineModule> modules = repoLoader.getOnlineModules();
if (!repoLoader.isRepoLoaded()) {
//binding.swipeRefreshLayout.setRefreshing(true);
binding.progress.show();
repoLoader.loadRemoteData();
} else {
adapter.setData(modules);

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z" />

View File

@ -44,6 +44,16 @@
</rikka.material.widget.AppBarLayout>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"
app:hideAnimationBehavior="outward"
android:layout_marginTop="?actionBarSize"
app:layout_fitSystemWindowsInsets="top" />
<rikka.widget.borderview.BorderRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ LSPosed is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2020 EdXposed Contributors
~ Copyright (C) 2021 LSPosed Contributors
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_refresh"
android:title="@string/refresh"
android:icon="@drawable/ic_refresh"
app:showAsAction="ifRoom" />
</menu>

View File

@ -156,6 +156,7 @@
<string name="module_information_collaborators">Collaborators</string>
<string name="module_release_view_assets">Assets</string>
<string name="menu_open_in_browser">Open in browser</string>
<string name="refresh">Refresh</string>
<string name="group_network">Network</string>
<string name="dns_over_http">DNS over HTTPS</string>
<string name="dns_over_http_summary">Workaround DNS poisoning in some nations</string>