Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import android.widget.ImageView

@RequiresApi(Build.VERSION_CODES.LOLLIPOP) // for View#clipToOutline
class DemoActivity : AppCompatActivity() {
var motionLayout : View? = null
private lateinit var motionLayout : MotionLayout

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -40,18 +40,14 @@ class DemoActivity : AppCompatActivity() {
}

val doShowPaths = intent.getBooleanExtra("showPaths", false)
(motionLayout as? MotionLayout)?.setShowPaths(doShowPaths)
motionLayout.setShowPaths(doShowPaths)
}

fun changeState(v: View?) {
if (motionLayout == null || motionLayout !is MotionLayout) {
return
}
val ml = motionLayout as? MotionLayout ?: return
if (ml.progress > 0.5f) {
ml.transitionToStart()
if (motionLayout.progress > 0.5f) {
motionLayout.transitionToStart()
} else {
ml.transitionToEnd()
motionLayout.transitionToEnd()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView

class DemosAdapter(private val myDataset: Array<DemosAdapter.Demo>) :
class DemosAdapter(private val dataset: Array<DemosAdapter.Demo>) :
RecyclerView.Adapter<DemosAdapter.ViewHolder>() {

data class Demo(val title: String, val description : String, val layout : Int = 0, val activity : Class<*> = DemoActivity::class.java) {
Expand Down Expand Up @@ -54,11 +54,11 @@ class DemosAdapter(private val myDataset: Array<DemosAdapter.Demo>) :
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.title.text = myDataset[position].title
holder.description.text = myDataset[position].description
holder.layoutFileId = myDataset[position].layout
holder.activity = myDataset[position].activity
holder.title.text = dataset[position].title
holder.description.text = dataset[position].description
holder.layoutFileId = dataset[position].layout
holder.activity = dataset[position].activity
}

override fun getItemCount() = myDataset.size
override fun getItemCount() = dataset.size
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity(), CompoundButton.OnCheckedChangeListener
private lateinit var viewManager: RecyclerView.LayoutManager
private var doShowPaths = false

private val myDataset: Array<DemosAdapter.Demo> = arrayOf(
private val dataset: Array<DemosAdapter.Demo> = arrayOf(
DemosAdapter.Demo("Basic Example (1/2)", "Basic motion example using referenced ConstraintLayout files", R.layout.motion_01_basic),
DemosAdapter.Demo("Basic Example (2/2)", "Basic motion example using ConstraintSets defined in the MotionScene file", R.layout.motion_02_basic),
DemosAdapter.Demo("Custom Attribute", "Show color interpolation (custom attribute)", R.layout.motion_03_custom_attribute),
Expand Down Expand Up @@ -48,7 +48,7 @@ class MainActivity : AppCompatActivity(), CompoundButton.OnCheckedChangeListener
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
viewManager = LinearLayoutManager(this)
viewAdapter = DemosAdapter(myDataset)
viewAdapter = DemosAdapter(dataset)

recyclerView = findViewById<RecyclerView>(R.id.recyclerview).apply {
setHasFixedSize(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CustomAdapter(private val userList: ArrayList<User>): RecyclerView.Adapter

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.item_layout, parent, false)
return ViewHolder(v);
return ViewHolder(v)
}

override fun getItemCount(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class FragmentExample2Activity : AppCompatActivity(), View.OnClickListener, Moti
override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) {
}

var lastProgress = 0f
private var lastProgress = 0f

var fragment : Fragment? = null
var last : Float = 0f
private var fragment : Fragment? = null
private var last : Float = 0f

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class FragmentExampleActivity : AppCompatActivity(), View.OnClickListener, Motio
override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) {
}

var lastProgress = 0f
private var lastProgress = 0f

var fragment : Fragment? = null
var last : Float = 0f
private var fragment : Fragment? = null
private var last : Float = 0f

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ class BoundsImageView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ImageView(context, attrs, defStyleAttr) {

private var mPaint = Paint()
private var paint = Paint()

init {
mPaint.setARGB(255, 200, 0, 0)
mPaint.strokeWidth = 4f
paint.setARGB(255, 200, 0, 0)
paint.strokeWidth = 4f
}


override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
canvas?.drawLine(0f, 0f, width.toFloat(), height.toFloat(), mPaint)
canvas?.drawLine(0f, height.toFloat(), width.toFloat(), 0f, mPaint)
canvas?.drawLine(0f, 0f, width.toFloat(), height.toFloat(), paint)
canvas?.drawLine(0f, height.toFloat(), width.toFloat(), 0f, paint)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.motion.MotionLayout;
import android.support.v4.view.NestedScrollingParent2;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import android.view.View

class Page : Fragment() {

var layoutId = 0
private var layoutId = 0

override fun setArguments(args: Bundle?) {
super.setArguments(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ import android.os.Bundle
import android.support.constraint.motion.MotionLayout
import android.support.v4.view.ViewPager
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.google.androidstudio.motionlayoutexample.R
import kotlinx.android.synthetic.main.motion_16_viewpager.*

class ViewPagerActivity : AppCompatActivity() {
var motionLayout: View? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val layout = R.layout.motion_16_viewpager
setContentView(layout)
motionLayout = findViewById(R.id.motionLayout)
val motionLayout = findViewById<MotionLayout>(R.id.motionLayout)

val adapter = ViewPagerAdapter(supportFragmentManager)
adapter.addPage("Page 1", R.layout.motion_16_viewpager_page1)
Expand All @@ -44,6 +42,6 @@ class ViewPagerActivity : AppCompatActivity() {
}

val doShowPaths = intent.getBooleanExtra("showPaths", false)
(motionLayout as? MotionLayout)?.setShowPaths(doShowPaths)
motionLayout.setShowPaths(doShowPaths)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ import com.google.androidstudio.motionlayoutexample.R
import kotlinx.android.synthetic.main.motion_16_viewpager.*

class ViewPagerActivity2 : AppCompatActivity() {
var motionLayout: View? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val layout = R.layout.motion_23_viewpager
setContentView(layout)
motionLayout = findViewById(R.id.motionLayout)
val motionLayout = findViewById<MotionLayout>(R.id.motionLayout)

val adapter = ViewPagerAdapter(supportFragmentManager)
adapter.addPage("Page 1", R.layout.motion_16_viewpager_page1)
Expand All @@ -44,6 +43,6 @@ class ViewPagerActivity2 : AppCompatActivity() {
}

val doShowPaths = intent.getBooleanExtra("showPaths", false)
(motionLayout as? MotionLayout)?.setShowPaths(doShowPaths)
motionLayout.setShowPaths(doShowPaths)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ import android.support.v4.app.FragmentPagerAdapter

class ViewPagerAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm) {

private val mFragmentList = ArrayList<Fragment>()
private val mFragmentTitleList = ArrayList<String>()
private val fragmentList = ArrayList<Fragment>()
private val fragmentTitleList = ArrayList<String>()

override fun getItem(position: Int): Fragment {
return mFragmentList[position]
return fragmentList[position]
}

override fun getCount(): Int {
return mFragmentList.size
return fragmentList.size
}

private fun addFragment(fragment: Fragment, title: String) {
mFragmentList.add(fragment)
mFragmentTitleList.add(title)
fragmentList.add(fragment)
fragmentTitleList.add(title)
}

override fun getPageTitle(position: Int): CharSequence? {
return mFragmentTitleList[position]
return fragmentTitleList[position]
}

fun addPage(s: String, layout: Int) {
Expand Down