Skip to content

Commit

Permalink
add baseDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
steadymoka committed Oct 14, 2019
1 parent 87d897c commit abfe114
Show file tree
Hide file tree
Showing 156 changed files with 702 additions and 139 deletions.
17 changes: 5 additions & 12 deletions app/src/main/java/moka/land/app/main/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package moka.land.app.main

import android.content.DialogInterface.BUTTON_POSITIVE
import android.os.Bundle
import android.view.LayoutInflater
import android.util.Log
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.LayoutInflaterCompat
import land.moka.dialog.LoadingDialog
import land.moka.dialog.TitleDialog
import moka.land.R

class MainActivity : AppCompatActivity() {
Expand All @@ -18,16 +14,13 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)

findViewById<TextView>(R.id.textView01).setOnClickListener {
TitleDialog(this)
TestDialog()
.apply {
setCustomTitle(LayoutInflater.from(this@MainActivity).inflate(R.layout.dialog_test, null))
// setTitle("Test")
// setMessage("Test")
setButton(BUTTON_POSITIVE, "OK") { dialogInterface, i ->

onClickOk = {
Log.wtf("tag", "${it}")
}
}
.show()
.show(supportFragmentManager, "")
}

findViewById<TextView>(R.id.textView02).setOnClickListener {
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/moka/land/app/main/TestDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package moka.land.app.main

import android.view.LayoutInflater
import android.view.View
import androidx.databinding.DataBindingUtil
import land.moka.dialog.BaseDialog
import moka.land.R
import moka.land.databinding.DialogTestBinding

class TestDialog : BaseDialog() {

var onClickOk: ((test: String) -> Unit)? = null

private lateinit var binding: DialogTestBinding

override fun getContentView(): View {
return DataBindingUtil.inflate<DialogTestBinding>(LayoutInflater.from(context), R.layout.dialog_test, null, false)
.apply { binding = this }.root
}

override fun init() {
onClickPositive = { onClickOk?.invoke("test") }
binding.textViewDream.text = "teeeeeeeeest"
}

override fun getPositiveText(): CharSequence = "닫기"

override fun isNeutralText(): Boolean = false

override fun isNegativeText(): Boolean = false

}
103 changes: 54 additions & 49 deletions app/src/main/res/layout/dialog_test.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
xmlns:app="http://schemas.android.com/apk/res-auto">

<EditText
android:id="@+id/editText_text"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="12dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="12dp"
android:background="@color/white_01"
android:elevation="3px"
android:hint="입력해주세요"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingRight="16dp"
android:paddingBottom="10dp"
android:textColorHint="@color/black_09"
android:textSize="13dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_height="wrap_content">

<TextView
android:id="@+id/textView_dream"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="목표 수정하기"
android:textColor="#FF808080"
android:textSize="13dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText_text" />
<EditText
android:id="@+id/editText_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="12dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="12dp"
android:background="@color/white_01"
android:elevation="3px"
android:hint="입력해주세요"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingRight="16dp"
android:paddingBottom="10dp"
android:textColorHint="@color/black_09"
android:textSize="13dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<View
android:id="@+id/view_divider01"
style="@style/HorizontalDivider"
android:layout_width="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:alpha="0.8"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_dream" />
<TextView
android:id="@+id/textView_dream"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="목표 수정하기"
android:textColor="#FF808080"
android:textSize="13dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText_text" />

</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/view_divider01"
style="@style/HorizontalDivider"
android:layout_width="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:alpha="0.8"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_dream" />

</androidx.constraintlayout.widget.ConstraintLayout>


</layout>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Generated by data binding compiler. Do not edit!
package land.moka.dialog.databinding;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import java.lang.Deprecated;
import java.lang.Object;
import land.moka.dialog.R;

public abstract class LayoutBaseDialogBinding extends ViewDataBinding {
@NonNull
public final TextView buttonNegative;

@NonNull
public final TextView buttonNeutral;

@NonNull
public final TextView buttonPositive;

@NonNull
public final FrameLayout content;

@NonNull
public final ConstraintLayout root;

protected LayoutBaseDialogBinding(Object _bindingComponent, View _root, int _localFieldCount,
TextView buttonNegative, TextView buttonNeutral, TextView buttonPositive, FrameLayout content,
ConstraintLayout root) {
super(_bindingComponent, _root, _localFieldCount);
this.buttonNegative = buttonNegative;
this.buttonNeutral = buttonNeutral;
this.buttonPositive = buttonPositive;
this.content = content;
this.root = root;
}

@NonNull
public static LayoutBaseDialogBinding inflate(@NonNull LayoutInflater inflater,
@Nullable ViewGroup root, boolean attachToRoot) {
return inflate(inflater, root, attachToRoot, DataBindingUtil.getDefaultComponent());
}

/**
* This method receives DataBindingComponent instance as type Object instead of
* type DataBindingComponent to avoid causing too many compilation errors if
* compilation fails for another reason.
* https://issuetracker.google.com/issues/116541301
* @Deprecated Use DataBindingUtil.inflate(inflater, R.layout.layout_base_dialog, root, attachToRoot, component)
*/
@NonNull
@Deprecated
public static LayoutBaseDialogBinding inflate(@NonNull LayoutInflater inflater,
@Nullable ViewGroup root, boolean attachToRoot, @Nullable Object component) {
return ViewDataBinding.<LayoutBaseDialogBinding>inflateInternal(inflater, R.layout.layout_base_dialog, root, attachToRoot, component);
}

@NonNull
public static LayoutBaseDialogBinding inflate(@NonNull LayoutInflater inflater) {
return inflate(inflater, DataBindingUtil.getDefaultComponent());
}

/**
* This method receives DataBindingComponent instance as type Object instead of
* type DataBindingComponent to avoid causing too many compilation errors if
* compilation fails for another reason.
* https://issuetracker.google.com/issues/116541301
* @Deprecated Use DataBindingUtil.inflate(inflater, R.layout.layout_base_dialog, null, false, component)
*/
@NonNull
@Deprecated
public static LayoutBaseDialogBinding inflate(@NonNull LayoutInflater inflater,
@Nullable Object component) {
return ViewDataBinding.<LayoutBaseDialogBinding>inflateInternal(inflater, R.layout.layout_base_dialog, null, false, component);
}

public static LayoutBaseDialogBinding bind(@NonNull View view) {
return bind(view, DataBindingUtil.getDefaultComponent());
}

/**
* This method receives DataBindingComponent instance as type Object instead of
* type DataBindingComponent to avoid causing too many compilation errors if
* compilation fails for another reason.
* https://issuetracker.google.com/issues/116541301
* @Deprecated Use DataBindingUtil.bind(view, component)
*/
@Deprecated
public static LayoutBaseDialogBinding bind(@NonNull View view, @Nullable Object component) {
return (LayoutBaseDialogBinding)bind(component, view, R.layout.layout_base_dialog);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import land.moka.dialog.databinding.LayoutBaseDialogBindingImpl;
import land.moka.dialog.databinding.LayoutLoadingDialogBindingImpl;

public class DataBinderMapperImpl extends DataBinderMapper {
private static final int LAYOUT_LAYOUTLOADINGDIALOG = 1;
private static final int LAYOUT_LAYOUTBASEDIALOG = 1;

private static final SparseIntArray INTERNAL_LAYOUT_ID_LOOKUP = new SparseIntArray(1);
private static final int LAYOUT_LAYOUTLOADINGDIALOG = 2;

private static final SparseIntArray INTERNAL_LAYOUT_ID_LOOKUP = new SparseIntArray(2);

static {
INTERNAL_LAYOUT_ID_LOOKUP.put(land.moka.dialog.R.layout.layout_base_dialog, LAYOUT_LAYOUTBASEDIALOG);
INTERNAL_LAYOUT_ID_LOOKUP.put(land.moka.dialog.R.layout.layout_loading_dialog, LAYOUT_LAYOUTLOADINGDIALOG);
}

Expand All @@ -35,6 +39,12 @@ public ViewDataBinding getDataBinder(DataBindingComponent component, View view,
throw new RuntimeException("view must have a tag");
}
switch(localizedLayoutId) {
case LAYOUT_LAYOUTBASEDIALOG: {
if ("layout/layout_base_dialog_0".equals(tag)) {
return new LayoutBaseDialogBindingImpl(component, view);
}
throw new IllegalArgumentException("The tag for layout_base_dialog is invalid. Received: " + tag);
}
case LAYOUT_LAYOUTLOADINGDIALOG: {
if ("layout/layout_loading_dialog_0".equals(tag)) {
return new LayoutLoadingDialogBindingImpl(component, view);
Expand Down Expand Up @@ -94,9 +104,10 @@ private static class InnerBrLookup {
}

private static class InnerLayoutIdLookup {
static final HashMap<String, Integer> sKeys = new HashMap<String, Integer>(1);
static final HashMap<String, Integer> sKeys = new HashMap<String, Integer>(2);

static {
sKeys.put("layout/layout_base_dialog_0", land.moka.dialog.R.layout.layout_base_dialog);
sKeys.put("layout/layout_loading_dialog_0", land.moka.dialog.R.layout.layout_loading_dialog);
}
}
Expand Down
Loading

0 comments on commit abfe114

Please sign in to comment.