package io.mokshjn.cosmo.utils;

import android.content.ContentUris;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.text.TextUtils;

/**
 * Created by moksh on 15/3/17.
 */

public class LibUtils {
    public static final String TAG = LibUtils.class.getSimpleName();

    public static Uri getMediaStoreAlbumCoverUri(long albumId) {
        final Uri sArtworkUri = Uri
                .parse("content://media/external/audio/albumart");

        return ContentUris.withAppendedId(sArtworkUri, albumId);
    }

    public static Uri getSongFileUri(long songId) {
        return ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, songId);
    }

    public static String getReadableDurationString(long songDurationMillis) {
        long minutes = (songDurationMillis / 1000) / 60;
        long seconds = (songDurationMillis / 1000) % 60;
        return String.format("%01d:%02d", minutes, seconds);
    }

    public static boolean isArtistNameUnknown(@Nullable String artistName) {
        if (TextUtils.isEmpty(artistName)) return false;
        artistName = artistName.trim().toLowerCase();
        return artistName.equals("unknown") || artistName.equals("<unknown>");
    }
}

@@ -56,20 +56,92 @@
 .Content
-Uris
+Resolver;%0Aimport android.content.ContentUris;%0Aimport android.database.Cursor
 ;%0Aimport
@@ -793,32 +793,542 @@
 songId);%0A    %7D%0A%0A
+    public static String getAlbumByAlbumId(long albumId, ContentResolver resolver) %7B%0A        String album = %22%22;%0A        String selection = %22_id = %22 + albumId;%0A        Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;%0A        Cursor cursor = resolver.query(uri, null, selection, null, null);%0A        if (cursor != null && cursor.moveToFirst()) %7B%0A            album = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM));%0A            cursor.close();%0A        %7D%0A        return album;%0A    %7D%0A%0A
     public stati

implement album helper method