Skip to content
Permalink
Browse files

add ConstraintLayout chain examples

  • Loading branch information...
beeete2 committed Mar 25, 2019
1 parent 76041d9 commit 995c0cfc97055cc30b6c5e525c57249e3408f80b
Showing with 853 additions and 18 deletions.
  1. +109 −0 .idea/codeStyles/Project.xml
  2. +9 −1 app/build.gradle
  3. +14 −3 app/src/main/AndroidManifest.xml
  4. +3 −4 app/src/main/java/com/beeete2/android/examples/MainActivity.kt
  5. +3 −4 app/src/main/java/com/beeete2/android/examples/di/AppComponent.kt
  6. +2 −0 app/src/main/java/com/beeete2/android/examples/model/repository/FriendLocalRepository.kt
  7. +13 −0 app/src/main/java/com/beeete2/android/examples/package-info.java
  8. +49 −1 app/src/main/java/com/beeete2/android/examples/ui/epoxy/EpoxyActivity.kt
  9. +1 −5 app/src/main/java/com/beeete2/android/examples/ui/epoxy/EpoxyViewModel.kt
  10. +25 −0 app/src/main/java/com/beeete2/android/examples/ui/friends/ConstraintChainSpreadActivity.kt
  11. +56 −0 app/src/main/java/com/beeete2/android/examples/ui/friends/ConstraintEllipsizeActivity.kt
  12. +85 −0 app/src/main/res/layout/activity_constraint_chain_spread.xml
  13. +15 −0 app/src/main/res/layout/activity_constraint_ellipsize.xml
  14. +60 −0 app/src/main/res/layout/item_constraintlayout_ellipsize.xml
  15. +59 −0 app/src/main/res/layout/item_constraintlayout_ellipsize_match_constraint.xml
  16. +60 −0 app/src/main/res/layout/item_constraintlayout_ellipsize_width.xml
  17. +59 −0 app/src/main/res/layout/item_epoxy_friend.xml
  18. +30 −0 app/src/main/res/layout/item_epoxy_header.xml
  19. +67 −0 app/src/main/res/layout/item_epoxy_packed.xml
  20. +67 −0 app/src/main/res/layout/item_epoxy_spread.xml
  21. +67 −0 app/src/main/res/layout/item_epoxy_spread_inside.xml
@@ -31,6 +31,115 @@
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
<XML>
<option name="XML_KEEP_LINE_BREAKS" value="false" />
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
</XML>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
@@ -38,6 +38,10 @@ android {
}
}

kapt {
correctErrorTypes = true
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
@@ -52,7 +56,6 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'


def dagger_version = "2.16"
implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
@@ -62,6 +65,11 @@ dependencies {

implementation 'me.tatarka.injectedvmprovider:injectedvmprovider-ktx:1.0'

def epoxy_version = "3.3.1"
implementation "com.airbnb.android:epoxy:$epoxy_version"
kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
implementation "com.airbnb.android:epoxy-databinding:$epoxy_version"

def spek_version = "2.0.1"
testImplementation 'junit:junit:4.12'
testImplementation "io.mockk:mockk:1.9.2"
@@ -31,11 +31,22 @@
<activity
android:name=".ui.friends.FriendMinHeightActivity"
android:label="FriendMinHeightActivity"/>
<activity android:name=".ui.keypad.KeypadActivity"
<activity
android:name=".ui.keypad.KeypadActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".ui.friends.ConstraintChainSpreadActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".ui.friends.ConstraintEllipsizeActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".ui.epoxy.EpoxyActivity"
android:theme="@style/AppTheme.NoActionBar">
<activity
android:name=".ui.epoxy.EpoxyActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>

</application>
</manifest>
@@ -9,13 +9,10 @@ import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
import com.beeete2.android.examples.ui.friends.FriendSimplyActivity
import com.beeete2.android.examples.databinding.ActivityMainBinding
import com.beeete2.android.examples.databinding.MenuItemBinding
import com.beeete2.android.examples.ui.epoxy.EpoxyActivity
import com.beeete2.android.examples.ui.friends.FriendBarrierActivity
import com.beeete2.android.examples.ui.friends.FriendFullyActivity
import com.beeete2.android.examples.ui.friends.FriendMinHeightActivity
import com.beeete2.android.examples.ui.friends.*
import com.beeete2.android.examples.ui.keypad.KeypadActivity

class MainActivity : AppCompatActivity() {
@@ -33,6 +30,8 @@ class MainActivity : AppCompatActivity() {
MenuItem("FriendBarrierActivity", FriendBarrierActivity::class.java),
MenuItem("FriendMinHeightActivity", FriendMinHeightActivity::class.java),
MenuItem("KeypadActivity", KeypadActivity::class.java),
MenuItem("ConstraintChainSpreadActivity", ConstraintChainSpreadActivity::class.java),
MenuItem("ConstraintEllipsizeActivity", ConstraintEllipsizeActivity::class.java),
MenuItem("EpoxyActivity", EpoxyActivity::class.java)
))
}
@@ -3,10 +3,7 @@ package com.beeete2.android.examples.di
import android.app.Application
import com.beeete2.android.examples.App
import com.beeete2.android.examples.ui.epoxy.EpoxyActivity
import com.beeete2.android.examples.ui.friends.FriendSimplyActivity
import com.beeete2.android.examples.ui.friends.FriendBarrierActivity
import com.beeete2.android.examples.ui.friends.FriendFullyActivity
import com.beeete2.android.examples.ui.friends.FriendMinHeightActivity
import com.beeete2.android.examples.ui.friends.*
import com.beeete2.android.examples.ui.keypad.KeypadActivity
import dagger.BindsInstance
import dagger.Component
@@ -24,6 +21,8 @@ import javax.inject.Singleton
FriendBarrierActivity.FriendBarrierActivityModule::class,
FriendMinHeightActivity.FriendMinHeightActivityModule::class,
KeypadActivity.KeypadActivityModule::class,
ConstraintChainSpreadActivity.ConstraintChainSpreadActivityModule::class,
ConstraintEllipsizeActivity.ConstraintEllipsizeActivityActivityModule::class,
EpoxyActivity.EpoxyActivityModule::class
]
)
@@ -82,4 +82,6 @@ class FriendLocalRepository : FriendRepository {
)
)



}
@@ -0,0 +1,13 @@
@EpoxyDataBindingLayouts({
R.layout.item_epoxy_friend,
R.layout.item_epoxy_header,
R.layout.item_epoxy_spread,
R.layout.item_epoxy_spread_inside,
R.layout.item_epoxy_packed,
R.layout.item_constraintlayout_ellipsize,
R.layout.item_constraintlayout_ellipsize_width,
R.layout.item_constraintlayout_ellipsize_match_constraint
})
package com.beeete2.android.examples;

import com.airbnb.epoxy.EpoxyDataBindingLayouts;
@@ -2,7 +2,9 @@ package com.beeete2.android.examples.ui.epoxy

import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.beeete2.android.examples.R
import androidx.recyclerview.widget.DividerItemDecoration
import com.airbnb.epoxy.EpoxyController
import com.beeete2.android.examples.*
import com.beeete2.android.examples.databinding.ActivityEpoxyBinding
import dagger.Module
import dagger.android.ContributesAndroidInjector
@@ -20,6 +22,8 @@ class EpoxyActivity : DaggerAppCompatActivity() {

private lateinit var viewModel: EpoxyViewModel

private val controller = ListController()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

@@ -33,13 +37,57 @@ class EpoxyActivity : DaggerAppCompatActivity() {
it.setDisplayHomeAsUpEnabled(true)
it.setHomeButtonEnabled(true)
}

binding.recyclerView.apply {
setHasFixedSize(true)
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
adapter = controller.adapter
}

controller.requestModelBuild()
}

override fun onSupportNavigateUp(): Boolean {
finish()
return true
}

inner class ListController : EpoxyController() {

override fun buildModels() {
itemEpoxyHeader {
id("header_spread")
title("spread")
}
itemEpoxySpread {
id("spread_inside")
}
itemEpoxyHeader {
id("space1")
}

itemEpoxyHeader {
id("header_spread_inside")
title("spread_inside")
}
itemEpoxySpreadInside {
id("spread_inside")
}
itemEpoxyHeader {
id("space2")
}

itemEpoxyHeader {
id("header_packed")
title("packed")
}
itemEpoxyPacked {
id("packed")
}
}

}

@Module
abstract class EpoxyActivityModule {
@ContributesAndroidInjector
@@ -3,8 +3,4 @@ package com.beeete2.android.examples.ui.epoxy
import androidx.lifecycle.ViewModel
import javax.inject.Inject

class EpoxyViewModel @Inject constructor() : ViewModel() {



}
class EpoxyViewModel @Inject constructor() : ViewModel()
@@ -0,0 +1,25 @@
package com.beeete2.android.examples.ui.friends

import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.beeete2.android.examples.R
import com.beeete2.android.examples.databinding.ActivityConstraintChainSpreadBinding
import dagger.Module
import dagger.android.ContributesAndroidInjector
import dagger.android.support.DaggerAppCompatActivity

class ConstraintChainSpreadActivity : DaggerAppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val binding: ActivityConstraintChainSpreadBinding = DataBindingUtil.setContentView(this, R.layout.activity_constraint_chain_spread)
}

@Module
abstract class ConstraintChainSpreadActivityModule {
@ContributesAndroidInjector
abstract fun contributeConstraintChainSpreadActivity(): ConstraintChainSpreadActivity
}

}
Oops, something went wrong.

0 comments on commit 995c0cf

Please sign in to comment.
You can’t perform that action at this time.