1 Star 0 Fork 0

ink_s / PopupUtils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

效果图: 01
02
03
04
05

使用方法:

build.gradle (Project)中

添加 maven { url 'https://jitpack.io' }

allprojects {

repositories {  

    jcenter()  
    
    maven { url 'https://jitpack.io' }  
    
}  

}

build.gradle (app)中

添加 implementation 'com.github.inksnow:popuputils:1.1.4'

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])  

 ......  
 
 implementation 'com.github.inksnow:popuputils:1.1.4'

}

//通用弹窗快捷使用,确认提示,单选多选,时间选择

public class ConvenientPopupActivity extends AppCompatActivity {

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


    public void ccc(View view) {
        switch (view.getId()) {
            case R.id.test5:
                ConvenientPopup.getInstance().showPopupMsg(ConvenientPopupActivity.this, "这是一个消息提示", true, "", true, new PopupView.onClickListener() {
                    @Override
                    public void onYesBack(int what) {
                        T.showShort(getApplicationContext(), "确认");
                    }

                    @Override
                    public void onCancelBack(int what) {
                        T.showShort(getApplicationContext(), "取消");
                    }
                });
                break;
            case R.id.test6:
                List<SelectListDataBean> list = new ArrayList<>();
                for (int i = 0; i < 5; i++) {
                    SelectListDataBean selectListDataBean = new SelectListDataBean();
                    selectListDataBean.setText("请选择选项"+i);
                    selectListDataBean.setChoosed(false);
                    list.add(selectListDataBean);
                }

                ConvenientPopup.getInstance().showSelectBottom(ConvenientPopupActivity.this, "请选择", true, list, null);
                break;

            case R.id.test7:
                List<SelectListDataBean> list2 = new ArrayList<>();
                for (int i = 0; i < 5; i++) {
                    SelectListDataBean selectListDataBean = new SelectListDataBean();
                    selectListDataBean.setText("请选择选项"+i);
                    selectListDataBean.setChoosed(false);
                    list2.add(selectListDataBean);
                }

                ConvenientPopup.getInstance().showSelectCenter(ConvenientPopupActivity.this, "", false, list2, null);
                break;
            case R.id.test8:

                ConvenientPopup.getInstance().showPopupSelectDataAmPm(ConvenientPopupActivity.this,null , 0);
                break;
            case R.id.test9:

                ConvenientPopup.getInstance().showPopupSelectDataHHSSMM(ConvenientPopupActivity.this,null , 0);
                break;


        }
    }
    //为了解决弹出PopupWindow后点击穿透问题
    @Override
    public boolean dispatchTouchEvent(MotionEvent event){
        if ( ConvenientPopup.getInstance().isPopupShowing()){
            return false;
        }else{
            return super.dispatchTouchEvent(event);
        }
    }
}

//popupPrompt使用

  PromptSettings.Builder builder = new PromptSettings.Builder();  
  
  PromptSettings promptSettings = builder.build();  
  
  popupPrompt.popupPrompt(window,context,inflater,promptSettings,0);  

//自定义效果

PromptSettings.Builder builder = new PromptSettings.Builder(); 
builder = new PromptSettings.Builder();
builder.bgAlpha(0.6f)
      .duration(2000)
      .bgColour(new int[]{0XFFFF0000,  0XFFFFFFFF})
      .showImage(true)
      .showMode(PromptSettings.MODE_SHOW_IMAGE)
      .image(getDrawable(R.drawable.ic_launcher_foreground))
      .imageWidth(160)
      .imageAnim(anim)
      .buttonColour(0XFFFF0000)
      .popupAnim(R.style.popup_bottom_top)
      .location(Gravity.BOTTOM);
promptSettings = builder.build();
popupPrompt.popupPrompt(window,context,inflater,promptSettings,0);

//PopupPrompt可设置的属性及其默认值

      //宽
      private int width = WindowManager.LayoutParams.MATCH_PARENT;
      //高
      private int height = 160;
      //位置
      private int location = Gravity.TOP;
      private boolean focusable = false;
      private boolean outsideTouchable = false;
      private boolean touchable = true;
      private int inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED;
      private int softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
      //弹窗miss监听
      private PopupWindow.OnDismissListener dismissListener = null;
      //右侧按键监听
      private PopupPrompt.onClickListener clickListener = null;
      //圆角 (必须是8个值)
      private  float[] radius={0,0,0,0,0,0,0,0};
      //背景色(渐变色数组,必须大于等于2个值,如果是单色就用2个一样的颜色)
      private int[] bgColour = {0XFF03a9f4,0XFF03a9f4};
      //ProgressBar 颜色
      private int proColour = 0XFFFFFFFF;
      //文字颜色
      private int textColour = 0XFFFFFFFF;
      //按钮文字颜色
      private int buttonColour = 0XFFFFFFFF;
      //文字和按钮字体大小
      private   float textSize = 18;
      //显示左边的图片
      private Drawable image = null;
      //显示左边的图片动画
      private Animation imageAnim = null;
      //提示文字
      private String text = "这是一个提示框!";
      //按钮文字
      private String buttonText = "好的";
      //是否显示文字
      private boolean showText = true;
      //是否显示按钮
      private boolean showButton = true;
      //是否显示左边Pro 或 图片
      private boolean showImage = false;
      //图片宽度
      private int imageWidth = 120;
      //Padding
      private int[] imagePaddings = {20, 20, 20, 20};
      private int[] buttonPaddings = {20, 20, 20, 20};
      private int[] textPaddings = {0, 0, 0, 0};
      //显示图片还是ProgressBar
      private int showMode = MODE_SHOW_PRO;
      //自动消失时间,小于等于0 不自动消失
      private int duration = 3000;
      //背景透明度
      private float bgAlpha = 1.0f;
      //text左  右  中
      private int textGravity = Gravity.CENTER_VERTICAL;
      //弹窗动画,默认style.popup_fade_in_out 写好的有 popup_top_down popup_bottom_top popup_left_right
      //可以传入自己的动画
      private int popupAnim = 0;
      //X  Y 坐标的偏移值,根据此值可以自定义位置
      private int gravityX = 0;
      private int gravityY = 0;

//PopupSelect使用

                SelectSettings.Builder builder = new SelectSettings.Builder();
                SelectSettings selectSettings =
                        builder.selectListDataBean(selectListDataBeans)
                                .clickListener(selectBackListener)
                                .build();
                popupSelect.popupSelect(window,context,inflater,selectSettings,0);
                
                
                
                 
                builder = new SelectSettings.Builder();
                selectSettings =
                        builder.selectListDataBean(selectListDataBeans2)
                                .clickListener(selectBackListener)
                                .titleTextStr("请选择语言")
                                .titleIcon(getDrawable(R.drawable.l))
                                .titleTextPaddings(new int[]{10,20,0,20})
                                .showTitleIcon(true)
                                .multipleSelection(false)
                                .showListIcon(true)
                                .build();
                popupSelect.popupSelect(window,context,inflater,selectSettings,0);

//popupSelect可设置的属性及其默认值

        //确认按钮点击后的回调,或单选没设置确认按钮点击list选项的回调
      private  PopupSelect.onClickListener clickListener = null;
      //List 数据
      private List<SelectListDataBean> selectListDataBean = null;
      //是否可以多选
      private boolean multipleSelection = true;

      //PopupWindow的一些设置,默认点击外边PopupWindow消失
      //如果想设置点击外边不消失设置focusable = false ,outsideTouchable = false
      //在activity中拦截点击事件
      //     @Override
      //    public boolean dispatchTouchEvent(MotionEvent event){
      //        if (popupSelect.getpWindow()!= null && popupSelect.getpWindow().isShowing()){
      //            return false;
      //        }else{
      //            return super.dispatchTouchEvent(event);
      //        }
      //    }
      private boolean focusable = true;
      private boolean outsideTouchable = false;
      private boolean touchable = true;
      private int inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED;
      private int softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
      //背景色,必须大于等于2个值,设置不同的多个值为渐变效果
      private int[] popupBg ={0XFFFFFFFF,0XFFFFFFFF};
      // 设置图片四个角圆形半径:1、2两个参数表示左上角,3、4表示右上角,5、6表示右下角,7、8表示左下角
      private float[] popupRadius ={20,20,20,20,20,20,20,20};
      //Paddings 设置此值可以调节布局位置
      private int[] titleIconPaddings = {60,10,10,10};
      private int[] titleTextPaddings={80,20,20,20};
      private int[] listPaddings={20,10,20,10};
      private int[] buttonPaddings={20,20,20,20};
      //宽
      private int popupWidth =700;
      //高
      private int popupHeight=460;
      //标题图标
      private int titleIconWidth=140;
      private int titleIconHeight=100;
      //是否显示标题图标和文字布局
      private boolean showTitle = true;
      //标题布局背景
      private int[] titleBg ={0X00000000,0X00000000};
      //是否显示标题图标
      private boolean showTitleIcon = true;
      //标题图标资源
      private Drawable titleIcon = null;
      //是否显示标题文字
      private boolean showTitleText = true;
      //标题文字内容
      private String titleTextStr = "请设置标题";
      //标题文字颜色
      private int titleTextColor = 0XFF333333;
      //标题文字大小
      private int titleTextSize = 18;
      //标题文字位置
      private int titleTextGravity = Gravity.CENTER_VERTICAL;
      //是否显示右边滚动条
      private boolean scrollBarEnabled = true;
      //滚动条自动消失时间
      private int scrollBarFadeDuration = 5000;
      //滚动条大小
      private int scrollBarSize = 5;
      //滚动条style
      private int scrollBarStyle =View.SCROLLBARS_INSIDE_INSET ;
      //button1文字
      private String buttonTextStr1 = "取消";
      //button2文字
      private String buttonTextStr2 = "确定";
      //按钮字体大小
      private int buttonTextSize = 18;
      //按钮文字颜色
      private int buttonTextColor1=0XFF03a9f4;
      private int buttonTextColor2=0XFF03a9f4;
      //是否显示该按钮
      private boolean showButton1 = true;
      private boolean showButton2 = true;
      //标题下分割线颜色
      private int titleDividingColor = 0X33AAAAAA;
      //按钮分割线颜色
      private int buttonDividingColor= 0X33AAAAAA;
      //每一条list高度
      private int listHeight = 100;
      //list选框高宽
      private int listSelectImageHeight = 80;
      private int listSelectImageWidth = 110;
      //list 图标高宽
      private int listIconHeight = 80;
      private int listIconWidth = 80;
      //list文字大小
      private int listTextSize = 16;
      //paddings
      private int[] listSelectImagePaddings={60,10,10,10};
      private int[] listIconPaddings={20,10,10,10};
      private int[] listTextPaddings={10,10,10,10};
      //选中选框
      private Drawable listSelectImageOn = null;
      //未选中选框
      private Drawable listSelectImageOff = null;
      private Drawable listIcon = null;
      //list文字颜色
      private int listTextColor = 0XFF333333;
      //list选中后文字颜色
      private int listTextSelectColor = 0XFF03a9f4;
      //list文字位置
      private int listTextGravity = Gravity.CENTER_VERTICAL;
      //是否显示选框
      private boolean showListSelectImage = true;
      //是否显示图标
      private boolean showListIcon = true;
      //list分割线
      private  Drawable listDivider = null;
      //list分割线高度
      private  int listDividerHeight = 1;
      //背景透明度
      private float bgAlpha = 0.6f;
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

暂无描述 展开 收起
Java
Apache-2.0
取消

发行版 (34)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ink_s/PopupTest.git
git@gitee.com:ink_s/PopupTest.git
ink_s
PopupTest
PopupUtils
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891