com.inferiorhumanorgans.WayToGo.Agency.BART.BaseXMLTask.java Source code

Java tutorial

Introduction

Here is the source code for com.inferiorhumanorgans.WayToGo.Agency.BART.BaseXMLTask.java

Source

/*
 *  Copyright (C) 2011 Inferior Human Organs Software
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.inferiorhumanorgans.WayToGo.Agency.BART;

import com.inferiorhumanorgans.WayToGo.Agency.BARTAgency;
import android.os.AsyncTask;
import junit.framework.Assert;
import org.apache.http.HttpVersion;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;

/**
 *
 * @author alex
 */
public abstract class BaseXMLTask extends AsyncTask<BARTAgency, Object, Void> {
    protected BARTAgency theAgency = null;
    protected final HttpParams params = new BasicHttpParams();
    protected final SchemeRegistry registry = new SchemeRegistry();

    @Override
    protected Void doInBackground(final BARTAgency... someAgencies) {
        Assert.assertEquals(1, someAgencies.length);
        theAgency = someAgencies[0];

        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
        HttpProtocolParams.setUseExpectContinue(params, true);
        /*HttpConnectionParams.setConnectionTimeout(params, 1000);
        HttpConnectionParams.setSoTimeout(params, 1000);
        ConnManagerParams.setTimeout(params, 1000);*/

        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

        return null;
    }
}