1990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount/*
2990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * Copyright (C) 2016 The Android Open Source Project
3990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount *
4990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * Licensed under the Apache License, Version 2.0 (the "License");
5990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * you may not use this file except in compliance with the License.
6990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * You may obtain a copy of the License at
7990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount *
8990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount *      http://www.apache.org/licenses/LICENSE-2.0
9990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount *
10990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * Unless required by applicable law or agreed to in writing, software
11990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * distributed under the License is distributed on an "AS IS" BASIS,
12990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * See the License for the specific language governing permissions and
14990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * limitations under the License.
15990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount */
16990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountpackage android.support.v4.app;
17990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
18990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountimport android.content.Context;
19990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountimport android.os.Bundle;
20990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountimport android.view.LayoutInflater;
21990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountimport android.view.View;
22990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountimport android.view.ViewGroup;
23990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
24990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount/**
25990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * Counts the number of onCreateView, onHiddenChanged (onHide, onShow), onAttach, and onDetach
26990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount * calls.
27990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount */
28990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mountpublic class CountCallsFragment extends StrictViewFragment {
29990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public int onCreateViewCount = 0;
30990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public int onDestroyViewCount = 0;
31990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public int onHideCount = 0;
32990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public int onShowCount = 0;
33990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public int onAttachCount = 0;
34990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public int onDetachCount = 0;
35990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
36990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    @Override
37990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public View onCreateView(LayoutInflater inflater, ViewGroup container,
38990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount            Bundle savedInstanceState) {
39990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        onCreateViewCount++;
40990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        return super.onCreateView(inflater, container, savedInstanceState);
41990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    }
42990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
43990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    @Override
44990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public void onHiddenChanged(boolean hidden) {
45990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        if (hidden) {
46990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount            onHideCount++;
47990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        } else {
48990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount            onShowCount++;
49990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        }
50990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        super.onHiddenChanged(hidden);
51990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    }
52990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
53990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    @Override
54990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public void onAttach(Context context) {
55990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        onAttachCount++;
56990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        super.onAttach(context);
57990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    }
58990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
59990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    @Override
60990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public void onDetach() {
61990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        onDetachCount++;
62990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        super.onDetach();
63990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    }
64990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount
65990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    @Override
66990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    public void onDestroyView() {
67990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        onDestroyViewCount++;
68990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount        super.onDestroyView();
69990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount    }
70990e6fc0326f5948736650c0cb71b6002d443c9cGeorge Mount}
71