Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

In this page you can find the example usage for android.util Log v.

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:fm.krui.kruifm.PlaylistFetcher.java

@Override
protected ArrayList<HashMap<String, Track>> doInBackground(Integer... params) {
    Integer trackCount = params[0];
    Log.v(TAG, "Entered PlaylistFetcher...");
    Log.v(TAG, "Track count is " + Integer.toString(trackCount));

    // Get the requested number of tracks from the staff.krui.fm api
    String apiQuery = "http://staff.krui.fm/api/playlist/main/items.json?limit=" + Integer.toString(trackCount);
    JSONArray arr = JSONFunctions.getJSONArrayFromURL(apiQuery);

    // Create Track list
    String dateHolder = "0";
    ArrayList<HashMap<String, Track>> trackList = new ArrayList<HashMap<String, Track>>();
    try {// w  w  w  .j  a v a  2  s . co  m
        for (int i = 0; i < arr.length(); i++) {

            // Create map for this entry.
            HashMap<String, Track> trackMap = new HashMap<String, Track>();

            // Retrieve the song object from the JSON array
            JSONArray nestedArr = arr.getJSONArray(i);
            JSONObject obj = nestedArr.getJSONObject(0);
            JSONObject songObj = obj.getJSONObject(Track.KEY_SONG);
            JSONObject userObj = obj.getJSONObject(Track.KEY_USER);

            // Store user characteristics for this play in a DJ object.
            DJ user = new DJ(userObj.optString(DJ.KEY_FIRST_NAME, ""), userObj.optString(DJ.KEY_LAST_NAME, ""));
            user.setUrl(userObj.optString(DJ.KEY_URL));
            user.setBio(userObj.optString(DJ.KEY_BIO));
            user.setTwitter(userObj.optString(DJ.KEY_TWITTER));
            user.setImageURL(userObj.optString(DJ.KEY_IMAGE));

            // Convert datetime to human readable format
            String rawDateTime = songObj.optString(Track.KEY_DATETIME);
            String hrTime = Utils.convertTime(rawDateTime, "yyyy-MM-dd'T'HH:mm:ss'Z'",
                    TimeZone.getTimeZone("UTC"), "kk:mm", TimeZone.getTimeZone("America/Chicago"));
            String date = Utils.convertTime(rawDateTime, "yyyy-MM-dd'T'HH:mm:ss'Z'",
                    TimeZone.getTimeZone("UTC"), "MM/dd/yy&EEEE", TimeZone.getTimeZone("America/Chicago"));

            // Store song and DJ characteristics into a Track
            Track track = new Track();
            track.setTitle(songObj.optString(Track.KEY_NAME, ""));
            track.setArtist(songObj.optString(Track.KEY_ARTIST, ""));
            track.setAlbum(songObj.optString(Track.KEY_ALBUM, ""));
            track.setRequest(songObj.optBoolean(Track.KEY_REQUEST, false));
            track.setTime(hrTime);
            track.setDate(date);
            track.setPlayedBy(user); //TODO: To save memory, maybe a reference ID is better here?

            // Check if the date has changed since the last track. If so, add a spacer object to allow proper listView functionality.
            if (!track.getDate().equals(dateHolder)) {
                Log.v(TAG, "Dummy track added at position " + i + "!");
                Log.v(TAG, "dateHolder (" + dateHolder + ") does not match current track date of "
                        + track.getDate());

                // Add a blank entry with a spacer flag to the list BEFORE adding the real track information.
                HashMap<String, Track> dummyTrackMap = new HashMap<String, Track>();
                dummyTrackMap.put("track", track);
                dummyTrackMap.put("spacer", new Track());
                trackList.add(dummyTrackMap);

                // Update dateHolder to this date
                dateHolder = track.getDate();
                Log.v(TAG, "dateHolder is now " + track.getDate());
            }

            // Add this track to the map
            trackMap.put("track", track);

            //Then add the map to the track list.
            trackList.add(trackMap);
        }

        // When finished, return the completed list.
        return trackList;

    } catch (JSONException e) {
        Log.e(TAG, "Failed to get song info from JSON! Tracklist is NOT fully compiled!");
        e.printStackTrace();
        return trackList;
    }
}

From source file:org.webinos.android.util.ModuleUtils.java

public static void install(Context ctx, String module, String path) {
    moduleDir.mkdirs();/*  ww w. j  a  v  a 2s .com*/
    File moduleResource;
    boolean remove_tmp_resource = false;

    /* if no path was specified, it is an error */
    if (path == null || path.isEmpty()) {
        Log.v(TAG, "install: no path specified");
        return;
    }

    /* resolve expected module type from path */
    ModuleType modType = guessModuleType(path);
    if (modType == null) {
        Log.v(TAG, "install: unable to determine module type: path = " + path);
        return;
    }

    /* guess the module name, if not already specified */
    if (module == null || module.isEmpty()) {
        module = guessModuleName(path, modType);
    }

    /* download module if http or https */
    if (path.startsWith("http://") || path.startsWith("https://")) {
        String filename = ModuleUtils.getResourceUriHash(path);
        try {
            moduleResource = downloadResource(new URI(path), filename);
            remove_tmp_resource = true;
        } catch (IOException e) {
            Log.v(TAG, "install: aborting (unable to download resource); exception: " + e + "; resource = "
                    + path);
            return;
        } catch (URISyntaxException e) {
            Log.v(TAG, "install: aborting (invalid URI specified for resource); exception: " + e
                    + "; resource = " + path);
            return;
        }

        /* extract to temp file if an asset */
    } else if (path.startsWith(AssetUtils.ASSET_URI)) {
        try {
            String filename = ModuleUtils.getResourceUriHash(path);
            String destination = new File(resourceDir, filename).getAbsolutePath();
            moduleResource = AssetUtils.writeAssetToFile(ctx, path.substring(AssetUtils.ASSET_URI.length()),
                    destination);
            remove_tmp_resource = true;
        } catch (IOException e) {
            Log.v(TAG,
                    "install: aborting (unable to extract resource); exception: " + e + "; resource = " + path);
            return;
        }

    } else {
        moduleResource = new File(path);
    }

    /* unpack if necessary */
    if (modType.unpacker != null) {
        try {
            moduleResource = unpack(moduleResource, module, modType);
            remove_tmp_resource = true;
        } catch (IOException e) {
            Log.v(TAG,
                    "install: aborting (unable to unpack resource); exception: " + e + "; resource = " + path);
            return;
        }
    }

    /* copy processed package to modules dir */
    File installLocation = getModuleFile(module, modType);
    if (installLocation.exists()) {
        if (!deleteFile(installLocation)) {
            Log.v(TAG, "install: aborting (unable to delete old module version); resource = " + path
                    + ", destination = " + installLocation.toString());
            return;
        }
    }
    if (copyFile(moduleResource, installLocation)) {
        if (remove_tmp_resource)
            deleteFile(moduleResource);
        Log.v(TAG, "install: success; resource = " + path + ", destination = " + installLocation.toString());
        return;
    }
    Log.v(TAG, "install: aborting (unable to copy resource); resource = " + path + ", destination = "
            + installLocation.toString());
}

From source file:org.openschedule.api.impl.EventTemplate.java

public List<Event> getPublishedEvents() {
    Log.v(TAG, "getPublishedEvents : enter");

    Log.v(TAG, "getPublishedEvents : exit");
    return restTemplate.getForObject(buildUri("public"), EventList.class);
}

From source file:com.triggertrap.ZeroConf.java

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    wifiManager = (WifiManager) this.cordova.getActivity()
            .getSystemService(android.content.Context.WIFI_SERVICE);
    wifiInfo = wifiManager.getConnectionInfo();

    lock = wifiManager.createMulticastLock("ZeroConfPluginLock");
    lock.setReferenceCounted(true);/*from  w  ww  . j a v a2s . c  o m*/
    lock.acquire();

    wifi_ip = wifiInfo.getIpAddress();
    Log.v("ZeroConf", "Initialized");
}

From source file:fm.krui.kruifm.HTTPConnection.java

@Override
protected String doInBackground(Void... voids) {
    String serverResponse = null;
    String callbackName = callbackListener.getClass().getName();
    Log.v(TAG, "** Callback listener is set to " + callbackName);

    try {//  ww w .  j  a  va  2s.  c  o m
        Log.i(TAG, "Executing the HTTP " + httpRequest.getMethod() + " request to "
                + httpRequest.getURI().toString());
        HttpResponse response;
        response = httpClient.execute(httpRequest);

        // Grab the returned string as it is returned and make it a String to save memory.
        StringBuilder stringBuilderResponse = inputStreamToString(response.getEntity().getContent());
        serverResponse = stringBuilderResponse.toString();

        // Log the response.
        Log.i(TAG, "** HTTP Response returned: " + response.getStatusLine().getStatusCode() + " - "
                + response.getStatusLine().getReasonPhrase());
        Log.i(TAG, "** " + response.getStatusLine().getStatusCode() + " - "
                + response.getStatusLine().getReasonPhrase());
        Log.i(TAG, "Response body: " + serverResponse);
        httpClient.close();
        return serverResponse;

    } catch (IOException e) {
        Log.e(TAG, "Error when executing HTTP " + httpRequest.getMethod() + " request!");
        e.printStackTrace();
        httpClient.close();
        return serverResponse;
    }
}

From source file:com.oneteam.framework.android.location.gplaces.PlacesService.java

public ArrayList<Place> findPlaces(double latitude, double longitude, String placeSpacification)
        throws IllegalStateException {

    String urlString = makeUrl(latitude, longitude, placeSpacification);

    try {//from  w  w  w. ja va  2s. c  om
        String json = getJSON(urlString);

        System.out.println(json);

        JSONObject object = new JSONObject(json);

        String status = object.getString("status");

        if (!"ok".equalsIgnoreCase(status)) {
            throw new IllegalStateException(status);
        }

        JSONArray array = object.getJSONArray("results");

        ArrayList<Place> arrayList = new ArrayList<Place>(array.length());
        for (int i = 0; i < array.length(); i++) {
            try {
                Place place = Place.jsonToPontoReferencia((JSONObject) array.get(i));
                Log.v("Places Services ", "" + place);
                arrayList.add(place);
            } catch (Exception e) {
            }
        }
        return arrayList;
    } catch (JSONException ex) {
        Logger.getLogger(PlacesService.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:fm.krui.kruifm.TrackUpdateHandler.java

@Override
protected void onPreExecute() {
    Log.v(TAG, "Track Update Handler started!");
}

From source file:gov.sfmta.sfpark.DetailViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.detailview);

    if (annotation == null) {
        Log.v(TAG, "annotation is null");
        return;//from  w ww.ja  v  a 2s  . c  o  m
    }

    // Set up ActionBar
    ActionBar ab = getSupportActionBar();
    ab.setDisplayShowTitleEnabled(true);
    ab.setTitle("  ::  " + annotation.title);
    ab.setIcon(R.drawable.logo_header);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    ab.setDisplayHomeAsUpEnabled(true);

    detailName = (TextView) findViewById(R.id.detailName);
    detailName.setText(annotation.title.toUpperCase());

    garageUse = (TextView) findViewById(R.id.usageText);
    garageUse.setText(annotation.subtitle);

    View availColor = findViewById(R.id.blockColor);
    availColor.setBackgroundColor(
            annotation.onStreet ? annotation.blockColorAvailability : annotation.garageColor);

    if (!annotation.onStreet) {
        addressLabel = (TextView) findViewById(R.id.addressText);
        phoneTextView = (TextView) findViewById(R.id.phoneText);

        addressLabel.setVisibility(View.VISIBLE);
        phoneTextView.setVisibility(View.VISIBLE);

        String str;

        str = annotation.allGarageData.optString("DESC") + " (" + annotation.allGarageData.optString("INTER")
                + ")";

        if (str != null) {
            addressLabel.setText(str);
        }

        str = annotation.allGarageData.optString("TEL");
        if (str != null) {
            phoneTextView.setText(str);
        }

    }

    listLayout = (LinearLayout) findViewById(R.id.detailLinearLayout);
    listLayout.setOrientation(LinearLayout.VERTICAL);

    try {
        parseHours();
        parseRates();
        parseInfo();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.swisscom.android.sunshine.data.FetchWeatherTask.java

/**
 * Helper method to handle insertion of a new location in the weather database.
 *
 * @param locationSetting The location string used to request updates from the server.
 * @param cityName A human-readable city name, e.g "Mountain View"
 * @param lat the latitude of the city//  www .jav  a  2  s.  co  m
 * @param lon the longitude of the city
 * @return the row ID of the added location.
 */
private long addLocation(String locationSetting, String cityName, double lat, double lon) {

    Log.v(LOG_TAG, "inserting " + cityName + ", with coord: " + lat + ", " + lon);

    // First, check if the location with this city name exists in the db
    Cursor cursor = mContext.getContentResolver().query(LocationEntry.CONTENT_URI,
            new String[] { LocationEntry._ID }, LocationEntry.COLUMN_LOCATION_SETTINGS + " = ?",
            new String[] { locationSetting }, null);

    if (cursor.moveToFirst()) {
        Log.v(LOG_TAG, "Found it in the database!");
        int locationIdIndex = cursor.getColumnIndex(LocationEntry._ID);
        return cursor.getLong(locationIdIndex);
    } else {
        Log.v(LOG_TAG, "Didn't find it in the database, inserting now!");
        ContentValues locationValues = new ContentValues();
        locationValues.put(LocationEntry.COLUMN_LOCATION_SETTINGS, locationSetting);
        locationValues.put(LocationEntry.COLUMN_CITY_NAME, cityName);
        locationValues.put(LocationEntry.COLUMN_LATITUDE, lat);
        locationValues.put(LocationEntry.COLUMN_LONGITUDE, lon);

        Uri locationInsertUri = mContext.getContentResolver().insert(LocationEntry.CONTENT_URI, locationValues);

        return ContentUris.parseId(locationInsertUri);
    }
}

From source file:com.auth0.api.internal.ApplicationInfoRequest.java

@Override
protected Request doBuildRequest(Request.Builder builder) {
    final Request request = builder.build();
    Log.v(TAG, "Fetching application info from " + request.urlString());
    return request;
}