Added Nullity Annotations
This commit is contained in:
parent
1dcc447e52
commit
5317c51400
102 changed files with 772 additions and 404 deletions
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.helper;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -31,7 +32,7 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class MenuItemClickHelper {
|
||||
|
||||
public static boolean handleSongMenuClick(AppCompatActivity activity, Song song, MenuItem item) {
|
||||
public static boolean handleSongMenuClick(@NonNull AppCompatActivity activity, @NonNull Song song, @NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_set_as_ringtone:
|
||||
MusicUtil.setRingtone(activity, song.id);
|
||||
|
|
@ -78,7 +79,7 @@ public class MenuItemClickHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean handlePlaylistMenuClick(AppCompatActivity activity, Playlist playlist, MenuItem item) {
|
||||
public static boolean handlePlaylistMenuClick(@NonNull AppCompatActivity activity, @NonNull Playlist playlist, @NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_play:
|
||||
MusicPlayerRemote.openQueue(new ArrayList<>(getPlaylistSongs(activity, playlist)), 0, true);
|
||||
|
|
@ -96,7 +97,8 @@ public class MenuItemClickHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static ArrayList<? extends Song> getPlaylistSongs(Activity activity, Playlist playlist) {
|
||||
@NonNull
|
||||
private static ArrayList<? extends Song> getPlaylistSongs(@NonNull Activity activity, Playlist playlist) {
|
||||
return playlist instanceof AbsSmartPlaylist ?
|
||||
((AbsSmartPlaylist) playlist).getSongs(activity) :
|
||||
PlaylistSongLoader.getPlaylistSongList(activity, playlist.id);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import android.content.Intent;
|
|||
import android.content.ServiceConnection;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
@ -26,11 +28,12 @@ public class MusicPlayerRemote {
|
|||
|
||||
public static final String TAG = MusicPlayerRemote.class.getSimpleName();
|
||||
|
||||
@Nullable
|
||||
public static MusicService musicService;
|
||||
|
||||
private static final WeakHashMap<Context, ServiceBinder> mConnectionMap = new WeakHashMap<>();
|
||||
|
||||
public static ServiceToken bindToService(final Context context,
|
||||
public static ServiceToken bindToService(@NonNull final Context context,
|
||||
final ServiceConnection callback) {
|
||||
Activity realActivity = ((Activity) context).getParent();
|
||||
if (realActivity == null) {
|
||||
|
|
@ -49,7 +52,7 @@ public class MusicPlayerRemote {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void unbindFromService(final ServiceToken token) {
|
||||
public static void unbindFromService(@Nullable final ServiceToken token) {
|
||||
if (token == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -161,6 +164,7 @@ public class MusicPlayerRemote {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ArrayList<Song> getPlayingQueue() {
|
||||
if (musicService != null) {
|
||||
return musicService.getPlayingQueue();
|
||||
|
|
@ -226,11 +230,11 @@ public class MusicPlayerRemote {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean shuffleAllSongs(final Context context, boolean startPlaying) {
|
||||
public static boolean shuffleAllSongs(@NonNull final Context context, boolean startPlaying) {
|
||||
return openAndShuffleQueue(context, SongLoader.getAllSongs(context), startPlaying);
|
||||
}
|
||||
|
||||
public static boolean openAndShuffleQueue(final Context context, final ArrayList<Song> songs, boolean startPlaying) {
|
||||
public static boolean openAndShuffleQueue(final Context context, @NonNull final ArrayList<Song> songs, boolean startPlaying) {
|
||||
if (musicService != null) {
|
||||
if (!songs.isEmpty()) {
|
||||
MusicPlayerRemote.openQueue(songs, new Random().nextInt(songs.size()), startPlaying);
|
||||
|
|
@ -259,7 +263,7 @@ public class MusicPlayerRemote {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean enqueue(ArrayList<Song> songs) {
|
||||
public static boolean enqueue(@NonNull ArrayList<Song> songs) {
|
||||
if (musicService != null) {
|
||||
musicService.addSongs(songs);
|
||||
final String toast = songs.size() == 1 ? musicService.getResources().getString(R.string.added_title_to_playing_queue) : musicService.getResources().getString(R.string.added_x_titles_to_playing_queue, songs.size());
|
||||
|
|
@ -269,7 +273,7 @@ public class MusicPlayerRemote {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean removeFromQueue(Song song) {
|
||||
public static boolean removeFromQueue(@NonNull Song song) {
|
||||
if (musicService != null) {
|
||||
musicService.removeSong(song);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.view.View;
|
||||
|
|
@ -38,9 +40,12 @@ public class PlayingNotificationHelper {
|
|||
public static final String ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED = "com.kabouzeid.gramophone.NOTIFICATION_COLOR_PREFERENCE_CHANGED";
|
||||
public static final String EXTRA_NOTIFICATION_COLORED = "com.kabouzeid.gramophone.EXTRA_NOTIFICATION_COLORED";
|
||||
|
||||
@NonNull
|
||||
private final MusicService service;
|
||||
|
||||
@NonNull
|
||||
private final NotificationManager notificationManager;
|
||||
@Nullable
|
||||
private Notification notification = null;
|
||||
|
||||
private RemoteViews notificationLayout;
|
||||
|
|
@ -54,9 +59,10 @@ public class PlayingNotificationHelper {
|
|||
private boolean isReceiverRegistered;
|
||||
private boolean isNotificationShown;
|
||||
|
||||
@NonNull
|
||||
final IntentFilter intentFilter;
|
||||
|
||||
public PlayingNotificationHelper(final MusicService service) {
|
||||
public PlayingNotificationHelper(@NonNull final MusicService service) {
|
||||
this.service = service;
|
||||
notificationManager = (NotificationManager) service
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
|
@ -65,9 +71,10 @@ public class PlayingNotificationHelper {
|
|||
intentFilter.addAction(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private BroadcastReceiver notificationColorPreferenceChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
public void onReceive(Context context, @NonNull Intent intent) {
|
||||
if (intent.getAction().equals(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED)) {
|
||||
boolean isColored = intent.getBooleanExtra(EXTRA_NOTIFICATION_COLORED, false);
|
||||
if (isNotificationShown && PlayingNotificationHelper.this.isColored != isColored) {
|
||||
|
|
@ -219,7 +226,7 @@ public class PlayingNotificationHelper {
|
|||
});
|
||||
}
|
||||
|
||||
private void setAlbumArt(Bitmap albumArt) {
|
||||
private void setAlbumArt(@Nullable Bitmap albumArt) {
|
||||
if (albumArt != null) {
|
||||
notificationLayout.setImageViewBitmap(R.id.icon, albumArt);
|
||||
notificationLayoutExpanded.setImageViewBitmap(R.id.icon, albumArt);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.app.SearchManager;
|
|||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
|
@ -19,7 +20,8 @@ public class SearchQueryHelper {
|
|||
private static final String ARTIST_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ARTIST + ") = ?";
|
||||
private static final String AND = " AND ";
|
||||
|
||||
public static ArrayList<Song> getSongs(final Context context, final Bundle extras) {
|
||||
@NonNull
|
||||
public static ArrayList<Song> getSongs(@NonNull final Context context, @NonNull final Bundle extras) {
|
||||
final String query = extras.getString(SearchManager.QUERY, null);
|
||||
final String artistName = extras.getString(MediaStore.EXTRA_MEDIA_ARTIST, null);
|
||||
final String albumName = extras.getString(MediaStore.EXTRA_MEDIA_ALBUM, null);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.kabouzeid.gramophone.helper;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
@ -10,7 +12,7 @@ import java.util.List;
|
|||
*/
|
||||
public class ShuffleHelper {
|
||||
|
||||
public static void makeShuffleList(List<Song> listToShuffle, final int current) {
|
||||
public static void makeShuffleList(@NonNull List<Song> listToShuffle, final int current) {
|
||||
if (current >= 0) {
|
||||
Song song = listToShuffle.remove(current);
|
||||
Collections.shuffle(listToShuffle);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
interface BlurProcess {
|
||||
/**
|
||||
|
|
@ -11,5 +12,6 @@ interface BlurProcess {
|
|||
* @param radius the radius in pixels to blur the image
|
||||
* @return the blurred version of the image.
|
||||
*/
|
||||
@Nullable
|
||||
Bitmap blur(Bitmap original, float radius);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Callable;
|
||||
|
|
@ -71,8 +73,9 @@ class JavaBlurProcess implements BlurProcess {
|
|||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Bitmap blur(Bitmap original, float radius) {
|
||||
public Bitmap blur(@NonNull Bitmap original, float radius) {
|
||||
int w = original.getWidth();
|
||||
int h = original.getHeight();
|
||||
int[] currentPixels = new int[w * h];
|
||||
|
|
@ -319,6 +322,7 @@ class JavaBlurProcess implements BlurProcess {
|
|||
_round = round;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
blurIteration(_src, _w, _h, _radius, _totalCores, _coreIndex, _round);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
|
||||
|
|
@ -46,11 +48,13 @@ public class StackBlurManager {
|
|||
/**
|
||||
* Most recent result of blurring
|
||||
*/
|
||||
@Nullable
|
||||
private Bitmap _result;
|
||||
|
||||
/**
|
||||
* Method of blurring
|
||||
*/
|
||||
@NonNull
|
||||
private final BlurProcess _blurProcess;
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +62,7 @@ public class StackBlurManager {
|
|||
*
|
||||
* @param image The image that will be analysed
|
||||
*/
|
||||
public StackBlurManager(Bitmap image) {
|
||||
public StackBlurManager(@NonNull Bitmap image) {
|
||||
_image = Util.getResizedBitmap(image, 500, 500, false);
|
||||
_blurProcess = new JavaBlurProcess();
|
||||
}
|
||||
|
|
@ -68,6 +72,7 @@ public class StackBlurManager {
|
|||
*
|
||||
* @param radius
|
||||
*/
|
||||
@Nullable
|
||||
public Bitmap process(int radius) {
|
||||
_result = _blurProcess.blur(_image, radius);
|
||||
return _result;
|
||||
|
|
@ -78,6 +83,7 @@ public class StackBlurManager {
|
|||
*
|
||||
* @return blurred image
|
||||
*/
|
||||
@Nullable
|
||||
public Bitmap returnBlurredImage() {
|
||||
return _result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue