public class MainApplication extends Application {
    private Graph mGraph;

    @Override
    public void onCreate() {
        super.onCreate();

        mGraph = Graph.Initializer.init(this, false);
    }

    public Graph getGraph() {
        return mGraph;
    }

    public void setMockMode(boolean provideMocks) {
        mGraph = Graph.Initializer.init(this, provideMocks);
    }

    public static MainApplication from(@NonNull Context context) {
        return (MainApplication) context.getApplicationContext();
    }
} public class ActivityDetailActivity extends AppCompatActivity implements IActivityDetailActivityView {
    private static final String ARG_ACTIVITY = "ActivityArg";
    public static Intent getLaunchIntent(Context context, ActivityInfoInternal activity) {
        return new Intent(context, ActivityDetailActivity.class).putExtra(ARG_ACTIVITY, activity);
    }

    @Inject
    IActivityDetailActivityPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    private ActivityDetailAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activity_detail);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(getString(R.string.title_activity_package_list));
        setSupportActionBar(toolbar);
        if(getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }

        MainApplication.from(this).getGraph().inject(this);

        ButterKnife.bind(this);

        mPresenter.setView(this);

        mPresenter.init(getIntent().getParcelableExtra(ARG_ACTIVITY));
    }

    @Override
    protected void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void setTitle(String title) {
        getSupportActionBar().setTitle(title);
    }

    @Override
    public void setModel(Object[] items, int[] dataSetTypes) {
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        mAdapter = new ActivityDetailAdapter(items, dataSetTypes);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

} public class ContentProviderDetailActivity extends AppCompatActivity implements IContentProviderDetailActivityView {
    private static final String ARG_CP = "ContentProvider";
    public static Intent getLaunchIntent(Context context, ContentProviderInfo provider) {
        return new Intent(context, ContentProviderDetailActivity.class).putExtra(ARG_CP, provider);
    }

    @Inject
    IContentProviderDetailActivityPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    private ContentProviderDetailAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_content_provider_detail);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(getString(R.string.title_activity_package_list));
        setSupportActionBar(toolbar);
        if(getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }

        MainApplication.from(this).getGraph().inject(this);

        ButterKnife.bind(this);

        mPresenter.setView(this);

        mPresenter.init(getIntent().getParcelableExtra(ARG_CP));
    }

    @Override
    protected void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void setTitle(String title) {
        getSupportActionBar().setTitle(title);
    }

    @Override
    public void setModel(Object[] items, int[] dataSetTypes) {
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        mAdapter = new ContentProviderDetailAdapter(items, dataSetTypes);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
} public class PackageListActivity extends AppCompatActivity implements IPackageListView {

    @Inject
    IPackageListActivityPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView rvPackages;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    private PackageListAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_package_list);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(getString(R.string.title_activity_package_list));
        setSupportActionBar(toolbar);

        MainApplication.from(this).getGraph().inject(this);

        ButterKnife.bind(this);

        mPresenter.setView(this);

        if (findViewById(R.id.item_detail_container) != null) {
            mPresenter.setTwoPane();
        }

        mPresenter.init();
    }

    @Override
    public void init() {
        rvPackages.setHasFixedSize(true);

        rvPackages.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new PackageListAdapter();
        rvPackages.setAdapter(mAdapter);

        mAdapter.setOnClickListener(onItemClickListener);
    }

    @Override
    protected void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.setView(this);
        mPresenter.loadPackages(false);
    }

    @Override
    public void setInstalledPackages(List<InstalledPackageHeader> items) {
        mAdapter.setData(items);
    }

    @Override
    public void setError(String message) {
        Snackbar.make(rvPackages, message, Snackbar.LENGTH_LONG).show();
    }

    private RecyclerViewOnClickListener<InstalledPackageHeader> onItemClickListener = item -> mPresenter.packageSelected(item);

    @Override
    public void startDetailActivity(InstalledPackageHeader item) {
        Intent intent = new Intent(getApplicationContext(), PackageDetailActivity.class);
        intent.putExtra(PackageDetailActivity.ARG_PACKAGE_NAME, item.getPackageName());
        PackageListActivity.this.startActivity(intent);
    }

    @Override
    public void setDetailFragment(InstalledPackageHeader item) {
        Bundle arguments = new Bundle();
        arguments.putString(PackageDetailFragment.ARG_PACKAGE_NAME, item.getPackageName());
        arguments.putBoolean(PackageDetailFragment.ARG_2_PANE, true);
        PackageDetailFragment fragment = new PackageDetailFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.item_detail_container, fragment)
                .commit();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_package_list, menu);

        menu.getItem(0).setChecked(SettingsHelper.shouldIncludeSystemApps(this));
        menu.getItem(1).setChecked(SettingsHelper.shouldIncludeUninstalledApps(this));

        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_include_uninstalled_aps) {
            item.setChecked(item.isChecked() == true ? false : true);

            SettingsHelper.setIncludeUninstalledApps(this, item.isChecked());

            mPresenter.loadPackages(true);

            return true;
        } else if (id == R.id.action_include_system_apps) {
            item.setChecked(item.isChecked() == true ? false : true);

            SettingsHelper.setIncludeSystemAppsApps(this, item.isChecked());

            mPresenter.loadPackages(true);
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showContentView() {
        rvPackages.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideContentView() {
        rvPackages.setVisibility(View.GONE);
    }
} public class ActivitiesFragment extends Fragment implements IActivitiesFragmentView {

    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IActivitiesFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private ActivitiesListAdapter mAdapter;

    public ActivitiesFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The app package name.
     * @return A new instance of fragment ActivitiesFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static ActivitiesFragment newInstance(String packageName) {
        ActivitiesFragment fragment = new ActivitiesFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_activities, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<ActivityInfoInternal> activities) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new ActivitiesListAdapter(activities);
        recyclerView.setAdapter(mAdapter);

        mAdapter.setOnClickListener(onItemClickListener);
    }

    private RecyclerViewOnClickListener<ActivityInfoInternal> onItemClickListener = new RecyclerViewOnClickListener<ActivityInfoInternal>() {
        @Override
        public void onItemClick(ActivityInfoInternal item) {
            mPresenter.onActivitySelected(item);
        }
    };


    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void startActivityDetailActivity(ActivityInfoInternal activity) {
        getContext().startActivity(ActivityDetailActivity.getLaunchIntent(getContext(), activity));
    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
} public class ApplicationInfoFragment extends Fragment implements IApplicationInfoFragmentView {
    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IApplicationInfoFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    private AppInfoAdapter mAdapter;

    public ApplicationInfoFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The model that this fragment needs to display.
     * @return A new instance of fragment ApplicationInfoFragment.
     */
    public static ApplicationInfoFragment newInstance(String packageName) {
        ApplicationInfoFragment fragment = new ApplicationInfoFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_application_info, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(Object[] items, int[] dataSetTypes) {
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));


        mAdapter = new AppInfoAdapter(items, dataSetTypes);
        recyclerView.setAdapter(mAdapter);
    }


    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }
} public class BroadcastReceiversFragment extends Fragment implements IBroadcastReceiversFragmentView {

    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IBroadcastReceiversFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private BroadcastReceiversListAdapter mAdapter;

    public BroadcastReceiversFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The app package name.
     * @return A new instance of fragment ActivitiesFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static BroadcastReceiversFragment newInstance(String packageName) {
        BroadcastReceiversFragment fragment = new BroadcastReceiversFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_broadcast_receivers, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<BroadcastReceiverInfo> receivers) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new BroadcastReceiversListAdapter(receivers);
        recyclerView.setAdapter(mAdapter);

        mAdapter.setOnClickListener(onItemClickListener);
    }

    private RecyclerViewOnClickListener<BroadcastReceiverInfo> onItemClickListener = new RecyclerViewOnClickListener<BroadcastReceiverInfo>() {
        @Override
        public void onItemClick(BroadcastReceiverInfo item) {
            mPresenter.onBroadcastReceiverSelected(item);
        }
    };


    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void startBroadcastReceiverDetailActivity(BroadcastReceiverInfo receiver) {

    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
} public class ContentProvidersFragment extends Fragment implements IContentProvidersFragmentView {

    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IContentProvidersFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private ContentProvidersAdapter mAdapter;

    public ContentProvidersFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The app package name.
     * @return A new instance of fragment ActivitiesFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static ContentProvidersFragment newInstance(String packageName) {
        ContentProvidersFragment fragment = new ContentProvidersFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_content_providers, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<ContentProviderInfo> providers) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new ContentProvidersAdapter(providers);
        recyclerView.setAdapter(mAdapter);

        mAdapter.setOnClickListener(onItemClickListener);
    }

    private RecyclerViewOnClickListener<ContentProviderInfo> onItemClickListener = new RecyclerViewOnClickListener<ContentProviderInfo>() {
        @Override
        public void onItemClick(ContentProviderInfo item) {
            mPresenter.onContentProviderSelected(item);
        }
    };


    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void startContentProviderDetailActivity(ContentProviderInfo provider) {
        startActivity(ContentProviderDetailActivity.getLaunchIntent(getActivity(), provider));

    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
} public class DeclaredPermissionsFragment extends Fragment implements IDeclaredPermissionsFragmentView {
    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IDeclaredPermissionsFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private DeclaredPermissionsAdapter mAdapter;

    public DeclaredPermissionsFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The model that this fragment needs to display.
     * @return A new instance of fragment ApplicationInfoFragment.
     */
    public static DeclaredPermissionsFragment newInstance(String packageName) {
        DeclaredPermissionsFragment fragment = new DeclaredPermissionsFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_declared_permissions, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<DeclaredPermission> permissions) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new DeclaredPermissionsAdapter(permissions);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
} public class PackageDetailFragment extends Fragment implements IPackageDetailFragmentView {

    public static String ARG_PACKAGE_NAME = "PackageName";
    public static String ARG_2_PANE = "2Pane";

    @Inject
    IPackageDetailFragmentPresenter mPresenter;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tabs)
    TabLayout mTabLayout;

    @Bind(R.id.viewpager)
    ViewPager mViewPager;

    private PackageDetailViewPagerAdapter mViewPagerAdapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_package_detail, container, false);



        String packageName = getArguments().getString(ARG_PACKAGE_NAME);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        mPresenter.setView(this);

        mPresenter.init(packageName);

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        mTabLayout.setVisibility(View.VISIBLE);
        mViewPager.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        mTabLayout.setVisibility(View.GONE);
        mViewPager.setVisibility(View.GONE);
    }

    @Override
    public void setTitle(String title) {
        ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(title);
    }

    @Override
    public void initViews(String appName, String packageName) {
        ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(appName);

        mViewPagerAdapter = new PackageDetailViewPagerAdapter(this.getChildFragmentManager());
        mViewPagerAdapter.addFragment(ApplicationInfoFragment.newInstance(packageName), getString(R.string.tab_header_application_info));
        mViewPagerAdapter.addFragment(ActivitiesFragment.newInstance(packageName), getString(R.string.tab_header_activities));
        mViewPagerAdapter.addFragment(ServicesFragment.newInstance(packageName), getString(R.string.tab_header_services));
        mViewPagerAdapter.addFragment(ContentProvidersFragment.newInstance(packageName), getString(R.string.tab_header_content_providers));
        mViewPagerAdapter.addFragment(BroadcastReceiversFragment.newInstance(packageName), getString(R.string.tab_header_broadcast_receivers));
        mViewPagerAdapter.addFragment(RequestedPermissionsFragment.newInstance(packageName), getString(R.string.tab_header_requested_permissions));
        mViewPagerAdapter.addFragment(DeclaredPermissionsFragment.newInstance(packageName), getString(R.string.tab_header_declared_permissions));
        mViewPagerAdapter.addFragment(RequestedFeaturesFragment.newInstance(packageName), getString(R.string.tab_header_requested_features));
        mViewPager.setAdapter(mViewPagerAdapter);
        mTabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public void showError(String message) {

    }
} public class RequestedFeaturesFragment extends Fragment implements IRequestedFeaturesFragmentView {
    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IRequestedFeaturesFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private RequestedFeaturesAdapter mAdapter;

    public RequestedFeaturesFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The model that this fragment needs to display.
     * @return A new instance of fragment ApplicationInfoFragment.
     */
    public static RequestedFeaturesFragment newInstance(String packageName) {
        RequestedFeaturesFragment fragment = new RequestedFeaturesFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_requested_features, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<FeatureInfoInternal> features) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new RequestedFeaturesAdapter(features);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
} public class RequestedPermissionsFragment extends Fragment implements IRequestedPermissionsFragmentView {
    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IRequestedPermissionsFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private RequestedPermissionsAdapter mAdapter;

    public RequestedPermissionsFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The model that this fragment needs to display.
     * @return A new instance of fragment ApplicationInfoFragment.
     */
    public static RequestedPermissionsFragment newInstance(String packageName) {
        RequestedPermissionsFragment fragment = new RequestedPermissionsFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_requested_permissions, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<RequestedPermission> permissions) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new RequestedPermissionsAdapter(permissions);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
} public class ServicesFragment extends Fragment implements IServicesFragmentView {
    private static final String ARG_PACKAGE_NAME = "package_name_param";

    @Inject
    IServicesFragmentPresenter mPresenter;

    @Bind(R.id.item_list)
    RecyclerView recyclerView;

    @Bind(R.id.progress_bar)
    ProgressBar mProgressBar;

    @Bind(R.id.tvNoValues)
    TextView tvNoValues;

    private ServicesAdapter mAdapter;

    public ServicesFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param packageName The model that this fragment needs to display.
     * @return A new instance of fragment ApplicationInfoFragment.
     */
    public static ServicesFragment newInstance(String packageName) {
        ServicesFragment fragment = new ServicesFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PACKAGE_NAME, packageName);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_declared_permissions, container, false);

        MainApplication.from(getActivity()).getGraph().inject(this);

        ButterKnife.bind(this, rootView);

        if (getArguments() != null) {
            mPresenter.setView(this);
            mPresenter.init(getArguments().getString(ARG_PACKAGE_NAME));
        }

        return rootView;
    }

    @Override
    public void onPause() {
        mPresenter.clearView();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.setView(this);
    }

    @Override
    public void showError(String message) {
        Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG).show();
    }

    @Override
    public void setModel(ArrayList<ServiceInfoInternal> permissions) {

        recyclerView.setHasFixedSize(true);

        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

        mAdapter = new ServicesAdapter(permissions);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    public void showWaitDialog() {
        mProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideWaitDialog() {
        mProgressBar.setVisibility(View.GONE);
    }

    @Override
    public void showDetailContainer() {
        recyclerView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideDetailContainer() {
        recyclerView.setVisibility(View.GONE);
    }

    @Override
    public void showNoValuesText() {
        tvNoValues.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideNoValuesText() {
        tvNoValues.setVisibility(View.GONE);
    }
}
import dagger.Component;
import com.livingstoneapp.MainApplication;
import com.livingstoneapp.activities.ActivityDetailActivity;
import com.livingstoneapp.activities.ContentProviderDetailActivity;
import com.livingstoneapp.activities.PackageListActivity;
import com.livingstoneapp.fragments.ActivitiesFragment;
import com.livingstoneapp.fragments.ApplicationInfoFragment;
import com.livingstoneapp.fragments.BroadcastReceiversFragment;
import com.livingstoneapp.fragments.ContentProvidersFragment;
import com.livingstoneapp.fragments.DeclaredPermissionsFragment;
import com.livingstoneapp.fragments.PackageDetailFragment;
import com.livingstoneapp.fragments.RequestedFeaturesFragment;
import com.livingstoneapp.fragments.RequestedPermissionsFragment;
import com.livingstoneapp.fragments.ServicesFragment;
package com.livingstoneapp.dagger;


/**
 * Created by renier on 1/12/2016.
 */
@Component(modules = { ApplicationModule.class, InteractorModule.class, PackageListActivityModule.class, PackageDetailActivityModule.class })
public interface Graph {
    void inject(PackageListActivity activity);
    void inject(PackageDetailFragment fragment);
    void inject(ApplicationInfoFragment fragment);
    void inject(ActivitiesFragment fragment);
    void inject(ActivityDetailActivity activity);
    void inject(DeclaredPermissionsFragment fragment);
    void inject(RequestedPermissionsFragment fragment);