This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class ListItem(val title: String, val subtitle: String) | |
// viewholder | |
class ItemViewHolder : RecyclerView.ViewHolder { | |
private val titleTv: TextView | |
private val subtitleTv: TextView | |
constructor(itemView: View) : super(itemView) { | |
titleTv = itemView.findViewById(R.id.title) | |
subtitleTv = itemView.findViewById(R.id.subtitle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TabsFragment : Fragment() { | |
private val tabFragments: Array<KClass<out BaseFragment>> | |
init { | |
val mainNavPlugins = PluginManager.getPlugins().filter { | |
it.getMainFragment() != null | |
}.toTypedArray() | |
tabFragments = arrayOf( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class PluginProvider : ContentProvider() { | |
abstract fun getPlugin(): Plugin | |
override fun onCreate(): Boolean { | |
PluginManager.registerPlugin(getPlugin()) | |
return true | |
} | |
// ... other provider methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiListPlugin : Plugin { | |
override fun getMainFragment() = ApiListFragment::class | |
} | |
class ApiListPluginProvider : PluginProvider() { | |
override fun getPlugin() = ApiListPlugin() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Plugin { | |
fun getMainFragment(): KClass<BaseFragment>? | |
} | |
object PluginManager { | |
private val plugins = mutableListOf<Plugin>() | |
@Synchronized | |
fun getPlugins() = plugins.toList() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FlowLayout extends FrameLayout { | |
// .. | |
@Override | |
protected LayoutParams generateDefaultLayoutParams() { | |
return new LayoutParams(super.generateDefaultLayoutParams()); | |
} | |
@Override | |
public LayoutParams generateLayoutParams(AttributeSet attrs) { | |
return new LayoutParams(getContext(), attrs); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FlowLayout extends FrameLayout { | |
public static class LayoutParams extends FrameLayout.LayoutParams { | |
private boolean fill = false; | |
public LayoutParams(Context c, AttributeSet attrs) { | |
super(c, attrs); | |
TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.FlowLayout_Layout); | |
fill = a.getBoolean(R.styleable.FlowLayout_Layout_guide_layout_fill, false); | |
a.recycle(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<declare-styleable name="FlowLayout"> | |
<attr name="android:gravity" /> | |
</declare-styleable> | |
<declare-styleable name="FlowLayout_Layout"> | |
<attr name="guide_layout_fill" format="boolean" /> | |
</declare-styleable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_margin="8dp" | |
android:text="OK" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageView extends android.widget.ImageView { | |
public ImageView(Context context) { | |
super(context, null, R.attr.carbon_imageViewStyle); | |
initImageView(null, R.attr.carbon_imageViewStyle); | |
} | |
public ImageView(Context context, AttributeSet attrs) { | |
super(context, attrs, R.attr.carbon_imageViewStyle); | |
initImageView(attrs, R.attr.carbon_imageViewStyle); | |
} | |
private void initImageView(AttributeSet attrs, int defStyleAttr) { |