Skip to content

Commit

Permalink
make library
Browse files Browse the repository at this point in the history
  • Loading branch information
mejdi14 committed Oct 13, 2019
1 parent 3d08d34 commit c078766
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 21 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

implementation project(path: ':flatdialoglibrary')
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/example/flat_dialog/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

import androidx.appcompat.app.AppCompatActivity;

import com.example.flatdialoglibrary.dialog.FlatDialog;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

FlatDialog flatDialog= new FlatDialog(MainActivity.this);



}
}
1 change: 1 addition & 0 deletions flatdialoglibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.flat_dialog.dialog;
package com.example.flatdialoglibrary.dialog;

import android.app.Dialog;
import android.content.Context;
Expand All @@ -7,68 +7,67 @@
import android.widget.EditText;
import android.widget.TextView;

import com.example.flat_dialog.R;
import com.example.flatdialoglibrary.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class FlatDialog extends Dialog {
Context context;
@BindView(R.id.title)
TextView title;

@BindView(R.id.subtitle)
TextView subtitle;

@BindView(R.id.first_button)
TextView first_button;

@BindView(R.id.second_button)
TextView second_button;

@BindView(R.id.third_button)
TextView third_button;

@BindView(R.id.first_edit_text)
EditText first_edit_text;

@BindView(R.id.second_edit_text)
EditText second_edit_text;

TextView confirm;
Unbinder unbinder;


public FlatDialog(Context context) {
super(context);
this.context = context;
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.custom_dialog);
unbinder = ButterKnife.bind(this);
title=findViewById(R.id.title);
subtitle=findViewById(R.id.subtitle);
first_button=findViewById(R.id.first_button);
second_button=findViewById(R.id.second_button);
third_button=findViewById(R.id.third_button);
first_edit_text=findViewById(R.id.first_edit_text);
second_edit_text=findViewById(R.id.second_edit_text);
this.getWindow().setBackgroundDrawableResource(android.R.color.white);
this.setCancelable(false);


}

public void setCancelable(boolean cancelable){
public FlatDialog isCancelable(boolean cancelable){
this.setCancelable(cancelable);
return this;
}

public void setTitle(String firstText) {
public FlatDialog setTitle(String firstText) {
title.setText(firstText);
return this;
}

public void isHasTitle(boolean hasTitle){
public FlatDialog isHasTitle(boolean hasTitle){
if (hasTitle) {
title.setVisibility(View.VISIBLE);
} else {
title.setVisibility(View.GONE);
}
return this;
}

public void setSubtitle(String secondText) {
public FlatDialog setSubtitle(String secondText) {
subtitle.setText(secondText);
return this;
}

public void isHasSubtitle(boolean hasSubtitle){
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions flatdialoglibrary/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
</resources>

0 comments on commit c078766

Please sign in to comment.