<commit_before>package com.taig.android.content.activity

import android.os.Bundle
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.{app => support}
import android.view.ViewGroup
import com.taig.android._
import com.taig.android.content.{Activity, Property}

trait	Pager
extends	Activity
with	Fragment
{
	protected implicit def `Seq[Class[Fragment]] -> Pager.Fragment`( fragments: Seq[Class[_ <: support.Fragment]] ): Pager.Fragment =
	{
		new Property( this ) with Pager.Fragment
		{
			override def all = fragments
		}
	}

	val pager = new Property( this ) with Pager.Property

	override def fragment: Pager.Fragment

	override def onCreate( state: Bundle )
	{
		super.onCreate( state )

		setContentView( R.layout.pager )

		pager.widget.setAdapter( pager.adapter )
	}

	protected class	Adapter
	extends			FragmentPagerAdapter( getSupportFragmentManager )
	{
		protected[Pager] var current: support.Fragment = null

		override def getItem( position: Int ) = fragment.instantiate( fragment.all( position ) )

		override def getCount = fragment.all.length

		override def setPrimaryItem( container: ViewGroup, position: Int, `object`: Any )
		{
			this.current = `object` match
			{
				case fragment: support.Fragment => fragment
				case _ => null
			}

			super.setPrimaryItem( container, position, `object` )
		}
	}
}

object Pager
{
	trait	Property
	extends	content.Property[Pager]
	{
		lazy val widget = content.findViewById( R.id.pager ).asInstanceOf[com.taig.android.widget.Pager]

		lazy val adapter = new content.Adapter

		def next() = widget.setCurrentItem( widget.getCurrentItem + 1 )

		def previous() = widget.setCurrentItem( widget.getCurrentItem - 1 )

		def jump( fragment: Fragment ): Unit = jump( content.fragment.all.indexOf( fragment ) )

		def jump( position: Int ): Unit = widget.setCurrentItem( position )
	}

	trait	Fragment<commit_msg>Added Intent paramter to set initial Pager page<commit_after>package com.taig.android.content.activity

import android.os.Bundle
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.{app => support}
import android.view.ViewGroup
import com.taig.android._
import com.taig.android.content.activity.Pager.Parameter
import com.taig.android.content.{Activity, Property}

trait	Pager
extends	Activity
with	Fragment
{
	protected implicit def `Seq[Class[Fragment]] -> Pager.Fragment`( fragments: Seq[Class[_ <: support.Fragment]] ): Pager.Fragment =
	{
		new Property( this ) with Pager.Fragment
		{
			override def all = fragments
		}
	}

	val pager = new Property( this ) with Pager.Property

	override def fragment: Pager.Fragment

	override def onCreate( state: Bundle )
	{
		super.onCreate( state )

		setContentView( R.layout.pager )

		pager.widget.setAdapter( pager.adapter )

		Option( getIntent.getSerializableExtra( Parameter.Page ) )
			.map( _.asInstanceOf[Class[support.Fragment]] )
			.foreach( selection => pager.widget.setCurrentItem( fragment.all.indexOf( selection ) ) )
	}

	protected class	Adapter
	extends			FragmentPagerAdapter( getSupportFragmentManager )
	{
		protected[Pager] var current: support.Fragment = null

		override def getItem( position: Int ) = fragment.instantiate( fragment.all( position ) )

		override def getCount = fragment.all.length

		override def setPrimaryItem( container: ViewGroup, position: Int, `object`: Any )
		{
			this.current = `object` match
			{
				case fragment: support.Fragment => fragment
				case _ => null
			}

			super.setPrimaryItem( container, position, `object` )
		}
	}
}

object Pager
{
	val Parameter = new
	{
		val Page = getClass.getName + ".Page"
	}

	trait	Property
	extends	content.Property[Pager]
	{
		lazy val widget = content.findViewById( R.id.pager ).asInstanceOf[com.taig.android.widget.Pager]

		lazy val adapter = new content.Adapter

		def next() = widget.setCurrentItem( widget.getCurrentItem + 1 )

		def previous() = widget.setCurrentItem( widget.getCurrentItem - 1 )

		def jump( fragment: Fragment ): Unit = jump( content.fragment.all.indexOf( fragment ) )

		def jump( position: Int ): Unit = widget.setCurrentItem( position )
	}

	trait	Fragment
{'fraction_non_alphanumeric': 0.1048951048951049, 'fraction_numerical': 0.0019291053773812395, 'mean_word_length': 4.1464019851116625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '6887493', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1265, 'n_words': 327}