mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-27 06:30:29 +00:00
update titlebar color and text for eventDetailsFragment
This commit is contained in:
parent
5fcd3872d3
commit
34f5ab14ba
5 changed files with 75 additions and 15 deletions
|
@ -50,6 +50,7 @@ dependencies {
|
|||
implementation 'com.android.support:cardview-v7:25.4.0'
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:design:25.4.0'
|
||||
compile 'com.android.support:palette-v7:25.4.0'
|
||||
compile 'com.google.android.exoplayer:exoplayer:r2.5.2'
|
||||
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
|
|
|
@ -42,7 +42,7 @@ public class EventRecyclerViewAdapter extends ItemRecyclerViewAdapter<Event> {
|
|||
holder.mTag.setText(tagString);
|
||||
}
|
||||
Glide.with(holder.mIcon.getContext())
|
||||
.load(event.getPosterUrl())
|
||||
.load(event.getThumbUrl())
|
||||
.dontAnimate()
|
||||
.fitCenter()
|
||||
.into(holder.mIcon);
|
||||
|
|
|
@ -1,32 +1,40 @@
|
|||
package de.nicidienase.chaosflix.touch.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.design.widget.CollapsingToolbarLayout;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||
|
||||
public class EventDetailsFragment extends Fragment {
|
||||
private static final String TAG = EventDetailsFragment.class.getSimpleName();
|
||||
private static final String EVENT_PARAM = "event_param";
|
||||
|
||||
private OnEventDetailsFragmentInteractionListener mListener;
|
||||
|
@ -36,6 +44,8 @@ public class EventDetailsFragment extends Fragment {
|
|||
CollapsingToolbarLayout collapsingToolbar;
|
||||
@BindView(R.id.anim_toolbar)
|
||||
Toolbar mToolbar;
|
||||
@BindView(R.id.appbar)
|
||||
AppBarLayout mAppBarLayout;
|
||||
@BindView(R.id.title_text)
|
||||
TextView mTitleText;
|
||||
@BindView(R.id.subtitle_text)
|
||||
|
@ -46,6 +56,10 @@ public class EventDetailsFragment extends Fragment {
|
|||
ImageView mThumbImage;
|
||||
@BindView(R.id.description_text)
|
||||
TextView mDescriptionText;
|
||||
@BindView(R.id.play_fab)
|
||||
FloatingActionButton mPlayButton;
|
||||
|
||||
private boolean appBarExpanded;
|
||||
|
||||
public EventDetailsFragment() {
|
||||
// Required empty public constructor
|
||||
|
@ -85,12 +99,24 @@ public class EventDetailsFragment extends Fragment {
|
|||
super.onViewCreated(view, savedInstanceState);
|
||||
ButterKnife.bind(this,view);
|
||||
|
||||
mPlayButton.setOnClickListener(v -> {
|
||||
Toast.makeText(v.getContext(),"Play the video",Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
view.setTransitionName(getString(R.string.card));
|
||||
|
||||
collapsingToolbar.setTitle(mEvent.getTitle());
|
||||
mToolbar.setTitle(mEvent.getTitle());
|
||||
// mToolbar.setTitle(mEvent.getTitle());
|
||||
mTitleText.setText(mEvent.getTitle());
|
||||
|
||||
mAppBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
double v = (double) Math.abs(verticalOffset) / appBarLayout.getTotalScrollRange();
|
||||
Log.d(TAG,"Offset changed: " + v);
|
||||
appBarExpanded = v > 0.8;
|
||||
collapsingToolbar.setTitleEnabled(appBarExpanded);
|
||||
// invalidateOptionsMenu();
|
||||
});
|
||||
|
||||
if(mEvent.getSubtitle() != null && mEvent.getSubtitle().length() > 0){
|
||||
mSubtitleText.setText(mEvent.getSubtitle());
|
||||
} else {
|
||||
|
@ -108,22 +134,40 @@ public class EventDetailsFragment extends Fragment {
|
|||
mThumbImage.setTransitionName(getString(R.string.thumbnail)+mEvent.getApiID());
|
||||
Glide.with(getContext())
|
||||
.load(mEvent.getPosterUrl())
|
||||
.asBitmap()
|
||||
.fitCenter()
|
||||
.dontAnimate()
|
||||
.listener(new RequestListener<String, GlideDrawable>() {
|
||||
.dontTransform()
|
||||
// .listener(new RequestListener<String, GlideDrawable>() {
|
||||
// @Override
|
||||
// public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
//// startPostponedEnterTransition();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onResourceReady(GlideDrawable resource, String model,
|
||||
// Target<GlideDrawable> target,
|
||||
// boolean isFromMemoryCache,
|
||||
// boolean isFirstResource) {
|
||||
//// startPostponedEnterTransition();
|
||||
// return false;
|
||||
// }
|
||||
// })
|
||||
.into(new BitmapImageViewTarget(mThumbImage){
|
||||
@Override
|
||||
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
|
||||
super.onResourceReady(resource, glideAnimation);
|
||||
mThumbImage.setImageBitmap(resource);
|
||||
Palette.from(resource).generate(palette -> {
|
||||
int vibrantColor = palette.getVibrantColor(getResources().getColor(R.color.primary_500));
|
||||
collapsingToolbar.setContentScrimColor(vibrantColor);
|
||||
collapsingToolbar.setStatusBarScrimColor(getResources().getColor(R.color.black_trans80));
|
||||
});
|
||||
startPostponedEnterTransition();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
startPostponedEnterTransition();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(mThumbImage);
|
||||
});
|
||||
// .into(mThumbImage);
|
||||
startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
|
@ -144,6 +188,11 @@ public class EventDetailsFragment extends Fragment {
|
|||
mListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
public interface OnEventDetailsFragmentInteractionListener {
|
||||
void onEventSelected(Event event, View v);
|
||||
}
|
||||
|
|
|
@ -49,8 +49,11 @@
|
|||
android:layout_marginRight="@dimen/details_title_margin"
|
||||
android:layout_marginTop="@dimen/details_title_margin"
|
||||
android:text="Title"
|
||||
android:visibility="visible"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
|
||||
android:textColor="@color/white"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
app:layout_collapseParallaxMultiplier="1.0"/>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
|
@ -73,6 +76,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<TextView
|
||||
|
@ -109,6 +113,7 @@
|
|||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/play_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
|
|
5
touch/src/main/res/values/colors.xml
Normal file
5
touch/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="primary_500">#3F51B5</color>
|
||||
<color name="black_trans80">#33000000</color>
|
||||
</resources>
|
Loading…
Reference in a new issue