Android Open Source - radio-presets-widget Metadata Parser






From Project

Back to project page radio-presets-widget.

License

The source code is released under:

Apache License

If you think the Android project radio-presets-widget 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

/*
 * Copyright (C) 2013 Reese Wilson | Shiny Mayhem
// w  ww  .  j  av  a2  s  .  c  om
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
package com.shinymayhem.radiopresets;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import com.shinymayhem.radiometadata.JazzRadio;
import com.shinymayhem.radiometadata.Parser;
import com.shinymayhem.radiometadata.ShoutcastV1;

public class MetadataParser {
    
    //TODO these should be ordered by most popular first
    private final List<Parser> parsers = new ArrayList<Parser>(Arrays.asList(
            new ShoutcastV1(),
            new JazzRadio()
    ));
    protected Parser mParser;
    protected String mUrl;
    
    /**
     * Iterate through known metadata parsers, checking if they will parse this url, then parsing
     * Fails silently
     * @param url
     * @return hashmap with keys from Parser and their values. empty hashmap on error or no data found
     */
    public HashMap<String, String> getMetadata(String url)
    {
        //TODO: check a cache first, with url as key
        boolean parses = false;
        HashMap<String, String> map;
        for (Parser parser : parsers)
        {
            if (parser.parsesUrl(url))
            {
                mUrl = url;
                mParser = parser;
                parses = true;
                break;
            }
        }
        if (parses)
        {
            map = mParser.getMetadata(url);
        }
        else
        {
            map = new HashMap<String, String>();
        }
        return map;
    }
    
}




Java Source Code List

com.radiopirate.android.service.IcyStreamMeta.java
com.shinymayhem.radiometadata.JazzRadio.java
com.shinymayhem.radiometadata.Parser.java
com.shinymayhem.radiometadata.ShoutcastV1.java
com.shinymayhem.radiometadata.XmlParser.java
com.shinymayhem.radiopresets.ActivityLogger.java
com.shinymayhem.radiopresets.ActivityMain.java
com.shinymayhem.radiopresets.ContentProviderRadio.java
com.shinymayhem.radiopresets.CursorAdapterStations.java
com.shinymayhem.radiopresets.DbContractRadio.java
com.shinymayhem.radiopresets.DialogFragmentAdd.java
com.shinymayhem.radiopresets.DialogFragmentEvent.java
com.shinymayhem.radiopresets.FragmentPlayer.java
com.shinymayhem.radiopresets.FragmentStations.java
com.shinymayhem.radiopresets.MetadataParser.java
com.shinymayhem.radiopresets.MultiChoiceModeListenerStation.java
com.shinymayhem.radiopresets.ReceiverRemoteControl.java
com.shinymayhem.radiopresets.ServiceAudioFormat.java
com.shinymayhem.radiopresets.ServiceRadioPlayer.java
com.shinymayhem.radiopresets.ServiceWidgetUpdate.java
com.shinymayhem.radiopresets.WidgetProviderPresets.java