Design optimizations
This commit is contained in:
parent
31f794336a
commit
5e4f8c8f17
8 changed files with 28 additions and 62 deletions
|
|
@ -11,7 +11,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.AddToPlaylistDialogHelper;
|
import com.kabouzeid.gramophone.helper.AddToPlaylistDialogHelper;
|
||||||
|
|
@ -34,6 +33,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class AlbumSongAdapter extends RecyclerView.Adapter<AlbumSongAdapter.ViewHolder> {
|
public class AlbumSongAdapter extends RecyclerView.Adapter<AlbumSongAdapter.ViewHolder> {
|
||||||
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
||||||
|
|
||||||
protected Activity activity;
|
protected Activity activity;
|
||||||
protected List<Song> dataSet;
|
protected List<Song> dataSet;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities;
|
package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
|
@ -97,17 +98,18 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
app = (App) getApplicationContext();
|
app = (App) getApplicationContext();
|
||||||
setTheme(app.getAppTheme());
|
setTheme(app.getAppTheme());
|
||||||
setUpTranslucence();
|
setUpTranslucence(true, false);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_album_detail);
|
setContentView(R.layout.activity_album_detail);
|
||||||
|
|
||||||
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
||||||
|
if (Util.hasLollipopSDK()) getWindow().setNavigationBarColor(getResources().getColor(R.color.materialmusic_default_bar_color));
|
||||||
|
|
||||||
Bundle intentExtras = getIntent().getExtras();
|
Bundle intentExtras = getIntent().getExtras();
|
||||||
int albumId = -1;
|
int albumId = -1;
|
||||||
|
|
@ -178,6 +180,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private void applyPalette(Bitmap bitmap) {
|
private void applyPalette(Bitmap bitmap) {
|
||||||
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
|
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
Palette.Swatch swatch = palette.getVibrantSwatch();
|
Palette.Swatch swatch = palette.getVibrantSwatch();
|
||||||
|
|
@ -185,6 +188,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
toolbarColor = swatch.getRgb();
|
toolbarColor = swatch.getRgb();
|
||||||
albumTitleView.setBackgroundColor(swatch.getRgb());
|
albumTitleView.setBackgroundColor(swatch.getRgb());
|
||||||
albumTitleView.setTextColor(swatch.getTitleTextColor());
|
albumTitleView.setTextColor(swatch.getTitleTextColor());
|
||||||
|
if (Util.hasLollipopSDK()) getWindow().setNavigationBarColor(swatch.getRgb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -192,7 +196,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private void setUpListView() {
|
private void setUpListView() {
|
||||||
recyclerView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
recyclerView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||||
setListViewPadding();
|
recyclerView.setPadding(0, albumArtViewHeight + titleViewHeight, 0, 0);
|
||||||
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
|
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
contentView.post(new Runnable() {
|
contentView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -203,29 +207,12 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListViewPadding() {
|
|
||||||
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
|
||||||
recyclerView.setPadding(0, albumArtViewHeight + titleViewHeight, 0, Util.getNavigationBarHeight(this));
|
|
||||||
} else {
|
|
||||||
recyclerView.setPadding(0, albumArtViewHeight + titleViewHeight, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpToolBar() {
|
private void setUpToolBar() {
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
getSupportActionBar().setTitle(null);
|
getSupportActionBar().setTitle(null);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpTranslucence() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
||||||
Util.setStatusBarTranslucent(getWindow(), true);
|
|
||||||
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
|
||||||
Util.setNavBarTranslucent(getWindow(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpSongsAdapter() {
|
private void setUpSongsAdapter() {
|
||||||
final List<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator());
|
final List<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator());
|
||||||
final AlbumSongAdapter albumSongAdapter = new AlbumSongAdapter(this, songs);
|
final AlbumSongAdapter albumSongAdapter = new AlbumSongAdapter(this, songs);
|
||||||
|
|
|
||||||
|
|
@ -113,14 +113,15 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setUpTranslucence(true, true);
|
setUpTranslucence(true, false);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_artist_detail);
|
setContentView(R.layout.activity_artist_detail);
|
||||||
|
|
||||||
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
||||||
|
if (Util.hasLollipopSDK()) getWindow().setNavigationBarColor(getResources().getColor(R.color.materialmusic_default_bar_color));
|
||||||
|
|
||||||
getIntentExtras();
|
getIntentExtras();
|
||||||
initViews();
|
initViews();
|
||||||
|
|
@ -174,9 +175,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private void setUpSongListView() {
|
private void setUpSongListView() {
|
||||||
songListView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
songListView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||||
|
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, 0);
|
||||||
setListViewPadding();
|
|
||||||
|
|
||||||
songListView.addHeaderView(songListHeader);
|
songListView.addHeaderView(songListHeader);
|
||||||
|
|
||||||
final List<Song> songs = ArtistSongLoader.getArtistSongList(this, artist.id);
|
final List<Song> songs = ArtistSongLoader.getArtistSongList(this, artist.id);
|
||||||
|
|
@ -231,14 +230,6 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListViewPadding() {
|
|
||||||
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
|
||||||
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, Util.getNavigationBarHeight(this));
|
|
||||||
} else {
|
|
||||||
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpArtistImageAndApplyPalette(final boolean forceDownload) {
|
private void setUpArtistImageAndApplyPalette(final boolean forceDownload) {
|
||||||
LastFMArtistImageUrlLoader.loadArtistImageUrl(this, artist.name, forceDownload, new LastFMArtistImageUrlLoader.ArtistImageUrlLoaderCallback() {
|
LastFMArtistImageUrlLoader.loadArtistImageUrl(this, artist.name, forceDownload, new LastFMArtistImageUrlLoader.ArtistImageUrlLoaderCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -252,7 +243,6 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
super.onSuccess();
|
super.onSuccess();
|
||||||
final Bitmap bitmap = ((BitmapDrawable) artistIv.getDrawable()).getBitmap();
|
final Bitmap bitmap = ((BitmapDrawable) artistIv.getDrawable()).getBitmap();
|
||||||
if (bitmap != null) applyPalette(bitmap);
|
if (bitmap != null) applyPalette(bitmap);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -261,6 +251,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private void applyPalette(Bitmap bitmap) {
|
private void applyPalette(Bitmap bitmap) {
|
||||||
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
|
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
Palette.Swatch swatch = palette.getVibrantSwatch();
|
Palette.Swatch swatch = palette.getVibrantSwatch();
|
||||||
|
|
@ -268,6 +259,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
toolbarColor = swatch.getRgb();
|
toolbarColor = swatch.getRgb();
|
||||||
artistNameTv.setBackgroundColor(swatch.getRgb());
|
artistNameTv.setBackgroundColor(swatch.getRgb());
|
||||||
artistNameTv.setTextColor(swatch.getTitleTextColor());
|
artistNameTv.setTextColor(swatch.getTitleTextColor());
|
||||||
|
if (Util.hasLollipopSDK()) getWindow().setNavigationBarColor(swatch.getRgb());
|
||||||
} else {
|
} else {
|
||||||
setStandardColors();
|
setStandardColors();
|
||||||
}
|
}
|
||||||
|
|
@ -275,6 +267,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
private void setStandardColors() {
|
private void setStandardColors() {
|
||||||
int titleTextColor = Util.resolveColor(this, R.attr.title_text_color);
|
int titleTextColor = Util.resolveColor(this, R.attr.title_text_color);
|
||||||
int defaultBarColor = getResources().getColor(R.color.materialmusic_default_bar_color);
|
int defaultBarColor = getResources().getColor(R.color.materialmusic_default_bar_color);
|
||||||
|
|
@ -282,6 +275,8 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
toolbarColor = defaultBarColor;
|
toolbarColor = defaultBarColor;
|
||||||
artistNameTv.setBackgroundColor(defaultBarColor);
|
artistNameTv.setBackgroundColor(defaultBarColor);
|
||||||
artistNameTv.setTextColor(titleTextColor);
|
artistNameTv.setTextColor(titleTextColor);
|
||||||
|
|
||||||
|
if (Util.hasLollipopSDK()) getWindow().setNavigationBarColor(getResources().getColor(R.color.materialmusic_default_bar_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpToolBar() {
|
private void setUpToolBar() {
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
||||||
Util.setStatusBarTranslucent(getWindow(), statusBarTranslucent);
|
Util.setStatusBarTranslucent(getWindow(), statusBarTranslucent);
|
||||||
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
||||||
Util.setNavBarTranslucent(getWindow(), navigationBarTranslucent);
|
Util.setNavBarTranslucent(getWindow(), navigationBarTranslucent);
|
||||||
|
} else {
|
||||||
|
Util.setNavBarTranslucent(getWindow(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public abstract class AbsMainActivityFragment extends Fragment implements KabVie
|
||||||
private boolean areViewsEnabled;
|
private boolean areViewsEnabled;
|
||||||
|
|
||||||
protected int getTopPadding() {
|
protected int getTopPadding() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (Util.hasKitKatSDK()) {
|
||||||
if (Util.isInPortraitMode(getActivity()) || Util.isTablet(getActivity())) {
|
if (Util.isInPortraitMode(getActivity()) || Util.isTablet(getActivity())) {
|
||||||
return Util.getActionBarSize(getActivity()) + getResources().getDimensionPixelSize(R.dimen.tab_height) + Util.getStatusBarHeight(getActivity());
|
return Util.getActionBarSize(getActivity()) + getResources().getDimensionPixelSize(R.dimen.tab_height) + Util.getStatusBarHeight(getActivity());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
|
||||||
android:divider="@null"
|
android:divider="@null"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:dividerHeight="0dp"
|
android:dividerHeight="0dp"
|
||||||
android:scrollbars="none"/>
|
android:scrollbars="none"/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,35 +3,17 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_marginBottom="-8dp"
|
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:text="@string/albums"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
|
|
||||||
android:textColor="?title_text_color"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="164dp"
|
android:layout_height="164dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
android:scrollbars="none"/>
|
android:scrollbars="none"/>
|
||||||
|
|
||||||
<TextView
|
<View
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="-8dp"
|
android:background="#0CFFFFFF"/>
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:text="@string/songs"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
|
|
||||||
android:textColor="?title_text_color"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="64dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="?rect_selector"
|
android:background="?rect_selector"
|
||||||
android:descendantFocusability="blocksDescendants"
|
android:descendantFocusability="blocksDescendants"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/track_number"
|
android:id="@+id/track_number"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="64dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:fontFamily="sans-serif"
|
android:fontFamily="sans-serif"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue