Remove dependency on getUserVisibleHint

This commit is contained in:
M66B
2019-06-19 10:15:47 +02:00
parent db0c857e29
commit ccbd430166
3 changed files with 21 additions and 61 deletions

View File

@@ -25,12 +25,9 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.widget.ScrollView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
@@ -158,19 +155,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
return Helper.hasPermission(this, name);
}
protected View getVisibleView() {
for (Fragment fragment : getSupportFragmentManager().getFragments())
if (fragment.getUserVisibleHint()) {
View view = fragment.getView();
Log.i("Visible fragment=" + fragment.getClass().getName() + " view=" + view);
if (view != null && !(view instanceof ScrollView)) // Snackbar cannot be attached to ScrollView
return view;
}
Log.i("Visible activity=" + this.getClass().getName());
return findViewById(android.R.id.content);
}
void addBackPressedListener(final IBackPressedListener listener, LifecycleOwner owner) {
Log.i("Adding back listener=" + listener);
backPressedListeners.add(listener);