Added Nullity Annotations
This commit is contained in:
parent
1dcc447e52
commit
5317c51400
102 changed files with 772 additions and 404 deletions
|
|
@ -8,6 +8,8 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
|
|
@ -181,6 +183,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -226,7 +229,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
public void onLoadingComplete(String imageUri, View view, @NonNull Bitmap loadedImage) {
|
||||
applyPalette(loadedImage);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
|
|
@ -236,13 +239,13 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
);
|
||||
}
|
||||
|
||||
private void applyPalette(Bitmap bitmap) {
|
||||
private void applyPalette(@Nullable Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
public void onGenerated(@NonNull Palette palette) {
|
||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
if (vibrantSwatch != null) {
|
||||
toolbarColor = vibrantSwatch.getRgb();
|
||||
|
|
@ -345,7 +348,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_sleep_timer:
|
||||
|
|
@ -389,7 +392,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDataBaseEvent(DataBaseChangedEvent event) {
|
||||
public void onDataBaseEvent(@NonNull DataBaseChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case DataBaseChangedEvent.SONGS_CHANGED:
|
||||
case DataBaseChangedEvent.ALBUMS_CHANGED:
|
||||
|
|
@ -402,7 +405,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onUIPreferenceChanged(UIPreferenceChangedEvent event) {
|
||||
public void onUIPreferenceChanged(@NonNull UIPreferenceChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ALBUM_CHANGED:
|
||||
setNavigationBarColored((boolean) event.getValue());
|
||||
|
|
@ -417,7 +420,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
}
|
||||
|
||||
@Override
|
||||
public MaterialCab openCab(int menuRes, final MaterialCab.Callback callback) {
|
||||
public MaterialCab openCab(int menuRes, @NonNull final MaterialCab.Callback callback) {
|
||||
if (cab != null && cab.isActive()) cab.finish();
|
||||
cab = new MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
|
@ -109,6 +111,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
private int bottomOffset;
|
||||
|
||||
private Artist artist;
|
||||
@Nullable
|
||||
private Spanned biography;
|
||||
private ArtistAlbumAdapter albumAdapter;
|
||||
private ArtistSongAdapter songAdapter;
|
||||
|
|
@ -219,6 +222,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
albumRecyclerView = ButterKnife.findById(songListHeader, R.id.recycler_view);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -276,7 +280,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
private void loadBiography() {
|
||||
lastFMRestClient.getApiService().getArtistInfo(artist.name, null, new Callback<ArtistInfo>() {
|
||||
@Override
|
||||
public void success(ArtistInfo artistInfo, Response response) {
|
||||
public void success(@NonNull ArtistInfo artistInfo, Response response) {
|
||||
if (artistInfo.getArtist() != null) {
|
||||
String bio = artistInfo.getArtist().getBio().getContent();
|
||||
if (bio != null && !bio.trim().equals("")) {
|
||||
|
|
@ -315,7 +319,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
lastFMRestClient.getApiService().getArtistInfo(artist.name, forceDownload ? "no-cache" : null, new Callback<ArtistInfo>() {
|
||||
@Override
|
||||
public void success(ArtistInfo artistInfo, Response response) {
|
||||
public void success(@NonNull ArtistInfo artistInfo, Response response) {
|
||||
if (artistInfo.getArtist() != null) {
|
||||
List<Image> images = artistInfo.getArtist().getImage();
|
||||
int lastElementIndex = images.size() - 1;
|
||||
|
|
@ -336,7 +340,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
public void onLoadingComplete(String imageUri, View view, @Nullable Bitmap loadedImage) {
|
||||
if (loadedImage != null) {
|
||||
applyPalette(loadedImage);
|
||||
artistImageBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
|
|
@ -373,14 +377,14 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.process(10));
|
||||
}
|
||||
|
||||
private void applyPalette(Bitmap bitmap) {
|
||||
private void applyPalette(@Nullable Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
public void onGenerated(@NonNull Palette palette) {
|
||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
if (vibrantSwatch != null) {
|
||||
toolbarColor = vibrantSwatch.getRgb();
|
||||
|
|
@ -447,7 +451,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_sleep_timer:
|
||||
|
|
@ -531,7 +535,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDataBaseEvent(DataBaseChangedEvent event) {
|
||||
public void onDataBaseEvent(@NonNull DataBaseChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case DataBaseChangedEvent.SONGS_CHANGED:
|
||||
case DataBaseChangedEvent.ALBUMS_CHANGED:
|
||||
|
|
@ -547,7 +551,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onUIPreferenceChanged(UIPreferenceChangedEvent event) {
|
||||
public void onUIPreferenceChanged(@NonNull UIPreferenceChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ARTIST_CHANGED:
|
||||
setNavigationBarColored((boolean) event.getValue());
|
||||
|
|
@ -562,7 +566,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
@Override
|
||||
public MaterialCab openCab(int menuRes, final MaterialCab.Callback callback) {
|
||||
public MaterialCab openCab(int menuRes, @NonNull final MaterialCab.Callback callback) {
|
||||
if (cab != null && cab.isActive()) cab.finish();
|
||||
cab = new MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.design.widget.AppBarLayout.OnOffsetChangedListener;
|
||||
import android.support.design.widget.NavigationView;
|
||||
|
|
@ -87,6 +88,7 @@ public class MainActivity extends AbsFabActivity
|
|||
private PagerAdapter pagerAdapter;
|
||||
private int currentPage = -1;
|
||||
private MaterialCab cab;
|
||||
@Nullable
|
||||
private View navigationDrawerHeader;
|
||||
|
||||
@Override
|
||||
|
|
@ -180,7 +182,7 @@ public class MainActivity extends AbsFabActivity
|
|||
));
|
||||
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem menuItem) {
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||
drawerLayout.closeDrawers();
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.nav_songs:
|
||||
|
|
@ -242,6 +244,7 @@ public class MainActivity extends AbsFabActivity
|
|||
setUpNavigationView();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -307,7 +310,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
if (isAlbumPage()) {
|
||||
getMenuInflater().inflate(R.menu.menu_albums, menu);
|
||||
setUpGridMenu(menu);
|
||||
|
|
@ -329,7 +332,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (drawerToggle.onOptionsItemSelected(item)) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -370,7 +373,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||
public void onUIPreferenceChangedEvent(@NonNull UIPreferenceChangedEvent event) {
|
||||
super.onUIPreferenceChangedEvent(event);
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_OTHER_SCREENS_CHANGED:
|
||||
|
|
@ -402,7 +405,7 @@ public class MainActivity extends AbsFabActivity
|
|||
PreferenceUtils.getInstance(MainActivity.this).setLastStartPage(currentPage);
|
||||
}
|
||||
|
||||
private void handlePlaybackIntent(Intent intent) {
|
||||
private void handlePlaybackIntent(@Nullable Intent intent) {
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -447,7 +450,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
}
|
||||
|
||||
private long parseIdFromIntent(Intent intent, String longKey,
|
||||
private long parseIdFromIntent(@NonNull Intent intent, String longKey,
|
||||
String stringKey) {
|
||||
long id = intent.getLongExtra(longKey, -1);
|
||||
if (id < 0) {
|
||||
|
|
@ -475,6 +478,7 @@ public class MainActivity extends AbsFabActivity
|
|||
return pager.getCurrentItem() == PagerAdapter.MusicFragments.ALBUM.ordinal();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AlbumViewFragment getAlbumFragment() {
|
||||
return (AlbumViewFragment) pagerAdapter.getFragment(PagerAdapter.MusicFragments.ALBUM.ordinal());
|
||||
}
|
||||
|
|
@ -495,7 +499,7 @@ public class MainActivity extends AbsFabActivity
|
|||
// return (PlaylistViewFragment) pagerAdapter.getFragment(PagerAdapter.MusicFragments.PLAYLIST.ordinal());
|
||||
// }
|
||||
|
||||
private void setUpGridMenu(Menu menu) {
|
||||
private void setUpGridMenu(@NonNull Menu menu) {
|
||||
boolean isPortrait = Util.isInPortraitMode(this);
|
||||
int columns = isPortrait ? PreferenceUtils.getInstance(this).getAlbumGridColumns() : PreferenceUtils.getInstance(this).getAlbumGridColumnsLand();
|
||||
String title = isPortrait ? getResources().getString(R.string.action_grid_columns) : getResources().getString(R.string.action_grid_columns_land);
|
||||
|
|
@ -507,7 +511,7 @@ public class MainActivity extends AbsFabActivity
|
|||
gridSizeMenu.getItem(columns - 1).setChecked(true);
|
||||
}
|
||||
|
||||
private boolean handleGridSize(MenuItem item) {
|
||||
private boolean handleGridSize(@NonNull MenuItem item) {
|
||||
int size = -1;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import android.os.Handler;
|
|||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
|
@ -279,7 +281,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
setUpProgressSlider();
|
||||
}
|
||||
|
||||
private void setTint(SeekBar seekBar, int color) {
|
||||
private void setTint(@NonNull SeekBar seekBar, int color) {
|
||||
ColorStateList s1 = ColorStateList.valueOf(color);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
seekBar.setThumbTintList(s1);
|
||||
|
|
@ -380,6 +382,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -443,7 +446,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
public void onLoadingComplete(String imageUri, View view, @NonNull Bitmap loadedImage) {
|
||||
applyPalette(loadedImage);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
}
|
||||
|
|
@ -451,13 +454,13 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
);
|
||||
}
|
||||
|
||||
private void applyPalette(Bitmap bitmap) {
|
||||
private void applyPalette(@Nullable Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
public void onGenerated(@NonNull Palette palette) {
|
||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
if (vibrantSwatch != null) {
|
||||
final int swatchRgb = vibrantSwatch.getRgb();
|
||||
|
|
@ -616,7 +619,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_music_playing, menu);
|
||||
boolean isFavorite = MusicUtil.isFavorite(this, song);
|
||||
menu.findItem(R.id.action_toggle_favorite)
|
||||
|
|
@ -626,7 +629,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_sleep_timer:
|
||||
|
|
@ -701,13 +704,13 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
private static class MusicProgressViewsUpdateHandler extends Handler {
|
||||
private WeakReference<MusicControllerActivity> activityReference;
|
||||
|
||||
public MusicProgressViewsUpdateHandler(final MusicControllerActivity activity, final Looper looper) {
|
||||
public MusicProgressViewsUpdateHandler(final MusicControllerActivity activity, @NonNull final Looper looper) {
|
||||
super(looper);
|
||||
activityReference = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == CMD_UPDATE_PROGRESS_VIEWS) {
|
||||
activityReference.get().updateProgressViews();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
|
@ -33,6 +35,7 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
|
||||
public static final String TAG = PlaylistDetailActivity.class.getSimpleName();
|
||||
|
||||
@NonNull
|
||||
public static String EXTRA_PLAYLIST = "extra_playlist";
|
||||
|
||||
@InjectView(R.id.recycler_view)
|
||||
|
|
@ -42,8 +45,10 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
@InjectView(android.R.id.empty)
|
||||
TextView empty;
|
||||
|
||||
@Nullable
|
||||
private Playlist playlist;
|
||||
private MaterialCab cab;
|
||||
@Nullable
|
||||
private AbsPlaylistSongAdapter adapter;
|
||||
|
||||
@Override
|
||||
|
|
@ -110,6 +115,7 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -122,7 +128,7 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_sleep_timer:
|
||||
|
|
@ -165,7 +171,7 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDataBaseEvent(DataBaseChangedEvent event) {
|
||||
public void onDataBaseEvent(@NonNull DataBaseChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case DataBaseChangedEvent.PLAYLISTS_CHANGED:
|
||||
case DataBaseChangedEvent.DATABASE_CHANGED:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.graphics.Color;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
|
|
@ -74,6 +75,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
setStatusBarThemeColor();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -92,7 +94,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_search, menu);
|
||||
|
||||
final MenuItem search = menu.findItem(R.id.action_search);
|
||||
|
|
@ -111,7 +113,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
public boolean onQueryTextSubmit(@NonNull String query) {
|
||||
onQueryTextChange(query);
|
||||
Util.hideSoftKeyboard(SearchActivity.this);
|
||||
searchView.clearFocus();
|
||||
|
|
@ -119,7 +121,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
public boolean onQueryTextChange(@NonNull String newText) {
|
||||
search(newText);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -142,7 +144,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void search(String query) {
|
||||
private void search(@NonNull String query) {
|
||||
if (searchAdapter != null) {
|
||||
searchAdapter.search(query);
|
||||
empty.setVisibility(searchAdapter.getItemCount() < 1 ? View.VISIBLE : View.GONE);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import android.preference.ListPreference;
|
|||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
|
|
@ -31,7 +33,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
public static final String TAG = SettingsActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_preferences);
|
||||
|
||||
|
|
@ -77,7 +79,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
setSummary(defaultStartPage);
|
||||
defaultStartPage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
public boolean onPreferenceChange(Preference preference, @NonNull Object o) {
|
||||
setSummary(defaultStartPage, o);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -87,7 +89,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
setSummary(generalTheme);
|
||||
generalTheme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
public boolean onPreferenceChange(Preference preference, @NonNull Object o) {
|
||||
setSummary(generalTheme, o);
|
||||
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.THEME_CHANGED, o));
|
||||
return true;
|
||||
|
|
@ -99,7 +101,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
DialogUtils.resolveColor(getActivity(), android.R.attr.textColorPrimary));
|
||||
primaryColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
public boolean onPreferenceClick(@NonNull Preference preference) {
|
||||
new ColorChooserDialog().show(getActivity(), preference.getTitleRes(),
|
||||
PreferenceUtils.getInstance(getActivity()).getThemeColorPrimary());
|
||||
return true;
|
||||
|
|
@ -111,7 +113,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
DialogUtils.resolveColor(getActivity(), android.R.attr.textColorPrimary));
|
||||
accentColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
public boolean onPreferenceClick(@NonNull Preference preference) {
|
||||
new ColorChooserDialog().show(getActivity(), preference.getTitleRes(),
|
||||
PreferenceUtils.getInstance(getActivity()).getThemeColorAccent());
|
||||
return true;
|
||||
|
|
@ -178,13 +180,13 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
});
|
||||
}
|
||||
|
||||
private static void setSummary(Preference preference) {
|
||||
private static void setSummary(@NonNull Preference preference) {
|
||||
setSummary(preference, PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
private static void setSummary(Preference preference, Object value) {
|
||||
private static void setSummary(Preference preference, @NonNull Object value) {
|
||||
String stringValue = value.toString();
|
||||
|
||||
if (preference instanceof ListPreference) {
|
||||
|
|
@ -211,7 +213,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||
protected void onUIPreferenceChangedEvent(@NonNull UIPreferenceChangedEvent event) {
|
||||
super.onUIPreferenceChangedEvent(event);
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_OTHER_SCREENS_CHANGED:
|
||||
|
|
@ -231,7 +233,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
|
|
@ -239,6 +241,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.ui.activities.base;
|
|||
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
|
|
@ -18,7 +19,7 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
private boolean areViewsEnabled;
|
||||
private final Object uiPreferenceChangeListener = new Object() {
|
||||
@Subscribe
|
||||
public void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||
public void onUIPreferenceChangedEvent(@NonNull UIPreferenceChangedEvent event) {
|
||||
AbsBaseActivity.this.onUIPreferenceChangedEvent(event);
|
||||
}
|
||||
};
|
||||
|
|
@ -34,6 +35,7 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected abstract String getTag();
|
||||
|
||||
@Override
|
||||
|
|
@ -57,7 +59,7 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
return areViewsEnabled;
|
||||
}
|
||||
|
||||
protected void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||
protected void onUIPreferenceChangedEvent(@NonNull UIPreferenceChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.THEME_CHANGED:
|
||||
recreate();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.kabouzeid.gramophone.ui.activities.base;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.util.Log;
|
||||
|
|
@ -30,6 +32,7 @@ import butterknife.Optional;
|
|||
public abstract class AbsFabActivity extends AbsPlaybackControlActivity {
|
||||
public static final String TAG = AbsFabActivity.class.getSimpleName();
|
||||
|
||||
@Nullable
|
||||
@Optional
|
||||
@InjectView(R.id.fab)
|
||||
FloatingActionButton fab;
|
||||
|
|
@ -83,7 +86,7 @@ public abstract class AbsFabActivity extends AbsPlaybackControlActivity {
|
|||
|
||||
getFab().setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent event) {
|
||||
public boolean onTouch(View view, @NonNull MotionEvent event) {
|
||||
gestureDetector.onTouchEvent(event);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -119,6 +122,7 @@ public abstract class AbsFabActivity extends AbsPlaybackControlActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected FloatingActionButton getFab() {
|
||||
if (fab == null) {
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
|
|
@ -136,7 +140,7 @@ public abstract class AbsFabActivity extends AbsPlaybackControlActivity {
|
|||
updateFabState();
|
||||
}
|
||||
|
||||
public Pair[] getSharedViewsWithFab(Pair[] sharedViews) {
|
||||
public Pair[] getSharedViewsWithFab(@Nullable Pair[] sharedViews) {
|
||||
Pair[] sharedViewsWithFab;
|
||||
if (sharedViews != null) {
|
||||
sharedViewsWithFab = new Pair[sharedViews.length + 1];
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import android.content.IntentFilter;
|
|||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
|
|
@ -18,6 +20,7 @@ import java.lang.ref.WeakReference;
|
|||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public abstract class AbsPlaybackControlActivity extends AbsBaseActivity {
|
||||
@Nullable
|
||||
private MusicPlayerRemote.ServiceToken serviceToken;
|
||||
private PlaybackStatusReceiver playbackStatusReceiver;
|
||||
|
||||
|
|
@ -88,6 +91,7 @@ public abstract class AbsPlaybackControlActivity extends AbsBaseActivity {
|
|||
|
||||
private static final class PlaybackStatusReceiver extends BroadcastReceiver {
|
||||
|
||||
@NonNull
|
||||
private final WeakReference<AbsPlaybackControlActivity> reference;
|
||||
|
||||
public PlaybackStatusReceiver(final AbsPlaybackControlActivity activity) {
|
||||
|
|
@ -95,7 +99,7 @@ public abstract class AbsPlaybackControlActivity extends AbsBaseActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
public void onReceive(final Context context, @NonNull final Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
switch (action) {
|
||||
case MusicService.META_CHANGED:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.kabouzeid.gramophone.ui.activities.base;
|
|||
import android.app.ActivityManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
|
||||
|
|
@ -21,6 +22,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
private int colorPrimaryDarker;
|
||||
private int colorAccent;
|
||||
|
||||
@Nullable
|
||||
private ActivityManager.TaskDescription taskDescription;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import android.media.MediaScannerConnection;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
|
@ -52,7 +54,6 @@ import java.util.Map;
|
|||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import butterknife.Optional;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
|
|
@ -77,7 +78,6 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
ObservableScrollView observableScrollView;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@Optional
|
||||
@InjectView(R.id.image)
|
||||
ImageView image;
|
||||
@InjectView(R.id.header)
|
||||
|
|
@ -220,9 +220,10 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
protected abstract int getContentViewLayout();
|
||||
|
||||
@NonNull
|
||||
protected abstract List<String> getSongPaths();
|
||||
|
||||
protected void searchWebFor(List<String> strings) {
|
||||
protected void searchWebFor(@NonNull List<String> strings) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String string : strings) {
|
||||
stringBuilder.append(string);
|
||||
|
|
@ -234,7 +235,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case android.R.id.home:
|
||||
|
|
@ -281,7 +282,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
protected void setImageBitmap(final Bitmap bitmap) {
|
||||
protected void setImageBitmap(@Nullable final Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
image.setImageBitmap(bitmap);
|
||||
applyPalette(bitmap);
|
||||
|
|
@ -290,12 +291,12 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void applyPalette(final Bitmap bitmap) {
|
||||
private void applyPalette(@NonNull final Bitmap bitmap) {
|
||||
Palette.from(bitmap)
|
||||
.resizeBitmapSize(100)
|
||||
.generate(new Palette.PaletteAsyncListener() {
|
||||
@Override
|
||||
public void onGenerated(Palette palette) {
|
||||
public void onGenerated(@NonNull Palette palette) {
|
||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
if (vibrantSwatch != null) {
|
||||
paletteColorPrimary = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||
|
|
@ -317,11 +318,11 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void writeValuesToFiles(final Map<FieldKey, String> fieldKeyValueMap) {
|
||||
protected void writeValuesToFiles(@NonNull final Map<FieldKey, String> fieldKeyValueMap) {
|
||||
writeValuesToFiles(fieldKeyValueMap, null, false);
|
||||
}
|
||||
|
||||
protected void writeValuesToFiles(final Map<FieldKey, String> fieldKeyValueMap, final Artwork artwork, final boolean deleteArtwork) {
|
||||
protected void writeValuesToFiles(@NonNull final Map<FieldKey, String> fieldKeyValueMap, @Nullable final Artwork artwork, final boolean deleteArtwork) {
|
||||
Util.hideSoftKeyboard(this);
|
||||
final String writingFileStr = getResources().getString(R.string.writing_file_number);
|
||||
final MaterialDialog progressDialog = new MaterialDialog.Builder(AbsTagEditorActivity.this)
|
||||
|
|
@ -361,7 +362,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
tag.setField(artwork);
|
||||
}
|
||||
audioFile.commit();
|
||||
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||
} catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||
Log.e(TAG, "Error while reading audio file.", e);
|
||||
} catch (CannotWriteException e) {
|
||||
Log.e(TAG, "Error while writing audio file.", e);
|
||||
|
|
@ -390,7 +391,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
}).start();
|
||||
}
|
||||
|
||||
private void rescanMediaAndQuitOnFinish(final OnScannedAllListener listener) {
|
||||
private void rescanMediaAndQuitOnFinish(@NonNull final OnScannedAllListener listener) {
|
||||
String[] toBeScanned = new String[songPaths.size()];
|
||||
toBeScanned = songPaths.toArray(toBeScanned);
|
||||
final int toBeScannedLength = toBeScanned.length;
|
||||
|
|
@ -418,7 +419,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return id;
|
||||
}
|
||||
|
||||
protected void writeValuesToFiles(final Map<FieldKey, String> fieldKeyValueMap, final Artwork artwork) {
|
||||
protected void writeValuesToFiles(@NonNull final Map<FieldKey, String> fieldKeyValueMap, @Nullable final Artwork artwork) {
|
||||
if (artwork == null) {
|
||||
writeValuesToFiles(fieldKeyValueMap, null, true);
|
||||
} else {
|
||||
|
|
@ -426,12 +427,12 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
protected void writeValuesToFiles(final Map<FieldKey, String> fieldKeyValueMap, boolean deleteArtwork) {
|
||||
protected void writeValuesToFiles(@NonNull final Map<FieldKey, String> fieldKeyValueMap, boolean deleteArtwork) {
|
||||
writeValuesToFiles(fieldKeyValueMap, null, deleteArtwork);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
|
||||
protected void onActivityResult(int requestCode, int resultCode, @NonNull Intent imageReturnedIntent) {
|
||||
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_SELECT_IMAGE:
|
||||
|
|
@ -444,6 +445,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
protected abstract void loadImageFromFile(Uri selectedFile);
|
||||
|
||||
@Nullable
|
||||
protected String getSongTitle() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.TITLE);
|
||||
|
|
@ -452,15 +454,16 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private AudioFile getAudioFile(String path) {
|
||||
private AudioFile getAudioFile(@NonNull String path) {
|
||||
try {
|
||||
return AudioFileIO.read(new File(path));
|
||||
} catch (CannotReadException | ReadOnlyFileException | InvalidAudioFrameException | TagException | IOException e) {
|
||||
} catch (@NonNull CannotReadException | ReadOnlyFileException | InvalidAudioFrameException | TagException | IOException e) {
|
||||
Log.e(TAG, "Error while trying to create the AudioFile from java.io.File", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getAlbumTitle() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.ALBUM);
|
||||
|
|
@ -469,6 +472,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getArtistName() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.ARTIST);
|
||||
|
|
@ -477,6 +481,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getAlbumArtistName() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.ALBUM_ARTIST);
|
||||
|
|
@ -485,6 +490,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getGenreName() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.GENRE);
|
||||
|
|
@ -493,6 +499,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getSongYear() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.YEAR);
|
||||
|
|
@ -501,6 +508,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getTrackNumber() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.TRACK);
|
||||
|
|
@ -509,6 +517,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Bitmap getAlbumArt() {
|
||||
try {
|
||||
Artwork artworkTag = getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirstArtwork();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.kabouzeid.gramophone.ui.activities.tageditor;
|
|||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
|
|
@ -67,6 +68,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
setUpViews();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -104,7 +106,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
}
|
||||
lastFMRestClient.getApiService().getAlbumInfo(albumTitleStr, albumArtistNameStr, new Callback<AlbumInfo>() {
|
||||
@Override
|
||||
public void success(AlbumInfo albumInfo, Response response) {
|
||||
public void success(@NonNull AlbumInfo albumInfo, Response response) {
|
||||
if (albumInfo.getAlbum() != null) {
|
||||
List<Image> images = albumInfo.getAlbum().getImage();
|
||||
int lastIndexOfImages = images.size() - 1;
|
||||
|
|
@ -187,6 +189,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
return R.layout.activity_album_tag_editor;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected List<String> getSongPaths() {
|
||||
ArrayList<Song> songs = AlbumSongLoader.getAlbumSongList(this, getId());
|
||||
|
|
@ -198,7 +201,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void loadImageFromFile(final Uri selectedFileUri) {
|
||||
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
|
||||
ImageLoader.getInstance().loadImage(selectedFileUri.toString(),
|
||||
new ImageSize(500, 500),
|
||||
new SimpleImageLoadingListener() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.ui.activities.tageditor;
|
|||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.widget.EditText;
|
||||
|
|
@ -45,6 +46,7 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
setUpViews();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -106,6 +108,7 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
return R.layout.activity_song_tag_editor;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected List<String> getSongPaths() {
|
||||
ArrayList<String> paths = new ArrayList<>(1);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
|
|
@ -12,6 +13,7 @@ import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
|||
public abstract class AbsMainActivityFragment extends Fragment implements KabViewsDisableAble {
|
||||
private boolean areViewsEnabled;
|
||||
|
||||
@NonNull
|
||||
protected MainActivity getMainActivity() {
|
||||
return (MainActivity) getActivity();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
|
|
@ -40,7 +41,7 @@ public abstract class AbsMainActivityRecyclerViewFragment extends AbsMainActivit
|
|||
private RecyclerView.Adapter mAdapter;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(getLayoutRes(), container, false);
|
||||
ButterKnife.inject(this, view);
|
||||
return view;
|
||||
|
|
@ -130,6 +131,7 @@ public abstract class AbsMainActivityRecyclerViewFragment extends AbsMainActivit
|
|||
|
||||
protected abstract RecyclerView.LayoutManager createLayoutManager();
|
||||
|
||||
@NonNull
|
||||
protected abstract RecyclerView.Adapter createAdapter();
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ public class AlbumViewFragment extends AbsMainActivityRecyclerViewFragment {
|
|||
return layoutManager;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.Adapter createAdapter() {
|
||||
return new AlbumAdapter(getMainActivity(), getMainActivity());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
|
|
@ -13,11 +14,13 @@ public class ArtistViewFragment extends AbsMainActivityRecyclerViewFragment {
|
|||
|
||||
public static final String TAG = ArtistViewFragment.class.getSimpleName();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.LayoutManager createLayoutManager() {
|
||||
return new GridLayoutManager(getActivity(), 1);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.Adapter createAdapter() {
|
||||
return new ArtistAdapter(getMainActivity(), getMainActivity());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
|
|
@ -13,11 +14,13 @@ public class PlaylistViewFragment extends AbsMainActivityRecyclerViewFragment {
|
|||
|
||||
public static final String TAG = PlaylistViewFragment.class.getSimpleName();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.LayoutManager createLayoutManager() {
|
||||
return new GridLayoutManager(getActivity(), 1);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.Adapter createAdapter() {
|
||||
return new PlaylistAdapter(getMainActivity(), getMainActivity());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
|
|
@ -13,11 +14,13 @@ public class SongViewFragment extends AbsMainActivityRecyclerViewFragment {
|
|||
|
||||
public static final String TAG = SongViewFragment.class.getSimpleName();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.LayoutManager createLayoutManager() {
|
||||
return new GridLayoutManager(getActivity(), 1);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.Adapter createAdapter() {
|
||||
return new SongAdapter(getMainActivity(), getMainActivity());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue