Using Activity to achieve dialog effect

Note: the requirement of the company is to add an input box in the bottom pop-up box, and the bottom part is the time selector. When clicking the edit box, the layout of the time selection box will be blocked

Input box cannot be controlled using fragmentDialog

1. Set Activity's pop-up theme and pop-up animation style in styles

 <!--ActivityDialog Bottom flyout start-->
    <style name="ActivityDialogTheme">
        <item name="android:windowBackground">@android:color/transparent
        </item> <!--Set up dialog Background of, where the transparency value given to the system-->
        <item name="android:windowFrame">@null</item>                <!--Dialog Of windowFrame Box is no-->
        <item name="android:windowNoTitle">true</item>         <!--Show title or not-->
        <item name="android:windowIsFloating">true</item>            <!--Whether to emerge in activity Above-->
        <item name="android:windowIsTranslucent">true</item>         <!--Translucence or not-->
        <item name="android:windowContentOverlay">@null</item>       <!--Whether there is coverage-->
        <item name="android:windowAnimationStyle">@style/AnimationActivity
        </item>   <!--Set up Activity Emergence mode-->
        <item name="android:backgroundDimEnabled">true</item>        <!--Whether the background is blurred-->
        <item name="android:windowTranslucentStatus">true</item>    <!-- Set background transparent color-->
        <item name="android:windowTranslucentNavigation">true</item>
    </style>

//Pop up animation style

 <!--Animation style popping from the bottom-->
    <style name="AnimationActivity" mce_bogus="1" parent="@android:style/Animation.Activity">
        <!--One activity Create the effect of the entry.-->
        <item name="android:activityOpenEnterAnimation">@anim/slide_in_bottom</item>
        <!--One activity Not yet finish()Lower exit effect, Like two activity A And B First start A Then start again B that A Not yet finish()  Then A The exit effect of.-->
        <item name="android:activityOpenExitAnimation">@anim/slide_out_bottom</item>
        <!--Indicates previous activity Return to the entry effect, for example, there are two activity A And B  B At the top, B Sign out(finish)after A The effect of re-entry.-->
        <item name="android:activityCloseEnterAnimation">@anim/slide_in_bottom</item>
        <!--It means that activity finish()After that, for example, there are two activity A And B B Will be finish() that B The exit effect of is defined here.-->
        <item name="android:activityCloseExitAnimation">@anim/slide_out_bottom</item>
    </style>

2. Exit and enter animation layout

(1) Under res file, create anim file and create slide out bottom.xml to exit animation layout

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromYDelta="0%"
        android:startOffset="0"
        android:toYDelta="100%" />
</set>

(2) Create slide out bottom to enter animation layout

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromYDelta="100%"
        android:startOffset="0"
        android:toYDelta="0%" />
</set>

3. Code part

(1) Create MinePetTimeActivityDialog class

Layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context=".ui.dialog.MinePetTimeActivityDialog">

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

        <LinearLayout
            android:id="@+id/rl"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical" />

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none">

            <RelativeLayout
                android:id="@+id/rl_root"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

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

                    <cn.ipets.chongmingandroid.ui.widget.roundlayout.RCRelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:focusable="false"
                        android:focusableInTouchMode="false"
                        app:round_corner_top_left="12dp"
                        app:round_corner_top_right="12dp">


                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:background="@drawable/shape_dialog_white_top"
                            android:orientation="vertical">


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


                                <RelativeLayout
                                    android:layout_width="match_parent"
                                    android:layout_height="@dimen/dp51"
                                    android:orientation="horizontal">

                                    <TextView
                                        android:id="@+id/tv_cancel"
                                        style="@style/TextViewFontNormal"
                                        android:layout_width="wrap_content"
                                        android:layout_height="@dimen/dp51"
                                        android:layout_alignParentStart="true"
                                        android:layout_centerVertical="true"
                                        android:layout_marginStart="@dimen/dp20"
                                        android:gravity="center_vertical"
                                        android:text="cancel"
                                        android:textColor="@color/colorGrayText1"
                                        android:textSize="16sp" />

                                    <TextView
                                        android:id="@+id/tv_title"
                                        style="@style/TextViewFontMedium"
                                        android:layout_width="match_parent"
                                        android:layout_height="@dimen/dp50"
                                        android:layout_centerInParent="true"
                                        android:ellipsize="end"
                                        android:gravity="center"
                                        android:paddingLeft="10dp"
                                        android:paddingRight="10dp"
                                        android:singleLine="true"
                                        android:text="Vaccine record"
                                        android:textColor="@color/colorBtnText"
                                        android:textSize="16sp" />

                                    <TextView
                                        android:id="@+id/tv_confirm"
                                        style="@style/TextViewFontMedium"
                                        android:layout_width="wrap_content"
                                        android:layout_height="@dimen/dp51"
                                        android:layout_alignParentEnd="true"
                                        android:layout_centerVertical="true"
                                        android:layout_marginEnd="@dimen/dp20"
                                        android:gravity="center_vertical"
                                        android:text="Determine"
                                        android:textColor="@color/colorBlueText"
                                        android:textSize="16sp" />

                                    <View
                                        android:layout_width="match_parent"
                                        android:layout_height="0.5dp"
                                        android:layout_alignParentBottom="true"
                                        android:background="@color/colorLine" />
                                </RelativeLayout>


                                <RelativeLayout
                                    android:id="@+id/rl_date"
                                    android:layout_width="match_parent"
                                    android:layout_height="@dimen/dp48"
                                    android:focusable="true"
                                    android:focusableInTouchMode="false">

                                    <TextView
                                        android:id="@+id/tv_date"
                                        style="@style/TextViewFontMedium"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content"
                                        android:layout_centerVertical="true"
                                        android:layout_marginStart="@dimen/dp20"
                                        android:focusable="false"
                                        android:focusableInTouchMode="false"
                                        android:gravity="center_vertical"
                                        android:text="Date of injection"
                                        android:textColor="@color/colorBlackText"
                                        android:textSize="16sp"
                                        tools:ignore="Suspicious0dp" />

                                    <TextView
                                        android:id="@+id/tv_time"
                                        style="@style/TextViewFontMedium"
                                        android:layout_width="wrap_content"
                                        android:layout_height="match_parent"
                                        android:layout_alignParentEnd="true"
                                        android:layout_centerVertical="true"
                                        android:layout_marginEnd="@dimen/dp20"
                                        android:focusable="false"
                                        android:focusableInTouchMode="false"
                                        android:gravity="center_vertical|end"
                                        android:text="2020-01-01"
                                        android:textColor="@color/colorBlackText"
                                        android:textSize="16sp" />

                                    <View
                                        android:layout_width="match_parent"
                                        android:layout_height="0.5dp"
                                        android:layout_alignParentBottom="true"
                                        android:background="@color/colorLine"
                                        android:focusable="false"
                                        android:focusableInTouchMode="false" />
                                </RelativeLayout>


                                <RelativeLayout
                                    android:id="@+id/rl_bei_zhu"
                                    android:layout_width="match_parent"
                                    android:layout_height="@dimen/dp48"
                                    android:focusable="false"
                                    android:focusableInTouchMode="false"
                                    android:gravity="center_vertical"
                                    android:orientation="horizontal">

                                    <TextView
                                        android:id="@+id/tv_bei_zhu"
                                        style="@style/TextViewFontMedium"
                                        android:layout_width="wrap_content"
                                        android:layout_height="match_parent"
                                        android:layout_marginStart="@dimen/dp20"
                                        android:gravity="center_vertical"
                                        android:text="Remarks"
                                        android:textColor="@color/colorGrayText1"
                                        android:textSize="16sp"
                                        tools:ignore="Suspicious0dp" />

                                    <EditText
                                        android:id="@+id/et_bei_zhu"
                                        style="@style/TextViewFontMedium"
                                        android:layout_width="@dimen/dp285"
                                        android:layout_height="match_parent"
                                        android:layout_alignParentEnd="true"
                                        android:layout_marginEnd="@dimen/dp20"
                                        android:background="@null"
                                        android:ellipsize="end"
                                        android:gravity="right|center_vertical"
                                        android:hint="Please fill in the name of vaccine"
                                        android:inputType="text"
                                        android:maxLength="20"
                                        android:maxLines="1"
                                        android:singleLine="true"
                                        android:textColor="@color/colorBlackText"
                                        android:textColorHint="@color/colorGrayText1"
                                        android:textSize="16sp" />

                                    <View
                                        android:layout_width="match_parent"
                                        android:layout_height="0.5dp"
                                        android:layout_alignParentBottom="true"
                                        android:background="@color/colorLine" />
                                </RelativeLayout>

                                <View
                                    android:id="@+id/v"
                                    android:layout_width="0dp"
                                    android:layout_height="0dp" />
                            </LinearLayout>


                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="bottom"
                                android:orientation="horizontal">

                                <FrameLayout
                                    android:id="@+id/fragment"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:focusable="false"
                                    android:focusableInTouchMode="false" />
                            </LinearLayout>
                        </LinearLayout>

                    </cn.ipets.chongmingandroid.ui.widget.roundlayout.RCRelativeLayout>

                </LinearLayout>

            </RelativeLayout>
        </ScrollView>
    </LinearLayout>
</RelativeLayout>

java code, mainly to start animation

//Define member variables for Activity exit animation
    protected int activityCloseEnterAnimation;
    protected int activityCloseExitAnimation;





//Initialize in onCreate method
 TypedArray activityStyle = getTheme().obtainStyledAttributes(new int[]{android.R.attr.windowAnimationStyle});
        int windowAnimationStyleResId = activityStyle.getResourceId(0, 0);
        activityStyle.recycle();
        activityStyle = getTheme().obtainStyledAttributes(windowAnimationStyleResId, new int[]{android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation});
        activityCloseEnterAnimation = activityStyle.getResourceId(0, 0);
        activityCloseExitAnimation = activityStyle.getResourceId(1, 0);
        activityStyle.recycle();



 //Override finish method
    @Override
    public void finish() {
        super.finish();
        //Call exit animation on finish
        overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
    }

(2) Set theme in Android manifest.xml

<activity
            android:name=".ui.dialog.MinePetTimeActivityDialog"
            android:theme="@style/ActivityDialogTheme"
            android:windowSoftInputMode="adjustResize|stateHidden" />
        <activity

4. Complete java code

package cn.ipets.chongmingandroid.ui.dialog;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.CustomListener;
import com.bigkoo.pickerview.listener.OnTimeSelectChangeListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.blankj.utilcode.util.SizeUtils;
import com.chongminglib.util.ScreenUtil;
import com.chongminglib.util.ScreenUtils;
import com.contrarywind.view.WheelView;

import org.greenrobot.eventbus.EventBus;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.ipets.chongmingandroid.R;
import cn.ipets.chongmingandroid.event.SendMinePetDialogDataEvent;
import cn.ipets.chongmingandroid.model.entity.PetHealthNoteBean;
import cn.ipets.chongmingandroid.model.entity.PetHealthRemindBean;
import cn.ipets.chongmingandroid.util.DateUtils;
import cn.ipets.chongmingandroid.util.KeyBoardUtil;
import cn.ipets.chongmingandroid.util.ToastUtils;

public class MinePetTimeActivityDialog extends Activity implements View.OnClickListener {
    @BindView(R.id.rl)
    LinearLayout relativeLayout;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    @BindView(R.id.tv_date)
    TextView tvDate;
    @BindView(R.id.tv_bei_zhu)
    TextView tvBeiZhu;
    @BindView(R.id.et_bei_zhu)
    EditText etBeiZhu;
    @BindView(R.id.fragment)
    FrameLayout fragment;

    @BindView(R.id.rl_date)
    RelativeLayout rlDate;
    @BindView(R.id.rl_bei_zhu)
    RelativeLayout rlBeiZhu;
    @BindView(R.id.v)
    View v;


    //Define member variables for Activity exit animation
    protected int activityCloseEnterAnimation;
    protected int activityCloseExitAnimation;
    private Context mContext;
    private TimePickerView pvTime;
    private long time = System.currentTimeMillis();
    private String mType = "";
    private int mPetId;
    private boolean isNotes;
    private PetHealthNoteBean.DataBean.ContentBean bean;
    private boolean isRemindToNotes;
    private PetHealthRemindBean.DataBean beanHealth;
    private boolean isSelect;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.activity_mine_pet_time_dialog);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        mType = getIntent().getStringExtra("type");
        mPetId = getIntent().getIntExtra("petId", 0);
        isNotes = getIntent().getBooleanExtra("isNotes", false);
        bean = (PetHealthNoteBean.DataBean.ContentBean) getIntent().getSerializableExtra("bean");
        beanHealth = (PetHealthRemindBean.DataBean) getIntent().getSerializableExtra("beanHealth");
        isRemindToNotes = getIntent().getBooleanExtra("isRemindToNotes", false);
        ButterKnife.bind(this);
        initView();
        initTransferData();
        initListener();
    }

    @Override
    protected void onStart() {
        super.onStart();
        if (isSelect) {
            etBeiZhu.setFocusable(true);
            etBeiZhu.requestFocus();
            etBeiZhu.setFocusableInTouchMode(true);
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.showSoftInput(etBeiZhu, InputMethodManager.SHOW_IMPLICIT);
        }
        Window window = getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        windowParams.dimAmount = 0.5f;//Set grayscale
        window.setAttributes(windowParams);
    }

    private void initView() {
        TypedArray activityStyle = getTheme().obtainStyledAttributes(new int[]{android.R.attr.windowAnimationStyle});
        int windowAnimationStyleResId = activityStyle.getResourceId(0, 0);
        activityStyle.recycle();
        activityStyle = getTheme().obtainStyledAttributes(windowAnimationStyleResId, new int[]{android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation});
        activityCloseEnterAnimation = activityStyle.getResourceId(0, 0);
        activityCloseExitAnimation = activityStyle.getResourceId(1, 0);
        activityStyle.recycle();

        //Set layout at bottom
        getWindow().setGravity(Gravity.BOTTOM);
        //Set layout fill full width
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        getWindow().setAttributes(layoutParams);
        initTimePicker();
        setYiMiaoTextColor(1);

        tvTime.setText(DateUtils.getStringDateYMD());

    }

    @SuppressLint("ClickableViewAccessibility")
    private void initListener() {
        relativeLayout.setOnClickListener(this);
        rlDate.setOnClickListener(this);
        tvCancel.setOnClickListener(this);
        tvConfirm.setOnClickListener(this);
        etBeiZhu.setOnTouchListener((v, event) -> {
            etBeiZhu.setFocusable(true);
            etBeiZhu.setFocusableInTouchMode(true);
            if (event.getAction() == MotionEvent.ACTION_UP) {
                isSelect = true;
                setYiMiaoTextColor(2);
            }
            return false;
        });

        rlBeiZhu.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
            Rect r = new Rect();
            //Get the visible part of the current interface
            getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
            //Get the height of the screen
            int screenHeight = getWindow().getDecorView().getRootView().getHeight();
            //This is used to get the height of the keyboard. When the keyboard does not pop up, the height is 0. When the keyboard pops up, it is a positive number
            int heightDifference = screenHeight - r.bottom;
            lockContentHeight();
            unlockContentHeightDelayed(heightDifference);

        });
    }


    /**
     * Lock content height to prevent flashing
     */
    private void lockContentHeight() {
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) rlBeiZhu.getLayoutParams();
        params.height = rlBeiZhu.getHeight();
        params.weight = 0.0F;
    }


    /**
     * Release locked content height
     */
    public void unlockContentHeightDelayed(final int heightDifference) {
        etBeiZhu.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (rlBeiZhu == null) {
                    return;
                }
                ((LinearLayout.LayoutParams) rlBeiZhu.getLayoutParams()).weight = 1.0F;
                ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
                //576
//                layoutParams.height = heightDifference - ScreenUtils.dp2px(mContext, 105);
                layoutParams.height = heightDifference - 120;
                v.setLayoutParams(layoutParams);
            }
        }, 10L);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_date:
                KeyBoardUtil.closeKeybord(etBeiZhu, mContext);
                etBeiZhu.setFocusable(false);
                etBeiZhu.setFocusableInTouchMode(false);
                setYiMiaoTextColor(1);
                break;
            case R.id.rl:
            case R.id.tv_cancel:
                EventBus.getDefault().post(new SendMinePetDialogDataEvent(new HashMap<>(), 4));//cancel
                finish();
                break;
            case R.id.tv_confirm:
                Map map = new HashMap();
                if (map.size() > 0) {
                    map.clear();
                }
                map.put("type", "VACCINE");
                map.put("content", etBeiZhu.getText().toString().trim());
                if (time >= System.currentTimeMillis()) {
                    ToastUtils.showCustomToast(mContext, "Record date cannot be greater than current date");
                    return;
                }
                map.put("noteTime", "" + time);
                map.put("petId", mPetId);
                if (isRemindToNotes) {
                    map.put("petHealthNoteRemindId", beanHealth.getId());
                }
                if (!isNotes && !isRemindToNotes) {
                    EventBus.getDefault().post(new SendMinePetDialogDataEvent(map, 1));//1 new additions
                } else if (isNotes) {
                    EventBus.getDefault().post(new SendMinePetDialogDataEvent(map, 2));// 2 record jump
                } else {
                    EventBus.getDefault().post(new SendMinePetDialogDataEvent(map, 3));//3 reminder transfer record
                }
                finish();
                break;
        }

    }


    private void initTransferData() {
        if (isNotes) {
            tvTime.setText(DateUtils.longToDate1(Long.parseLong(bean.getNoteTime())));
            time = Long.parseLong(bean.getNoteTime());
            if (!TextUtils.isEmpty(bean.getContent())) {
                etBeiZhu.setText(bean.getContent());
            }
        }

    }

    private void setYiMiaoTextColor(int i) {//1Date 2 edit box
        switch (i) {
            case 1:
                tvDate.setTextColor(mContext.getResources().getColor(R.color.colorBlackText));
                tvTime.setTextColor(mContext.getResources().getColor(R.color.colorBlackText));
                tvBeiZhu.setTextColor(mContext.getResources().getColor(R.color.colorGrayText1));
                etBeiZhu.setTextColor(mContext.getResources().getColor(R.color.colorGrayText1));

                break;
            case 2:
                tvDate.setTextColor(mContext.getResources().getColor(R.color.colorGrayText1));
                tvTime.setTextColor(mContext.getResources().getColor(R.color.colorGrayText1));
                tvBeiZhu.setTextColor(mContext.getResources().getColor(R.color.colorBlackText));
                etBeiZhu.setTextColor(mContext.getResources().getColor(R.color.colorBlackText));
                break;
        }

    }

    private void initTimePicker() {
        //Control time range (if the range is not set, the default time is 1900-2100, which can be commented)
        //Because the month of the system Calendar is from 0-11, if you call the set method of Calendar to set the time, the range of the month is also from 0-11
        Calendar selectedDate = Calendar.getInstance();

        if (isNotes) {
            selectedDate.set(Integer.parseInt(DateUtils.getDateToString(Long.parseLong(bean.getNoteTime()), "yyyy")),
                    Integer.parseInt(DateUtils.getDateToString(Long.parseLong(bean.getNoteTime()), "MM")) - 1,
                    Integer.parseInt(DateUtils.getDateToString(Long.parseLong(bean.getNoteTime()), "dd")));

        }
        Calendar startDate = Calendar.getInstance();

        startDate.set(1975, 0, 1);


        Calendar endDate = Calendar.getInstance();
        endDate.set(2095, 11, 31);
        //Time selector
        pvTime = new TimePickerBuilder(mContext, (date, v) -> {//Select event callback
        })
                .setTimeSelectChangeListener(new OnTimeSelectChangeListener() {//Listen when event callback is selected
                    @Override
                    public void onTimeSelectChanged(Date date) {
                        if (tvTime != null) {
                            tvTime.setText(DateUtils.dateToString(date, "yyyy-MM-dd"));
                        }
                        time = date.getTime();
                    }
                })
                .setLayoutRes(R.layout.pickerview_custom_time, new CustomListener() {

                    @Override
                    public void customLayout(View v) {
                        final TextView tvSubmit = v.findViewById(R.id.tv_finish);
                        ImageView ivCancel = v.findViewById(R.id.iv_cancel);
                        WheelView year = v.findViewById(R.id.year);
                        year.setTextSize(45);
                        year.setCyclic(true);
                        tvSubmit.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                pvTime.returnData();
                                /*pvTime.dismiss();*/
                            }
                        });
                        ivCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                /*pvTime.dismiss();*/
                            }
                        });
                    }
                })
                .setType(new boolean[]{true, true, true, false, false, false})
                .setLabel("year", "month", "day", "", "", "") //Set an empty string to hide the unit prompt hide label
//                .setDividerColor(Color.DKGRAY)
//                . setContentTextSize(20) / / set text size
                .setItemVisibleCount(7)
                .setDate(selectedDate)//Selected time
                .setRangDate(startDate, endDate)
//                .setRangDate(startDate, endDate)
                .setDecorView(fragment)//In non dialog mode, set ViewGroup, and pickerview will be added to this ViewGroup
                .setOutSideColor(0x00000000)
                .setOutSideCancelable(false)
                .isAlphaGradient(true)//Transparency gradient
                .setDividerColor(mContext.getResources().getColor(R.color.colorC8C7CC))
                .setTextColorCenter(mContext.getResources().getColor(R.color.colorBtnText))
                .setTextColorOut(mContext.getResources().getColor(R.color.color999999))
//                . setLineSpacingMultiplier(1.8f) / / set row height
                .build();
        pvTime.show();
        pvTime.setKeyBackCancelable(false);//System back key monitoring blocked

    }

    //New creation
    public static void startDialogActivity(Context context, String type, int petId) {
        Intent intent = new Intent(context, MinePetTimeActivityDialog.class);
        intent.putExtra("type", type);
        intent.putExtra("petId", petId);
        context.startActivity(intent);
    }

    //Record specific

    public static void startDialogActivity(Context context, String type, int petId, boolean isNotes, PetHealthNoteBean.DataBean.ContentBean bean) {
        Intent intent = new Intent(context, MinePetTimeActivityDialog.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable("bean", bean);
        intent.putExtras(bundle);
        intent.putExtra("type", type);
        intent.putExtra("petId", petId);
        intent.putExtra("isNotes", isNotes);
        context.startActivity(intent);
    }

    //Reminder transfer record
    public static void startDialogActivity(Context context, String type, int petId, boolean isRemindToNotes, PetHealthRemindBean.DataBean bean) {
        Intent intent = new Intent(context, MinePetTimeActivityDialog.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable("beanHealth", bean);
        intent.putExtras(bundle);
        intent.putExtra("type", type);
        intent.putExtra("petId", petId);
        intent.putExtra("isRemindToNotes", isRemindToNotes);
        context.startActivity(intent);
    }

    //Override finish method
    @Override
    public void finish() {
        super.finish();
        //Call exit animation on finish
        overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
    }


    @Override
    protected void onDestroy() {
        mType = "";
        mPetId = 0;
        isNotes = false;
        bean = null;
        super.onDestroy();
    }
}

Design sketch

Published 59 original articles, won praise 13, visited 30000+
Private letter follow

Tags: Android Java xml Fragment

Posted on Tue, 11 Feb 2020 11:19:24 -0500 by renekosterman