// Path: app/src/main/java/it/skarafaz/mercury/adapter/LogListAdapter.java
// public class LogListAdapter extends ArrayAdapter<String> {
// 
//     public LogListAdapter(Context context, List<String> lines) {
//         super(context, R.layout.log_list_item, lines);
//     }
// 
//     @Override
//     public boolean isEnabled(int position) {
//         return false;
//     }
// }


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.*;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.adapter.LogListAdapter;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_log, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        reload();
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.menu_log, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_clear:
                clearLog();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void reload() {
// Path: app/src/main/java/it/skarafaz/mercury/adapter/LogListAdapter.java
// public class LogListAdapter extends ArrayAdapter<String> {
// 
//     public LogListAdapter(Context context, List<String> lines) {
//         super(context, R.layout.log_list_item, lines);
//     }
// 
//     @Override
//     public boolean isEnabled(int position) {
//         return false;
//     }
// }


// Path: app/src/main/java/it/skarafaz/mercury/fragment/LogFragment.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.*;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.adapter.LogListAdapter;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_log, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        reload();
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.menu_log, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_clear:
                clearLog();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void reload() {
        setListAdapter(new LogListAdapter(getActivity(), readLog()));