summaryrefslogtreecommitdiff
path: root/library/src/main/java/moe/yuuta/flow/PageFragment.java
blob: 4e7996bc9328e8697d513d4f11953e163dc86e6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package moe.yuuta.flow;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

public abstract class PageFragment extends Fragment {
    /**
     * Once mInfo is changed, you should call {@link IFlowFragment#notifyCurrentFlowInfoUpdated()} to publish it.
     * Note: it will be permanently change the recorded info.
     */
    protected FlowInfo mInfo;

    @NonNull
    protected final IFlowFragment getHostFragment() {
        final Fragment parent = getParentFragment();
        if (!(parent instanceof IFlowFragment)) {
            throw new IllegalStateException("This fragment is not attached to a valid flow host");
        }
        Log.d("Page", "get");
        return (IFlowFragment) parent;
    }

    /**
     * @return true: the fragment handled this event and you do not need to call super. false: call super.
     */
    public boolean onBackPressed() {
        return false;
    }
}