Now using "butterknife" library in all activities.
This commit is contained in:
parent
ee235f1b5d
commit
6880710920
14 changed files with 317 additions and 282 deletions
|
|
@ -67,4 +67,6 @@ dependencies {
|
|||
|
||||
compile 'com.afollestad:material-dialogs:0.7.6.0'
|
||||
compile 'com.afollestad:material-cab:0.1.4'
|
||||
|
||||
compile 'com.jakewharton:butterknife:6.1.0'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
|
@ -54,9 +55,12 @@ import com.squareup.otto.Subscribe;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
/**
|
||||
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Should be kinda stable ONLY AS IT IS!!!
|
||||
*/
|
||||
public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
||||
|
|
@ -65,14 +69,22 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
private static final int TAG_EDITOR_REQUEST = 2001;
|
||||
private Album album;
|
||||
|
||||
private ObservableRecyclerView recyclerView;
|
||||
@InjectView(R.id.list)
|
||||
ObservableRecyclerView recyclerView;
|
||||
@InjectView(R.id.album_art)
|
||||
ImageView albumArtImageView;
|
||||
@InjectView(R.id.album_art_background)
|
||||
ImageView albumArtBackground;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@InjectView(R.id.album_title)
|
||||
TextView albumTitleView;
|
||||
@InjectView(R.id.list_background)
|
||||
View songsBackgroundView;
|
||||
|
||||
private AlbumSongAdapter adapter;
|
||||
private ArrayList<Song> songs;
|
||||
private ImageView albumArtImageView;
|
||||
private ImageView albumArtBackground;
|
||||
private View songsBackgroundView;
|
||||
private TextView albumTitleView;
|
||||
private Toolbar toolbar;
|
||||
|
||||
private MaterialCab cab;
|
||||
private int headerOffset;
|
||||
private int titleViewHeight;
|
||||
|
|
@ -81,6 +93,63 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
private float toolbarAlpha;
|
||||
private int bottomOffset;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTransparent();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_album_detail);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
App.bus.register(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbum())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
Bundle intentExtras = getIntent().getExtras();
|
||||
int albumId = -1;
|
||||
if (intentExtras != null) {
|
||||
albumId = intentExtras.getInt(AppKeys.E_ALBUM);
|
||||
}
|
||||
album = AlbumLoader.getAlbum(this, albumId);
|
||||
if (album.id == -1) {
|
||||
finish();
|
||||
}
|
||||
|
||||
setUpObservableListViewParams();
|
||||
setUpToolBar();
|
||||
setUpViews();
|
||||
animateFabCircularRevealOnEnterTransitionEnd();
|
||||
}
|
||||
|
||||
private void animateFabCircularRevealOnEnterTransitionEnd() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().getEnterTransition().addListener(new SmallTransitionListener() {
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
albumArtBackground.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
int cx = (albumArtBackground.getLeft() + albumArtBackground.getRight()) / 2;
|
||||
int cy = (albumArtBackground.getTop() + albumArtBackground.getBottom()) / 2;
|
||||
int finalRadius = Math.max(albumArtBackground.getWidth(), albumArtBackground.getHeight());
|
||||
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(albumArtBackground, cx, cy, albumArtImageView.getWidth() / 2, finalRadius);
|
||||
animator.setInterpolator(new DecelerateInterpolator());
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
|
||||
albumArtBackground.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
|
|
@ -108,73 +177,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTransparent();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_album_detail);
|
||||
|
||||
App.bus.register(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbum())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
Bundle intentExtras = getIntent().getExtras();
|
||||
int albumId = -1;
|
||||
if (intentExtras != null) {
|
||||
albumId = intentExtras.getInt(AppKeys.E_ALBUM);
|
||||
}
|
||||
album = AlbumLoader.getAlbum(this, albumId);
|
||||
if (album.id == -1) {
|
||||
finish();
|
||||
}
|
||||
|
||||
initViews();
|
||||
setUpObservableListViewParams();
|
||||
setUpToolBar();
|
||||
setUpViews();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().getEnterTransition().addListener(new SmallTransitionListener() {
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
albumArtBackground.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
int cx = (albumArtBackground.getLeft() + albumArtBackground.getRight()) / 2;
|
||||
int cy = (albumArtBackground.getTop() + albumArtBackground.getBottom()) / 2;
|
||||
int finalRadius = Math.max(albumArtBackground.getWidth(), albumArtBackground.getHeight());
|
||||
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(albumArtBackground, cx, cy, albumArtImageView.getWidth() / 2, finalRadius);
|
||||
animator.setInterpolator(new DecelerateInterpolator());
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
|
||||
albumArtBackground.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
albumArtImageView = (ImageView) findViewById(R.id.album_art);
|
||||
albumArtBackground = (ImageView) findViewById(R.id.album_art_background);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
recyclerView = (ObservableRecyclerView) findViewById(R.id.list);
|
||||
albumTitleView = (TextView) findViewById(R.id.album_title);
|
||||
songsBackgroundView = findViewById(R.id.list_background);
|
||||
}
|
||||
|
||||
private void setUpObservableListViewParams() {
|
||||
bottomOffset = getResources().getDimensionPixelSize(R.dimen.bottom_offset_fab_activity);
|
||||
albumArtViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
|
@ -54,6 +55,7 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
|||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.kabouzeid.gramophone.views.SquareIfPlaceImageView;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||
|
|
@ -62,22 +64,34 @@ import com.squareup.otto.Subscribe;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
/**
|
||||
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Should be kinda stable ONLY AS IT IS!!!
|
||||
*/
|
||||
public class ArtistDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
||||
|
||||
public static final String TAG = ArtistDetailActivity.class.getSimpleName();
|
||||
private Artist artist;
|
||||
|
||||
private ObservableListView songListView;
|
||||
private ImageView artistImage;
|
||||
private ImageView artistImageBackground;
|
||||
private View songsBackgroundView;
|
||||
private TextView artistNameTv;
|
||||
private Toolbar toolbar;
|
||||
@InjectView(R.id.artist_image_background)
|
||||
ImageView artistImageBackground;
|
||||
@InjectView(R.id.artist_image)
|
||||
SquareIfPlaceImageView artistImage;
|
||||
@InjectView(R.id.list_background)
|
||||
View songListBackground;
|
||||
@InjectView(R.id.list)
|
||||
ObservableListView songListView;
|
||||
@InjectView(R.id.artist_name)
|
||||
TextView artistName;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
View songListHeader;
|
||||
RecyclerView albumRecyclerView;
|
||||
|
||||
private MaterialCab cab;
|
||||
private int headerOffset;
|
||||
private int titleViewHeight;
|
||||
|
|
@ -86,47 +100,19 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
private float toolbarAlpha;
|
||||
private int bottomOffset;
|
||||
|
||||
private View songListHeader;
|
||||
private RecyclerView albumRecyclerView;
|
||||
private Artist artist;
|
||||
private Spanned biography;
|
||||
private ArtistAlbumAdapter albumAdapter;
|
||||
private ArtistSongAdapter songAdapter;
|
||||
private ArrayList<Song> songs;
|
||||
private ArrayList<Album> albums;
|
||||
|
||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
scrollY += artistImageViewHeight + titleViewHeight;
|
||||
super.onScrollChanged(scrollY, b, b2);
|
||||
float flexibleRange = artistImageViewHeight - headerOffset;
|
||||
|
||||
// Translate album cover
|
||||
artistImage.setTranslationY(Math.max(-artistImageViewHeight, -scrollY / 2));
|
||||
|
||||
// Translate list background
|
||||
songsBackgroundView.setTranslationY(Math.max(0, -scrollY + artistImageViewHeight));
|
||||
|
||||
// Change alpha of overlay
|
||||
toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||
ViewUtil.setBackgroundAlpha(toolbar, toolbarAlpha, toolbarColor);
|
||||
setStatusBarColor(Util.getColorWithAlpha(cab != null && cab.isActive() ? 1 : toolbarAlpha, toolbarColor));
|
||||
|
||||
// Translate name text
|
||||
int maxTitleTranslationY = artistImageViewHeight;
|
||||
int titleTranslationY = maxTitleTranslationY - scrollY;
|
||||
titleTranslationY = Math.max(headerOffset, titleTranslationY);
|
||||
|
||||
artistNameTv.setTranslationY(titleTranslationY);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTransparent();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_artist_detail);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
App.bus.register(this);
|
||||
|
||||
|
|
@ -158,6 +144,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
artistImageBackground.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
int cx = (artistImageBackground.getLeft() + artistImageBackground.getRight()) / 2;
|
||||
|
|
@ -175,17 +162,32 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
artistImage = (ImageView) findViewById(R.id.artist_image);
|
||||
artistImageBackground = (ImageView) findViewById(R.id.artist_image_background);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
songListView = (ObservableListView) findViewById(R.id.list);
|
||||
artistNameTv = (TextView) findViewById(R.id.artist_name);
|
||||
songsBackgroundView = findViewById(R.id.list_background);
|
||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
scrollY += artistImageViewHeight + titleViewHeight;
|
||||
super.onScrollChanged(scrollY, b, b2);
|
||||
float flexibleRange = artistImageViewHeight - headerOffset;
|
||||
|
||||
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
||||
albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view);
|
||||
}
|
||||
// Translate album cover
|
||||
artistImage.setTranslationY(Math.max(-artistImageViewHeight, -scrollY / 2));
|
||||
|
||||
// Translate list background
|
||||
songListBackground.setTranslationY(Math.max(0, -scrollY + artistImageViewHeight));
|
||||
|
||||
// Change alpha of overlay
|
||||
toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||
ViewUtil.setBackgroundAlpha(toolbar, toolbarAlpha, toolbarColor);
|
||||
setStatusBarColor(Util.getColorWithAlpha(cab != null && cab.isActive() ? 1 : toolbarAlpha, toolbarColor));
|
||||
|
||||
// Translate name text
|
||||
int maxTitleTranslationY = artistImageViewHeight;
|
||||
int titleTranslationY = maxTitleTranslationY - scrollY;
|
||||
titleTranslationY = Math.max(headerOffset, titleTranslationY);
|
||||
|
||||
artistName.setTranslationY(titleTranslationY);
|
||||
}
|
||||
};
|
||||
|
||||
private void setUpObservableListViewParams() {
|
||||
bottomOffset = getResources().getDimensionPixelSize(R.dimen.bottom_offset_fab_activity);
|
||||
|
|
@ -198,13 +200,18 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
||||
albumRecyclerView = ButterKnife.findById(songListHeader, R.id.recycler_view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
artistNameTv.setText(artist.name);
|
||||
artistName.setText(artist.name);
|
||||
|
||||
ViewUtil.addOnGlobalLayoutListener(artistImage, new Runnable() {
|
||||
@Override
|
||||
|
|
@ -239,7 +246,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
contentView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
songsBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
songListBackground.getLayoutParams().height = contentView.getHeight();
|
||||
observableScrollViewCallbacks.onScrollChanged(-(artistImageViewHeight + titleViewHeight), false, false);
|
||||
}
|
||||
});
|
||||
|
|
@ -315,8 +322,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
if (vibrantSwatch != null) {
|
||||
toolbarColor = vibrantSwatch.getRgb();
|
||||
artistNameTv.setBackgroundColor(vibrantSwatch.getRgb());
|
||||
artistNameTv.setTextColor(Util.getOpaqueColor(vibrantSwatch.getTitleTextColor()));
|
||||
artistName.setBackgroundColor(vibrantSwatch.getRgb());
|
||||
artistName.setTextColor(Util.getOpaqueColor(vibrantSwatch.getTitleTextColor()));
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(vibrantSwatch.getRgb());
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
|
|
@ -353,8 +360,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
int defaultBarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
||||
|
||||
toolbarColor = defaultBarColor;
|
||||
artistNameTv.setBackgroundColor(defaultBarColor);
|
||||
artistNameTv.setTextColor(titleTextColor);
|
||||
artistName.setBackgroundColor(defaultBarColor);
|
||||
artistName.setTextColor(titleTextColor);
|
||||
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
|
@ -426,6 +433,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void fixLollipopTransitionImageWrongSize() {
|
||||
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -62,29 +62,39 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
public class MainActivity extends AbsFabActivity
|
||||
implements KabViewsDisableAble, CabHolder, View.OnClickListener {
|
||||
|
||||
public static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
private DrawerLayout drawerLayout;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@InjectView(R.id.tabs)
|
||||
TabLayout tabs;
|
||||
@InjectView(R.id.appbar)
|
||||
AppBarLayout appbar;
|
||||
@InjectView(R.id.pager)
|
||||
ViewPager pager;
|
||||
@InjectView(R.id.navigation_view)
|
||||
NavigationView navigationView;
|
||||
@InjectView(R.id.drawer_layout)
|
||||
DrawerLayout drawerLayout;
|
||||
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
private AppBarLayout appBar;
|
||||
private Toolbar toolbar;
|
||||
private PagerAdapter pagerAdapter;
|
||||
private ViewPager viewPager;
|
||||
private TabLayout tabLayout;
|
||||
private int currentPage = -1;
|
||||
private MaterialCab cab;
|
||||
private NavigationView navigationView;
|
||||
private View navigationDrawerHeader;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
initViews();
|
||||
setUpDrawerLayout();
|
||||
setUpToolbar();
|
||||
setUpViewPager();
|
||||
|
|
@ -102,8 +112,8 @@ public class MainActivity extends AbsFabActivity
|
|||
pagerAdapter.add(fragment.getFragmentClass(), null);
|
||||
}
|
||||
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
viewPager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
|
||||
pager.setAdapter(pagerAdapter);
|
||||
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
|
||||
|
||||
int startPosition = PreferenceUtils.getInstance(this).getDefaultStartPage();
|
||||
startPosition = startPosition == -1 ? PreferenceUtils.getInstance(this).getLastStartPage() : startPosition;
|
||||
|
|
@ -111,8 +121,8 @@ public class MainActivity extends AbsFabActivity
|
|||
|
||||
navigationView.getMenu().getItem(startPosition).setChecked(true);
|
||||
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
tabs.setupWithViewPager(pager);
|
||||
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
|
|
@ -130,16 +140,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
});
|
||||
|
||||
viewPager.setCurrentItem(startPosition);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
viewPager = (ViewPager) findViewById(R.id.pager);
|
||||
tabLayout = (TabLayout) findViewById(R.id.tabs);
|
||||
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
appBar = (AppBarLayout) findViewById(R.id.appbar);
|
||||
pager.setCurrentItem(startPosition);
|
||||
}
|
||||
|
||||
private void setUpToolbar() {
|
||||
|
|
@ -150,7 +151,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
private void setAppBarColor() {
|
||||
appBar.setBackgroundColor(getThemeColorPrimary());
|
||||
appbar.setBackgroundColor(getThemeColorPrimary());
|
||||
}
|
||||
|
||||
private void setUpNavigationView() {
|
||||
|
|
@ -186,19 +187,19 @@ public class MainActivity extends AbsFabActivity
|
|||
switch (menuItem.getItemId()) {
|
||||
case R.id.nav_songs:
|
||||
menuItem.setChecked(true);
|
||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.SONG.ordinal(), true);
|
||||
pager.setCurrentItem(PagerAdapter.MusicFragments.SONG.ordinal(), true);
|
||||
break;
|
||||
case R.id.nav_albums:
|
||||
menuItem.setChecked(true);
|
||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.ALBUM.ordinal(), true);
|
||||
pager.setCurrentItem(PagerAdapter.MusicFragments.ALBUM.ordinal(), true);
|
||||
break;
|
||||
case R.id.nav_artists:
|
||||
menuItem.setChecked(true);
|
||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.ARTIST.ordinal(), true);
|
||||
pager.setCurrentItem(PagerAdapter.MusicFragments.ARTIST.ordinal(), true);
|
||||
break;
|
||||
case R.id.nav_playlists:
|
||||
menuItem.setChecked(true);
|
||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.PLAYLIST.ordinal(), true);
|
||||
pager.setCurrentItem(PagerAdapter.MusicFragments.PLAYLIST.ordinal(), true);
|
||||
break;
|
||||
case R.id.nav_settings:
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
|
|
@ -278,7 +279,7 @@ public class MainActivity extends AbsFabActivity
|
|||
try {
|
||||
super.enableViews();
|
||||
toolbar.setEnabled(true);
|
||||
((AbsMainActivityFragment) pagerAdapter.getItem(viewPager.getCurrentItem())).enableViews();
|
||||
((AbsMainActivityFragment) pagerAdapter.getItem(pager.getCurrentItem())).enableViews();
|
||||
} catch (NullPointerException e) {
|
||||
//Log.e(TAG, "wasn't able to enable the views", e);
|
||||
}
|
||||
|
|
@ -288,7 +289,7 @@ public class MainActivity extends AbsFabActivity
|
|||
public void disableViews() {
|
||||
try {
|
||||
super.disableViews();
|
||||
((AbsMainActivityFragment) pagerAdapter.getItem(viewPager.getCurrentItem())).disableViews();
|
||||
((AbsMainActivityFragment) pagerAdapter.getItem(pager.getCurrentItem())).disableViews();
|
||||
} catch (NullPointerException e) {
|
||||
//Log.e(TAG, "wasn't able to disable the views", e);
|
||||
}
|
||||
|
|
@ -459,7 +460,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
// private boolean isArtistPage() {
|
||||
// return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.ARTIST.ordinal();
|
||||
// return pager.getCurrentItem() == PagerAdapter.MusicFragments.ARTIST.ordinal();
|
||||
// }
|
||||
//
|
||||
// public ArtistViewFragment getArtistFragment() {
|
||||
|
|
@ -467,7 +468,7 @@ public class MainActivity extends AbsFabActivity
|
|||
// }
|
||||
|
||||
private boolean isAlbumPage() {
|
||||
return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.ALBUM.ordinal();
|
||||
return pager.getCurrentItem() == PagerAdapter.MusicFragments.ALBUM.ordinal();
|
||||
}
|
||||
|
||||
public AlbumViewFragment getAlbumFragment() {
|
||||
|
|
@ -475,7 +476,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
// private boolean isSongPage() {
|
||||
// return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.SONG.ordinal();
|
||||
// return pager.getCurrentItem() == PagerAdapter.MusicFragments.SONG.ordinal();
|
||||
// }
|
||||
//
|
||||
// public SongViewFragment getSongFragment() {
|
||||
|
|
@ -483,7 +484,7 @@ public class MainActivity extends AbsFabActivity
|
|||
// }
|
||||
|
||||
private boolean isPlaylistPage() {
|
||||
return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.PLAYLIST.ordinal();
|
||||
return pager.getCurrentItem() == PagerAdapter.MusicFragments.PLAYLIST.ordinal();
|
||||
}
|
||||
|
||||
// public PlaylistViewFragment getPlaylistFragment() {
|
||||
|
|
@ -604,14 +605,14 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
public void addOnAppBarOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
||||
appBar.addOnOffsetChangedListener(onOffsetChangedListener);
|
||||
appbar.addOnOffsetChangedListener(onOffsetChangedListener);
|
||||
}
|
||||
|
||||
public void removeOnAppBArOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
||||
appBar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
||||
appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
||||
}
|
||||
|
||||
public int getTotalAppBarScrollingRange() {
|
||||
return appBar.getTotalScrollRange();
|
||||
return appbar.getTotalScrollRange();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
|
|
@ -26,6 +27,7 @@ import android.view.ViewGroup;
|
|||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -59,30 +61,49 @@ import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListene
|
|||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
public class MusicControllerActivity extends AbsFabActivity {
|
||||
|
||||
public static final String TAG = MusicControllerActivity.class.getSimpleName();
|
||||
private static final int COLOR_TRANSITION_TIME = 400;
|
||||
private static final int UPDATE_PROGRESS_VIEWS = 1;
|
||||
|
||||
private Song song;
|
||||
private SquareIfPlaceImageView albumArt;
|
||||
private ImageView albumArtBackground;
|
||||
private TextView songTitle;
|
||||
private TextView songArtist;
|
||||
private TextView currentSongProgress;
|
||||
private TextView totalSongDuration;
|
||||
private View footer;
|
||||
private SeekBar progressSlider;
|
||||
private ImageButton nextButton;
|
||||
private ImageButton prevButton;
|
||||
private ImageButton repeatButton;
|
||||
private ImageButton shuffleButton;
|
||||
private View mediaControllerContainer;
|
||||
private CardView playbackControllerCard;
|
||||
private Toolbar toolbar;
|
||||
@InjectView(R.id.song_title)
|
||||
TextView songTitle;
|
||||
@InjectView(R.id.song_artist)
|
||||
TextView songArtist;
|
||||
@InjectView(R.id.footer)
|
||||
LinearLayout footer;
|
||||
@InjectView(R.id.playback_controller_card)
|
||||
CardView playbackControllerCard;
|
||||
@InjectView(R.id.prev_button)
|
||||
ImageButton prevButton;
|
||||
@InjectView(R.id.next_button)
|
||||
ImageButton nextButton;
|
||||
@InjectView(R.id.repeat_button)
|
||||
ImageButton repeatButton;
|
||||
@InjectView(R.id.shuffle_button)
|
||||
ImageButton shuffleButton;
|
||||
@InjectView(R.id.media_controller_container)
|
||||
RelativeLayout mediaControllerContainer;
|
||||
@InjectView(R.id.album_art_background)
|
||||
ImageView albumArtBackground;
|
||||
@InjectView(R.id.album_art)
|
||||
SquareIfPlaceImageView albumArt;
|
||||
@InjectView(R.id.song_current_progress)
|
||||
TextView songCurrentProgress;
|
||||
@InjectView(R.id.song_total_time)
|
||||
TextView songTotalTime;
|
||||
@InjectView(R.id.progress_slider)
|
||||
SeekBar progressSlider;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
private int lastFooterColor = -1;
|
||||
private int lastTextColor = -2;
|
||||
|
||||
private Handler progressViewsUpdateHandler;
|
||||
private HandlerThread handlerThread;
|
||||
|
||||
|
|
@ -93,6 +114,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
private boolean alternativeProgressSlider;
|
||||
private boolean showPlaybackControllerCard;
|
||||
|
||||
private Song song;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTransparent();
|
||||
|
|
@ -102,8 +125,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
initAppearanceVarsFromSharedPrefs();
|
||||
|
||||
setContentView(alternativeProgressSlider ? R.layout.activity_music_controller_alternative_progress_slider : R.layout.activity_music_controller);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
initViews();
|
||||
moveSeekBarIntoPlace();
|
||||
adjustTitleBoxSize();
|
||||
setUpPlaybackControllerCard();
|
||||
|
|
@ -142,6 +165,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
mediaControllerContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
int cx = (getFab().getLeft() + getFab().getRight()) / 2;
|
||||
|
|
@ -225,24 +249,6 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
mediaControllerContainer.setBackgroundColor(showPlaybackControllerCard ? Color.TRANSPARENT : Util.resolveColor(this, R.attr.music_controller_container_color));
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
nextButton = (ImageButton) findViewById(R.id.next_button);
|
||||
prevButton = (ImageButton) findViewById(R.id.prev_button);
|
||||
repeatButton = (ImageButton) findViewById(R.id.repeat_button);
|
||||
shuffleButton = (ImageButton) findViewById(R.id.shuffle_button);
|
||||
albumArt = (SquareIfPlaceImageView) findViewById(R.id.album_art);
|
||||
albumArtBackground = (ImageView) findViewById(R.id.album_art_background);
|
||||
songTitle = (TextView) findViewById(R.id.song_title);
|
||||
songArtist = (TextView) findViewById(R.id.song_artist);
|
||||
currentSongProgress = (TextView) findViewById(R.id.song_current_progress);
|
||||
totalSongDuration = (TextView) findViewById(R.id.song_total_time);
|
||||
footer = findViewById(R.id.footer);
|
||||
progressSlider = (SeekBar) findViewById(R.id.progress_slider);
|
||||
mediaControllerContainer = findViewById(R.id.media_controller_container);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
playbackControllerCard = (CardView) findViewById(R.id.playback_controller_card);
|
||||
}
|
||||
|
||||
private void setUpMusicControllers() {
|
||||
setUpPrevNext();
|
||||
setUpRepeatButton();
|
||||
|
|
@ -376,8 +382,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
getCurrentSong();
|
||||
setHeadersText();
|
||||
setUpAlbumArtAndApplyPalette();
|
||||
totalSongDuration.setText(MusicUtil.getReadableDurationString(song.duration));
|
||||
currentSongProgress.setText(MusicUtil.getReadableDurationString(0));
|
||||
songTotalTime.setText(MusicUtil.getReadableDurationString(song.duration));
|
||||
songCurrentProgress.setText(MusicUtil.getReadableDurationString(0));
|
||||
}
|
||||
|
||||
private void setHeadersText() {
|
||||
|
|
@ -497,8 +503,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
public void run() {
|
||||
progressSlider.setMax(totalMillis);
|
||||
progressSlider.setProgress(progressMillis);
|
||||
currentSongProgress.setText(MusicUtil.getReadableDurationString(progressMillis));
|
||||
totalSongDuration.setText(MusicUtil.getReadableDurationString(totalMillis));
|
||||
songCurrentProgress.setText(MusicUtil.getReadableDurationString(progressMillis));
|
||||
songTotalTime.setText(MusicUtil.getReadableDurationString(totalMillis));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ import java.util.ArrayList;
|
|||
public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder {
|
||||
|
||||
public static final String TAG = PlaylistDetailActivity.class.getSimpleName();
|
||||
|
||||
private Playlist playlist;
|
||||
private MaterialCab cab;
|
||||
private PlaylistSongAdapter adapter;
|
||||
private ArrayList<PlaylistSong> songs;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.SearchAdapter;
|
||||
|
|
@ -23,13 +24,23 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
|||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
public class SearchActivity extends AbsBaseActivity {
|
||||
|
||||
public static final String TAG = SearchActivity.class.getSimpleName();
|
||||
private RecyclerView recyclerView;
|
||||
@InjectView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@SuppressWarnings("ButterKnifeNoViewWithId")
|
||||
@InjectView(android.R.id.empty)
|
||||
TextView empty;
|
||||
|
||||
|
||||
private SearchView searchView;
|
||||
private SearchAdapter searchAdapter;
|
||||
private View noResults;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
|
|
@ -37,9 +48,8 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
setTitle(null);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_search);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
noResults = findViewById(android.R.id.empty);
|
||||
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
searchAdapter = new SearchAdapter(this);
|
||||
recyclerView.setAdapter(searchAdapter);
|
||||
|
|
@ -55,7 +65,6 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||
setSupportActionBar(toolbar);
|
||||
//noinspection ConstantConditions
|
||||
|
|
@ -136,7 +145,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
private void search(String query) {
|
||||
if (searchAdapter != null) {
|
||||
searchAdapter.search(query);
|
||||
noResults.setVisibility(searchAdapter.getItemCount() < 1 ? View.VISIBLE : View.GONE);
|
||||
empty.setVisibility(searchAdapter.getItemCount() < 1 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import com.squareup.otto.Subscribe;
|
|||
*/
|
||||
public abstract class AbsBaseActivity extends AbsThemeActivity implements KabViewsDisableAble {
|
||||
|
||||
private App app;
|
||||
private boolean areViewsEnabled;
|
||||
private final Object uiPreferenceChangeListener = new Object() {
|
||||
@Subscribe
|
||||
|
|
@ -34,13 +33,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
}
|
||||
}
|
||||
|
||||
protected App getApp() {
|
||||
if (app == null) {
|
||||
app = (App) getApplicationContext();
|
||||
}
|
||||
return app;
|
||||
}
|
||||
|
||||
protected abstract String getTag();
|
||||
|
||||
@Override
|
||||
|
|
@ -64,7 +56,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
return areViewsEnabled;
|
||||
}
|
||||
|
||||
|
||||
protected void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.THEME_CHANGED:
|
||||
|
|
|
|||
|
|
@ -20,18 +20,26 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
|||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.views.PlayPauseDrawable;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import butterknife.Optional;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public abstract class AbsFabActivity extends AbsPlaybackStatusActivity {
|
||||
public static final String TAG = AbsFabActivity.class.getSimpleName();
|
||||
|
||||
private FloatingActionButton fab;
|
||||
@Optional
|
||||
@InjectView(R.id.fab)
|
||||
FloatingActionButton fab;
|
||||
|
||||
private PlayPauseDrawable playPauseDrawable;
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
ButterKnife.inject(this);
|
||||
setUpFab();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||
|
|
@ -50,6 +51,10 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import butterknife.Optional;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
|
|
@ -63,31 +68,25 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
private int paletteColorPrimary;
|
||||
private boolean isInNoImageMode;
|
||||
|
||||
private FloatingActionButton fab;
|
||||
private ObservableScrollView scrollView;
|
||||
private Toolbar toolBar;
|
||||
private ImageView image;
|
||||
private View header;
|
||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
float alpha;
|
||||
if (!isInNoImageMode) {
|
||||
alpha = 1 - (float) Math.max(0, headerVariableSpace - scrollY) / headerVariableSpace;
|
||||
} else {
|
||||
header.setTranslationY(scrollY);
|
||||
alpha = 1;
|
||||
}
|
||||
ViewUtil.setBackgroundAlpha(toolBar, alpha, paletteColorPrimary);
|
||||
image.setTranslationY(scrollY / 2);
|
||||
}
|
||||
};
|
||||
@InjectView(R.id.fab)
|
||||
FloatingActionButton fab;
|
||||
@InjectView(R.id.observableScrollView)
|
||||
ObservableScrollView observableScrollView;
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@Optional
|
||||
@InjectView(R.id.image)
|
||||
ImageView image;
|
||||
@InjectView(R.id.header)
|
||||
LinearLayout header;
|
||||
|
||||
private List<String> songPaths;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getContentViewLayout());
|
||||
ButterKnife.inject(this);
|
||||
|
||||
getIntentExtras();
|
||||
|
||||
|
|
@ -99,23 +98,13 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
headerVariableSpace = getResources().getDimensionPixelSize(R.dimen.tagEditorHeaderVariableSpace);
|
||||
|
||||
|
||||
initViews();
|
||||
setUpViews();
|
||||
|
||||
setSupportActionBar(toolBar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
scrollView = (ObservableScrollView) findViewById(R.id.observableScrollView);
|
||||
toolBar = (Toolbar) findViewById(R.id.toolbar);
|
||||
image = (ImageView) findViewById(R.id.image);
|
||||
header = findViewById(R.id.header);
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
resetColors();
|
||||
setUpScrollView();
|
||||
|
|
@ -124,9 +113,24 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
}
|
||||
|
||||
private void setUpScrollView() {
|
||||
scrollView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||
observableScrollView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||
}
|
||||
|
||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
float alpha;
|
||||
if (!isInNoImageMode) {
|
||||
alpha = 1 - (float) Math.max(0, headerVariableSpace - scrollY) / headerVariableSpace;
|
||||
} else {
|
||||
header.setTranslationY(scrollY);
|
||||
alpha = 1;
|
||||
}
|
||||
ViewUtil.setBackgroundAlpha(toolbar, alpha, paletteColorPrimary);
|
||||
image.setTranslationY(scrollY / 2);
|
||||
}
|
||||
};
|
||||
|
||||
private void setUpImageView() {
|
||||
loadCurrentImage();
|
||||
image.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
@ -189,9 +193,8 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
|
||||
private void resetColors() {
|
||||
final int primaryColor = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
paletteColorPrimary = primaryColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
paletteColorPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditor())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
|
|
@ -237,12 +240,12 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
isInNoImageMode = true;
|
||||
image.setVisibility(View.GONE);
|
||||
image.setEnabled(false);
|
||||
scrollView.setPadding(0, Util.getActionBarSize(this), 0, 0);
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
observableScrollView.setPadding(0, Util.getActionBarSize(this), 0, 0);
|
||||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
|
||||
paletteColorPrimary = getIntent().getIntExtra(AppKeys.E_PALETTE,
|
||||
PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||
toolBar.setBackgroundColor(paletteColorPrimary);
|
||||
toolbar.setBackgroundColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
|
|
@ -285,9 +288,8 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
public void onGenerated(Palette palette) {
|
||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||
if (vibrantSwatch != null) {
|
||||
final int vibrantColor = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||
paletteColorPrimary = vibrantColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
paletteColorPrimary = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditor())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
|
|
|
|||
|
|
@ -33,22 +33,30 @@ import java.util.EnumMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
||||
|
||||
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
|
||||
|
||||
@InjectView(R.id.album_title)
|
||||
EditText albumTitle;
|
||||
@InjectView(R.id.album_artist)
|
||||
EditText albumArtist;
|
||||
@InjectView(R.id.genre)
|
||||
EditText genre;
|
||||
@InjectView(R.id.year)
|
||||
EditText year;
|
||||
|
||||
private Bitmap albumArtBitmap;
|
||||
private boolean deleteAlbumArt;
|
||||
|
||||
private EditText albumTitle;
|
||||
private EditText albumArtistName;
|
||||
private EditText genreName;
|
||||
private EditText year;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
initViews();
|
||||
setUpViews();
|
||||
}
|
||||
|
||||
|
|
@ -57,26 +65,19 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
return TAG;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
albumTitle = (EditText) findViewById(R.id.album_title);
|
||||
albumArtistName = (EditText) findViewById(R.id.album_artist);
|
||||
genreName = (EditText) findViewById(R.id.genre);
|
||||
year = (EditText) findViewById(R.id.year);
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
fillViewsWithFileTags();
|
||||
albumTitle.addTextChangedListener(this);
|
||||
albumArtistName.addTextChangedListener(this);
|
||||
genreName.addTextChangedListener(this);
|
||||
albumArtist.addTextChangedListener(this);
|
||||
genre.addTextChangedListener(this);
|
||||
year.addTextChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
private void fillViewsWithFileTags() {
|
||||
albumTitle.setText(getAlbumTitle());
|
||||
albumArtistName.setText(getAlbumArtistName());
|
||||
genreName.setText(getGenreName());
|
||||
albumArtist.setText(getAlbumArtistName());
|
||||
genre.setText(getGenreName());
|
||||
year.setText(getSongYear());
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
@Override
|
||||
protected void getImageFromLastFM() {
|
||||
String albumTitleStr = albumTitle.getText().toString();
|
||||
String albumArtistNameStr = albumArtistName.getText().toString();
|
||||
String albumArtistNameStr = albumArtist.getText().toString();
|
||||
if (albumArtistNameStr.trim().equals("") || albumTitleStr.trim().equals("")) {
|
||||
Toast.makeText(this, getResources().getString(R.string.album_or_artist_empty), Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
|
|
@ -130,7 +131,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
protected void searchImageOnWeb() {
|
||||
List<String> query = new ArrayList<>();
|
||||
query.add(albumTitle.getText().toString());
|
||||
query.add(albumArtistName.getText().toString());
|
||||
query.add(albumArtist.getText().toString());
|
||||
searchWebFor(query);
|
||||
}
|
||||
|
||||
|
|
@ -147,9 +148,9 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
||||
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||
fieldKeyValueMap.put(FieldKey.ARTIST, albumArtistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ARTIST, albumArtist.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtist.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.GENRE, genre.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||
|
||||
File albumArtFile = MusicUtil.createAlbumArtFile(String.valueOf(getId()));
|
||||
|
|
|
|||
|
|
@ -15,22 +15,32 @@ import java.util.EnumMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
public class SongTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
||||
|
||||
public static final String TAG = SongTagEditorActivity.class.getSimpleName();
|
||||
private EditText songTitle;
|
||||
private EditText albumTitle;
|
||||
private EditText artistName;
|
||||
private EditText genreName;
|
||||
private EditText year;
|
||||
private EditText trackNumber;
|
||||
|
||||
@InjectView(R.id.title1)
|
||||
EditText songTitle;
|
||||
@InjectView(R.id.title2)
|
||||
EditText albumTitle;
|
||||
@InjectView(R.id.artist)
|
||||
EditText artist;
|
||||
@InjectView(R.id.genre)
|
||||
EditText genre;
|
||||
@InjectView(R.id.year)
|
||||
EditText year;
|
||||
@InjectView(R.id.track_number)
|
||||
EditText trackNumber;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
setNoImageMode();
|
||||
initViews();
|
||||
setUpViews();
|
||||
}
|
||||
|
||||
|
|
@ -39,31 +49,21 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
return TAG;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
songTitle = (EditText) findViewById(R.id.title1);
|
||||
albumTitle = (EditText) findViewById(R.id.title2);
|
||||
artistName = (EditText) findViewById(R.id.artist);
|
||||
genreName = (EditText) findViewById(R.id.genre);
|
||||
year = (EditText) findViewById(R.id.year);
|
||||
trackNumber = (EditText) findViewById(R.id.track_number);
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
fillViewsWithFileTags();
|
||||
songTitle.addTextChangedListener(this);
|
||||
albumTitle.addTextChangedListener(this);
|
||||
artistName.addTextChangedListener(this);
|
||||
genreName.addTextChangedListener(this);
|
||||
artist.addTextChangedListener(this);
|
||||
genre.addTextChangedListener(this);
|
||||
year.addTextChangedListener(this);
|
||||
trackNumber.addTextChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
private void fillViewsWithFileTags() {
|
||||
songTitle.setText(getSongTitle());
|
||||
albumTitle.setText(getAlbumTitle());
|
||||
artistName.setText(getArtistName());
|
||||
genreName.setText(getGenreName());
|
||||
artist.setText(getArtistName());
|
||||
genre.setText(getGenreName());
|
||||
year.setText(getSongYear());
|
||||
trackNumber.setText(getTrackNumber());
|
||||
}
|
||||
|
|
@ -93,8 +93,8 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
fieldKeyValueMap.put(FieldKey.TITLE, songTitle.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ARTIST, artistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ARTIST, artist.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.GENRE, genre.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.TRACK, trackNumber.getText().toString());
|
||||
writeValuesToFiles(fieldKeyValueMap);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:id="@+id/navigation_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
|
@ -23,11 +23,11 @@
|
|||
android:id="@android:id/empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/empty_text_size"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/no_results"
|
||||
android:layout_gravity="center" />
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/empty_text_size" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue