[Android] Code cleaning
Geoffrey Métais
git at videolan.org
Wed Jan 17 15:29:47 CET 2018
vlc-android | branch: chromecast | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 17 14:48:52 2018 +0100| [e49d881d5ebe350981aa8e60bef33d7adb244bce] | committer: Geoffrey Métais
Code cleaning
> https://code.videolan.org/videolan/vlc-android/commit/e49d881d5ebe350981aa8e60bef33d7adb244bce
---
.../org/videolan/vlc/gui/tv/MainTvActivity.java | 82 ++++++++--------------
1 file changed, 29 insertions(+), 53 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index 376a9eb62..61c91ff42 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -201,10 +201,8 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
@Override
protected void onStart() {
super.onStart();
- if (!mBackgroundManager.isAttached())
- mBackgroundManager.attach(getWindow());
- if (mSelectedItem != null)
- TvUtil.updateBackground(mBackgroundManager, mSelectedItem);
+ if (!mBackgroundManager.isAttached()) mBackgroundManager.attach(getWindow());
+ if (mSelectedItem != null) TvUtil.updateBackground(mBackgroundManager, mSelectedItem);
}
@Override
@@ -217,21 +215,16 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
@Override
protected void onResume() {
super.onResume();
- if (mService != null)
- mService.addCallback(this);
- if (mMediaLibrary.isInitiated())
- setmedialibraryListeners();
- else
- setupMediaLibraryReceiver();
+ if (mService != null) mService.addCallback(this);
+ if (mMediaLibrary.isInitiated()) setmedialibraryListeners();
+ else setupMediaLibraryReceiver();
}
@Override
protected void onPause() {
- if (mUpdateTask != null)
- mUpdateTask.cancel(true);
+ if (mUpdateTask != null) mUpdateTask.cancel(true);
super.onPause();
- if (mService != null)
- mService.removeCallback(this);
+ if (mService != null) mService.removeCallback(this);
mMediaLibrary.removeMediaUpdatedCb();
}
@@ -257,12 +250,11 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if ((keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_BUTTON_Y) && mSelectedItem instanceof MediaWrapper) {
+ if ((keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_BUTTON_Y)
+ && mSelectedItem instanceof MediaWrapper) {
MediaWrapper media = (MediaWrapper) mSelectedItem;
- if (media.getType() != MediaWrapper.TYPE_DIR)
- return false;
- final Intent intent = new Intent(this,
- DetailsActivity.class);
+ if (media.getType() != MediaWrapper.TYPE_DIR) return false;
+ final Intent intent = new Intent(this, DetailsActivity.class);
// pass the item information
intent.putExtra("media", (MediaWrapper) mSelectedItem);
intent.putExtra("item", new MediaItemDetails(media.getTitle(), media.getArtist(), media.getAlbum(), media.getLocation(), media.getArtworkURL()));
@@ -281,20 +273,17 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
@Override
public void onMediaUpdated(final MediaWrapper[] mediaList) {
- if (mVideoAdapter == null || mVideoAdapter.size() > NUM_ITEMS_PREVIEW)
- return;
+ if (mVideoAdapter == null || mVideoAdapter.size() > NUM_ITEMS_PREVIEW) return;
mHandler.post(new Runnable() {
@Override
public void run() {
- for (MediaWrapper media : mediaList)
- updateItem(media);
+ for (MediaWrapper media : mediaList) updateItem(media);
}
});
}
public void updateItem(MediaWrapper item) {
- if (item == null)
- return;
+ if (item == null) return;
if (mVideoAdapter != null) {
if (mVideoIndex.containsKey(item.getLocation())) {
mVideoAdapter.notifyArrayItemRangeChanged(mVideoIndex.get(item.getLocation()), 1);
@@ -325,28 +314,22 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
startActivity(new Intent(this, AudioPlayerActivity.class));
return;
}
- CardPresenter.SimpleCard card = (CardPresenter.SimpleCard) item;
- Intent intent = new Intent(mContext, VerticalGridActivity.class);
+ final CardPresenter.SimpleCard card = (CardPresenter.SimpleCard) item;
+ final Intent intent = new Intent(mContext, VerticalGridActivity.class);
intent.putExtra(BROWSER_TYPE, HEADER_CATEGORIES);
intent.putExtra(MusicFragment.AUDIO_CATEGORY, card.getId());
startActivity(intent);
} else if (row.getId() == HEADER_MISC) {
long id = ((CardPresenter.SimpleCard) item).getId();
- if (id == ID_SETTINGS)
- startActivityForResult(new Intent(this, org.videolan.vlc.gui.tv.preferences.PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
- else if (id == ID_ABOUT)
- startActivity(new Intent(this, org.videolan.vlc.gui.tv.AboutActivity.class));
- else if (id == ID_LICENCE)
- startActivity(new Intent(this, org.videolan.vlc.gui.tv.LicenceActivity.class));
- } else {
- TvUtil.openMedia(mContext, item, row);
- }
+ if (id == ID_SETTINGS) startActivityForResult(new Intent(this, org.videolan.vlc.gui.tv.preferences.PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
+ else if (id == ID_ABOUT) startActivity(new Intent(this, org.videolan.vlc.gui.tv.AboutActivity.class));
+ else if (id == ID_LICENCE) startActivity(new Intent(this, org.videolan.vlc.gui.tv.LicenceActivity.class));
+ } else TvUtil.openMedia(mContext, item, row);
}
@Override
public void onClick(View v) {
- Intent intent = new Intent(mContext, SearchActivity.class);
- startActivity(intent);
+ startActivity(new Intent(mContext, SearchActivity.class));
}
@Override
@@ -356,8 +339,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
@Override
protected void onParsingServiceProgress() {
- if (mProgressBar.getVisibility() == View.GONE)
- mHandler.sendEmptyMessage(SHOW_LOADING);
+ if (mProgressBar.getVisibility() == View.GONE) mHandler.sendEmptyMessage(SHOW_LOADING);
}
@Override
@@ -489,9 +471,8 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
private void updateBrowsers() {
if (mBrowserAdapter == null) return;
mBrowserAdapter.clear();
- List<MediaWrapper> directories = AndroidDevices.getMediaDirectoriesList();
- if (!AndroidDevices.showInternalStorage && !directories.isEmpty())
- directories.remove(0);
+ final List<MediaWrapper> directories = AndroidDevices.getMediaDirectoriesList();
+ if (!AndroidDevices.showInternalStorage && !directories.isEmpty()) directories.remove(0);
for (MediaWrapper directory : directories)
mBrowserAdapter.add(new CardPresenter.SimpleCard(HEADER_DIRECTORIES, directory.getTitle(), R.drawable.ic_menu_folder_big, directory.getUri()));
@@ -543,8 +524,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
}
public void updateNowPlayingCard () {
- if (mService == null)
- return;
+ if (mService == null) return;
final boolean hasmedia = mService.hasMedia();
final boolean canSwitch = mService.canSwitchToVideo();
if ((!hasmedia || canSwitch) && mNowPlayingCard != null) {
@@ -561,18 +541,14 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
@Override
public void run() {
if (mNowPlayingCard == null) {
- if (cover != null)
- mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, cover);
- else
- mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, R.drawable.ic_default_cone);
+ if (cover != null) mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, cover);
+ else mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, R.drawable.ic_default_cone);
mCategoriesAdapter.add(0, mNowPlayingCard);
} else {
mNowPlayingCard.setId(MusicFragment.CATEGORY_NOW_PLAYING);
mNowPlayingCard.setName(display);
- if (cover != null)
- mNowPlayingCard.setImage(cover);
- else
- mNowPlayingCard.setImageId(R.drawable.ic_default_cone);
+ if (cover != null) mNowPlayingCard.setImage(cover);
+ else mNowPlayingCard.setImageId(R.drawable.ic_default_cone);
}
mCategoriesAdapter.notifyArrayItemRangeChanged(0,1);
}
More information about the Android
mailing list