// Path: src/main/java/de/e621/rebane/components/listadapter/PostListAdapter.java
// public class PostListAdapter extends XMLListAdapter {
//     private String quality;
//     private int pageoffset;
//     private String escapedQuery;
// 
//     public PostListAdapter(PostsActivity context, int textViewResourceId, List<XMLNode> rowDataList, String quality) {
//         super(context.getApplicationContext(), textViewResourceId, rowDataList);
//         this.quality = quality;
//         this.pageoffset = (context.page-1)*context.pagesize;
//         this.escapedQuery = context.query;
//     }
// 
//     public View getView(final int position, View convertView, ViewGroup parent) {
//         PostListViewHolder holder = new PostListViewHolder(quality, this);
// 
//         LayoutInflater inflator = LayoutInflater.from(parent.getContext());
//         convertView = inflator.inflate(R.layout.preview_layout, parent, false);
// 
//         holder.populate(position, convertView, list.get(position), pageoffset, escapedQuery);
// 
//         return convertView;
//     }
// }


import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.itwookie.XMLreader.XMLNode;
import java.net.URLDecoder;
import de.e621.rebane.a621.R;
import de.e621.rebane.components.listadapter.PostListAdapter;

                database.setValue(SettingsActivity.SETTINGPOSTSPERPAGE, "15");
            }
        }
    }

    @Override
    void handleIntent(Intent intent) {
        super.handleIntent(intent);
        //page = intent.getIntExtra(SEARCHQUERYPAGE,1); //done by super
        if (!Intent.ACTION_SEARCH.equals(intent.getAction())) { //true case handled by super
            openDB();
            query = database.getValue(SettingsActivity.SETTINGDEFAULTSEARCH);
            if (query == null) query = "";
        }

        if (results==null) searchPosts(query, page);
    }

    @Override
    void searchPosts(String escapedQuery, int page) {
        API_URI = "post/index.xml?tags="+escapedQuery+"&page="+ page + "&limit="+pagesize;
        API_LOGIN = true;   //for vote meta search

        super.searchPosts(escapedQuery, page);
    }

    void onSearchResult(XMLNode result, String query, int page) {
        openDB();
        String quality = database.getValue(SettingsActivity.SETTINGPREVIEWQUALITY);


// Path: src/main/java/de/e621/rebane/components/listadapter/PostListAdapter.java
// public class PostListAdapter extends XMLListAdapter {
//     private String quality;
//     private int pageoffset;
//     private String escapedQuery;
// 
//     public PostListAdapter(PostsActivity context, int textViewResourceId, List<XMLNode> rowDataList, String quality) {
//         super(context.getApplicationContext(), textViewResourceId, rowDataList);
//         this.quality = quality;
//         this.pageoffset = (context.page-1)*context.pagesize;
//         this.escapedQuery = context.query;
//     }
// 
//     public View getView(final int position, View convertView, ViewGroup parent) {
//         PostListViewHolder holder = new PostListViewHolder(quality, this);
// 
//         LayoutInflater inflator = LayoutInflater.from(parent.getContext());
//         convertView = inflator.inflate(R.layout.preview_layout, parent, false);
// 
//         holder.populate(position, convertView, list.get(position), pageoffset, escapedQuery);
// 
//         return convertView;
//     }
// }


// Path: src/main/java/de/e621/rebane/activities/PostsActivity.java
import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.itwookie.XMLreader.XMLNode;
import java.net.URLDecoder;
import de.e621.rebane.a621.R;
import de.e621.rebane.components.listadapter.PostListAdapter;

                database.setValue(SettingsActivity.SETTINGPOSTSPERPAGE, "15");
            }
        }
    }

    @Override
    void handleIntent(Intent intent) {
        super.handleIntent(intent);
        //page = intent.getIntExtra(SEARCHQUERYPAGE,1); //done by super
        if (!Intent.ACTION_SEARCH.equals(intent.getAction())) { //true case handled by super
            openDB();
            query = database.getValue(SettingsActivity.SETTINGDEFAULTSEARCH);
            if (query == null) query = "";
        }

        if (results==null) searchPosts(query, page);
    }

    @Override
    void searchPosts(String escapedQuery, int page) {
        API_URI = "post/index.xml?tags="+escapedQuery+"&page="+ page + "&limit="+pagesize;
        API_LOGIN = true;   //for vote meta search

        super.searchPosts(escapedQuery, page);
    }

    void onSearchResult(XMLNode result, String query, int page) {
        openDB();
        String quality = database.getValue(SettingsActivity.SETTINGPREVIEWQUALITY);


        results = new PostListAdapter(this, R.id.txtMid, blacklist.proxyBlacklist(result.getChildren()), quality);
