公会时间筛选器功能修改
This commit is contained in:
@@ -14,6 +14,7 @@ import com.jzxiang.pickerview.data.Type;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
import com.yizhuan.erban.module_hall.hall.view.dialog.TimePickerClanDialog;
|
||||
import com.yizhuan.erban.module_hall.hall.view.dialog.TimePickerDialog;
|
||||
import com.yizhuan.erban.module_hall.hall.view.indicator.StatisticsIndicatorAdapter;
|
||||
import com.yizhuan.erban.module_hall.income.ClanIncomeFragment;
|
||||
@@ -45,7 +46,7 @@ import butterknife.OnClick;
|
||||
|
||||
@CreatePresenter(ClanIncomePresenter.class)
|
||||
public class ClanIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, ClanIncomePresenter>
|
||||
implements IIncomeStatisticsView, TimePickerDialog.TimePickerListener, ClanIncomeFragment.DayIncomeFragmentListener {
|
||||
implements IIncomeStatisticsView, TimePickerClanDialog.TimePickerListener, ClanIncomeFragment.DayIncomeFragmentListener {
|
||||
|
||||
private static final int TYPE_DAY = 0;
|
||||
private static final int TYPE_WEEK = 1;
|
||||
@@ -186,7 +187,7 @@ public class ClanIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, C
|
||||
boolean isMonth = mCurrentType == TYPE_MONTH;
|
||||
boolean isDay = mCurrentType == TYPE_DAY;
|
||||
|
||||
TimePickerDialog.Builder builder = new TimePickerDialog.Builder()
|
||||
TimePickerClanDialog.Builder builder = new TimePickerClanDialog.Builder()
|
||||
.setType(Type.YEAR_MONTH_DAY)
|
||||
.setTitleStringId("")
|
||||
.setThemeColor(getResources().getColor(R.color.line_color))
|
||||
@@ -201,7 +202,7 @@ public class ClanIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, C
|
||||
.setDayFirstTime(mDayFirstTime)
|
||||
.setDayLastTime(mDayLastTime);
|
||||
|
||||
TimePickerDialog dialog = builder.build();
|
||||
TimePickerClanDialog dialog = builder.build();
|
||||
dialog.setmTimePickerListener(this);
|
||||
dialog.show(getSupportFragmentManager(), "year_month_day");
|
||||
break;
|
||||
|
@@ -0,0 +1,447 @@
|
||||
package com.yizhuan.erban.module_hall.hall.view.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.jzxiang.pickerview.config.PickerConfig;
|
||||
import com.jzxiang.pickerview.data.Type;
|
||||
import com.jzxiang.pickerview.data.WheelCalendar;
|
||||
import com.jzxiang.pickerview.listener.OnDateSetListener;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Created by jzxiang on 16/4/19.
|
||||
*/
|
||||
public class TimePickerClanDialog extends DialogFragment implements View.OnClickListener {
|
||||
PickerConfig mPickerConfig;
|
||||
RelativeLayout rlWeekGroup;
|
||||
TextView tvWeekFirstDay;
|
||||
TextView tvWeekLastDay;
|
||||
TextView tvDay;
|
||||
TextView tvWeek;
|
||||
TextView tvMonth;
|
||||
private TimeWheel mTimeWheel;
|
||||
private long mCurrentMillSeconds;
|
||||
private long mFirstMs;
|
||||
private TimePickerListener mTimePickerListener;
|
||||
private String mWeekFirstDay;
|
||||
private String mWeekLastDay;
|
||||
|
||||
private long mDayFirstTime;
|
||||
private long mDayLastTime;
|
||||
private final String defDayEndText = ResUtil.getString(R.string.view_dialog_timepickerdialog_01);
|
||||
|
||||
private static final int TYPE_DAY = 0;
|
||||
private static final int TYPE_WEEK = 1;
|
||||
private static final int TYPE_MONTH = 2;
|
||||
|
||||
/**
|
||||
* 显示周区间
|
||||
*/
|
||||
private boolean mIsWeek;
|
||||
private boolean isMonth;
|
||||
private boolean isDay;
|
||||
private int mCurrentType;
|
||||
|
||||
private static TimePickerClanDialog newInstance(PickerConfig pickerConfig, long firstMs, boolean isWeek, boolean isMonth, boolean isDay, long dayFirstTime, long dayLastTime) {
|
||||
TimePickerClanDialog timePickerDialog = new TimePickerClanDialog();
|
||||
timePickerDialog.initialize(pickerConfig, firstMs, isWeek, isMonth, isDay, dayFirstTime, dayLastTime);
|
||||
return timePickerDialog;
|
||||
}
|
||||
|
||||
public void setmTimePickerListener(TimePickerListener mTimePickerListener) {
|
||||
this.mTimePickerListener = mTimePickerListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Activity activity = getActivity();
|
||||
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Window window = getDialog().getWindow();
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);//Here!
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
private void initialize(PickerConfig pickerConfig, long firstMs, boolean isWeek, boolean isMonth, boolean isDay, long dayFirstTime, long dayLastTime) {
|
||||
mPickerConfig = pickerConfig;
|
||||
mFirstMs = firstMs;
|
||||
mIsWeek = isWeek;
|
||||
this.isMonth = isMonth;
|
||||
this.isDay = isDay;
|
||||
this.mDayFirstTime = dayFirstTime;
|
||||
this.mDayLastTime = dayLastTime;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Dialog dialog = new Dialog(getActivity(), R.style.Dialog_NoTitle);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
dialog.setContentView(initView());
|
||||
return dialog;
|
||||
}
|
||||
|
||||
View initView() {
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
View view = inflater.inflate(R.layout.dialog_clan_time_picker, null);
|
||||
Context context = view.getContext();
|
||||
TextView cancel = view.findViewById(R.id.tv_cancel);
|
||||
cancel.setOnClickListener(this);
|
||||
cancel.setTextColor(context.getResources().getColor(R.color.color_b3b3b3));
|
||||
TextView sure = view.findViewById(R.id.tv_sure);
|
||||
sure.setOnClickListener(this);
|
||||
sure.setTextColor(context.getResources().getColor(R.color.color_1F1A4E));
|
||||
TextView title = view.findViewById(R.id.tv_title);
|
||||
View toolbar = view.findViewById(R.id.toolbar);
|
||||
|
||||
rlWeekGroup = view.findViewById(R.id.rl_week_group);
|
||||
tvWeekFirstDay = view.findViewById(R.id.tv_week_first_day);
|
||||
tvWeekLastDay = view.findViewById(R.id.tv_week_last_day);
|
||||
tvWeekFirstDay.setSelected(true);
|
||||
tvWeekLastDay.setSelected(mIsWeek);
|
||||
rlWeekGroup.setVisibility(mIsWeek || isDay ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvDay = view.findViewById(R.id.tvDay);
|
||||
tvWeek = view.findViewById(R.id.tvWeek);
|
||||
tvMonth = view.findViewById(R.id.tvMonth);
|
||||
tvDay.setOnClickListener(this);
|
||||
tvWeek.setOnClickListener(this);
|
||||
tvMonth.setOnClickListener(this);
|
||||
tvDay.setSelected(true);
|
||||
|
||||
if (isDay) {
|
||||
if (mDayFirstTime != mDayLastTime) {
|
||||
tvWeekLastDay.setText(TimeUtils.getDateTimeString(mDayLastTime, TimeUtils.DATE_FORMAT));
|
||||
} else {
|
||||
tvWeekLastDay.setText(defDayEndText);
|
||||
}
|
||||
tvWeekFirstDay.setOnClickListener(v -> {
|
||||
tvWeekFirstDay.setSelected(true);
|
||||
tvWeekLastDay.setSelected(false);
|
||||
});
|
||||
tvWeekLastDay.setOnClickListener(v -> {
|
||||
tvWeekFirstDay.setSelected(false);
|
||||
tvWeekLastDay.setSelected(true);
|
||||
});
|
||||
}
|
||||
title.setText(mPickerConfig.mTitleString);
|
||||
title.setTextColor(context.getResources().getColor(R.color.color_333333));
|
||||
cancel.setText(mPickerConfig.mCancelString);
|
||||
sure.setText(mPickerConfig.mSureString);
|
||||
|
||||
if (isMonth) {
|
||||
mPickerConfig.mType = Type.YEAR_MONTH;
|
||||
}
|
||||
toolbar.setBackgroundResource(R.drawable.shape_white_top_18dp);
|
||||
|
||||
mTimeWheel = new TimeWheel(view, mPickerConfig);
|
||||
Calendar currCalendar = Calendar.getInstance();
|
||||
if (mFirstMs <= 0) {
|
||||
mFirstMs = System.currentTimeMillis();
|
||||
}
|
||||
currCalendar.setTimeInMillis(mFirstMs);
|
||||
setWeekView(currCalendar);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
mTimeWheel.setOnTimeChangeListener(() -> {
|
||||
int year = mTimeWheel.getCurrentYear();
|
||||
int month = mTimeWheel.getCurrentMonth();
|
||||
int day = mTimeWheel.getCurrentDay();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.set(Calendar.MONTH, month - 1);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||||
setWeekView(calendar);
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setWeekView(Calendar calendar) {
|
||||
long firstDayTime;
|
||||
|
||||
if (isDay) {
|
||||
if (tvWeekFirstDay.isSelected()) {
|
||||
mDayFirstTime = calendar.getTimeInMillis();
|
||||
tvWeekFirstDay.setText(TimeUtils.getDateTimeString(mDayFirstTime, TimeUtils.DATE_FORMAT));
|
||||
} else {
|
||||
mDayLastTime = calendar.getTimeInMillis();
|
||||
tvWeekLastDay.setText(TimeUtils.getDateTimeString(mDayLastTime, TimeUtils.DATE_FORMAT));
|
||||
}
|
||||
} else {
|
||||
//获取周几 1-7
|
||||
int currweekDay = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
if (currweekDay == 1) {//周日
|
||||
firstDayTime = calendar.getTimeInMillis() - (TimeUtils.MILLIS_OF_A_DAY * (7 - currweekDay));
|
||||
} else {
|
||||
firstDayTime = calendar.getTimeInMillis() - (TimeUtils.MILLIS_OF_A_DAY * (currweekDay - 2));
|
||||
}
|
||||
|
||||
String first = TimeUtils.getDateTimeString(firstDayTime, TimeUtils.DATE_FORMAT);
|
||||
mWeekFirstDay = first;
|
||||
tvWeekFirstDay.setText(first);
|
||||
|
||||
//周日
|
||||
long lastDayTime = firstDayTime + (TimeUtils.MILLIS_OF_A_DAY * 6);
|
||||
String last = TimeUtils.getDateTimeString(lastDayTime, TimeUtils.DATE_FORMAT);
|
||||
mWeekLastDay = last;
|
||||
tvWeekLastDay.setText(last);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.tv_cancel) {
|
||||
dismiss();
|
||||
} else if (i == R.id.tv_sure) {
|
||||
sureClicked();
|
||||
}else if(i == R.id.tvDay) {
|
||||
tvDay.setSelected(true);
|
||||
tvWeek.setSelected(false);
|
||||
tvMonth.setSelected(false);
|
||||
mCurrentType = TYPE_DAY;
|
||||
|
||||
}else if(i == R.id.tvWeek) {
|
||||
tvDay.setSelected(false);
|
||||
tvWeek.setSelected(true);
|
||||
tvMonth.setSelected(false);
|
||||
mCurrentType = TYPE_WEEK;
|
||||
|
||||
}else if(i == R.id.tvMonth) {
|
||||
tvDay.setSelected(false);
|
||||
tvWeek.setSelected(false);
|
||||
tvMonth.setSelected(true);
|
||||
mCurrentType = TYPE_MONTH;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @desc This method returns the current milliseconds. If current milliseconds is not set,
|
||||
* this will return the system milliseconds.
|
||||
* @param none
|
||||
* @return long - the current milliseconds.
|
||||
*/
|
||||
public long getCurrentMillSeconds() {
|
||||
if (mCurrentMillSeconds == 0)
|
||||
return System.currentTimeMillis();
|
||||
|
||||
return mCurrentMillSeconds;
|
||||
}
|
||||
|
||||
/*
|
||||
* @desc This method is called when onClick method is invoked by sure button. A Calendar instance is created and
|
||||
* initialized.
|
||||
* @param none
|
||||
* @return none
|
||||
*/
|
||||
void sureClicked() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.clear();
|
||||
|
||||
calendar.set(Calendar.YEAR, mTimeWheel.getCurrentYear());
|
||||
calendar.set(Calendar.MONTH, mTimeWheel.getCurrentMonth() - 1);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, mTimeWheel.getCurrentDay());
|
||||
calendar.set(Calendar.HOUR_OF_DAY, mTimeWheel.getCurrentHour());
|
||||
calendar.set(Calendar.MINUTE, mTimeWheel.getCurrentMinute());
|
||||
|
||||
mCurrentMillSeconds = calendar.getTimeInMillis();
|
||||
|
||||
if (mTimePickerListener != null) {
|
||||
if (isDay) {
|
||||
if (defDayEndText.equals(tvWeekLastDay.getText().toString())) {
|
||||
mDayLastTime = mDayFirstTime;
|
||||
}
|
||||
if (mDayFirstTime > mDayLastTime) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.view_dialog_timepickerdialog_02));
|
||||
return;
|
||||
}
|
||||
if (mDayLastTime - mDayFirstTime > 180 * TimeUtils.MILLIS_OF_A_DAY) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.view_dialog_timepickerdialog_03));
|
||||
return;
|
||||
}
|
||||
mTimePickerListener.getTime(mCurrentMillSeconds,
|
||||
TimeUtils.getDateTimeString(mDayFirstTime, TimeUtils.DATE_FORMAT),
|
||||
TimeUtils.getDateTimeString(mDayLastTime, TimeUtils.DATE_FORMAT));
|
||||
|
||||
} else {
|
||||
mTimePickerListener.getTime(mCurrentMillSeconds, mWeekFirstDay, mWeekLastDay);
|
||||
}
|
||||
}
|
||||
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public interface TimePickerListener {
|
||||
void getTime(long chooseTime, String weekFirstDay, String weekLastDay);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
PickerConfig mPickerConfig;
|
||||
long firstMs;
|
||||
boolean mIsWeek;
|
||||
boolean isMonth;
|
||||
boolean isDay;
|
||||
private long mDayFirstTime;
|
||||
private long mDayLastTime;
|
||||
|
||||
public Builder() {
|
||||
mPickerConfig = new PickerConfig();
|
||||
}
|
||||
|
||||
public Builder setType(Type type) {
|
||||
mPickerConfig.mType = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setThemeColor(int color) {
|
||||
mPickerConfig.mThemeColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCancelStringId(String left) {
|
||||
mPickerConfig.mCancelString = left;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSureStringId(String right) {
|
||||
mPickerConfig.mSureString = right;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setTitleStringId(String title) {
|
||||
mPickerConfig.mTitleString = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setToolBarTextColor(int color) {
|
||||
mPickerConfig.mToolBarTVColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setWheelItemTextNormalColor(int color) {
|
||||
mPickerConfig.mWheelTVNormalColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setWheelItemTextSelectorColor(int color) {
|
||||
mPickerConfig.mWheelTVSelectorColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setWheelItemTextSize(int size) {
|
||||
mPickerConfig.mWheelTVSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCyclic(boolean cyclic) {
|
||||
mPickerConfig.cyclic = cyclic;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMinMillseconds(long millseconds) {
|
||||
mPickerConfig.mMinCalendar = new WheelCalendar(millseconds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaxMillseconds(long millseconds) {
|
||||
mPickerConfig.mMaxCalendar = new WheelCalendar(millseconds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCurrentMillseconds(long millseconds) {
|
||||
firstMs = millseconds;
|
||||
mPickerConfig.mCurrentCalendar = new WheelCalendar(millseconds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setYearText(String year) {
|
||||
mPickerConfig.mYear = year;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMonthText(String month) {
|
||||
mPickerConfig.mMonth = month;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDayText(String day) {
|
||||
mPickerConfig.mDay = day;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setHourText(String hour) {
|
||||
mPickerConfig.mHour = hour;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMinuteText(String minute) {
|
||||
mPickerConfig.mMinute = minute;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCallBack(OnDateSetListener listener) {
|
||||
mPickerConfig.mCallBack = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setmIsWeek(boolean isWeek) {
|
||||
mIsWeek = isWeek;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setIsMonth(boolean isMonth) {
|
||||
this.isMonth = isMonth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setIsDay(boolean isDay) {
|
||||
this.isDay = isDay;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDayFirstTime(long dayFirstTime) {
|
||||
this.mDayFirstTime = dayFirstTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDayLastTime(long dayLastTime) {
|
||||
this.mDayLastTime = dayLastTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TimePickerClanDialog build() {
|
||||
return newInstance(mPickerConfig, firstMs, mIsWeek, isMonth, isDay, mDayFirstTime, mDayLastTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -22,11 +22,9 @@ import com.jzxiang.pickerview.data.Type;
|
||||
import com.jzxiang.pickerview.data.WheelCalendar;
|
||||
import com.jzxiang.pickerview.listener.OnDateSetListener;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.UIUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -38,9 +36,6 @@ public class TimePickerDialog extends DialogFragment implements View.OnClickList
|
||||
RelativeLayout rlWeekGroup;
|
||||
TextView tvWeekFirstDay;
|
||||
TextView tvWeekLastDay;
|
||||
TextView tvDay;
|
||||
TextView tvWeek;
|
||||
TextView tvMonth;
|
||||
private TimeWheel mTimeWheel;
|
||||
private long mCurrentMillSeconds;
|
||||
private long mFirstMs;
|
||||
@@ -113,10 +108,10 @@ public class TimePickerDialog extends DialogFragment implements View.OnClickList
|
||||
Context context = view.getContext();
|
||||
TextView cancel = view.findViewById(R.id.tv_cancel);
|
||||
cancel.setOnClickListener(this);
|
||||
cancel.setTextColor(context.getResources().getColor(R.color.color_b3b3b3));
|
||||
cancel.setTextColor(context.getResources().getColor(R.color.color_999999));
|
||||
TextView sure = view.findViewById(R.id.tv_sure);
|
||||
sure.setOnClickListener(this);
|
||||
sure.setTextColor(context.getResources().getColor(R.color.color_1F1A4E));
|
||||
sure.setTextColor(context.getResources().getColor(R.color.app_248cfe));
|
||||
TextView title = view.findViewById(R.id.tv_title);
|
||||
View toolbar = view.findViewById(R.id.toolbar);
|
||||
|
||||
@@ -127,14 +122,6 @@ public class TimePickerDialog extends DialogFragment implements View.OnClickList
|
||||
tvWeekLastDay.setSelected(mIsWeek);
|
||||
rlWeekGroup.setVisibility(mIsWeek || isDay ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvDay = view.findViewById(R.id.tvDay);
|
||||
tvWeek = view.findViewById(R.id.tvWeek);
|
||||
tvMonth = view.findViewById(R.id.tvMonth);
|
||||
tvDay.setOnClickListener(this);
|
||||
tvWeek.setOnClickListener(this);
|
||||
tvMonth.setOnClickListener(this);
|
||||
tvDay.setSelected(true);
|
||||
|
||||
if (isDay) {
|
||||
if (mDayFirstTime != mDayLastTime) {
|
||||
tvWeekLastDay.setText(TimeUtils.getDateTimeString(mDayLastTime, TimeUtils.DATE_FORMAT));
|
||||
@@ -158,7 +145,7 @@ public class TimePickerDialog extends DialogFragment implements View.OnClickList
|
||||
if (isMonth) {
|
||||
mPickerConfig.mType = Type.YEAR_MONTH;
|
||||
}
|
||||
toolbar.setBackgroundResource(R.drawable.shape_white_top_18dp);
|
||||
toolbar.setBackgroundColor(context.getResources().getColor(R.color.white));
|
||||
|
||||
mTimeWheel = new TimeWheel(view, mPickerConfig);
|
||||
Calendar currCalendar = Calendar.getInstance();
|
||||
@@ -220,23 +207,6 @@ public class TimePickerDialog extends DialogFragment implements View.OnClickList
|
||||
dismiss();
|
||||
} else if (i == R.id.tv_sure) {
|
||||
sureClicked();
|
||||
}else if(i == R.id.tvDay) {
|
||||
tvDay.setSelected(true);
|
||||
tvWeek.setSelected(false);
|
||||
tvMonth.setSelected(false);
|
||||
isDay = true;
|
||||
|
||||
}else if(i == R.id.tvWeek) {
|
||||
tvDay.setSelected(false);
|
||||
tvWeek.setSelected(true);
|
||||
tvMonth.setSelected(false);
|
||||
mIsWeek = true;
|
||||
|
||||
}else if(i == R.id.tvMonth) {
|
||||
tvDay.setSelected(false);
|
||||
tvWeek.setSelected(false);
|
||||
tvMonth.setSelected(true);
|
||||
isMonth = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/toolbar"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/timepicker_toolbar_bg"
|
||||
android:paddingTop="@dimen/dp_20"
|
||||
android:paddingStart="@dimen/dp_5"
|
||||
android:paddingEnd="@dimen/dp_5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/timepicker_sel_text_item"
|
||||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text="@string/picker_cancel"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center"
|
||||
android:text="@string/picker_title"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sure"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/timepicker_sel_text_item"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/picker_sure"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:paddingTop="@dimen/dp_20"
|
||||
android:paddingBottom="@dimen/dp_12"
|
||||
android:background="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDay"
|
||||
android:text="@string/clan_day"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_time_date_select"
|
||||
android:textColor="@color/color_selector_9168fa_false_b3b3c3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvWeek"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWeek"
|
||||
android:text="@string/clan_week"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_time_date_select"
|
||||
android:textColor="@color/color_selector_9168fa_false_b3b3c3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvDay"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvMonth"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMonth"
|
||||
android:text="@string/clan_month"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_time_date_select"
|
||||
android:textColor="@color/color_selector_9168fa_false_b3b3c3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvWeek"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_week_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_week_first_day"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/dp_14"
|
||||
android:layout_toStartOf="@+id/tv_utill"
|
||||
android:textColor="@color/color_selector_333_false_999"
|
||||
android:textSize="@dimen/sp_15"
|
||||
tools:text="2018-01-02" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_utill"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/layout_dialog_custom_time_picker_01"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="@dimen/sp_15" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_week_last_day"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_14"
|
||||
android:layout_toEndOf="@+id/tv_utill"
|
||||
android:textColor="@color/color_selector_333_false_999"
|
||||
android:textSize="@dimen/sp_15"
|
||||
tools:text="2018-01-08" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="190dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_wheel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@android:color/white"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.jzxiang.pickerview.wheel.WheelView
|
||||
android:id="@+id/year"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.3" />
|
||||
|
||||
|
||||
<com.jzxiang.pickerview.wheel.WheelView
|
||||
android:id="@+id/month"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0" />
|
||||
|
||||
|
||||
<com.jzxiang.pickerview.wheel.WheelView
|
||||
android:id="@+id/day"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0" />
|
||||
|
||||
|
||||
<com.jzxiang.pickerview.wheel.WheelView
|
||||
android:id="@+id/hour"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0" />
|
||||
|
||||
<com.jzxiang.pickerview.wheel.WheelView
|
||||
android:id="@+id/minute"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -3,103 +3,12 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/timepicker_toolbar_bg"
|
||||
android:paddingTop="@dimen/dp_20"
|
||||
android:paddingStart="@dimen/dp_5"
|
||||
android:paddingEnd="@dimen/dp_5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/timepicker_sel_text_item"
|
||||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text="@string/picker_cancel"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center"
|
||||
android:text="@string/picker_title"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sure"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/timepicker_sel_text_item"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/picker_sure"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:paddingTop="@dimen/dp_20"
|
||||
android:paddingBottom="@dimen/dp_12"
|
||||
android:background="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDay"
|
||||
android:text="@string/clan_day"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_time_date_select"
|
||||
android:textColor="@color/color_selector_9168fa_false_b3b3c3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvWeek"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWeek"
|
||||
android:text="@string/clan_week"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_time_date_select"
|
||||
android:textColor="@color/color_selector_9168fa_false_b3b3c3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvDay"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvMonth"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMonth"
|
||||
android:text="@string/clan_month"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_time_date_select"
|
||||
android:textColor="@color/color_selector_9168fa_false_b3b3c3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvWeek"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
layout="@layout/timepicker_toolbar" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_week_group"
|
||||
|
Reference in New Issue
Block a user