use of com.simplecity.amp_library.ui.activities.MainActivity in project Shuttle by timusus.
the class QueueFragment method onResume.
@Override
public void onResume() {
super.onResume();
songAdapter.notifyItemRangeChanged(0, songAdapter.getItemCount());
IntentFilter filter = new IntentFilter();
filter.addAction(MusicService.InternalIntents.META_CHANGED);
filter.addAction(MusicService.InternalIntents.QUEUE_CHANGED);
filter.addAction(MusicService.InternalIntents.SHUFFLE_CHANGED);
filter.addAction(MusicService.InternalIntents.PLAY_STATE_CHANGED);
filter.addAction(MusicService.InternalIntents.SERVICE_CONNECTED);
getActivity().registerReceiver(receiver, filter);
updateTrackInfo();
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).setScrollableView(recyclerView);
}
if (getParentFragment() != null && getParentFragment() instanceof PlayerFragment) {
((PlayerFragment) getParentFragment()).setDragView(rootView);
}
refreshAdapterItems();
}
use of com.simplecity.amp_library.ui.activities.MainActivity in project Shuttle by timusus.
the class ThemeUtils method themeActionBar.
@SuppressLint("NewApi")
public static Drawable themeActionBar(AppCompatActivity activity) {
if (activity == null) {
return null;
}
if (ShuttleUtils.hasLollipop()) {
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
if (bitmap != null) {
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bitmap, ColorUtils.getPrimaryColor());
activity.setTaskDescription(td);
bitmap.recycle();
}
}
if (ThemeUtils.getInstance().themeType == ThemeType.TYPE_LIGHT || ThemeUtils.getInstance().themeType == ThemeType.TYPE_DARK) {
activity.getSupportActionBar().setBackgroundDrawable(DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.ab_transparent)));
}
if (activity instanceof MainActivity || isActionBarSolid(activity)) {
ActionBar actionBar = activity.getSupportActionBar();
Drawable actionBarDrawable = DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.action_bar_bg));
actionBar.setBackgroundDrawable(actionBarDrawable);
return actionBarDrawable;
}
return null;
}
use of com.simplecity.amp_library.ui.activities.MainActivity in project Shuttle by timusus.
the class DetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_detail, container, false);
recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
if (canEdit()) {
itemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback((from, to) -> {
long songViewCount = Stream.of(adapter.items).filter(adaptableItem -> adaptableItem instanceof SongView).count();
int offset = (int) (adapter.getItemCount() - songViewCount);
if (to >= offset) {
adapter.moveItem(from, to);
}
}, (from, to) -> {
// The 'offset' here is the number of items in the list which are not
// SongViews. We need this to determine the actual playlist positions of the items.
long songViewCount = Stream.of(adapter.items).filter(adaptableItem -> adaptableItem instanceof SongView).count();
int offset = (int) (adapter.getItemCount() - songViewCount);
from -= offset;
to -= offset;
try {
MediaStore.Audio.Playlists.Members.moveItem(getActivity().getContentResolver(), playlist.id, from, to);
} catch (IllegalArgumentException e) {
CrashlyticsCore.getInstance().log(String.format("Failed to move playlist item from %s to %s. Adapter count: %s. Error:%s", from, to, adapter.getItemCount(), e.getMessage()));
}
}, null));
itemTouchHelper.attachToRecyclerView(recyclerView);
}
fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
fab.setOnClickListener(this);
lineOne = (TextView) rootView.findViewById(R.id.line_one);
lineTwo = (TextView) rootView.findViewById(R.id.line_two);
overflowButton = (NonScrollImageButton) rootView.findViewById(R.id.btn_overflow);
overflowButton.setOnClickListener(this);
if (albumArtist != null) {
lineOne.setText(albumArtist.name);
overflowButton.setContentDescription(getString(R.string.btn_options, albumArtist.name));
} else if (album != null) {
lineOne.setText(album.name);
overflowButton.setContentDescription(getString(R.string.btn_options, album.name));
} else if (genre != null) {
lineOne.setText(genre.name);
overflowButton.setVisibility(View.GONE);
} else if (playlist != null) {
lineOne.setText(playlist.name);
overflowButton.setContentDescription(getString(R.string.btn_options, playlist.name));
}
textProtectionScrim = rootView.findViewById(R.id.textProtectionScrim);
headerImageView = (ImageView) rootView.findViewById(R.id.background);
String transitionName = getArguments().getString(ARG_TRANSITION_NAME);
ViewCompat.setTransitionName(headerImageView, transitionName);
if (transitionName != null) {
textProtectionScrim.setVisibility(View.GONE);
fab.setVisibility(View.GONE);
}
int width = ResourceUtils.getScreenSize().width + ResourceUtils.toPixels(60);
int height = getResources().getDimensionPixelSize(R.dimen.header_view_height);
if (albumArtist != null || album != null) {
requestManager.load(albumArtist == null ? album : albumArtist).override(width, height).diskCacheStrategy(DiskCacheStrategy.SOURCE).priority(Priority.HIGH).placeholder(GlideUtils.getPlaceHolderDrawable(albumArtist == null ? album.name : albumArtist.name, false)).centerCrop().animate(new AlwaysCrossFade(false)).into(headerImageView);
}
actionMode = null;
//Set the RecyclerView HeaderView height equal to the headerItem height
headerView = rootView.findViewById(R.id.headerView);
headerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
headerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
DetailFragment.this.headerItem.height = headerView.getHeight();
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
headerTranslation = headerView.getTranslationY() - dy;
headerImageTranslation = headerImageView.getTranslationY() + dy / 2;
//the header translation.
if (headerTranslation == 0) {
headerImageTranslation = 0;
}
float ratio = Math.min(1, -headerTranslation / headerView.getHeight());
headerView.setTranslationY(headerTranslation);
headerImageView.setTranslationY(headerImageTranslation);
//when recreating this fragment.
if (getActivity() != null) {
if (((MainActivity) getActivity()).canSetAlpha()) {
((MainActivity) getActivity()).setActionBarAlpha(ratio, true);
}
}
}
});
themeUIComponents();
headerView.setTranslationY(headerTranslation);
headerImageView.setTranslationY(headerImageTranslation);
return rootView;
}
Aggregations