From 82e8077af1430af51e908a80fa93e35133922042 Mon Sep 17 00:00:00 2001 From: Saul M Date: Sun, 7 Feb 2016 18:52:52 +0100 Subject: [PATCH] solved scrolling while the info is loading --- .../activities/CharacterDetailActivity.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java b/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java index 7549b10..234d28a 100644 --- a/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java +++ b/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java @@ -12,6 +12,8 @@ import android.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.os.Bundle; +import android.support.design.widget.AppBarLayout; +import android.support.design.widget.CollapsingToolbarLayout; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.graphics.Palette; @@ -20,6 +22,8 @@ import android.view.View; import android.view.ViewTreeObserver; import android.widget.ImageView; + +import butterknife.Bind; import butterknife.BindColor; import butterknife.BindInt; import butterknife.ButterKnife; @@ -42,11 +46,10 @@ import saulmm.avengers.views.utils.AnimUtils; public class CharacterDetailActivity extends AppCompatActivity implements CharacterDetailView { - - private static final String EXTRA_CHARACTER_NAME = "character.name"; public static final String EXTRA_CHARACTER_ID = "character.id"; + @Bind(R.id.character_collapsing) CollapsingToolbarLayout mCollapsing; @BindInt(R.integer.duration_medium) int mAnimMediumDuration; @BindInt(R.integer.duration_huge) int mAnimHugeDuration; @BindColor(R.color.brand_primary_dark) int mColorPrimaryDark; @@ -62,6 +65,8 @@ public void onReceive(Bitmap bitmap) { } }; + private int mLayoutFlags; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -71,6 +76,15 @@ public void onCreate(Bundle savedInstanceState) { initializePresenter(); initToolbar(); initTransitions(); + + disableScroll(); + } + + private void disableScroll() { + mLayoutFlags = ((AppBarLayout.LayoutParams) mCollapsing.getLayoutParams()).getScrollFlags(); + AppBarLayout.LayoutParams layoutParams = ((AppBarLayout.LayoutParams) mCollapsing.getLayoutParams()); + layoutParams.setScrollFlags(0); + mCollapsing.setLayoutParams(layoutParams); } private void initializeBinding() { @@ -200,6 +214,9 @@ public void showError(String errorMessage) { @Override public void bindCharacter(MarvelCharacter character) { mBinding.setCharacter(character); + AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) mCollapsing.getLayoutParams(); + layoutParams.setScrollFlags(mLayoutFlags); + mCollapsing.setLayoutParams(layoutParams); } @Override