Android Open Source - frc-notebook Add Matches From U R L






From Project

Back to project page frc-notebook.

License

The source code is released under:

GNU General Public License

If you think the Android project frc-notebook 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

package com.plnyyanks.frcnotebook.background;
//w  w w .  j av  a2  s. c  o m
import android.app.Activity;
import android.os.AsyncTask;
import android.widget.Toast;

import com.plnyyanks.frcnotebook.datafeed.USFIRSTParser;

/**
 * File created by phil on 4/19/14.
 * Copyright 2014, Phil Lopreiato
 * This file is part of FRC Notebook.
 * FRC Notebook 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.
 * FRC Notebook 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 FRC Notebook. If not, see http://www.gnu.org/licenses/.
 */
public class AddMatchesFromURL extends AsyncTask<String,String,String> {

    private Activity activity;

    public AddMatchesFromURL(Activity act){
        activity = act;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        try{
            Toast.makeText(activity,"Fetching matches...",Toast.LENGTH_SHORT).show();
        }catch(RuntimeException e){
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(activity,"Fetching matches...",Toast.LENGTH_SHORT).show();
                }
            });
        }
    }

    @Override
    protected String doInBackground(String... params) {
        String url = params[0],eventKey = params[1];
        String[] parts  = url.split("\\.");
        String extension = parts[parts.length-1];
        if(extension.equals("html") || extension.equals("csv")){
            return USFIRSTParser.fetchMatchesFromURL(url, eventKey);
        }else{
            return "Unsupported filetype. Use .html or .csv";
        }
    }

    @Override
    protected void onPostExecute(final String s) {
        super.onPostExecute(s);
        try {
            if (!s.isEmpty()) {
                Toast.makeText(activity, s, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(activity, "Matches added", Toast.LENGTH_SHORT).show();
            }
        }catch(RuntimeException e){
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (!s.isEmpty()) {
                        Toast.makeText(activity, s, Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(activity, "Matches added", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }
    }
}




Java Source Code List

.BasicTest.java
.TestStartActivity.java
com.plnyyanks.frcnotebook.Constants.java
com.plnyyanks.frcnotebook.activities.AddEvent.java
com.plnyyanks.frcnotebook.activities.EventDownloadActivity.java
com.plnyyanks.frcnotebook.activities.FieldMonitorActivity.java
com.plnyyanks.frcnotebook.activities.PredefinedNoteManager.java
com.plnyyanks.frcnotebook.activities.SettingsActivity.java
com.plnyyanks.frcnotebook.activities.StartActivity.java
com.plnyyanks.frcnotebook.activities.ViewEvent.java
com.plnyyanks.frcnotebook.activities.ViewMatch.java
com.plnyyanks.frcnotebook.activities.ViewTeam.java
com.plnyyanks.frcnotebook.adapters.ActionBarCallback.java
com.plnyyanks.frcnotebook.adapters.AdapterInterface.java
com.plnyyanks.frcnotebook.adapters.AllianceExpandableListAdapter.java
com.plnyyanks.frcnotebook.adapters.CustomExapandableListAdapter.java
com.plnyyanks.frcnotebook.adapters.ListViewArrayAdapter.java
com.plnyyanks.frcnotebook.adapters.MatchListExpandableListAdapter.java
com.plnyyanks.frcnotebook.adapters.NotesExpandableListAdapter.java
com.plnyyanks.frcnotebook.background.AddMatchesFromURL.java
com.plnyyanks.frcnotebook.background.DeleteEvent.java
com.plnyyanks.frcnotebook.background.GetEventMatches.java
com.plnyyanks.frcnotebook.background.GetNotesForMatch.java
com.plnyyanks.frcnotebook.background.GetNotesForTeam.java
com.plnyyanks.frcnotebook.background.GetTeamsAttending.java
com.plnyyanks.frcnotebook.background.ShowLocalEvents.java
com.plnyyanks.frcnotebook.background.ValidateNewEventData.java
com.plnyyanks.frcnotebook.database.BackupDatabase.java
com.plnyyanks.frcnotebook.database.DatabaseHandler.java
com.plnyyanks.frcnotebook.database.ImportDatabase.java
com.plnyyanks.frcnotebook.database.PreferenceHandler.java
com.plnyyanks.frcnotebook.datafeed.EventDetailFetcher.java
com.plnyyanks.frcnotebook.datafeed.EventListFetcher.java
com.plnyyanks.frcnotebook.datafeed.GET_Request.java
com.plnyyanks.frcnotebook.datafeed.MATCH_PROPS.java
com.plnyyanks.frcnotebook.datafeed.MatchDetailFetcher.java
com.plnyyanks.frcnotebook.datafeed.TBADatafeed.java
com.plnyyanks.frcnotebook.datafeed.USFIRSTParser.java
com.plnyyanks.frcnotebook.datatypes.Event.java
com.plnyyanks.frcnotebook.datatypes.ListElement.java
com.plnyyanks.frcnotebook.datatypes.ListGroup.java
com.plnyyanks.frcnotebook.datatypes.ListHeader.java
com.plnyyanks.frcnotebook.datatypes.ListItem.java
com.plnyyanks.frcnotebook.datatypes.Match.java
com.plnyyanks.frcnotebook.datatypes.Note.java
com.plnyyanks.frcnotebook.datatypes.Team.java
com.plnyyanks.frcnotebook.dialogs.AddNoteDialog.java
com.plnyyanks.frcnotebook.dialogs.AddPredefNoteDialog.java
com.plnyyanks.frcnotebook.dialogs.DatePickerFragment.java
com.plnyyanks.frcnotebook.dialogs.DeleteDialog.java
com.plnyyanks.frcnotebook.dialogs.EditNoteDialog.java
com.plnyyanks.frcnotebook.dialogs.EditPredefNoteDialog.java
com.plnyyanks.frcnotebook.dialogs.InputURLForMatchesDialog.java
com.plnyyanks.frcnotebook.dialogs.ProgressDialog.java
com.plnyyanks.frcnotebook.json.JSONManager.java