package alterego.solutions.company_information.search_company;


import android.content.Context;
import android.util.Log;

import java.util.ArrayList;

import alterego.solutions.company_information.Company;
import alterego.solutions.company_information.dbHelper.DBHelper;

public class SearchPresenter {

    String search;
    Context context;
    DBHelper mHelper;
    ArrayList<Company> companies = new ArrayList<>();

    public SearchPresenter(String Companysearched, Context Context) {
        this.context = Context;
        this.search = Companysearched.toUpperCase();
    }

    public ArrayList<Company> manageQuery(){
        if(search.equals("TUTTE")){
            searchAllCompanies();
        }
        else searchCompany();


        return companies;
    }
    //Method for search company using DBHelper for database manipulation
    private ArrayList<Company> searchCompany(){

        mHelper = new DBHelper(context);
        Company c = mHelper.searchCompanyByName(search);
        companies.add(c);

        return companies;
    }

    //Method for return all compaies with blank query in search view
    private ArrayList<Company> searchAllCompanies(){
        mHelper = new DBHelper(context);
        companies = (ArrayList<Company>)mHelper.getAllCompanys();

        return companies;
    }
}

@@ -93,33 +93,8 @@
 ext;
-%0Aimport android.util.Log;
 %0A%0Aim

Fix search log library