mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 12:53:08 +00:00
Use DataBinding in EventDetails
This commit is contained in:
parent
9ccc085957
commit
fb72d101cb
3 changed files with 148 additions and 176 deletions
|
@ -1,12 +1,12 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.2"
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.1"
|
||||
defaultConfig {
|
||||
applicationId "de.nicidienase.chaosflix"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 25
|
||||
targetSdkVersion 26
|
||||
versionCode 5
|
||||
versionName "0.2.0"
|
||||
multiDexEnabled true
|
||||
|
@ -40,17 +40,23 @@ android {
|
|||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation project(':common')
|
||||
implementation 'com.android.support:support-v4:25.4.0'
|
||||
implementation 'com.android.support:recyclerview-v7:25.4.0'
|
||||
implementation 'com.android.support:cardview-v7:25.4.0'
|
||||
implementation 'com.android.support:support-v4:26.1.0'
|
||||
implementation 'com.android.support:recyclerview-v7:26.1.0'
|
||||
implementation 'com.android.support:cardview-v7:26.1.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
implementation "android.arch.lifecycle:runtime:1.0.0"
|
||||
implementation "android.arch.lifecycle:extensions:1.0.0-alpha9-1"
|
||||
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9-1"
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:design:25.4.0'
|
||||
compile 'com.android.support:design:26.1.0'
|
||||
|
||||
compile 'com.google.android.exoplayer:exoplayer:r2.5.2'
|
||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||
|
|
|
@ -3,9 +3,6 @@ package de.nicidienase.chaosflix.touch.fragments;
|
|||
import android.content.Context;
|
||||
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.widget.Toolbar;
|
||||
import android.transition.Transition;
|
||||
|
@ -17,16 +14,13 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||
import de.nicidienase.chaosflix.databinding.FragmentEventDetailsNewBinding;
|
||||
|
||||
public class EventDetailsFragment extends Fragment {
|
||||
private static final String TAG = EventDetailsFragment.class.getSimpleName();
|
||||
|
@ -35,25 +29,6 @@ public class EventDetailsFragment extends Fragment {
|
|||
private OnEventDetailsFragmentInteractionListener mListener;
|
||||
private Event mEvent;
|
||||
|
||||
@BindView(R.id.collapsing_toolbar)
|
||||
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)
|
||||
TextView mSubtitleText;
|
||||
@BindView(R.id.speaker_text)
|
||||
TextView mSpeakerText;
|
||||
@BindView(R.id.thumb_image)
|
||||
ImageView mThumbImage;
|
||||
@BindView(R.id.description_text)
|
||||
TextView mDescriptionText;
|
||||
@BindView(R.id.play_fab)
|
||||
FloatingActionButton mPlayButton;
|
||||
|
||||
private boolean appBarExpanded;
|
||||
|
||||
public EventDetailsFragment() {
|
||||
|
@ -93,51 +68,31 @@ public class EventDetailsFragment extends Fragment {
|
|||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
ButterKnife.bind(this,view);
|
||||
FragmentEventDetailsNewBinding binding = FragmentEventDetailsNewBinding.bind(view);
|
||||
binding.setEvent(mEvent);
|
||||
|
||||
mPlayButton.setOnClickListener(v -> {
|
||||
binding.playFab.setOnClickListener(v -> {
|
||||
play();
|
||||
});
|
||||
|
||||
view.setTransitionName(getString(R.string.card));
|
||||
|
||||
if(mListener != null)
|
||||
mListener.setActionbar(mToolbar);
|
||||
collapsingToolbar.setTitle(mEvent.getTitle());
|
||||
// mToolbar.setTitle(mEvent.getTitle());
|
||||
mTitleText.setText(mEvent.getTitle());
|
||||
mListener.setActionbar(binding.animToolbar);
|
||||
|
||||
mAppBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
binding.appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
double v = (double) Math.abs(verticalOffset) / appBarLayout.getTotalScrollRange();
|
||||
Log.d(TAG,"Offset changed: " + v);
|
||||
if(appBarExpanded ^ v > 0.8){
|
||||
// invalidateOptionsMenu();
|
||||
if(mListener != null)
|
||||
mListener.onToolbarStateChange();
|
||||
appBarExpanded = v > 0.8;
|
||||
collapsingToolbar.setTitleEnabled(appBarExpanded);
|
||||
binding.collapsingToolbar.setTitleEnabled(appBarExpanded);
|
||||
}
|
||||
});
|
||||
|
||||
if(mEvent.getSubtitle() != null && mEvent.getSubtitle().length() > 0){
|
||||
mSubtitleText.setText(mEvent.getSubtitle());
|
||||
} else {
|
||||
mSubtitleText.setVisibility(View.GONE);
|
||||
}
|
||||
mSpeakerText.setText(
|
||||
android.text.TextUtils.join(", ",mEvent.getPersons()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(mEvent.getDescription())
|
||||
.append("\n")
|
||||
.append("\nreleased at: ").append(mEvent.getReleaseDate())
|
||||
.append("\nTags: ").append(android.text.TextUtils.join(", ", mEvent.getTags()));
|
||||
mDescriptionText.setText(sb);
|
||||
|
||||
mThumbImage.setTransitionName(getString(R.string.thumbnail)+mEvent.getApiID());
|
||||
binding.thumbImage.setTransitionName(getString(R.string.thumbnail)+mEvent.getApiID());
|
||||
Picasso.with(getContext())
|
||||
.load(mEvent.getThumbUrl())
|
||||
.noFade()
|
||||
.into(mThumbImage, new Callback() {
|
||||
.into(binding.thumbImage, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
startPostponedEnterTransition();
|
||||
|
|
|
@ -1,128 +1,139 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
<layout>
|
||||
<data>
|
||||
<import type="android.text.TextUtils"/>
|
||||
<variable
|
||||
name="event"
|
||||
type="de.nicidienase.chaosflix.common.entities.recording.Event"/>
|
||||
</data>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/appbar_header_height"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="@color/primary"
|
||||
app:statusBarScrim="@color/primary"
|
||||
app:expandedTitleMarginStart="25dp"
|
||||
app:titleEnabled="false"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thumb_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/appbar_header_height"
|
||||
android:background="@drawable/default_background"
|
||||
android:fitsSystemWindows="true"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_collapseMode="parallax"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/scrim"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="@dimen/details_title_margin"
|
||||
android:layout_marginLeft="@dimen/details_title_margin"
|
||||
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
|
||||
android:id="@+id/anim_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/AppTheme"/>
|
||||
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/appbar_header_height"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:title="@{event.title}"
|
||||
app:contentScrim="@color/primary"
|
||||
app:statusBarScrim="@color/primary"
|
||||
app:expandedTitleMarginStart="25dp"
|
||||
app:titleEnabled="false"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thumb_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/appbar_header_height"
|
||||
android:background="@drawable/default_background"
|
||||
android:fitsSystemWindows="true"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_collapseMode="parallax"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/scrim"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="@dimen/details_title_margin"
|
||||
android:layout_marginLeft="@dimen/details_title_margin"
|
||||
android:layout_marginRight="@dimen/details_title_margin"
|
||||
android:layout_marginTop="@dimen/details_title_margin"
|
||||
android:text="@{event.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
|
||||
android:id="@+id/anim_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/AppTheme"/>
|
||||
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="24dp">
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/details_text_margin"
|
||||
android:layout_marginRight="@dimen/details_text_margin"
|
||||
android:layout_marginLeft="@dimen/details_text_margin"
|
||||
android:text="Subtitle"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speaker_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/details_text_margin"
|
||||
android:layout_marginRight="@dimen/details_text_margin"
|
||||
android:layout_marginLeft="@dimen/details_text_margin"
|
||||
android:text="speaker"/>
|
||||
<TextView
|
||||
android:id="@+id/subtitle_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/details_text_margin"
|
||||
android:layout_marginRight="@dimen/details_text_margin"
|
||||
android:layout_marginLeft="@dimen/details_text_margin"
|
||||
android:text="@{event.subtitle}"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/details_text_margin"
|
||||
android:layout_marginRight="@dimen/details_text_margin"
|
||||
android:layout_marginLeft="@dimen/details_text_margin"
|
||||
android:layout_marginBottom="@dimen/details_text_margin"
|
||||
android:text="Lorem Ipsum"/>
|
||||
<TextView
|
||||
android:id="@+id/speaker_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/details_text_margin"
|
||||
android:layout_marginRight="@dimen/details_text_margin"
|
||||
android:layout_marginLeft="@dimen/details_text_margin"
|
||||
android:text="@{event.speakerString}"/>
|
||||
|
||||
<!--TODO Add list of related or other videos-->
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/details_text_margin"
|
||||
android:layout_marginRight="@dimen/details_text_margin"
|
||||
android:layout_marginLeft="@dimen/details_text_margin"
|
||||
android:layout_marginBottom="@dimen/details_text_margin"
|
||||
android:text="@{event.extendedDescription}"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/play_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:clickable="true"
|
||||
android:src="@android:drawable/ic_media_play"
|
||||
app:backgroundTint="@color/primary"
|
||||
app:fabSize="normal"
|
||||
app:layout_anchor="@+id/appbar"
|
||||
app:layout_anchorGravity="bottom|right|end"/>
|
||||
<!--TODO Add list of related or other videos-->
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/play_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:clickable="true"
|
||||
android:src="@android:drawable/ic_media_play"
|
||||
app:backgroundTint="@color/primary"
|
||||
app:fabSize="normal"
|
||||
app:layout_anchor="@+id/appbar"
|
||||
app:layout_anchorGravity="bottom|right|end"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
</layout>
|
Loading…
Reference in a new issue