content: package com.alexvasilkov.foldablelayout.sample.activities;
  
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.ListView;
  import android.widget.TextView;
  
  import com.alexvasilkov.android.commons.texts.SpannableBuilder;
  import com.alexvasilkov.android.commons.ui.Views;
  import com.alexvasilkov.foldablelayout.UnfoldableView;
  import com.alexvasilkov.foldablelayout.sample.R;
  import com.alexvasilkov.foldablelayout.sample.items.Painting;
  import com.alexvasilkov.foldablelayout.sample.items.PaintingsAdapter;
  import com.alexvasilkov.foldablelayout.sample.utils.GlideHelper;
  import com.alexvasilkov.foldablelayout.shading.GlanceFoldShading;
  
  public class UnfoldableDetailsActivity extends BaseActivity {
  
      private View listTouchInterceptor;
      private View detailsLayout;
      private UnfoldableView unfoldableView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_unfoldable_details);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          ListView listView = Views.find(this, R.id.list_view);
          listView.setAdapter(new PaintingsAdapter(this));
  
          listTouchInterceptor = Views.find(this, R.id.touch_interceptor_view);
          listTouchInterceptor.setClickable(false);
  
          detailsLayout = Views.find(this, R.id.details_layout);
          detailsLayout.setVisibility(View.INVISIBLE);
  
          unfoldableView = Views.find(this, R.id.unfoldable_view);
  
          Bitmap glance = BitmapFactory.decodeResource(getResources(), R.drawable.unfold_glance);
          unfoldableView.setFoldShading(new GlanceFoldShading(glance));
  
          unfoldableView.setOnFoldingListener(new UnfoldableView.SimpleFoldingListener() {
              @Override
              public void onUnfolding(UnfoldableView unfoldableView) {
                  listTouchInterceptor.setClickable(true);
                  detailsLayout.setVisibility(View.VISIBLE);
              }
  
              @Override
              public void onUnfolded(UnfoldableView unfoldableView) {
                  listTouchInterceptor.setClickable(false);
              }
  
              @Override
              public void onFoldingBack(UnfoldableView unfoldableView) {
                  listTouchInterceptor.setClickable(true);
              }
  
              @Override
              public void onFoldedBack(UnfoldableView unfoldableView) {
                  listTouchInterceptor.setClickable(false);
                  detailsLayout.setVisibility(View.INVISIBLE);
              }
          });
      }
  
      @Override
      public void onBackPressed() {
          if (unfoldableView != null
                  && (unfoldableView.isUnfolded() || unfoldableView.isUnfolding())) {
              unfoldableView.foldBack();
          } else {
              super.onBackPressed();
          }
      }
  
      public void openDetails(View coverView, Painting painting) {
          final ImageView image = Views.find(detailsLayout, R.id.details_image);
          final TextView title = Views.find(detailsLayout, R.id.details_title);
          final TextView description = Views.find(detailsLayout, R.id.details_text);
  
          GlideHelper.loadPaintingImage(image, painting);
          title.setText(painting.getTitle());
  
          SpannableBuilder builder = new SpannableBuilder(this);
          builder
                  .createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
                  .append(R.string.year).append(": ")
                  .clearStyle()
                  .append(painting.getYear()).append("\n")
                  .createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
                  .append(R.string.location).append(": ")
                  .clearStyle()
                  .append(painting.getLocation());
          description.setText(builder.build());
  
          unfoldableView.unfold(coverView, detailsLayout);
      }
  
  }
  