// Path: app/src/main/java/com/kaliturin/blacklist/adapters/InformationArrayAdapter.java
// public class InformationArrayAdapter extends ArrayAdapter<InformationArrayAdapter.Model> {
//     private SparseArray<ViewHolder> rowsArray = new SparseArray<>();
// 
//     public InformationArrayAdapter(Context context) {
//         super(context, 0);
//     }
// 
//     @Override
//     @NonNull
//     public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
//         // get created row by position
//         View rowView;
//         ViewHolder viewHolder = rowsArray.get(position);
//         if (viewHolder != null) {
//             rowView = viewHolder.rowView;
//         } else {
//             // get model by position
//             Model model = getItem(position);
//             // get row layout
//             int layoutId = R.layout.row_info;
//             if (model != null) {
//                 if (model.type == Model.TITLE) {
//                     layoutId = R.layout.row_title;
//                 }
//             }
//             // create row
//             LayoutInflater inflater = LayoutInflater.from(getContext());
//             rowView = inflater.inflate(layoutId, parent, false);
//             if (model != null) {
//                 viewHolder = new ViewHolder(rowView, model, position);
//                 rowsArray.put(position, viewHolder);
//             }
//         }
// 
//         return rowView;
//     }
// 
//     private void addModel(int type, @StringRes int titleId, @StringRes int commentId) {
//         add(new Model(type, getString(titleId), getString(commentId)));
//     }
// 
//     public void addTitle(@StringRes int titleId) {
//         addModel(Model.TITLE, titleId, 0);
//     }
// 
//     public void addText(@StringRes int commentId) {
//         addText(null, getString(commentId));
//     }
// 
//     public void addText(String title, String comment) {
//         add(new Model(Model.TEXT, title, comment));
//     }
// 
//     @Nullable
//     private String getString(@StringRes int stringRes) {
//         return (stringRes != 0 ? getContext().getString(stringRes) : null);
//     }
// 
//     // Row item data
//     class Model {
//         private static final int TITLE = 1;
//         private static final int TEXT = 2;
// 
//         final int type;
//         final String title;
//         final String comment;
// 
//         Model(int type, String title, String comment) {
//             this.type = type;
//             this.title = title;
//             this.comment = comment;
//         }
//     }
// 
//     // Row view holder
//     private class ViewHolder {
//         final Model model;
//         final View rowView;
// 
//         ViewHolder(View rowView, Model model, int position) {
//             this.rowView = rowView;
//             this.model = model;
//             rowView.setTag(this);
// 
//             // title
//             TextView titleView = (TextView) rowView.findViewById(R.id.text_title);
//             if (titleView != null) {
//                 if (model.title != null) {
//                     titleView.setText(model.title);
//                     titleView.setVisibility(View.VISIBLE);
//                 } else {
//                     titleView.setVisibility(View.GONE);
//                 }
//             }
//             if (model.type == Model.TITLE) {
//                 if (position == 0) {
//                     View borderView = rowView.findViewById(R.id.top_border);
//                     if (borderView != null) {
//                         borderView.setVisibility(View.GONE);
//                     }
//                 }
//             }
// 
//             // comment
//             if (model.comment != null) {
//                 TextView commentView = (TextView) rowView.findViewById(R.id.text_comment);
//                 if (commentView != null) {
//                     commentView.setText(model.comment);
//                     commentView.setVisibility(View.VISIBLE);
//                 }
//             }
//         }
//     }
// }


import com.kaliturin.blacklist.R;
import com.kaliturin.blacklist.adapters.InformationArrayAdapter;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
/*
 * Copyright (C) 2017 Anton Kaliturin <kaliturin@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.kaliturin.blacklist.fragments;




/**
 * Information fragment
 */
public class InformationFragment extends Fragment implements FragmentArguments {
    private static final String TAG = InformationFragment.class.getName();
    private ListView listView = null;
    private int listPosition = 0;

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

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        // set activity title
        Bundle arguments = getArguments();
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (arguments != null && actionBar != null) {
            actionBar.setTitle(arguments.getString(TITLE));
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (savedInstanceState != null) {
            listPosition = savedInstanceState.getInt(LIST_POSITION, 0);
        }

        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_information, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        listView = (ListView) view.findViewById(R.id.help_list);

// Path: app/src/main/java/com/kaliturin/blacklist/adapters/InformationArrayAdapter.java
// public class InformationArrayAdapter extends ArrayAdapter<InformationArrayAdapter.Model> {
//     private SparseArray<ViewHolder> rowsArray = new SparseArray<>();
// 
//     public InformationArrayAdapter(Context context) {
//         super(context, 0);
//     }
// 
//     @Override
//     @NonNull
//     public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
//         // get created row by position
//         View rowView;
//         ViewHolder viewHolder = rowsArray.get(position);
//         if (viewHolder != null) {
//             rowView = viewHolder.rowView;
//         } else {
//             // get model by position
//             Model model = getItem(position);
//             // get row layout
//             int layoutId = R.layout.row_info;
//             if (model != null) {
//                 if (model.type == Model.TITLE) {
//                     layoutId = R.layout.row_title;
//                 }
//             }
//             // create row
//             LayoutInflater inflater = LayoutInflater.from(getContext());
//             rowView = inflater.inflate(layoutId, parent, false);
//             if (model != null) {
//                 viewHolder = new ViewHolder(rowView, model, position);
//                 rowsArray.put(position, viewHolder);
//             }
//         }
// 
//         return rowView;
//     }
// 
//     private void addModel(int type, @StringRes int titleId, @StringRes int commentId) {
//         add(new Model(type, getString(titleId), getString(commentId)));
//     }
// 
//     public void addTitle(@StringRes int titleId) {
//         addModel(Model.TITLE, titleId, 0);
//     }
// 
//     public void addText(@StringRes int commentId) {
//         addText(null, getString(commentId));
//     }
// 
//     public void addText(String title, String comment) {
//         add(new Model(Model.TEXT, title, comment));
//     }
// 
//     @Nullable
//     private String getString(@StringRes int stringRes) {
//         return (stringRes != 0 ? getContext().getString(stringRes) : null);
//     }
// 
//     // Row item data
//     class Model {
//         private static final int TITLE = 1;
//         private static final int TEXT = 2;
// 
//         final int type;
//         final String title;
//         final String comment;
// 
//         Model(int type, String title, String comment) {
//             this.type = type;
//             this.title = title;
//             this.comment = comment;
//         }
//     }
// 
//     // Row view holder
//     private class ViewHolder {
//         final Model model;
//         final View rowView;
// 
//         ViewHolder(View rowView, Model model, int position) {
//             this.rowView = rowView;
//             this.model = model;
//             rowView.setTag(this);
// 
//             // title
//             TextView titleView = (TextView) rowView.findViewById(R.id.text_title);
//             if (titleView != null) {
//                 if (model.title != null) {
//                     titleView.setText(model.title);
//                     titleView.setVisibility(View.VISIBLE);
//                 } else {
//                     titleView.setVisibility(View.GONE);
//                 }
//             }
//             if (model.type == Model.TITLE) {
//                 if (position == 0) {
//                     View borderView = rowView.findViewById(R.id.top_border);
//                     if (borderView != null) {
//                         borderView.setVisibility(View.GONE);
//                     }
//                 }
//             }
// 
//             // comment
//             if (model.comment != null) {
//                 TextView commentView = (TextView) rowView.findViewById(R.id.text_comment);
//                 if (commentView != null) {
//                     commentView.setText(model.comment);
//                     commentView.setVisibility(View.VISIBLE);
//                 }
//             }
//         }
//     }
// }


// Path: app/src/main/java/com/kaliturin/blacklist/fragments/InformationFragment.java
import com.kaliturin.blacklist.R;
import com.kaliturin.blacklist.adapters.InformationArrayAdapter;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

/*
 * Copyright (C) 2017 Anton Kaliturin <kaliturin@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.kaliturin.blacklist.fragments;




/**
 * Information fragment
 */
public class InformationFragment extends Fragment implements FragmentArguments {
    private static final String TAG = InformationFragment.class.getName();
    private ListView listView = null;
    private int listPosition = 0;

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

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        // set activity title
        Bundle arguments = getArguments();
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (arguments != null && actionBar != null) {
            actionBar.setTitle(arguments.getString(TITLE));
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (savedInstanceState != null) {
            listPosition = savedInstanceState.getInt(LIST_POSITION, 0);
        }

        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_information, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        listView = (ListView) view.findViewById(R.id.help_list);

        InformationArrayAdapter adapter = new InformationArrayAdapter(getContext());