<commit_before>package com.comcast.freeflow.examples.artbook;

import org.freeflow.core.Container;
import org.freeflow.core.Container.OnScrollListener;
import org.freeflow.layouts.VGridLayout;
import org.freeflow.layouts.VGridLayout.LayoutParams;

import com.comcast.freeflow.examples.artbook.data.DribbbleDataAdapter;
import com.comcast.freeflow.examples.artbook.layouts.ArtbookLayout;

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

public class ArtbookActivity extends Activity {

	public static final String TAG = "ArtbookActivity";

	private Container container;
	private VGridLayout grid;
	private ArtbookLayout custom;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_artbook);
		DribbbleFetch fetch = new DribbbleFetch();
		fetch.load(this);

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

		Display display = getWindowManager().getDefaultDisplay();
		Point size = new Point();
		display.getSize(size);

		grid = new VGridLayout();
		VGridLayout.LayoutParams params = new VGridLayout.LayoutParams(size.x/2, size.x/2);
		grid.setLayoutParams(params);

		custom = new ArtbookLayout();

	}

	public void onDataLoaded(DribbbleFeed feed) {
		Log.d(TAG, "photo: " + feed.getShots().get(0).getImage_teaser_url());
		DribbbleDataAdapter adapter = new DribbbleDataAdapter(this, feed);
		container.setLayout(custom);
		container.setAdapter(adapter);
		container.addScrollListener( new OnScrollListener() {
			
			@Override
			public void onScroll(Container container) {
				
				float ht = container.getLayout().getContentHeight();
				float scrollableHeight = ht - container.getHeight();
				
				Log.d(TAG, "scrolling % "+ container.getViewportTop() / scrollableHeight );
			}
		});
	}

	@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):
			if(container.getLayout() == grid){<commit_msg>Uses scrollPercent values<commit_after>package com.comcast.freeflow.examples.artbook;

import org.freeflow.core.Container;
import org.freeflow.core.Container.OnScrollListener;
import org.freeflow.layouts.VGridLayout;
import org.freeflow.layouts.VGridLayout.LayoutParams;

import com.comcast.freeflow.examples.artbook.data.DribbbleDataAdapter;
import com.comcast.freeflow.examples.artbook.layouts.ArtbookLayout;

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

public class ArtbookActivity extends Activity {

	public static final String TAG = "ArtbookActivity";

	private Container container;
	private VGridLayout grid;
	private ArtbookLayout custom;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_artbook);
		DribbbleFetch fetch = new DribbbleFetch();
		fetch.load(this);

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

		Display display = getWindowManager().getDefaultDisplay();
		Point size = new Point();
		display.getSize(size);

		grid = new VGridLayout();
		VGridLayout.LayoutParams params = new VGridLayout.LayoutParams(size.x/2, size.x/2);
		grid.setLayoutParams(params);

		custom = new ArtbookLayout();

	}

	public void onDataLoaded(DribbbleFeed feed) {
		Log.d(TAG, "photo: " + feed.getShots().get(0).getImage_teaser_url());
		DribbbleDataAdapter adapter = new DribbbleDataAdapter(this, feed);
		container.setLayout(custom);
		container.setAdapter(adapter);
		container.addScrollListener( new OnScrollListener() {
			
			@Override
			public void onScroll(Container container) {
				Log.d(TAG, "scroll percent "+ container.getScrollPercentX() );
			}
		});
	}

	@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):
			if(container.getLayout() == grid){
{'fraction_non_alphanumeric': 0.11078585904075659, 'fraction_numerical': 0.0013510470614726414, 'mean_word_length': 5.4563953488372094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4826780', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1345, 'n_words': 266}