Android Open Source - ShopShopViewer Read Shop Shop File Task






From Project

Back to project page ShopShopViewer.

License

The source code is released under:

GNU General Public License

If you think the Android project ShopShopViewer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * ShopShopViewer//  ww  w .  j a  va2  s  .c  o m
 * Copyright (C) 2012 Remko Plantenga
 * 
 * This file is part of ShopShopViewer.
 *
 * ShopShopViewer 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.
 * 
 * ShopShopViewer 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 ShopShopViewer. If not, see <http://www.gnu.org/licenses/>.
 */
package de.remk0.shopshopviewer.task;

import java.io.InputStream;

import android.os.AsyncTask;
import android.util.Log;

import com.dd.plist.NSDictionary;
import com.dd.plist.NSObject;

import de.remk0.shopshopviewer.ShopShopViewerApplication;
import de.remk0.shopshopviewer.io.FileAccess;
import de.remk0.shopshopviewer.io.FileAccessException;
import de.remk0.shopshopviewer.parse.ShopShopFileParser;
import de.remk0.shopshopviewer.parse.ShopShopFileParserException;

/**
 * Task to read a ShopShop file.
 * 
 * @author Remko Plantenga
 * 
 */
public class ReadShopShopFileTask extends AsyncTask<String, Integer, Boolean> {

    private FileAccess fileAccess;
    private ShopShopFileParser parser;

    public void setFileAccess(FileAccess fileAccess) {
        this.fileAccess = fileAccess;
    }

    public void setParser(ShopShopFileParser parser) {
        this.parser = parser;
    }

    public NSDictionary getRoot() {
        return parser.getRoot();
    }

    public NSObject[] getShoppingList() {
        return parser.getShoppingList();
    }

    @Override
    protected final Boolean doInBackground(String... params) {

        String fileName = params[0];

        try {
            InputStream is = fileAccess.getFile(fileName);

            return parser.read(is);
        } catch (FileAccessException e) {
            Log.e(ShopShopViewerApplication.APP_NAME, "Error while accessing "
                    + fileName, e);
        } catch (ShopShopFileParserException e) {
            Log.e(ShopShopViewerApplication.APP_NAME, "Error while parsing "
                    + fileName, e);
        }
        return false;
    }

}




Java Source Code List

de.remk0.shopshopviewer.CheckableArrayAdapter.java
de.remk0.shopshopviewer.DisplayFileActivity.java
de.remk0.shopshopviewer.DropboxAuthActivity.java
de.remk0.shopshopviewer.ShopShopViewerActivity.java
de.remk0.shopshopviewer.ShopShopViewerApplication.java
de.remk0.shopshopviewer.io.DropboxFileAccess.java
de.remk0.shopshopviewer.io.ExternalFilesDirFileAccess.java
de.remk0.shopshopviewer.io.FileAccessException.java
de.remk0.shopshopviewer.io.FileAccess.java
de.remk0.shopshopviewer.io.RemoteFileAccessException.java
de.remk0.shopshopviewer.io.RemoteFileAccess.java
de.remk0.shopshopviewer.parse.PlistParser.java
de.remk0.shopshopviewer.parse.ShopShopFileParserException.java
de.remk0.shopshopviewer.parse.ShopShopFileParser.java
de.remk0.shopshopviewer.task.ReadShopShopFileTask.java
de.remk0.shopshopviewer.task.SynchronizeTask.java
de.remk0.shopshopviewer.task.WriteShopShopFileTask.java