// Path: src/main/java/de/e621/rebane/components/listadapter/ForumListAdapter.java
// public class ForumListAdapter extends XMLListAdapter {
// 
//     public int getLastPage(int pagesize) {
//         return 100;
//     } //can't be retrieved
// 
//     public ForumListAdapter(Context context, int textViewResourceId, List<XMLNode> rowDataList) {
//         super(context, textViewResourceId, rowDataList);
//         svNumPosts = Integer.MAX_VALUE; //can't be computed
//     }
// 
//     public View getView(final int position, View convertView, ViewGroup parent) {
//         ForumViewHolder holder = new ForumViewHolder();
// 
//         LayoutInflater inflator = LayoutInflater.from(parent.getContext());
//         convertView = inflator.inflate(R.layout.twolined_listentry, parent, false);
// 
//         holder.populate(position, convertView, list.get(position));
// 
//         return convertView;
//     }
// }


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.view.View;
import com.itwookie.XMLreader.XMLNode;
import de.e621.rebane.a621.R;
import de.e621.rebane.components.listadapter.ForumListAdapter;

package de.e621.rebane.activities;





/** with what little information is returned by the forum API I won't continue that for now */
public class ForumsActivity extends PaginatedListActivity implements SwipeRefreshLayout.OnRefreshListener, View.OnClickListener {

    final static String FORUMQUERYPAGE = "a621 SearchManager Forum Page";

    /*@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_paginated_list);
        postLayoutInflated(this.getClass());
    }*/

    @Override
    @SuppressLint("MissingSuperCall")
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(R.layout.content_paginated_list, savedInstanceState);
        //setContentView(R.layout.activity_posts);
        postLayoutInflated(this.getClass());
    }

    @Override void setPagesize() {
        pagesize = 30; //given by API
    }

    @Override
    public void onSaveInstanceState(Bundle outState){
        super.onSaveInstanceState(outState);
        outState.putInt(FORUMQUERYPAGE, page);
    }

    @Override
    void handleIntent(Intent intent) {
        super.handleIntent(intent);
        page = intent.getIntExtra(FORUMQUERYPAGE,1);

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

    @Override void searchPosts(String escapedQuery, int page) {
        API_URI = "forum/index.xml?page="+page;
        API_LOGIN = false;

        super.searchPosts(escapedQuery, page);
    }

    @Override void onSearchResult(XMLNode result, String query, int page) {

// Path: src/main/java/de/e621/rebane/components/listadapter/ForumListAdapter.java
// public class ForumListAdapter extends XMLListAdapter {
// 
//     public int getLastPage(int pagesize) {
//         return 100;
//     } //can't be retrieved
// 
//     public ForumListAdapter(Context context, int textViewResourceId, List<XMLNode> rowDataList) {
//         super(context, textViewResourceId, rowDataList);
//         svNumPosts = Integer.MAX_VALUE; //can't be computed
//     }
// 
//     public View getView(final int position, View convertView, ViewGroup parent) {
//         ForumViewHolder holder = new ForumViewHolder();
// 
//         LayoutInflater inflator = LayoutInflater.from(parent.getContext());
//         convertView = inflator.inflate(R.layout.twolined_listentry, parent, false);
// 
//         holder.populate(position, convertView, list.get(position));
// 
//         return convertView;
//     }
// }


// Path: src/main/java/de/e621/rebane/activities/ForumsActivity.java
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.view.View;
import com.itwookie.XMLreader.XMLNode;
import de.e621.rebane.a621.R;
import de.e621.rebane.components.listadapter.ForumListAdapter;

package de.e621.rebane.activities;





/** with what little information is returned by the forum API I won't continue that for now */
public class ForumsActivity extends PaginatedListActivity implements SwipeRefreshLayout.OnRefreshListener, View.OnClickListener {

    final static String FORUMQUERYPAGE = "a621 SearchManager Forum Page";

    /*@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_paginated_list);
        postLayoutInflated(this.getClass());
    }*/

    @Override
    @SuppressLint("MissingSuperCall")
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(R.layout.content_paginated_list, savedInstanceState);
        //setContentView(R.layout.activity_posts);
        postLayoutInflated(this.getClass());
    }

    @Override void setPagesize() {
        pagesize = 30; //given by API
    }

    @Override
    public void onSaveInstanceState(Bundle outState){
        super.onSaveInstanceState(outState);
        outState.putInt(FORUMQUERYPAGE, page);
    }

    @Override
    void handleIntent(Intent intent) {
        super.handleIntent(intent);
        page = intent.getIntExtra(FORUMQUERYPAGE,1);

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

    @Override void searchPosts(String escapedQuery, int page) {
        API_URI = "forum/index.xml?page="+page;
        API_LOGIN = false;

        super.searchPosts(escapedQuery, page);
    }

    @Override void onSearchResult(XMLNode result, String query, int page) {

        results = new ForumListAdapter(getApplicationContext(), R.id.lblTitle, result.getChildren());
