Renamed layout files (cleanup)
This commit is contained in:
parent
ef48e9305b
commit
1bf584e638
22 changed files with 50 additions and 339 deletions
|
|
@ -1,13 +1,16 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.transition.Transition;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -120,6 +123,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
|||
setUpToolBar();
|
||||
setUpViews();
|
||||
|
||||
if (Util.hasLollipopSDK()) fixLollipopTransitionImageWrongSize();
|
||||
if (Util.hasLollipopSDK()) startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +188,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// header view has position 0
|
||||
if(position == 0){
|
||||
if (position == 0) {
|
||||
return;
|
||||
}
|
||||
MusicPlayerRemote.openQueue(songs, position - 1, true);
|
||||
|
|
@ -306,4 +310,34 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
|||
songListView.setEnabled(false);
|
||||
toolbar.setEnabled(false);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void fixLollipopTransitionImageWrongSize(){
|
||||
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
setUpArtistImageAndApplyPalette(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionCancel(Transition transition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionPause(Transition transition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionResume(Transition transition) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,151 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.artistviewpager;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView;
|
||||
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
|
||||
import com.github.ksoichiro.android.observablescrollview.ScrollState;
|
||||
import com.github.ksoichiro.android.observablescrollview.ScrollUtils;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.gramophone.ui.activities.ArtistDetailActivity;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
|
||||
public abstract class AbsViewPagerTabArtistListFragment extends Fragment implements ObservableScrollViewCallbacks, KabViewsDisableAble {
|
||||
public static final String TAG = AbsViewPagerTabArtistListFragment.class.getSimpleName();
|
||||
protected App app;
|
||||
private ObservableRecyclerView observableRecyclerView;
|
||||
private int artistId = -1;
|
||||
private String artistName = "";
|
||||
private int recyclerViewPaddingTop;
|
||||
private boolean areViewsEnabled;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
app = (App) getActivity().getApplicationContext();
|
||||
getArgs();
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_recyclerview, container, false);
|
||||
observableRecyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
|
||||
setRecyclerViewPadding();
|
||||
setNumColumns(getNumColumns());
|
||||
RecyclerView.Adapter adapter = getAdapter();
|
||||
if (adapter != null) {
|
||||
observableRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
observableRecyclerView.setScrollViewCallbacks(this);
|
||||
|
||||
ScrollUtils.addOnGlobalLayoutListener(observableRecyclerView, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
observableRecyclerView.smoothScrollBy(0,1);
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setRecyclerViewPadding() {
|
||||
final int artistImageViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
||||
final int titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
||||
final int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
|
||||
|
||||
recyclerViewPaddingTop = artistImageViewHeight + titleViewHeight + tabHeight;
|
||||
|
||||
if (Util.isInPortraitMode(getActivity()) || Util.isTablet(getActivity())) {
|
||||
observableRecyclerView.setPadding(0, recyclerViewPaddingTop, 0, Util.getNavigationBarHeight(getActivity()));
|
||||
} else {
|
||||
observableRecyclerView.setPadding(0, recyclerViewPaddingTop, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void getArgs() {
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
artistId = args.getInt(ArtistDetailActivity.ARG_ARTIST_ID, -1);
|
||||
artistName = args.getString(ArtistDetailActivity.ARG_ARTIST_NAME, "");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* IMPORTANT:
|
||||
*
|
||||
* You CAN return null here and use setAdapter(ListAdapter adapter) inside getAdapter() to manually set the adapter.
|
||||
*
|
||||
* (use only in case you must set the adapter async).
|
||||
*
|
||||
* */
|
||||
protected abstract RecyclerView.Adapter getAdapter();
|
||||
|
||||
protected abstract int getNumColumns();
|
||||
|
||||
protected void setNumColumns(int columns) {
|
||||
observableRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), columns));
|
||||
}
|
||||
|
||||
protected void setAdapter(RecyclerView.Adapter adapter) {
|
||||
observableRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
enableViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableViews() {
|
||||
areViewsEnabled = true;
|
||||
observableRecyclerView.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableViews() {
|
||||
areViewsEnabled = false;
|
||||
observableRecyclerView.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areViewsEnabled() {
|
||||
return areViewsEnabled;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return observableRecyclerView.getCurrentScrollY() + recyclerViewPaddingTop;
|
||||
}
|
||||
|
||||
protected int getArtistId() {
|
||||
return artistId;
|
||||
}
|
||||
|
||||
protected String getArtistName() {
|
||||
return artistName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
if (getActivity() instanceof ObservableScrollViewCallbacks) {
|
||||
if (getUserVisibleHint()) {
|
||||
((ObservableScrollViewCallbacks) getActivity()).onScrollChanged(scrollY + recyclerViewPaddingTop, b, b2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownMotionEvent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.artistviewpager;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import com.kabouzeid.gramophone.adapter.AlbumAdapter;
|
||||
import com.kabouzeid.gramophone.loader.ArtistAlbumLoader;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by karim on 04.01.15.
|
||||
*/
|
||||
public class ViewPagerTabArtistAlbumFragment extends AbsViewPagerTabArtistListFragment {
|
||||
|
||||
@Override
|
||||
protected RecyclerView.Adapter getAdapter() {
|
||||
List<Album> albums = ArtistAlbumLoader.getArtistAlbumList(getActivity(), getArtistId());
|
||||
return new AlbumAdapter(getActivity(), albums);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumColumns() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.artistviewpager;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistBiographyLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ViewPagerTabArtistBioFragment extends AbsViewPagerTabArtistListFragment {
|
||||
|
||||
|
||||
@Override
|
||||
protected RecyclerView.Adapter getAdapter() {
|
||||
final SimpleTextAdapter adapter = new SimpleTextAdapter(getActivity(), "loading");
|
||||
setAdapter(adapter);
|
||||
|
||||
LastFMArtistBiographyLoader.loadArtistBio(getActivity(), getArtistName(), new LastFMArtistBiographyLoader.ArtistBioLoaderCallback() {
|
||||
@Override
|
||||
public void onArtistBioLoaded(String biography) {
|
||||
if (biography == null || biography.trim().equals("")) {
|
||||
try {
|
||||
biography = getResources().getString(R.string.biography_unavailable);
|
||||
} catch (IllegalStateException e) {
|
||||
biography = "Error";
|
||||
}
|
||||
}
|
||||
adapter.setText(biography);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumColumns() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static class SimpleTextAdapter extends RecyclerView.Adapter<SimpleTextAdapter.ViewHolder> {
|
||||
private Context context;
|
||||
private String text;
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.item_artist_details_biography, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
holder.textView.setText(Html.fromHtml(text));
|
||||
holder.textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView textView;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
textView = (TextView) itemView.findViewById(R.id.text);
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleTextAdapter(Context context, String text) {
|
||||
this.context = context;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void setText(String text){
|
||||
this.text = text;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.artistviewpager;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.AlbumSongAdapter;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by karim on 04.01.15.
|
||||
*/
|
||||
public class ViewPagerTabArtistSongListFragment extends AbsViewPagerTabArtistListFragment {
|
||||
@Override
|
||||
protected RecyclerView.Adapter getAdapter() {
|
||||
final List<Song> songs = ArtistSongLoader.getArtistSongList(getActivity(), getArtistId());
|
||||
return new AlbumSongAdapter(getActivity(), songs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumColumns() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue