MCPcopy Index your code
hub / github.com/AnJiaoDe/BaseDialog

github.com/AnJiaoDe/BaseDialog @V1.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release V1.2.2 ↗ · + Follow
149 symbols 314 edges 11 files 45 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

微信公众号 这里写图片描述

简书

GitHub

APK

使用方法

将libray模块复制到项目中,或者直接在build.gradle中依赖:

allprojects {
        repositories {

            maven { url 'https://jitpack.io' }
        }
    }
dependencies {
            compile 'com.github.AnJiaoDe:BaseDialog:V1.1.8'
    }

1.Center

这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:background="@drawable/white_shape"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:text="确定删除吗?"
        android:textSize="16sp"
        android:gravity="center"/>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/line"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="48dp"

            android:text="取消"
            android:id="@+id/tv_cancel"
            android:gravity="center"
            android:textSize="16sp"/>
        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="@color/line"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:id="@+id/tv_confirm"
            android:layout_height="48dp"
            android:text="确定"
            android:gravity="center"

            android:textSize="16sp"/>
    </LinearLayout>
</LinearLayout>

2.Left

这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:background="@color/white"

    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="Google Assistant: 一句 OK, Google,多少手指都用不上了
人工智能是今年的 Google I/O 的一大主题。在发布会一开始,Google CEO 桑达拉·皮蔡(Sundar Pichai)就强调机器学习在生活中扮演的重要角色。随后,一系列基于 Google 人工智能的产品纷至沓来。



OK, Google. 这句耳熟能详的命令,如今承载了 Google 全新的产品——Google Assistant.

之所以 Google Assistant 是发布会上首个亮相的产品,是因为后续登场的数个产品都基于这一技术。Google 用将近十年的时间,改善自己的语音识别技术,更强调自然语义和对话式搜索。"
        android:textSize="16sp" />

</LinearLayout>

3.Top

这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_photo"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:gravity="center"
            android:text="拍照"
            android:textSize="16sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="0.1dp"
            android:background="@color/line" />

        <TextView

            android:id="@+id/tv_album"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:gravity="center"
            android:text="从相册选择"

            android:textSize="16sp" />
    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="@color/bg"/>
    <TextView
        android:id="@+id/tv_photo_cancel"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:gravity="center"
        android:text="取消"

        android:textSize="16sp" />
</LinearLayout>

4.Right

这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:background="@color/white"

    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="Google Assistant: 一句 OK, Google,多少手指都用不上了
人工智能是今年的 Google I/O 的一大主题。在发布会一开始,Google CEO 桑达拉·皮蔡(Sundar Pichai)就强调机器学习在生活中扮演的重要角色。随后,一系列基于 Google 人工智能的产品纷至沓来。



OK, Google. 这句耳熟能详的命令,如今承载了 Google 全新的产品——Google Assistant.

之所以 Google Assistant 是发布会上首个亮相的产品,是因为后续登场的数个产品都基于这一技术。Google 用将近十年的时间,改善自己的语音识别技术,更强调自然语义和对话式搜索。"
        android:textSize="16sp" />

</LinearLayout>

5.Bottom

这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_photo"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:gravity="center"
            android:text="拍照"
            android:textSize="16sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="0.1dp"
            android:background="@color/line" />

        <TextView

            android:id="@+id/tv_album"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:gravity="center"
            android:text="从相册选择"

            android:textSize="16sp" />
    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="@color/bg"/>
    <TextView
        android:id="@+id/tv_photo_cancel"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:gravity="center"
        android:text="取消"

        android:textSize="16sp" />
</LinearLayout>

6.Progress

这里写图片描述

public class MainActivity extends BaseActivity {
    private BaseDialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn_center).setOnClickListener(this);
        findViewById(R.id.btn_left).setOnClickListener(this);
        findViewById(R.id.btn_top).setOnClickListener(this);
        findViewById(R.id.btn_right).setOnClickListener(this);
        findViewById(R.id.btn_bottom).setOnClickListener(this);
        findViewById(R.id.btn_progress).setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.btn_center:
                dialog = new BaseDialog(this);
                dialog.contentView(R.layout.dialog_center)
                        .canceledOnTouchOutside(true).show();
                dialog.findViewById(R.id.tv_confirm).setOnClickListener(this);
                dialog.findViewById(R.id.tv_cancel).setOnClickListener(this);

                break;
            case R.id.btn_left:
                BaseDialog dialog_left = new BaseDialog(this);

                dialog_left.contentView(R.layout.dialog_left)
                        .layoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT))
                        .dimAmount(0.5f)
                        .gravity(Gravity.LEFT | Gravity.CENTER)
                        .animType(BaseDialog.AnimInType.LEFT)
                        .canceledOnTouchOutside(true).show();

                break;
            case R.id.btn_top:
                BaseDialog dialog_top = new BaseDialog(this);

                dialog_top.contentView(R.layout.dialog_photo)
                        .layoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
                        .dimAmount(0.5f)
                        .gravity(Gravity.TOP)
                        .offset(0, ScreenUtils.dpInt2px(this, 48))
                        .animType(BaseDialog.AnimInType.TOP)
                        .canceledOnTouchOutside(true).show();


                break;
            case R.id.btn_right:
                BaseDialog dialog_right = new BaseDialog(this);

                dialog_right.contentView(R.layout.dialog_right)
                        .layoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT))

                        .gravity(Gravity.RIGHT | Gravity.CENTER)
                        .animType(BaseDialog.AnimInType.RIGHT)
                        .offset(20, 0)
                        .canceledOnTouchOutside(true).show();

                break;
            case R.id.btn_bottom:
                BaseDialog dialog_bottom = new BaseDialog(this);

                dialog_bottom.contentView(R.layout.dialog_photo)
                        .gravity(Gravity.BOTTOM)
                        .animType(BaseDialog.AnimInType.BOTTOM)
                        .canceledOnTouchOutside(true).show();


                break;
            case R.id.btn_progress:

                ProgressDialog progressDialog = new ProgressDialog(this);
                progressDialog.color_iv(0xffffffff)
                        .color_bg_progress(0xffffffff)
                        .colors_progress(0xff2a5caa).show();
                break;
            case R.id.tv_confirm:
                dialog.dismiss();
                break;
            case R.id.tv_cancel:
                dialog.dismiss();
                break;
        }

    }
}

源码:

BaseDialog

``` public class BaseDialog extends Dialog {

public BaseDialog(Context context) {
    this(context, 0);

}


public BaseDialog(Context context, int themeResId) {
    super(context, themeResId);

    requestWindowFeature(Window.FEATURE_NO_TITLE);// 去除对话框的标题
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(0x00000000);
    getWindow().setBackgroundDrawable(gradientDrawable);//设置对话框边框背景,必须在代码中设置对话框背景,不然对话框背景是黑色的

    dimAmount(0.2f);
}

public BaseDialog contentView(@LayoutRes int layoutResID) {
    getWindow().setContentView(layoutResID);
    return this;
}


public BaseDialog contentView(@NonNull View view) {
    getWindow().setContentView(view);
    return this;
}

public BaseDialog contentView(@NonNull View view, @Nullable ViewGroup.LayoutParams params) {
    getWindow().setContentView(view, params);
    return this;
}
public BaseDialog layoutParams(@Nullable ViewGroup.LayoutParams params) {
    getWindow().setLayout(params.width, params.height);
    return this;
}


/**
 * 点击外面是否能dissmiss
 *
 * @param canceledOnTouchOutside
 * @return
 */
public BaseDialog canceledOnTouchOutside(boolean canceledOnTouchOutside) {
    setCanceledOnTouchOutside(canceledOnTouchOutside);
    return this;
}

/**
 * 位置
 *
 * @param gravity
 * @return
 */
public BaseDialog gravity(int gravity) {

    getWindow().setGravity(gravity);

    return this;

}

/**
 * 偏移
 *
 * @param x
 * @param y
 * @return
 */
public BaseDialog offset(int x, int y) {
    WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
    layoutParams.x = x;
    layoutParams.y = y;

    return this;
}

/*
   设置背景阴影,必须setContentView之后调用才生效
    */
public BaseDialog dimAmount(float dimAmount) {

    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.dimAmount = dimAmount;
    return this;
}


/*

动画类型 */ public BaseDialog animType(BaseDialog.AnimInType animInType) {

    switch (animInType.getIntType()) {
        case 0:
            getWindow().setWindowAnimations(R.style.dialog_zoom);

            break;
        case 1:
            getWindow().setWindowAnimations(R.style.dialog_anim_left);

            break;
        case 2:
            getWindow().setWindowAnimations(R.style.dialog_anim_top);

            break;
        case 3:
            getWindow().setWindowAnimations(R.style.dialog_anim_right);

            break;
        case 4:
            getWindow().setWindowAnimations(R.style.dialog_anim_bottom);

Extension points exported contracts — how you extend this code

OnPermissionHaveListener (Interface)
(no doc)
app/src/main/java/com/cy/basedialog/BaseActivity.java

Core symbols most depended-on inside this repo

invalidateSelf
called by 9
dialog/src/main/java/com/cy/dialog/progress/MaterialProgressDrawable.java
show
called by 8
dialog/src/main/java/com/cy/dialog/BaseDialog.java
setColor
called by 7
dialog/src/main/java/com/cy/dialog/progress/MaterialProgressDrawable.java
setColorIndex
called by 6
dialog/src/main/java/com/cy/dialog/progress/MaterialProgressDrawable.java
contentView
called by 5
dialog/src/main/java/com/cy/dialog/BaseDialog.java
canceledOnTouchOutside
called by 5
dialog/src/main/java/com/cy/dialog/BaseDialog.java
setStartTrim
called by 5
dialog/src/main/java/com/cy/dialog/progress/MaterialProgressDrawable.java
gravity
called by 4
dialog/src/main/java/com/cy/dialog/BaseDialog.java

Shape

Method 134
Class 13
Enum 1
Interface 1

Languages

Java100%

Modules by API surface

dialog/src/main/java/com/cy/dialog/progress/MaterialProgressDrawable.java71 symbols
app/src/main/java/com/cy/basedialog/BaseActivity.java17 symbols
dialog/src/main/java/com/cy/dialog/progress/CircleImageView.java14 symbols
dialog/src/main/java/com/cy/dialog/BaseDialog.java13 symbols
app/src/main/java/com/cy/basedialog/ScreenUtils.java12 symbols
dialog/src/main/java/com/cy/dialog/progress/ProgressDialog.java11 symbols
app/src/main/java/com/cy/basedialog/MainActivity.java3 symbols
dialog/src/test/java/com/cy/dialog/ExampleUnitTest.java2 symbols
dialog/src/androidTest/java/com/cy/dialog/ExampleInstrumentedTest.java2 symbols
app/src/test/java/com/cy/basedialog/ExampleUnitTest.java2 symbols
app/src/androidTest/java/com/cy/basedialog/ExampleInstrumentedTest.java2 symbols

For agents

$ claude mcp add BaseDialog \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact