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