Android Open Source - FreeFlow Artbook Activity






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
 * /*  w ww .j ava 2s . c  om*/
 * 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;

import com.comcast.freeflow.core.AbsLayoutContainer;
import com.comcast.freeflow.core.AbsLayoutContainer.OnItemClickListener;
import com.comcast.freeflow.core.FreeFlowContainer;
import com.comcast.freeflow.core.FreeFlowItem;
import com.comcast.freeflow.core.FreeFlowContainer.OnScrollListener;
import com.comcast.freeflow.layouts.FreeFlowLayout;
import com.comcast.freeflow.layouts.HLayout;
import com.comcast.freeflow.layouts.VGridLayout;
import com.comcast.freeflow.layouts.VLayout;
import com.comcast.freeflow.layouts.VGridLayout.LayoutParams;
import com.comcast.freeflow.examples.artbook.data.DribbbleDataAdapter;
import com.comcast.freeflow.examples.artbook.layouts.ArtbookLayout;
import com.comcast.freeflow.examples.artbook.models.DribbbleFeed;
import com.comcast.freeflow.examples.artbook.models.DribbbleFetch;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Point;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;

public class ArtbookActivity extends Activity implements OnClickListener{

  public static final String TAG = "ArtbookActivity";

  private FreeFlowContainer container;
  private VGridLayout grid;
  private ArtbookLayout custom;

  private DribbbleFetch fetch;
  private int itemsPerPage = 25;
  private int pageIndex = 1;
  
  DribbbleDataAdapter adapter;
  
  FreeFlowLayout[] layouts;
  int currLayoutIndex = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artbook);
    

    container = (FreeFlowContainer) findViewById(R.id.container);

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    
    findViewById(R.id.load_more).setOnClickListener(this);
    //Our new layout
    custom = new ArtbookLayout();
    
    //Grid Layout
    grid = new VGridLayout();
    VGridLayout.LayoutParams params = new VGridLayout.LayoutParams(size.x/2, size.x/2);
    grid.setLayoutParams(params);
    
    //Vertical Layout
    VLayout vlayout = new VLayout();
    VLayout.LayoutParams params2 = new VLayout.LayoutParams(size.x);
    vlayout.setLayoutParams(params2);
    
    //HLayout
    HLayout hlayout = new HLayout();
    hlayout.setLayoutParams(new HLayout.LayoutParams(size.x));
    
    
    layouts = new FreeFlowLayout[]{custom, grid, vlayout, hlayout};
    
    adapter = new DribbbleDataAdapter(this);
    
    
    container.setLayout(layouts[currLayoutIndex]);
    container.setAdapter(adapter);
    
    
    fetch = new DribbbleFetch();
    
    fetch.load(this,itemsPerPage , pageIndex);

  }

  public void onDataLoaded(DribbbleFeed feed) {
    Log.d(TAG, "photo: " + feed.getShots().get(0).getImage_teaser_url());
    adapter.update(feed);
    container.dataInvalidated();
    container.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick(AbsLayoutContainer parent, FreeFlowItem proxy) {
        
      }
    });
    
    container.addScrollListener( new OnScrollListener() {
       
      @Override
      public void onScroll(FreeFlowContainer container) {
        Log.d(TAG, "scroll percent "+ container.getScrollPercentY() );
      }
    });
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.artbook, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch(item.getItemId()){
    case (R.id.action_change_layout):
      currLayoutIndex++;
      if(currLayoutIndex == layouts.length){
        currLayoutIndex =  0;
      }
      container.setLayout(layouts[currLayoutIndex]);
      
      break;
    case (R.id.action_about): Intent about = new Intent(this, AboutActivity.class);
      startActivity(about);
      break;
    }
    
    return true;
    
  }

  @Override
  public void onClick(View v) {
    Log.d(TAG, "Loading data");
    pageIndex++;
    fetch.load(this, itemsPerPage, pageIndex);
  }
}




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