Skip to content

Commit

Permalink
solved scrolling while the info is loading
Browse files Browse the repository at this point in the history
  • Loading branch information
saulmm committed Feb 7, 2016
1 parent 3f61c07 commit 82e8077
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -62,6 +65,8 @@ public void onReceive(Bitmap bitmap) {
}
};

private int mLayoutFlags;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 82e8077

Please sign in to comment.