Java Code Examples for androidx.fragment.app.Fragment#getViewLifecycleOwner()

The following examples show how to use androidx.fragment.app.Fragment#getViewLifecycleOwner() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdapterImage.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterImage(Fragment parentFragment) {
    this.parentFragment = parentFragment;
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterImage.this + " parent destroyed");
            AdapterImage.this.parentFragment = null;
        }
    });
}
 
Example 2
Source File: AdapterOrder.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterOrder(Fragment parentFragment) {
    this.parentFragment = parentFragment;
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterOrder.this + " parent destroyed");
            AdapterOrder.this.parentFragment = null;
        }
    });
}
 
Example 3
Source File: AdapterOperation.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterOperation(Fragment parentFragment) {
    this.parentFragment = parentFragment;
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterOperation.this + " parent destroyed");
            AdapterOperation.this.parentFragment = null;
        }
    });
}
 
Example 4
Source File: AdapterAccount.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterAccount(final Fragment parentFragment, boolean settings) {
    this.parentFragment = parentFragment;
    this.settings = settings;

    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
    this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnreadHighlight : android.R.attr.textColorPrimary);
    this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);

    this.DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.SHORT);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterAccount.this + " parent destroyed");
            AdapterAccount.this.parentFragment = null;
        }
    });
}
 
Example 5
Source File: AdapterIdentity.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterIdentity(Fragment parentFragment) {
    this.parentFragment = parentFragment;
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    this.DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.SHORT);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterIdentity.this + " parent destroyed");
            AdapterIdentity.this.parentFragment = null;
        }
    });
}
 
Example 6
Source File: AdapterRule.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterRule(Fragment parentFragment) {
    this.parentFragment = parentFragment;
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterRule.this + " parent destroyed");
            AdapterRule.this.parentFragment = null;
        }
    });
}
 
Example 7
Source File: AdapterLog.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterLog(Fragment parentFragment) {
    this.parentFragment = parentFragment;
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(parentFragment.getContext());

    this.TF = Helper.getTimeInstance(context);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterLog.this + " parent destroyed");
            AdapterLog.this.parentFragment = null;
        }
    });
}
 
Example 8
Source File: AdapterContact.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterContact(Fragment parentFragment) {
    this.parentFragment = parentFragment;

    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    this.contacts = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);
    this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
    this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterContact.this + " parent destroyed");
            AdapterContact.this.parentFragment = null;
        }
    });
}
 
Example 9
Source File: AdapterAttachment.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
AdapterAttachment(Fragment parentFragment, boolean readonly) {
    this.parentFragment = parentFragment;
    this.readonly = readonly;

    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(context);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    this.debug = prefs.getBoolean("debug", false);

    setHasStableIds(true);

    owner.getLifecycle().addObserver(new LifecycleObserver() {
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        public void onDestroyed() {
            Log.d(AdapterAttachment.this + " parent destroyed");
            AdapterAttachment.this.parentFragment = null;
        }
    });
}
 
Example 10
Source File: AdapterCertificate.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
AdapterCertificate(Fragment parentFragment) {
    this.context = parentFragment.getContext();
    this.owner = parentFragment.getViewLifecycleOwner();
    this.inflater = LayoutInflater.from(parentFragment.getContext());

    this.TF = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);

    setHasStableIds(true);
}
 
Example 11
Source File: AdapterFolder.java    From FairEmail with GNU General Public License v3.0 4 votes vote down vote up
AdapterFolder(Fragment parentFragment, long account, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {
    this(parentFragment.getContext(), parentFragment.getViewLifecycleOwner(), account, primary, show_compact, show_hidden, show_flagged, listener);
    this.parentFragment = parentFragment;
}