mirror of
https://github.com/stom79/exodus-android-app
synced 2024-12-22 03:14:46 +01:00
Fix issue #83
This commit is contained in:
parent
18c19ace49
commit
91f5dea591
@ -60,6 +60,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private String packageName;
|
||||
private MainBinding binding;
|
||||
private ApplicationListAdapter.OnAppClickListener onAppClickListener;
|
||||
private int appPosition;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -70,7 +71,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setTitle(R.string.app_title);
|
||||
}
|
||||
fragments = new ArrayList<>();
|
||||
|
||||
appPosition = 0;
|
||||
NetworkListener networkListener = new NetworkListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
@ -119,11 +120,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
.commit();
|
||||
};
|
||||
|
||||
onAppClickListener = vm -> {
|
||||
onAppClickListener = (vm, position) -> {
|
||||
try {
|
||||
PackageManager pm = getPackageManager();
|
||||
PackageInfo packageInfo = pm.getPackageInfo(vm.packageName, PackageManager.GET_PERMISSIONS);
|
||||
|
||||
appPosition = position;
|
||||
ReportFragment report = ReportFragment.newInstance(pm, vm, packageInfo, onTrackerClickListener);
|
||||
fragments.add(report);
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
@ -166,6 +167,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
else {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
fragments.remove(fragments.size() - 1);
|
||||
Updatable updatable = fragments.get(fragments.size() - 1);
|
||||
if (updatable instanceof HomeFragment) {
|
||||
((HomeFragment) updatable).scrollTo(appPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static final String TAG = "Exodus_privacy";
|
||||
@SuppressLint("PackageManagerGetSignatures")
|
||||
public static String getCertificateSHA1Fingerprint(PackageManager pm, String packageName) {
|
||||
int flags = PackageManager.GET_SIGNATURES;
|
||||
|
@ -90,7 +90,7 @@ public class ApplicationListAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onAppClickListener.onAppClick(vm);
|
||||
onAppClickListener.onAppClick(vm, position);
|
||||
}
|
||||
});
|
||||
} else //noinspection RedundantSuppression
|
||||
@ -151,7 +151,7 @@ public class ApplicationListAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
}
|
||||
|
||||
public interface OnAppClickListener {
|
||||
void onAppClick(ApplicationViewModel vm);
|
||||
void onAppClick(ApplicationViewModel vm, int position);
|
||||
}
|
||||
|
||||
static class ApplicationEmptyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
@ -93,6 +93,10 @@ public class AppListFragment extends Fragment {
|
||||
TRACKER
|
||||
}
|
||||
|
||||
public void scrollTo(int position) {
|
||||
applistBinding.appList.scrollToPosition(position);
|
||||
}
|
||||
|
||||
public enum Order {
|
||||
NAME_ASC,
|
||||
NAME_DSC,
|
||||
|
@ -44,7 +44,7 @@ public class HomeFragment extends Fragment implements ComputeAppListTask.Listene
|
||||
private int lastResource = 0;
|
||||
private int lastProgress = 0;
|
||||
private int lastMaxProgress = 0;
|
||||
|
||||
private int scrollTo = 0;
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (applications == null)
|
||||
@ -94,6 +94,19 @@ public class HomeFragment extends Fragment implements ComputeAppListTask.Listene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (scrollTo > 0) {
|
||||
appListFragment.scrollTo(scrollTo);
|
||||
scrollTo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void scrollTo(int position) {
|
||||
scrollTo = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateComplete() {
|
||||
refreshInProgress = false;
|
||||
|
Loading…
Reference in New Issue
Block a user