Android Open Source - FreeFlow Dribbble Data Adapter






From Project

Back to project page FreeFlow.

License

The source code is released under:

Apache License

If you think the Android project FreeFlow listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright 2013 Comcast Cable Communications Management, LLC
 * //from   w  w  w .  j  a  va  2 s  . c o  m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.comcast.freeflow.examples.artbook.data;

import java.util.ArrayList;

import com.comcast.freeflow.core.FreeFlowItem;
import com.comcast.freeflow.core.Section;
import com.comcast.freeflow.core.SectionedAdapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.comcast.freeflow.examples.artbook.R;
import com.comcast.freeflow.examples.artbook.models.DribbbleFeed;
import com.comcast.freeflow.examples.artbook.models.Shot;
import com.squareup.picasso.Picasso;

public class DribbbleDataAdapter implements SectionedAdapter {
  
  public static final  String TAG = "DribbbleDataAdapter";
  
  private Context context;
  private Section section;

  private int[] colors = new int[] { 0xcc152431, 0xff264C58, 0xffF5C543,
      0xffE0952C, 0xff9A5325, 0xaaE0952C, 0xaa9A5325, 0xaa152431,
      0xaa264C58, 0xaaF5C543, 0x44264C58, 0x44F5C543, 0x44152431 };
  
  private boolean hideImages = false;

  public DribbbleDataAdapter(Context context) {
    this.context = context;
    section = new Section();
    section.setSectionTitle("Pics");
    
  }
  
  public void update(DribbbleFeed feed){
    
    for(Object o : feed.getShots()){
      section.getData().add(o);
    }
    
    Log.d(TAG, "Data updated to: "+section.getDataCount());
    
  }

  @Override
  public long getItemId(int section, int position) {
    return section * 1000 + position;
  }

  @Override
  public View getItemView(int sectionIndex, int position, View convertView,
      ViewGroup parent) {
    if (convertView == null) {
      convertView = LayoutInflater.from(context).inflate(
          R.layout.pic_view, parent, false);
    }
    ImageView img = (ImageView) convertView.findViewById(R.id.pic);
    if (hideImages) {
      int idx = position % colors.length;
      img.setBackgroundColor(colors[idx]);

    } else {
      Shot s = (Shot)(this.section.getData().get(position));
      Picasso.with(context)
          .load(s.getImage_teaser_url())
          .into(img);
    }

    return convertView;
  }

  @Override
  public View getHeaderViewForSection(int section, View convertView,
      ViewGroup parent) {
    return null;
  }

  @Override
  public int getNumberOfSections() {
    if(section.getData().size() == 0) return 0;
    return 1;
  }

  @Override
  public Section getSection(int index) {
    return section;
  }

  @Override
  public Class[] getViewTypes() {
    return new Class[] { LinearLayout.class };
  }

  @Override
  public Class getViewType(FreeFlowItem proxy) {
    return LinearLayout.class;
  }

  @Override
  public boolean shouldDisplaySectionHeaders() {
    return false;
  }

}




Java Source Code List

com.comcast.freeflow.animations.DefaultLayoutAnimator.java
com.comcast.freeflow.animations.FreeFlowLayoutAnimator.java
com.comcast.freeflow.animations.NoAnimationLayoutAnimator.java
com.comcast.freeflow.animations.interpolators.EaseInOutQuintInterpolator.java
com.comcast.freeflow.core.AbsLayoutContainer.java
com.comcast.freeflow.core.FreeFlowContainerTest.java
com.comcast.freeflow.core.FreeFlowContainer.java
com.comcast.freeflow.core.FreeFlowEventListener.java
com.comcast.freeflow.core.FreeFlowItem.java
com.comcast.freeflow.core.IndexPath.java
com.comcast.freeflow.core.LayoutChangeset.java
com.comcast.freeflow.core.Section.java
com.comcast.freeflow.core.SectionedAdapter.java
com.comcast.freeflow.core.ViewPool.java
com.comcast.freeflow.debug.BaseFreeFlowEventListener.java
com.comcast.freeflow.debug.TouchDebugUtils.java
com.comcast.freeflow.examples.artbook.AboutActivity.java
com.comcast.freeflow.examples.artbook.ArtbookActivity.java
com.comcast.freeflow.examples.artbook.data.DribbbleDataAdapter.java
com.comcast.freeflow.examples.artbook.layouts.ArtbookLayout.java
com.comcast.freeflow.examples.artbook.models.DribbbleFeed.java
com.comcast.freeflow.examples.artbook.models.DribbbleFetch.java
com.comcast.freeflow.examples.artbook.models.Player.java
com.comcast.freeflow.examples.artbook.models.Shot.java
com.comcast.freeflow.examples.freeflowphotogrid.MainActivity.java
com.comcast.freeflow.helpers.DefaultSectionAdapter.java
com.comcast.freeflow.layouts.FreeFlowLayoutBase.java
com.comcast.freeflow.layouts.FreeFlowLayout.java
com.comcast.freeflow.layouts.HGridLayout.java
com.comcast.freeflow.layouts.HLayout.java
com.comcast.freeflow.layouts.VGridLayoutTest.java
com.comcast.freeflow.layouts.VGridLayout.java
com.comcast.freeflow.layouts.VLayout.java
com.comcast.freeflow.teststub.MainActivity.java
com.comcast.freeflow.utils.MathUtils.java
com.comcast.freeflow.utils.ViewUtils.java