From 881cd721341641b55d764d19a76c1d111795cd14 Mon Sep 17 00:00:00 2001 From: tongchao Date: Thu, 12 Jun 2025 17:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=9F=E5=9C=B0=E8=BF=9D=E6=B3=95=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- TimePickerDialog/.gitignore | 0 TimePickerDialog/bintray.gradle | 0 TimePickerDialog/build.gradle | 31 + TimePickerDialog/proguard-rules.pro | 17 + TimePickerDialog/src/main/AndroidManifest.xml | 11 + .../jzxiang/pickerview/TimePickerDialog.java | 243 +++++ .../com/jzxiang/pickerview/TimeWheel.java | 276 +++++ .../adapters/AbstractWheelAdapter.java | 75 ++ .../adapters/AbstractWheelTextAdapter.java | 267 +++++ .../adapters/ArrayWheelAdapter.java | 59 ++ .../adapters/NumericWheelAdapter.java | 114 +++ .../pickerview/adapters/WheelViewAdapter.java | 74 ++ .../pickerview/config/DefaultConfig.java | 26 + .../pickerview/config/PickerConfig.java | 48 + .../com/jzxiang/pickerview/data/Type.java | 14 + .../pickerview/data/WheelCalendar.java | 39 + .../data/source/TimeDataSource.java | 48 + .../data/source/TimeRepository.java | 138 +++ .../listener/OnDateSetListener.java | 13 + .../pickerview/utils/PickerContants.java | 18 + .../com/jzxiang/pickerview/utils/Utils.java | 37 + .../jzxiang/pickerview/wheel/ItemsRange.java | 86 ++ .../wheel/OnWheelChangedListener.java | 18 + .../wheel/OnWheelClickedListener.java | 17 + .../wheel/OnWheelScrollListener.java | 36 + .../pickerview/wheel/WheelRecycle.java | 127 +++ .../pickerview/wheel/WheelScroller.java | 208 ++++ .../jzxiang/pickerview/wheel/WheelView.java | 942 ++++++++++++++++++ .../src/main/res/anim/slide_in_bottom.xml | 16 + .../src/main/res/anim/slide_out_bottom.xml | 14 + .../res/drawable/timepicker_divider_line.xml | 13 + .../res/drawable/timepicker_sel_text_item.xml | 12 + .../src/main/res/drawable/wheel_bg.xml | 48 + .../src/main/res/drawable/wheel_val.xml | 23 + .../src/main/res/layout/timepicker_layout.xml | 104 ++ .../src/main/res/layout/timepicker_line.xml | 8 + .../src/main/res/values/colors.xml | 7 + .../src/main/res/values/dimens.xml | 10 + .../src/main/res/values/strings.xml | 12 + .../src/main/res/values/style.xml | 17 + app/build.gradle | 5 +- app/src/main/AndroidManifest.xml | 20 + .../tairui/gov_affairs_cloud/entity/Api.java | 11 +- .../ui/home/HomeFragment.java | 17 +- .../ui/home/entity/HomeEntity.java | 12 - .../land/AddIllegalInformationActivity.java | 291 ++++++ .../ui/land/AddInspectionActivity.java | 11 +- .../ui/land/EditInspectionActivity.java | 276 +++++ .../ui/land/IllegalDetailActivity.java | 68 ++ .../ui/land/IllegalListActivity.java | 206 ++++ .../ui/land/InspectionDetailActivity.java | 198 +++- .../ui/land/InspectionListActivity.java | 151 +-- .../ui/land/adapter/IllegalListAdapter.java | 32 + .../ui/land/entity/DictDataEntity.java | 8 +- .../ui/land/entity/GridMemberEntity.java | 95 +- .../ui/land/entity/IllegalDetailEntity.java | 127 +++ .../ui/land/entity/IllegalListEntity.java | 129 +++ .../land/entity/IllegalListParentEntity.java | 101 ++ .../ui/land/entity/InspectionListEntity.java | 612 ++++++------ .../ui/land/entity/MemberListEntity.java | 98 ++ .../ui/login/LoginActivity.java | 58 +- .../gov_affairs_cloud/ui/my/MyFragment.java | 23 +- .../ui/my/entity/UserInfoEntity.java | 333 ++++++- .../ui/todo/TodoFragment.java | 2 +- .../ui/workspace/WorkSpaceFragment.java | 3 + .../gov_affairs_cloud/util/DateUtils.java | 8 + .../util/SingleClickListener.java | 1 + .../bg_container_red_border_raduis_2.xml | 15 + .../activity_add_illegal_information.xml | 287 ++++++ .../res/layout/activity_edit_inspection.xml | 268 +++++ .../res/layout/activity_illegal_detail.xml | 228 +++++ .../main/res/layout/activity_illegal_list.xml | 91 ++ .../res/layout/activity_inspection_detail.xml | 626 +++++++----- .../res/layout/activity_inspection_list.xml | 49 +- app/src/main/res/layout/item_illegal.xml | 72 ++ app/src/main/res/layout/item_illegal_2.xml | 68 ++ .../res/mipmap-xxhdpi/ic_add_white_small.webp | Bin 0 -> 666 bytes .../mipmap-xxhdpi/ic_submit_white_small.png | Bin 0 -> 1158 bytes settings.gradle | 1 + 80 files changed, 6931 insertions(+), 939 deletions(-) create mode 100644 TimePickerDialog/.gitignore create mode 100644 TimePickerDialog/bintray.gradle create mode 100644 TimePickerDialog/build.gradle create mode 100644 TimePickerDialog/proguard-rules.pro create mode 100644 TimePickerDialog/src/main/AndroidManifest.xml create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimePickerDialog.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimeWheel.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelAdapter.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelTextAdapter.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/ArrayWheelAdapter.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/NumericWheelAdapter.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/WheelViewAdapter.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/DefaultConfig.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/PickerConfig.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/Type.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/WheelCalendar.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeDataSource.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeRepository.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/listener/OnDateSetListener.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/PickerContants.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/Utils.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/ItemsRange.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelChangedListener.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelClickedListener.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelScrollListener.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelRecycle.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelScroller.java create mode 100644 TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelView.java create mode 100644 TimePickerDialog/src/main/res/anim/slide_in_bottom.xml create mode 100644 TimePickerDialog/src/main/res/anim/slide_out_bottom.xml create mode 100644 TimePickerDialog/src/main/res/drawable/timepicker_divider_line.xml create mode 100644 TimePickerDialog/src/main/res/drawable/timepicker_sel_text_item.xml create mode 100644 TimePickerDialog/src/main/res/drawable/wheel_bg.xml create mode 100644 TimePickerDialog/src/main/res/drawable/wheel_val.xml create mode 100644 TimePickerDialog/src/main/res/layout/timepicker_layout.xml create mode 100644 TimePickerDialog/src/main/res/layout/timepicker_line.xml create mode 100644 TimePickerDialog/src/main/res/values/colors.xml create mode 100644 TimePickerDialog/src/main/res/values/dimens.xml create mode 100644 TimePickerDialog/src/main/res/values/strings.xml create mode 100644 TimePickerDialog/src/main/res/values/style.xml create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddIllegalInformationActivity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/EditInspectionActivity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalDetailActivity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalListActivity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/adapter/IllegalListAdapter.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalDetailEntity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListEntity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListParentEntity.java create mode 100644 app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/MemberListEntity.java create mode 100644 app/src/main/res/drawable/bg_container_red_border_raduis_2.xml create mode 100644 app/src/main/res/layout/activity_add_illegal_information.xml create mode 100644 app/src/main/res/layout/activity_edit_inspection.xml create mode 100644 app/src/main/res/layout/activity_illegal_detail.xml create mode 100644 app/src/main/res/layout/activity_illegal_list.xml create mode 100644 app/src/main/res/layout/item_illegal.xml create mode 100644 app/src/main/res/layout/item_illegal_2.xml create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_add_white_small.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_submit_white_small.png diff --git a/.gitignore b/.gitignore index d935441..c25e015 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ /build /captures .externalNativeBuild -.cxx \ No newline at end of file +.cxx +/TimePickerDialog/build \ No newline at end of file diff --git a/TimePickerDialog/.gitignore b/TimePickerDialog/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/TimePickerDialog/bintray.gradle b/TimePickerDialog/bintray.gradle new file mode 100644 index 0000000..e69de29 diff --git a/TimePickerDialog/build.gradle b/TimePickerDialog/build.gradle new file mode 100644 index 0000000..d4179c4 --- /dev/null +++ b/TimePickerDialog/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'com.android.library' +} + +android { + compileSdkVersion 33 + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 33 + versionCode 1 + versionName "1.0" + + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.4.1' +} \ No newline at end of file diff --git a/TimePickerDialog/proguard-rules.pro b/TimePickerDialog/proguard-rules.pro new file mode 100644 index 0000000..d4c7de7 --- /dev/null +++ b/TimePickerDialog/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/jzxiang/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/TimePickerDialog/src/main/AndroidManifest.xml b/TimePickerDialog/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f028287 --- /dev/null +++ b/TimePickerDialog/src/main/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimePickerDialog.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimePickerDialog.java new file mode 100644 index 0000000..dc77b4f --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimePickerDialog.java @@ -0,0 +1,243 @@ +package com.jzxiang.pickerview; + +import java.util.Calendar; + +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 android.app.Activity; +import android.app.Dialog; +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.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + +/** + * Created by jzxiang on 16/4/19. + */ +public class TimePickerDialog extends DialogFragment implements View.OnClickListener { + PickerConfig mPickerConfig; + private TimeWheel mTimeWheel; + private long mCurrentMillSeconds; + + private static TimePickerDialog newIntance(PickerConfig pickerConfig) { + TimePickerDialog timePickerDialog = new TimePickerDialog(); + timePickerDialog.initialize(pickerConfig); + return timePickerDialog; + } + + @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(); + int height = getResources().getDimensionPixelSize(R.dimen.picker_height); + + Window window = getDialog().getWindow(); + window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, height);//Here! + window.setGravity(Gravity.BOTTOM); + } + + private void initialize(PickerConfig pickerConfig) { + mPickerConfig = pickerConfig; + } + + @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.timepicker_layout, null); + TextView cancel = (TextView) view.findViewById(R.id.tv_cancel); + cancel.setOnClickListener(this); + TextView sure = (TextView) view.findViewById(R.id.tv_sure); + sure.setOnClickListener(this); + TextView title = (TextView) view.findViewById(R.id.tv_title); + + title.setText(mPickerConfig.mTitleString); + cancel.setText(mPickerConfig.mCancelString); + sure.setText(mPickerConfig.mSureString); + + mTimeWheel = new TimeWheel(view, mPickerConfig); + return view; + } + + @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(); + } + } + + /* + * @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 (mPickerConfig.mCallBack != null) { + mPickerConfig.mCallBack.onDateSet(this, mCurrentMillSeconds); + } + dismiss(); + } + + public static class Builder { + PickerConfig mPickerConfig; + + 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) { + 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 TimePickerDialog build() { + return newIntance(mPickerConfig); + } + + } + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimeWheel.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimeWheel.java new file mode 100644 index 0000000..33529c9 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/TimeWheel.java @@ -0,0 +1,276 @@ +package com.jzxiang.pickerview; + +import java.util.Calendar; + +import com.jzxiang.pickerview.adapters.NumericWheelAdapter; +import com.jzxiang.pickerview.config.PickerConfig; +import com.jzxiang.pickerview.data.source.TimeRepository; +import com.jzxiang.pickerview.utils.PickerContants; +import com.jzxiang.pickerview.utils.Utils; +import com.jzxiang.pickerview.wheel.OnWheelChangedListener; +import com.jzxiang.pickerview.wheel.WheelView; + +import android.content.Context; +import android.view.View; + +/** + * Created by jzxiang on 16/4/20. + */ +public class TimeWheel { + Context mContext; + + WheelView year, month, day, hour, minute; + NumericWheelAdapter mYearAdapter, mMonthAdapter, mDayAdapter, mHourAdapter, mMinuteAdapter; + + PickerConfig mPickerConfig; + TimeRepository mRepository; + OnWheelChangedListener yearListener = new OnWheelChangedListener() { + @Override + public void onChanged(WheelView wheel, int oldValue, int newValue) { + updateMonths(); + } + }; + OnWheelChangedListener monthListener = new OnWheelChangedListener() { + @Override + public void onChanged(WheelView wheel, int oldValue, int newValue) { + updateDays(); + } + }; + OnWheelChangedListener dayListener = new OnWheelChangedListener() { + @Override + public void onChanged(WheelView wheel, int oldValue, int newValue) { + updateHours(); + } + }; + OnWheelChangedListener minuteListener = new OnWheelChangedListener() { + @Override + public void onChanged(WheelView wheel, int oldValue, int newValue) { + updateMinutes(); + } + }; + + public TimeWheel(View view, PickerConfig pickerConfig) { + mPickerConfig = pickerConfig; + + mRepository = new TimeRepository(pickerConfig); + mContext = view.getContext(); + initialize(view); + } + + public void initialize(View view) { + initView(view); + initYear(); + initMonth(); + initDay(); + initHour(); + initMinute(); + } + + + void initView(View view) { + year = (WheelView) view.findViewById(R.id.year); + month = (WheelView) view.findViewById(R.id.month); + day = (WheelView) view.findViewById(R.id.day); + hour = (WheelView) view.findViewById(R.id.hour); + minute = (WheelView) view.findViewById(R.id.minute); + + switch (mPickerConfig.mType) { + case ALL: + + break; + case YEAR_MONTH_DAY: + Utils.hideViews(hour, minute); + break; + case YEAR_MONTH: + Utils.hideViews(day, hour, minute); + break; + case MONTH_DAY_HOUR_MIN: + Utils.hideViews(year); + break; + case HOURS_MINS: + Utils.hideViews(year, month, day); + break; + case YEAR: + Utils.hideViews(month, day, hour, minute); + break; + } + + year.addChangingListener(yearListener); + year.addChangingListener(monthListener); + year.addChangingListener(dayListener); + year.addChangingListener(minuteListener); + month.addChangingListener(monthListener); + month.addChangingListener(dayListener); + month.addChangingListener(minuteListener); + day.addChangingListener(dayListener); + day.addChangingListener(minuteListener); + hour.addChangingListener(minuteListener); + } + + void initYear() { + int minYear = mRepository.getMinYear(); + int maxYear = mRepository.getMaxYear(); + + mYearAdapter = new NumericWheelAdapter(mContext, minYear, maxYear, PickerContants.FORMAT, mPickerConfig.mYear); + mYearAdapter.setConfig(mPickerConfig); + year.setViewAdapter(mYearAdapter); + year.setCurrentItem(mRepository.getDefaultCalendar().year - minYear); + } + + void initMonth() { + updateMonths(); + int curYear = getCurrentYear(); + int minMonth = mRepository.getMinMonth(curYear); + month.setCurrentItem(mRepository.getDefaultCalendar().month - minMonth); + month.setCyclic(mPickerConfig.cyclic); + } + + void initDay() { + updateDays(); + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + + int minDay = mRepository.getMinDay(curYear, curMonth); + day.setCurrentItem(mRepository.getDefaultCalendar().day - minDay); + day.setCyclic(mPickerConfig.cyclic); + } + + void initHour() { + updateHours(); + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + int curDay = getCurrentDay(); + + int minHour = mRepository.getMinHour(curYear, curMonth, curDay); + hour.setCurrentItem(mRepository.getDefaultCalendar().hour - minHour); + hour.setCyclic(mPickerConfig.cyclic); + } + + void initMinute() { + updateMinutes(); + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + int curDay = getCurrentDay(); + int curHour = getCurrentHour(); + int minMinute = mRepository.getMinMinute(curYear, curMonth, curDay, curHour); + + minute.setCurrentItem(mRepository.getDefaultCalendar().minute - minMinute); + minute.setCyclic(mPickerConfig.cyclic); + + } + + void updateMonths() { + if (month.getVisibility() == View.GONE) + return; + + int curYear = getCurrentYear(); + int minMonth = mRepository.getMinMonth(curYear); + int maxMonth = mRepository.getMaxMonth(curYear); + mMonthAdapter = new NumericWheelAdapter(mContext, minMonth, maxMonth, PickerContants.FORMAT, mPickerConfig.mMonth); + mMonthAdapter.setConfig(mPickerConfig); + month.setViewAdapter(mMonthAdapter); + + if (mRepository.isMinYear(curYear)) { + month.setCurrentItem(0, false); + } + } + + void updateDays() { + if (day.getVisibility() == View.GONE) + return; + + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + year.getCurrentItem()); + calendar.set(Calendar.MONTH, curMonth); + + int maxDay = mRepository.getMaxDay(curYear, curMonth); + int minDay = mRepository.getMinDay(curYear, curMonth); + mDayAdapter = new NumericWheelAdapter(mContext, minDay, maxDay, PickerContants.FORMAT, mPickerConfig.mDay); + mDayAdapter.setConfig(mPickerConfig); + day.setViewAdapter(mDayAdapter); + + if (mRepository.isMinMonth(curYear, curMonth)) { + day.setCurrentItem(0, true); + } + + int dayCount = mDayAdapter.getItemsCount(); + if (day.getCurrentItem() >= dayCount) { + day.setCurrentItem(dayCount - 1, true); + } + } + + void updateHours() { + if (hour.getVisibility() == View.GONE) + return; + + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + int curDay = getCurrentDay(); + + int minHour = mRepository.getMinHour(curYear, curMonth, curDay); + int maxHour = mRepository.getMaxHour(curYear, curMonth, curDay); + + mHourAdapter = new NumericWheelAdapter(mContext, minHour, maxHour, PickerContants.FORMAT, mPickerConfig.mHour); + mHourAdapter.setConfig(mPickerConfig); + hour.setViewAdapter(mHourAdapter); + + if (mRepository.isMinDay(curYear, curMonth, curDay)) + hour.setCurrentItem(0, false); + } + + void updateMinutes() { + if (minute.getVisibility() == View.GONE) + return; + + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + int curDay = getCurrentDay(); + int curHour = getCurrentHour(); + + int minMinute = mRepository.getMinMinute(curYear, curMonth, curDay, curHour); + int maxMinute = mRepository.getMaxMinute(curYear, curMonth, curDay, curHour); + + mMinuteAdapter = new NumericWheelAdapter(mContext, minMinute, maxMinute, PickerContants.FORMAT, mPickerConfig.mMinute); + mMinuteAdapter.setConfig(mPickerConfig); + minute.setViewAdapter(mMinuteAdapter); + + if (mRepository.isMinHour(curYear, curMonth, curDay, curHour)) + minute.setCurrentItem(0, false); + } + + public int getCurrentYear() { + return year.getCurrentItem() + mRepository.getMinYear(); + } + + public int getCurrentMonth() { + int curYear = getCurrentYear(); + return month.getCurrentItem() + +mRepository.getMinMonth(curYear); + } + + public int getCurrentDay() { + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + return day.getCurrentItem() + mRepository.getMinDay(curYear, curMonth); + } + + public int getCurrentHour() { + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + int curDay = getCurrentDay(); + return hour.getCurrentItem() + mRepository.getMinHour(curYear, curMonth, curDay); + } + + public int getCurrentMinute() { + int curYear = getCurrentYear(); + int curMonth = getCurrentMonth(); + int curDay = getCurrentDay(); + int curHour = getCurrentHour(); + + return minute.getCurrentItem() + mRepository.getMinMinute(curYear, curMonth, curDay, curHour); + } + + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelAdapter.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelAdapter.java new file mode 100644 index 0000000..5e20200 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelAdapter.java @@ -0,0 +1,75 @@ +/* + * Copyright 2011 Yuri Kanivets + * + * 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. + */ + +package com.jzxiang.pickerview.adapters; + +import android.database.DataSetObserver; +import android.view.View; +import android.view.ViewGroup; + +import java.util.LinkedList; +import java.util.List; + +/** + * Abstract Wheel adapter. + */ +public abstract class AbstractWheelAdapter implements WheelViewAdapter { + // Observers + private List datasetObservers; + + @Override + public View getEmptyItem(View convertView, ViewGroup parent) { + return null; + } + + @Override + public void registerDataSetObserver(DataSetObserver observer) { + if (datasetObservers == null) { + datasetObservers = new LinkedList(); + } + datasetObservers.add(observer); + } + + @Override + public void unregisterDataSetObserver(DataSetObserver observer) { + if (datasetObservers != null) { + datasetObservers.remove(observer); + } + } + + /** + * Notifies observers about data changing + */ + protected void notifyDataChangedEvent() { + if (datasetObservers != null) { + for (DataSetObserver observer : datasetObservers) { + observer.onChanged(); + } + } + } + + /** + * Notifies observers about invalidating data + */ + protected void notifyDataInvalidatedEvent() { + if (datasetObservers != null) { + for (DataSetObserver observer : datasetObservers) { + observer.onInvalidated(); + } + } + } + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelTextAdapter.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelTextAdapter.java new file mode 100644 index 0000000..2e758b8 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/AbstractWheelTextAdapter.java @@ -0,0 +1,267 @@ +/* + * Copyright 2011 Yuri Kanivets + * + * 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. + */ +package com.jzxiang.pickerview.adapters; + +import com.jzxiang.pickerview.R; +import com.jzxiang.pickerview.config.PickerConfig; + +import android.content.Context; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +/** + * Abstract wheel adapter provides common functionality for adapters. + */ +public abstract class AbstractWheelTextAdapter extends AbstractWheelAdapter { + + /** + * Text view resource. Used as a default view for adapter. + */ + public static final int TEXT_VIEW_ITEM_RESOURCE = -1; + + /** + * Default text color + */ + public static final int LABEL_COLOR = 0xFF700070; + /** + * Default text size + */ + public static final int DEFAULT_TEXT_SIZE = 24; + /** + * No resource constant. + */ + protected static final int NO_RESOURCE = 0; + // Current context + protected Context context; + // Layout inflater + protected LayoutInflater inflater; + // Items resources + protected int itemResourceId; + protected int itemTextResourceId; + // Empty items resources + protected int emptyItemResourceId; + + private int padding = 0; + + private PickerConfig mPickerConfig; + + /** + * Constructor + * + * @param context the current context + */ + protected AbstractWheelTextAdapter(Context context) { + this(context, TEXT_VIEW_ITEM_RESOURCE); + } + + /** + * Constructor + * + * @param context the current context + * @param itemResource the resource ID for a layout file containing a TextView to use when instantiating items views + */ + protected AbstractWheelTextAdapter(Context context, int itemResource) { + this(context, itemResource, NO_RESOURCE); + } + + /** + * Constructor + * + * @param context the current context + * @param itemResource the resource ID for a layout file containing a TextView to use when instantiating items views + * @param itemTextResource the resource ID for a text view in the item layout + */ + protected AbstractWheelTextAdapter(Context context, int itemResource, int itemTextResource) { + this.context = context; + itemResourceId = itemResource; + itemTextResourceId = itemTextResource; + padding = context.getResources().getDimensionPixelSize(R.dimen.textview_default_padding); + + inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + /** + * Gets resource Id for items views + * + * @return the item resource Id + */ + public int getItemResource() { + return itemResourceId; + } + + /** + * Sets resource Id for items views + * + * @param itemResourceId the resource Id to set + */ + public void setItemResource(int itemResourceId) { + this.itemResourceId = itemResourceId; + } + + /** + * Gets resource Id for text view in item layout + * + * @return the item text resource Id + */ + public int getItemTextResource() { + return itemTextResourceId; + } + + /** + * Sets resource Id for text view in item layout + * + * @param itemTextResourceId the item text resource Id to set + */ + public void setItemTextResource(int itemTextResourceId) { + this.itemTextResourceId = itemTextResourceId; + } + + /** + * Gets resource Id for empty items views + * + * @return the empty item resource Id + */ + public int getEmptyItemResource() { + return emptyItemResourceId; + } + + /** + * Sets resource Id for empty items views + * + * @param emptyItemResourceId the empty item resource Id to set + */ + public void setEmptyItemResource(int emptyItemResourceId) { + this.emptyItemResourceId = emptyItemResourceId; + } + + + /** + * Returns text for specified item + * + * @param index the item index + * @return the text of specified items + */ + protected abstract CharSequence getItemText(int index); + + @Override + public View getItem(int index, View convertView, ViewGroup parent) { + if (index >= 0 && index < getItemsCount()) { + if (convertView == null) { + convertView = getView(itemResourceId, parent); + } + TextView textView = getTextView(convertView, itemTextResourceId); + if (textView != null) { + CharSequence text = getItemText(index); + if (text == null) { + text = ""; + } + textView.setText(text); + if (itemResourceId == TEXT_VIEW_ITEM_RESOURCE) { + configureTextView(textView); + } + } + return convertView; + } + return null; + } + + @Override + public View getEmptyItem(View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = getView(emptyItemResourceId, parent); + } + if (emptyItemResourceId == TEXT_VIEW_ITEM_RESOURCE && convertView instanceof TextView) { + configureTextView((TextView) convertView); + } + + return convertView; + } + + + /** + * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. + * + * @param view the text view to be configured + */ + protected void configureTextView(TextView view) { + if (mPickerConfig == null) + mPickerConfig = new PickerConfig(); + view.setTextColor(mPickerConfig.mWheelTVNormalColor); + + view.setGravity(Gravity.CENTER); + view.setPadding(0, padding, 0, padding); + view.setTextSize(mPickerConfig.mWheelTVSize); + view.setLines(1); +// view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); + } + + /** + * Loads a text view from view + * + * @param view the text view or layout containing it + * @param textResource the text resource Id in layout + * @return the loaded text view + */ + private TextView getTextView(View view, int textResource) { + TextView text = null; + try { + if (textResource == NO_RESOURCE && view instanceof TextView) { + text = (TextView) view; + } else if (textResource != NO_RESOURCE) { + text = (TextView) view.findViewById(textResource); + } + } catch (ClassCastException e) { + Log.e("AbstractWheelAdapter", "You must supply a resource ID for a TextView"); + throw new IllegalStateException( + "AbstractWheelAdapter requires the resource ID to be a TextView", e); + } + + return text; + } + + /** + * Loads view from resources + * + * @param resource the resource Id + * @return the loaded view or null if resource is not set + */ + private View getView(int resource, ViewGroup parent) { + switch (resource) { + case NO_RESOURCE: + return null; + case TEXT_VIEW_ITEM_RESOURCE: + return new TextView(context); + default: + return inflater.inflate(resource, parent, false); + } + } + + @Override + public PickerConfig getConfig() { + if (mPickerConfig == null) + mPickerConfig = new PickerConfig(); + return mPickerConfig; + } + + @Override + public void setConfig(PickerConfig config) { + mPickerConfig = config; + } +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/ArrayWheelAdapter.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/ArrayWheelAdapter.java new file mode 100644 index 0000000..565b547 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/ArrayWheelAdapter.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 Yuri Kanivets + * + * 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. + */ +package com.jzxiang.pickerview.adapters; + +import android.content.Context; + +/** + * The simple Array wheel adapter + * + * @param the element type + */ +public class ArrayWheelAdapter extends AbstractWheelTextAdapter { + + // items + private T items[]; + + /** + * Constructor + * + * @param context the current context + * @param items the items + */ + public ArrayWheelAdapter(Context context, T items[]) { + super(context); + + //setEmptyItemResource(TEXT_VIEW_ITEM_RESOURCE); + this.items = items; + } + + @Override + public CharSequence getItemText(int index) { + if (index >= 0 && index < items.length) { + T item = items[index]; + if (item instanceof CharSequence) { + return (CharSequence) item; + } + return item.toString(); + } + return null; + } + + @Override + public int getItemsCount() { + return items.length; + } +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/NumericWheelAdapter.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/NumericWheelAdapter.java new file mode 100644 index 0000000..4cb9910 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/NumericWheelAdapter.java @@ -0,0 +1,114 @@ +/* + * Copyright 2011 Yuri Kanivets + * + * 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. + */ + +package com.jzxiang.pickerview.adapters; + +import android.content.Context; +import android.text.TextUtils; + +/** + * Numeric Wheel adapter. + */ +public class NumericWheelAdapter extends AbstractWheelTextAdapter { + + /** + * The default min value + */ + public static final int DEFAULT_MAX_VALUE = 9; + + /** + * The default max value + */ + private static final int DEFAULT_MIN_VALUE = 0; + + // Values + private int minValue; + private int maxValue; + + // format + private String format; + //unit + private String unit; + + + /** + * Constructor + * + * @param context the current context + */ + public NumericWheelAdapter(Context context) { + this(context, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE); + } + + /** + * Constructor + * + * @param context the current context + * @param minValue the wheel min value + * @param maxValue the wheel max value + */ + public NumericWheelAdapter(Context context, int minValue, int maxValue) { + this(context, minValue, maxValue, null); + } + + /** + * Constructor + * + * @param context the current context + * @param minValue the wheel min value + * @param maxValue the wheel max value + * @param format the format string + */ + public NumericWheelAdapter(Context context, int minValue, int maxValue, String format) { + this(context, minValue, maxValue, format, null); + } + + /** + * Constructor + * + * @param context the current context + * @param minValue the wheel min value + * @param maxValue the wheel max value + * @param format the format string + * @param unit the wheel unit value + */ + public NumericWheelAdapter(Context context, int minValue, int maxValue, String format, String unit) { + super(context); + this.minValue = minValue; + this.maxValue = maxValue; + this.format = format; + this.unit = unit; + } + + @Override + public CharSequence getItemText(int index) { + if (index >= 0 && index < getItemsCount()) { + int value = minValue + index; + String text = !TextUtils.isEmpty(format) ? String.format(format, value) : Integer.toString(value); + text = TextUtils.isEmpty(unit) ? text : text + unit; + + return text; + } + return null; + } + + @Override + public int getItemsCount() { + return maxValue - minValue + 1; + } + + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/WheelViewAdapter.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/WheelViewAdapter.java new file mode 100644 index 0000000..a056311 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/adapters/WheelViewAdapter.java @@ -0,0 +1,74 @@ +/* + * Copyright 2011 Yuri Kanivets + * + * 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. + */ + +package com.jzxiang.pickerview.adapters; + +import android.database.DataSetObserver; +import android.view.View; +import android.view.ViewGroup; + +import com.jzxiang.pickerview.config.PickerConfig; + +/** + * Wheel items adapter interface + */ +public interface WheelViewAdapter { + /** + * Gets items count + * + * @return the count of wheel items + */ + int getItemsCount(); + + /** + * Get a View that displays the data at the specified position in the data set + * + * @param index the item index + * @param convertView the old view to reuse if possible + * @param parent the parent that this view will eventually be attached to + * @return the wheel item View + */ + View getItem(int index, View convertView, ViewGroup parent); + + /** + * Get a View that displays an empty wheel item placed before the first or after + * the last wheel item. + * + * @param convertView the old view to reuse if possible + * @param parent the parent that this view will eventually be attached to + * @return the empty item View + */ + View getEmptyItem(View convertView, ViewGroup parent); + + /** + * Register an observer that is called when changes happen to the data used by this adapter. + * + * @param observer the observer to be registered + */ + void registerDataSetObserver(DataSetObserver observer); + + /** + * Unregister an observer that has previously been registered + * + * @param observer the observer to be unregistered + */ + void unregisterDataSetObserver(DataSetObserver observer); + + PickerConfig getConfig(); + + void setConfig(PickerConfig config); + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/DefaultConfig.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/DefaultConfig.java new file mode 100644 index 0000000..4a1e322 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/DefaultConfig.java @@ -0,0 +1,26 @@ +package com.jzxiang.pickerview.config; + +import com.jzxiang.pickerview.data.Type; + +/** + * Created by jzxiang on 16/5/15. + */ +public class DefaultConfig { + public static final Type TYPE = Type.ALL; + public static final int COLOR = 0XFF007AFF; + public static final int TOOLBAR_TV_COLOR = 0xFFFFFFFF; + public static final int TV_NORMAL_COLOR = 0xFF999999; + public static final int TV_SELECTOR_COLOR = 0XFF404040; + public static final int TV_SIZE = 12; + public static final boolean CYCLIC = true; + public static String CANCEL = "取消"; + public static String SURE = "确定"; + public static String TITLE = "TimePicker"; + public static String YEAR = "年"; + public static String MONTH = "月"; + public static String DAY = "日"; + public static String HOUR = "时"; + public static String MINUTE = "分"; + + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/PickerConfig.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/PickerConfig.java new file mode 100644 index 0000000..ad3be79 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/config/PickerConfig.java @@ -0,0 +1,48 @@ +package com.jzxiang.pickerview.config; + +import com.jzxiang.pickerview.data.Type; +import com.jzxiang.pickerview.data.WheelCalendar; +import com.jzxiang.pickerview.listener.OnDateSetListener; + + +/** + * Created by jzxiang on 16/5/15. + */ +public class PickerConfig { + + public Type mType = DefaultConfig.TYPE; + public int mThemeColor = DefaultConfig.COLOR; + + public String mCancelString = DefaultConfig.CANCEL; + public String mSureString = DefaultConfig.SURE; + public String mTitleString = DefaultConfig.TITLE; + public int mToolBarTVColor = DefaultConfig.TOOLBAR_TV_COLOR; + + public int mWheelTVNormalColor = DefaultConfig.TV_NORMAL_COLOR; + public int mWheelTVSelectorColor = DefaultConfig.TV_SELECTOR_COLOR; + public int mWheelTVSize = DefaultConfig.TV_SIZE; + public boolean cyclic = DefaultConfig.CYCLIC; + + public String mYear = DefaultConfig.YEAR; + public String mMonth = DefaultConfig.MONTH; + public String mDay = DefaultConfig.DAY; + public String mHour = DefaultConfig.HOUR; + public String mMinute = DefaultConfig.MINUTE; + + /** + * The min timeMillseconds + */ + public WheelCalendar mMinCalendar = new WheelCalendar(0); + + /** + * The max timeMillseconds + */ + public WheelCalendar mMaxCalendar = new WheelCalendar(0); + + /** + * The default selector timeMillseconds + */ + public WheelCalendar mCurrentCalendar = new WheelCalendar(System.currentTimeMillis()); + + public OnDateSetListener mCallBack; +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/Type.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/Type.java new file mode 100644 index 0000000..b1b4e36 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/Type.java @@ -0,0 +1,14 @@ +package com.jzxiang.pickerview.data; + +/** + * Created by jzxiang on 16/4/21. + */ +public enum Type { + // 五种选择模式,年月日时分,年月日,时分,月日时分,年月 + ALL, + YEAR_MONTH_DAY, + HOURS_MINS, + MONTH_DAY_HOUR_MIN, + YEAR_MONTH, + YEAR +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/WheelCalendar.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/WheelCalendar.java new file mode 100644 index 0000000..1f3a7b2 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/WheelCalendar.java @@ -0,0 +1,39 @@ +package com.jzxiang.pickerview.data; + +import java.util.Calendar; + +/** + * Created by jzxiang on 16/4/19. + */ +public class WheelCalendar { + + public int year, month, day, hour, minute; + + private boolean noRange; + + public WheelCalendar(long millseconds) { + initData(millseconds); + } + + private void initData(long millseconds) { + if (millseconds == 0) { + noRange = true; + return; + } + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.setTimeInMillis(millseconds); + + year = calendar.get(Calendar.YEAR); + month = calendar.get(Calendar.MONTH) + 1; + day = calendar.get(Calendar.DAY_OF_MONTH); + hour = calendar.get(Calendar.HOUR_OF_DAY); + minute = calendar.get(Calendar.MINUTE); + } + + public boolean isNoRange() { + return noRange; + } + + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeDataSource.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeDataSource.java new file mode 100644 index 0000000..8377910 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeDataSource.java @@ -0,0 +1,48 @@ +package com.jzxiang.pickerview.data.source; + +import com.jzxiang.pickerview.data.WheelCalendar; + +/** + * Created by jzxiang on 16/6/13. + */ +public interface TimeDataSource { + + int getMinYear(); + + int getMaxYear(); + + int getMinMonth(int currentYear); + + int getMaxMonth(int currentYear); + + int getMinDay(int year, int month); + + int getMaxDay(int year, int month); + + int getMinHour(int year, int month, int day); + + int getMaxHour(int year, int month, int day); + + int getMinMinute(int year, int month, int day, int hour); + + int getMaxMinute(int year, int month, int day, int hour); + + boolean isMinYear(int year); + + boolean isMinMonth(int year, int month); + + boolean isMinDay(int year, int month, int day); + + boolean isMinHour(int year, int month, int day, int hour); +// +// boolean isMaxYear(int year); +// +// boolean isMaxMonth(int year, int month); +// +// boolean isMaxDay(int year, int month, int day); +// +// boolean isMaxMinute(int year, int month, int day, int hour); + + WheelCalendar getDefaultCalendar(); + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeRepository.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeRepository.java new file mode 100644 index 0000000..e75e598 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/data/source/TimeRepository.java @@ -0,0 +1,138 @@ +package com.jzxiang.pickerview.data.source; + +import com.jzxiang.pickerview.config.PickerConfig; +import com.jzxiang.pickerview.data.WheelCalendar; +import com.jzxiang.pickerview.utils.PickerContants; +import com.jzxiang.pickerview.utils.Utils; + +import java.util.Calendar; + +/** + * Created by jzxiang on 16/6/13. + */ +public class TimeRepository implements TimeDataSource { + PickerConfig mPickerConfig; + WheelCalendar mCalendarMin, mCalendarMax; + + boolean mIsMinNoRange, mIsMaxNoRange; + + public TimeRepository(PickerConfig pickerConfig) { + mPickerConfig = pickerConfig; + mCalendarMin = pickerConfig.mMinCalendar; + mCalendarMax = pickerConfig.mMaxCalendar; + + mIsMinNoRange = mCalendarMin.isNoRange(); + mIsMaxNoRange = mCalendarMax.isNoRange(); + } + + @Override + public int getMinYear() { + if (mIsMinNoRange) + return PickerContants.DEFAULT_MIN_YEAR; + else + return mCalendarMin.year; + } + + @Override + public int getMaxYear() { + if (mIsMaxNoRange) + return getMinYear() + PickerContants.YEAR_COUNT; + + return mCalendarMax.year; + } + + @Override + public int getMinMonth(int year) { + if (!mIsMinNoRange && Utils.isTimeEquals(mCalendarMin, year)) + return mCalendarMin.month; + + return PickerContants.MIN_MONTH; + } + + @Override + public int getMaxMonth(int year) { + if (!mIsMaxNoRange && Utils.isTimeEquals(mCalendarMax, year)) + return mCalendarMax.month; + + return PickerContants.MAX_MONTH; + } + + @Override + public int getMinDay(int year, int month) { + if (!mIsMinNoRange && Utils.isTimeEquals(mCalendarMin, year, month)) + return mCalendarMin.day; + + return PickerContants.MIN_DAY; + } + + @Override + public int getMaxDay(int year, int month) { + if (!mIsMaxNoRange && Utils.isTimeEquals(mCalendarMax, year, month)) + return mCalendarMax.day; + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.DATE, 1); + calendar.set(Calendar.MONTH, month - 1); + + return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + } + + @Override + public int getMinHour(int year, int month, int day) { + if (!mIsMinNoRange && Utils.isTimeEquals(mCalendarMin, year, month, day)) + return mCalendarMin.hour; + else + return PickerContants.MIN_HOUR; + } + + @Override + public int getMaxHour(int year, int month, int day) { + if (!mIsMaxNoRange && Utils.isTimeEquals(mCalendarMax, year, month, day)) + return mCalendarMax.hour; + + return PickerContants.MAX_HOUR; + } + + @Override + public int getMinMinute(int year, int month, int day, int hour) { + if (!mIsMinNoRange && Utils.isTimeEquals(mCalendarMin, year, month, day, hour)) + return mCalendarMin.minute + 1; + else + return PickerContants.MIN_MINUTE; + } + + @Override + public int getMaxMinute(int year, int month, int day, int hour) { + if (!mIsMaxNoRange && Utils.isTimeEquals(mCalendarMax, year, month, day, hour)) + return mCalendarMax.minute; + + return PickerContants.MAX_MINUTE; + } + + @Override + public boolean isMinYear(int year) { + return Utils.isTimeEquals(mCalendarMin, year); + } + + @Override + public boolean isMinMonth(int year, int month) { + return Utils.isTimeEquals(mCalendarMin, year, month); + } + + @Override + public boolean isMinDay(int year, int month, int day) { + return Utils.isTimeEquals(mCalendarMin, year, month, day); + } + + @Override + public boolean isMinHour(int year, int month, int day, int hour) { + return Utils.isTimeEquals(mCalendarMin, year, month, day, hour); + } + + + @Override + public WheelCalendar getDefaultCalendar() { + return mPickerConfig.mCurrentCalendar; + } +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/listener/OnDateSetListener.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/listener/OnDateSetListener.java new file mode 100644 index 0000000..f8ca412 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/listener/OnDateSetListener.java @@ -0,0 +1,13 @@ +package com.jzxiang.pickerview.listener; + +import com.jzxiang.pickerview.TimePickerDialog; + +import java.util.Calendar; + +/** + * Created by jzxiang on 16/4/20. + */ +public interface OnDateSetListener { + + void onDateSet(TimePickerDialog timePickerView, long millseconds); +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/PickerContants.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/PickerContants.java new file mode 100644 index 0000000..99ecfea --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/PickerContants.java @@ -0,0 +1,18 @@ +package com.jzxiang.pickerview.utils; + +/** + * Created by jzxiang on 16/4/20. + */ +public class PickerContants { + public static final String FORMAT = "%02d"; + + public static final int DEFAULT_MIN_YEAR = 2015; + public static final int YEAR_COUNT = 50; + public static final int MIN_MONTH = 1; + public static final int MAX_MONTH = 12; + public static final int MIN_DAY = MIN_MONTH; + public static final int MIN_HOUR = 0; + public static final int MAX_HOUR = 23; + public static final int MIN_MINUTE = 0; + public static final int MAX_MINUTE = 59; +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/Utils.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/Utils.java new file mode 100644 index 0000000..85e779e --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/utils/Utils.java @@ -0,0 +1,37 @@ +package com.jzxiang.pickerview.utils; + +import android.view.View; + +import com.jzxiang.pickerview.data.WheelCalendar; + +/** + * Created by jzxiang on 16/4/20. + */ +public class Utils { + + public static boolean isTimeEquals(WheelCalendar calendar, int... params) { + switch (params.length) { + case 1: + return calendar.year == params[0]; + case 2: + return calendar.year == params[0] && + calendar.month == params[1]; + case 3: + return calendar.year == params[0] && + calendar.month == params[1] && + calendar.day == params[2]; + case 4: + return calendar.year == params[0] && + calendar.month == params[1] && + calendar.day == params[2] && + calendar.hour == params[3]; + } + return false; + } + + public static void hideViews(View... views) { + for (int i = 0; i < views.length; i++) { + views[i].setVisibility(View.GONE); + } + } +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/ItemsRange.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/ItemsRange.java new file mode 100644 index 0000000..9d1498c --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/ItemsRange.java @@ -0,0 +1,86 @@ +/* + * Android Wheel Control. + * https://code.google.com/p/android-wheel/ + * + * Copyright 2011 Yuri Kanivets + * + * 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. + */ + +package com.jzxiang.pickerview.wheel; + +/** + * Range for visible items. + */ +public class ItemsRange { + // First item number + private int first; + + // Items count + private int count; + + /** + * Default constructor. Creates an empty range + */ + public ItemsRange() { + this(0, 0); + } + + /** + * Constructor + * + * @param first the number of first item + * @param count the count of items + */ + public ItemsRange(int first, int count) { + this.first = first; + this.count = count; + } + + /** + * Gets number of first item + * + * @return the number of the first item + */ + public int getFirst() { + return first; + } + + /** + * Gets number of last item + * + * @return the number of last item + */ + public int getLast() { + return getFirst() + getCount() - 1; + } + + /** + * Get items count + * + * @return the count of items + */ + public int getCount() { + return count; + } + + /** + * Tests whether item is contained by range + * + * @param index the item number + * @return true if item is contained + */ + public boolean contains(int index) { + return index >= getFirst() && index <= getLast(); + } +} \ No newline at end of file diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelChangedListener.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelChangedListener.java new file mode 100644 index 0000000..47b786c --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelChangedListener.java @@ -0,0 +1,18 @@ +package com.jzxiang.pickerview.wheel; + +/** + * Wheel changed listener interface. + * The onChanged() method is called whenever current wheel positions is changed: + * New Wheel position is set + * Wheel view is scrolled + */ +public interface OnWheelChangedListener { + /** + * Callback method to be invoked when current item changed + * + * @param wheel the wheel view whose state has changed + * @param oldValue the old value of current item + * @param newValue the new value of current item + */ + void onChanged(WheelView wheel, int oldValue, int newValue); +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelClickedListener.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelClickedListener.java new file mode 100644 index 0000000..9a65129 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelClickedListener.java @@ -0,0 +1,17 @@ +package com.jzxiang.pickerview.wheel; + +/** + * Wheel clicked listener interface. + *

The onItemClicked() method is called whenever a wheel item is clicked + * New Wheel position is set + * Wheel view is scrolled + */ +public interface OnWheelClickedListener { + /** + * Callback method to be invoked when current item clicked + * + * @param wheel the wheel view + * @param itemIndex the index of clicked item + */ + void onItemClicked(WheelView wheel, int itemIndex); +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelScrollListener.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelScrollListener.java new file mode 100644 index 0000000..2cae2be --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/OnWheelScrollListener.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010 Yuri Kanivets + * + * 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. + */ + +package com.jzxiang.pickerview.wheel; + +/** + * Wheel scrolled listener interface. + */ +public interface OnWheelScrollListener { + /** + * Callback method to be invoked when scrolling started. + * + * @param wheel the wheel view whose state has changed. + */ + void onScrollingStarted(WheelView wheel); + + /** + * Callback method to be invoked when scrolling ended. + * + * @param wheel the wheel view whose state has changed. + */ + void onScrollingFinished(WheelView wheel); +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelRecycle.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelRecycle.java new file mode 100644 index 0000000..823e0d0 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelRecycle.java @@ -0,0 +1,127 @@ +package com.jzxiang.pickerview.wheel; + +import android.view.View; +import android.widget.LinearLayout; + +import java.util.LinkedList; +import java.util.List; + +/** + * Recycle stores wheel items to reuse. + */ +public class WheelRecycle { + // Cached items + private List items; + + // Cached empty items + private List emptyItems; + + // Wheel view + private WheelView wheel; + + + public WheelRecycle(WheelView wheel) { + this.wheel = wheel; + } + + public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range, int currentItem) { + int index = firstItem; + for (int i = 0; i < layout.getChildCount(); ) { + if (!range.contains(index)) { + recycleView(layout.getChildAt(i), index, currentItem); + layout.removeViewAt(i); + if (i == 0) { // first item + firstItem++; + } + } else { + i++; // go to next item + } + index++; + } + return firstItem; + } + + /** + * Gets item view + * + * @return the cached view + */ + public View getItem() { + return getCachedView(items); + } + + /** + * Gets empty item view + * + * @return the cached empty view + */ + public View getEmptyItem() { + return getCachedView(emptyItems); + } + + /** + * Clears all views + */ + public void clearAll() { + if (items != null) { + items.clear(); + } + if (emptyItems != null) { + emptyItems.clear(); + } + } + + /** + * Adds view to specified cache. Creates a cache list if it is null. + * + * @param view the view to be cached + * @param cache the cache list + * @return the cache list + */ + private List addView(View view, List cache) { + if (cache == null) { + cache = new LinkedList(); + } + + cache.add(view); + return cache; + } + + /** + * Adds view to cache. Determines view type (item view or empty one) by index. + * + * @param view the view to be cached + * @param index the index of view + */ + private void recycleView(View view, int index, int current) { + int count = wheel.getViewAdapter().getItemsCount(); + + + if ((index < 0 || index >= count) && !wheel.isCyclic()) { + // empty view + emptyItems = addView(view, emptyItems); + } else { + while (index < 0) { + index = count + index; + } + index %= count; + items = addView(view, items); + } + } + + /** + * Gets view from specified cache. + * + * @param cache the cache + * @return the first view from cache. + */ + private View getCachedView(List cache) { + if (cache != null && cache.size() > 0) { + View view = cache.get(0); + cache.remove(0); + return view; + } + return null; + } + +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelScroller.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelScroller.java new file mode 100644 index 0000000..f905b24 --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelScroller.java @@ -0,0 +1,208 @@ +package com.jzxiang.pickerview.wheel; + +import android.content.Context; +import android.os.Handler; +import android.os.Message; +import android.view.GestureDetector; +import android.view.GestureDetector.SimpleOnGestureListener; +import android.view.MotionEvent; +import android.view.animation.Interpolator; +import android.widget.Scroller; + +public class WheelScroller { + + public static final int MIN_DELTA_FOR_SCROLLING = 1; + private static final int SCROLLING_DURATION = 400; + // Messages + private final int MESSAGE_SCROLL = 0; + private final int MESSAGE_JUSTIFY = 1; + private ScrollingListener listener; + // Context + private Context context; + // Scrolling + private GestureDetector gestureDetector; + private Scroller scroller; + private int lastScrollY; + private float lastTouchedY; + private boolean isScrollingPerformed; + // animation handler + private Handler animationHandler = new Handler() { + public void handleMessage(Message msg) { + scroller.computeScrollOffset(); + int currY = scroller.getCurrY(); + int delta = lastScrollY - currY; + lastScrollY = currY; + if (delta != 0) { + listener.onScroll(delta); + } + + // scrolling is not finished when it comes to final Y + // so, finish it manually + if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) { + currY = scroller.getFinalY(); + scroller.forceFinished(true); + } + if (!scroller.isFinished()) { + animationHandler.sendEmptyMessage(msg.what); + } else if (msg.what == MESSAGE_SCROLL) { + justify(); + } else { + finishScrolling(); + } + } + }; + // gesture listener + private SimpleOnGestureListener gestureListener = new SimpleOnGestureListener() { + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { + // Do scrolling in onTouchEvent() since onScroll() are not call immediately + // when user touch and move the wheel + return true; + } + + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + lastScrollY = 0; + final int maxY = 0x7FFFFFFF; + final int minY = -maxY; + scroller.fling(0, lastScrollY, 0, (int) -velocityY, 0, 0, minY, maxY); + setNextMessage(MESSAGE_SCROLL); + return true; + } + }; + + + public WheelScroller(Context context, ScrollingListener listener) { + gestureDetector = new GestureDetector(context, gestureListener); + gestureDetector.setIsLongpressEnabled(false); + + scroller = new Scroller(context); + + this.listener = listener; + this.context = context; + } + + + public void setInterpolator(Interpolator interpolator) { + scroller.forceFinished(true); + scroller = new Scroller(context, interpolator); + } + + public void scroll(int distance, int time) { + scroller.forceFinished(true); + + lastScrollY = 0; + + scroller.startScroll(0, 0, 0, distance, time != 0 ? time : SCROLLING_DURATION); + setNextMessage(MESSAGE_SCROLL); + + startScrolling(); + } + + /** + * Stops scrolling + */ + public void stopScrolling() { + scroller.forceFinished(true); + } + + /** + * Handles Touch event + * + * @param event the motion event + * @return + */ + public boolean onTouchEvent(MotionEvent event) { + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + lastTouchedY = event.getY(); + scroller.forceFinished(true); + clearMessages(); + break; + + case MotionEvent.ACTION_MOVE: + // perform scrolling + int distanceY = (int) (event.getY() - lastTouchedY); + if (distanceY != 0) { + startScrolling(); + listener.onScroll(distanceY); + lastTouchedY = event.getY(); + } + break; + } + + if (!gestureDetector.onTouchEvent(event) && event.getAction() == MotionEvent.ACTION_UP) { + justify(); + } + + return true; + } + + /** + * Set next message to queue. Clears queue before. + * + * @param message the message to set + */ + private void setNextMessage(int message) { + clearMessages(); + animationHandler.sendEmptyMessage(message); + } + + /** + * Clears messages from queue + */ + private void clearMessages() { + animationHandler.removeMessages(MESSAGE_SCROLL); + animationHandler.removeMessages(MESSAGE_JUSTIFY); + } + + /** + * Justifies wheel + */ + private void justify() { + listener.onJustify(); + setNextMessage(MESSAGE_JUSTIFY); + } + + /** + * Starts scrolling + */ + private void startScrolling() { + if (!isScrollingPerformed) { + isScrollingPerformed = true; + listener.onStarted(); + } + } + + /** + * Finishes scrolling + */ + void finishScrolling() { + if (isScrollingPerformed) { + listener.onFinished(); + isScrollingPerformed = false; + } + } + + public interface ScrollingListener { + /** + * Scrolling callback called when scrolling is performed. + * + * @param distance the distance to scroll + */ + void onScroll(int distance); + + /** + * Starting callback called when scrolling is started + */ + void onStarted(); + + /** + * Finishing callback called after justifying + */ + void onFinished(); + + /** + * Justifying callback called to justify a view when scrolling is ended + */ + void onJustify(); + } +} diff --git a/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelView.java b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelView.java new file mode 100644 index 0000000..86bc22b --- /dev/null +++ b/TimePickerDialog/src/main/java/com/jzxiang/pickerview/wheel/WheelView.java @@ -0,0 +1,942 @@ +/* + * Android Wheel Control. + * https://code.google.com/p/android-wheel/ + * + * Copyright 2011 Yuri Kanivets + * + * 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. + */ + +package com.jzxiang.pickerview.wheel; + +import java.util.LinkedList; +import java.util.List; + +import com.jzxiang.pickerview.R; +import com.jzxiang.pickerview.adapters.WheelViewAdapter; +import com.jzxiang.pickerview.config.DefaultConfig; +import com.jzxiang.pickerview.config.PickerConfig; + +import android.content.Context; +import android.database.DataSetObserver; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.animation.Interpolator; +import android.widget.LinearLayout; +import android.widget.TextView; + + +/** + * Numeric wheel view. + * + * @author Yuri Kanivets + */ +public class WheelView extends View { + + /** + * Top and bottom items offset (to hide that) + */ + private static final int ITEM_OFFSET_PERCENT = 10; + + /** + * Left and right padding value + */ + private static final int PADDING = 10; + + /** + * Default count of visible items + */ + private static final int DEF_VISIBLE_ITEMS = 5; + // Cyclic + boolean isCyclic = false; + int defaultColor, selectorColor; + // Wheel Values + private int currentItem = 0; + // Count of visible items + private int visibleItems = DEF_VISIBLE_ITEMS; + // Item height + private int itemHeight = 0; + // Scrolling + private WheelScroller scroller; + private boolean isScrollingPerformed; + private int scrollingOffset; + // Items layout + private LinearLayout itemsLayout; + // The number of first item in layout + private int firstItem; + // View adapter + private WheelViewAdapter viewAdapter; + + // Recycle + private WheelRecycle recycle = new WheelRecycle(this); + private Paint mPaintLineCenter, mPaintLineRight, mPaintRectCenter; + private int mLineRightMar; + // Listeners + private List changingListeners = new LinkedList(); + private List scrollingListeners = new LinkedList(); + // Scrolling listener + WheelScroller.ScrollingListener scrollingListener = new WheelScroller.ScrollingListener() { + public void onStarted() { + isScrollingPerformed = true; + notifyScrollingListenersAboutStart(); + } + + public void onScroll(int distance) { + doScroll(distance); + + int height = getHeight(); + if (scrollingOffset > height) { + scrollingOffset = height; + scroller.stopScrolling(); + } else if (scrollingOffset < -height) { + scrollingOffset = -height; + scroller.stopScrolling(); + } + } + + public void onFinished() { + if (isScrollingPerformed) { + notifyScrollingListenersAboutEnd(); + isScrollingPerformed = false; + } + + scrollingOffset = 0; + invalidate(); + } + + public void onJustify() { + if (Math.abs(scrollingOffset) > WheelScroller.MIN_DELTA_FOR_SCROLLING) { + scroller.scroll(scrollingOffset, 0); + } + } + }; + private List clickingListeners = new LinkedList(); + // Adapter listener + private DataSetObserver dataObserver = new DataSetObserver() { + @Override + public void onChanged() { + invalidateWheel(false); + } + + @Override + public void onInvalidated() { + invalidateWheel(true); + } + }; + + /** + * Constructor + */ + public WheelView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + initData(context); + } + + /** + * Constructor + */ + public WheelView(Context context, AttributeSet attrs) { + super(context, attrs); + initData(context); + } + + /** + * Constructor + */ + public WheelView(Context context) { + super(context); + initData(context); + } + + /** + * Initializes class data + * + * @param context the context + */ + private void initData(Context context) { + scroller = new WheelScroller(getContext(), scrollingListener); + + mPaintLineCenter = new Paint(); + mPaintLineCenter.setColor(DefaultConfig.COLOR); + mPaintLineCenter.setAntiAlias(true); + mPaintLineCenter.setStrokeWidth(1); + mPaintLineCenter.setStyle(Paint.Style.FILL); + + mPaintLineRight = new Paint(); + mPaintLineRight.setColor(0xffe8e8e8); + mPaintLineRight.setAntiAlias(true); +// mPaintLineRight.setStrokeWidth(context.getResources().getDimensionPixelSize(R.dimen.picker_line_width)); + mPaintLineRight.setStrokeWidth(1); + mPaintLineRight.setStyle(Paint.Style.FILL); + + mPaintRectCenter = new Paint(); + mPaintRectCenter.setColor(DefaultConfig.COLOR); + mPaintRectCenter.setAlpha((int) (0.1 * 255)); + mPaintRectCenter.setAntiAlias(true); + mPaintRectCenter.setStyle(Paint.Style.FILL); + + mLineRightMar = context.getResources().getDimensionPixelSize(R.dimen.picker_line_mar); + + + defaultColor = DefaultConfig.TV_NORMAL_COLOR; + selectorColor = DefaultConfig.TV_SELECTOR_COLOR; + + } + + public void setConfig(PickerConfig config) { + mPaintLineCenter.setColor(config.mThemeColor); + + mPaintRectCenter.setColor(config.mThemeColor); + mPaintRectCenter.setAlpha((int) (0.1 * 255)); + + defaultColor = config.mWheelTVNormalColor; + selectorColor = config.mWheelTVSelectorColor; + } + + + /** + * Set the the specified scrolling interpolator + * + * @param interpolator the interpolator + */ + public void setInterpolator(Interpolator interpolator) { + scroller.setInterpolator(interpolator); + } + + /** + * Gets count of visible items + * + * @return the count of visible items + */ + public int getVisibleItems() { + return visibleItems; + } + + /** + * Sets the desired count of visible items. + * Actual amount of visible items depends on wheel layout parameters. + * To apply changes and rebuild view call measure(). + * + * @param count the desired count for visible items + */ + public void setVisibleItems(int count) { + visibleItems = count; + } + + /** + * Gets view adapter + * + * @return the view adapter + */ + public WheelViewAdapter getViewAdapter() { + return viewAdapter; + } + + /** + * Sets view adapter. Usually new adapters contain different views, so + * it needs to rebuild view by calling measure(). + * + * @param viewAdapter the view adapter + */ + public void setViewAdapter(WheelViewAdapter viewAdapter) { + if (this.viewAdapter != null) { + this.viewAdapter.unregisterDataSetObserver(dataObserver); + } + this.viewAdapter = viewAdapter; + if (this.viewAdapter != null) { + this.viewAdapter.registerDataSetObserver(dataObserver); + } + + setConfig(viewAdapter.getConfig()); + invalidateWheel(true); + } + + /** + * Adds wheel changing listener + * + * @param listener the listener + */ + public void addChangingListener(OnWheelChangedListener listener) { + changingListeners.add(listener); + } + + /** + * Removes wheel changing listener + * + * @param listener the listener + */ + public void removeChangingListener(OnWheelChangedListener listener) { + changingListeners.remove(listener); + } + + /** + * Notifies changing listeners + * + * @param oldValue the old wheel value + * @param newValue the new wheel value + */ + protected void notifyChangingListeners(int oldValue, int newValue) { + for (OnWheelChangedListener listener : changingListeners) { + listener.onChanged(this, oldValue, newValue); + } + + if (oldValue < 0 || newValue < 0 || itemsLayout == null) + return; + + View oldView = itemsLayout.getChildAt(oldValue - firstItem); + View newView = itemsLayout.getChildAt(newValue - firstItem); + + refreshTextStatus(oldView, oldValue); + refreshTextStatus(newView, newValue); + + } + + /** + * Adds wheel scrolling listener + * + * @param listener the listener + */ + public void addScrollingListener(OnWheelScrollListener listener) { + scrollingListeners.add(listener); + } + + /** + * Removes wheel scrolling listener + * + * @param listener the listener + */ + public void removeScrollingListener(OnWheelScrollListener listener) { + scrollingListeners.remove(listener); + } + + /** + * Notifies listeners about starting scrolling + */ + protected void notifyScrollingListenersAboutStart() { + for (OnWheelScrollListener listener : scrollingListeners) { + listener.onScrollingStarted(this); + } + } + + /** + * Notifies listeners about ending scrolling + */ + protected void notifyScrollingListenersAboutEnd() { + for (OnWheelScrollListener listener : scrollingListeners) { + listener.onScrollingFinished(this); + } + + + } + + /** + * Adds wheel clicking listener + * + * @param listener the listener + */ + public void addClickingListener(OnWheelClickedListener listener) { + clickingListeners.add(listener); + } + + /** + * Removes wheel clicking listener + * + * @param listener the listener + */ + public void removeClickingListener(OnWheelClickedListener listener) { + clickingListeners.remove(listener); + } + + /** + * Notifies listeners about clicking + */ + protected void notifyClickListenersAboutClick(int item) { + for (OnWheelClickedListener listener : clickingListeners) { + listener.onItemClicked(this, item); + } + } + + /** + * Gets current value + * + * @return the current value + */ + public int getCurrentItem() { + return currentItem; + } + + /** + * Sets the current item w/o animation. Does nothing when index is wrong. + * + * @param index the item index + */ + public void setCurrentItem(int index) { + setCurrentItem(index, false); + } + + /** + * Sets the current item. Does nothing when index is wrong. + * + * @param index the item index + * @param animated the animation flag + */ + public void setCurrentItem(int index, boolean animated) { + if (viewAdapter == null || viewAdapter.getItemsCount() == 0) { + return; // throw? + } + + int itemCount = viewAdapter.getItemsCount(); + if (index < 0 || index >= itemCount) { + if (isCyclic) { + while (index < 0) { + index += itemCount; + } + index %= itemCount; + } else { + return; // throw? + } + } + + + if (index != currentItem) { + if (animated) { + int itemsToScroll = index - currentItem; + if (isCyclic) { + int scroll = itemCount + Math.min(index, currentItem) - Math.max(index, currentItem); + if (scroll < Math.abs(itemsToScroll)) { + itemsToScroll = itemsToScroll < 0 ? scroll : -scroll; + } + } + scroll(itemsToScroll, 0); + } else { + scrollingOffset = 0; + + int old = currentItem; + currentItem = index; + + notifyChangingListeners(old, currentItem); + + invalidate(); + } + + + } + } + + /** + * Tests if wheel is cyclic. That means before the 1st item there is shown the last one + * + * @return true if wheel is cyclic + */ + public boolean isCyclic() { + return isCyclic; + } + + /** + * Set wheel cyclic flag + * + * @param isCyclic the flag to set + */ + public void setCyclic(boolean isCyclic) { + this.isCyclic = isCyclic; + invalidateWheel(false); + } + + /** + * Invalidates wheel + * + * @param clearCaches if true then cached views will be clear + */ + public void invalidateWheel(boolean clearCaches) { + if (clearCaches) { + recycle.clearAll(); + if (itemsLayout != null) { + itemsLayout.removeAllViews(); + } + scrollingOffset = 0; + } else if (itemsLayout != null) { + // cache all items + recycle.recycleItems(itemsLayout, firstItem, new ItemsRange(), currentItem); + } + + invalidate(); + } + + /** + * Initializes resources + */ + private void initResourcesIfNecessary() { + setBackgroundResource(android.R.color.white); + } + + /** + * Calculates desired height for layout + * + * @param layout the source layout + * @return the desired layout height + */ + private int getDesiredHeight(LinearLayout layout) { + if (layout != null && layout.getChildAt(0) != null) { + itemHeight = layout.getChildAt(0).getMeasuredHeight(); + } + + int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50; + + return Math.max(desired, getSuggestedMinimumHeight()); + } + + /** + * Returns height of wheel item + * + * @return the item height + */ + private int getItemHeight() { + if (itemHeight != 0) { + return itemHeight; + } + + if (itemsLayout != null && itemsLayout.getChildAt(0) != null) { + itemHeight = itemsLayout.getChildAt(0).getHeight(); + return itemHeight; + } + + return getHeight() / visibleItems; + } + + /** + * Calculates control width and creates text layouts + * + * @param widthSize the input layout width + * @param mode the layout mode + * @return the calculated control width + */ + private int calculateLayoutWidth(int widthSize, int mode) { + initResourcesIfNecessary(); + + // TODO: make it static + itemsLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + itemsLayout.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.UNSPECIFIED), + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + int width = itemsLayout.getMeasuredWidth(); + + if (mode == MeasureSpec.EXACTLY) { + width = widthSize; + } else { + width += 2 * PADDING; + + // Check against our minimum width + width = Math.max(width, getSuggestedMinimumWidth()); + + if (mode == MeasureSpec.AT_MOST && widthSize < width) { + width = widthSize; + } + } + + itemsLayout.measure(MeasureSpec.makeMeasureSpec(width - 2 * PADDING, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + + return width; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + int heightMode = MeasureSpec.getMode(heightMeasureSpec); + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + buildViewForMeasuring(); + + int width = calculateLayoutWidth(widthSize, widthMode); + + int height; + if (heightMode == MeasureSpec.EXACTLY) { + height = heightSize; + } else { + height = getDesiredHeight(itemsLayout); + + if (heightMode == MeasureSpec.AT_MOST) { + height = Math.min(height, heightSize); + } + } + + setMeasuredDimension(width, height); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + layout(r - l, b - t); + } + + /** + * Sets layouts width and height + * + * @param width the layout width + * @param height the layout height + */ + private void layout(int width, int height) { + int itemsWidth = width - 2 * PADDING; + + itemsLayout.layout(0, 0, itemsWidth, height); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (viewAdapter != null && viewAdapter.getItemsCount() > 0) { + updateView(); + drawItems(canvas); + drawCenterRect(canvas); + } + } + + + /** + * Draws items + * + * @param canvas the canvas for drawing + */ + private void drawItems(Canvas canvas) { + canvas.save(); + + int top = (currentItem - firstItem) * getItemHeight() + (getItemHeight() - getHeight()) / 2; + canvas.translate(PADDING, -top + scrollingOffset); + + itemsLayout.draw(canvas); + + canvas.restore(); + } + + /** + * Draws rect for current value + * + * @param canvas the canvas for drawing + */ + private void drawCenterRect(Canvas canvas) { + int center = getHeight() / 2; + int offset = (int) (getItemHeight() / 2 * 1.2); +// centerDrawable.setBounds(0, center - offset, getWidth(), center + offset); +// centerDrawable.draw(canvas); + canvas.drawRect(0, center - offset, getWidth(), center + offset, mPaintRectCenter); + + canvas.drawLine(0, center - offset, getWidth(), center - offset, mPaintLineCenter); + canvas.drawLine(0, center + offset, getWidth(), center + offset, mPaintLineCenter); + + int x = getWidth() - 1; + canvas.drawLine(x, mLineRightMar, x, getHeight() - mLineRightMar, mPaintLineRight); + } + + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (!isEnabled() || getViewAdapter() == null) { + return true; + } + + switch (event.getAction()) { + case MotionEvent.ACTION_MOVE: + if (getParent() != null) { + getParent().requestDisallowInterceptTouchEvent(true); + } + break; + + case MotionEvent.ACTION_UP: + if (!isScrollingPerformed) { + int distance = (int) event.getY() - getHeight() / 2; + if (distance > 0) { + distance += getItemHeight() / 2; + } else { + distance -= getItemHeight() / 2; + } + int items = distance / getItemHeight(); + if (items != 0 && isValidItemIndex(currentItem + items)) { + notifyClickListenersAboutClick(currentItem + items); + } + } + break; + } + + return scroller.onTouchEvent(event); + } + + /** + * Scrolls the wheel + * + * @param delta the scrolling value + */ + private void doScroll(int delta) { + scrollingOffset += delta; + + int itemHeight = getItemHeight(); + int count = scrollingOffset / itemHeight; + + int pos = currentItem - count; + int itemCount = viewAdapter.getItemsCount(); + + int fixPos = scrollingOffset % itemHeight; + if (Math.abs(fixPos) <= itemHeight / 2) { + fixPos = 0; + } + if (isCyclic && itemCount > 0) { + if (fixPos > 0) { + pos--; + count++; + } else if (fixPos < 0) { + pos++; + count--; + } + // fix position by rotating + while (pos < 0) { + pos += itemCount; + } + pos %= itemCount; + } else { + // + if (pos < 0) { + count = currentItem; + pos = 0; + } else if (pos >= itemCount) { + count = currentItem - itemCount + 1; + pos = itemCount - 1; + } else if (pos > 0 && fixPos > 0) { + pos--; + count++; + } else if (pos < itemCount - 1 && fixPos < 0) { + pos++; + count--; + } + } + + int offset = scrollingOffset; + if (pos != currentItem) { + setCurrentItem(pos, false); + } else { + invalidate(); + } + + // update offset + scrollingOffset = offset - count * itemHeight; + if (scrollingOffset > getHeight()) { + scrollingOffset = scrollingOffset % getHeight() + getHeight(); + } + } + + /** + * Scroll the wheel + * + * @param itemsToScroll items to scroll + * @param time scrolling duration + */ + public void scroll(int itemsToScroll, int time) { + int distance = itemsToScroll * getItemHeight() - scrollingOffset; + scroller.scroll(distance, time); + } + + /** + * Calculates range for wheel items + * + * @return the items range + */ + private ItemsRange getItemsRange() { + if (getItemHeight() == 0) { + return null; + } + + int first = currentItem; + int count = 1; + + while (count * getItemHeight() < getHeight()) { + first--; + count += 2; // top + bottom items + } + + if (scrollingOffset != 0) { + if (scrollingOffset > 0) { + first--; + } + count++; + + // process empty items above the first or below the second + int emptyItems = scrollingOffset / getItemHeight(); + first -= emptyItems; + count += Math.asin(emptyItems); + } + return new ItemsRange(first, count); + } + + /** + * Rebuilds wheel items if necessary. Caches all unused items. + * + * @return true if items are rebuilt + */ + private boolean rebuildItems() { + boolean updated = false; + ItemsRange range = getItemsRange(); + if (itemsLayout != null) { + int first = recycle.recycleItems(itemsLayout, firstItem, range, currentItem); + updated = firstItem != first; + firstItem = first; + } else { + createItemsLayout(); + updated = true; + } + + if (!updated) { + updated = firstItem != range.getFirst() || itemsLayout.getChildCount() != range.getCount(); + } + + if (firstItem > range.getFirst() && firstItem <= range.getLast()) { + for (int i = firstItem - 1; i >= range.getFirst(); i--) { + if (!addViewItem(i, true)) { + break; + } + firstItem = i; + } + } else { + firstItem = range.getFirst(); + } + + int first = firstItem; + for (int i = itemsLayout.getChildCount(); i < range.getCount(); i++) { + if (!addViewItem(firstItem + i, false) && itemsLayout.getChildCount() == 0) { + first++; + } + } + firstItem = first; + + return updated; + } + + /** + * Updates view. Rebuilds items and label if necessary, recalculate items sizes. + */ + private void updateView() { + if (rebuildItems()) { + calculateLayoutWidth(getWidth(), MeasureSpec.EXACTLY); + layout(getWidth(), getHeight()); + } + } + + /** + * Creates item layouts if necessary + */ + private void createItemsLayout() { + if (itemsLayout == null) { + itemsLayout = new LinearLayout(getContext()); + itemsLayout.setOrientation(LinearLayout.VERTICAL); + } + } + + /** + * Builds view for measuring + */ + private void buildViewForMeasuring() { + // clear all items + if (itemsLayout != null) { + recycle.recycleItems(itemsLayout, firstItem, new ItemsRange(), currentItem); + } else { + createItemsLayout(); + } + + // add views + int addItems = visibleItems / 2; + for (int i = currentItem + addItems; i >= currentItem - addItems; i--) { + if (addViewItem(i, true)) { + firstItem = i; + } + } + } + + /** + * Adds view for item to items layout + * + * @param index the item index + * @param first the flag indicates if view should be first + * @return true if corresponding item exists and is added + */ + private boolean addViewItem(int index, boolean first) { + View view = getItemView(index); + refreshTextStatus(view, index); + if (view != null) { + if (first) { + itemsLayout.addView(view, 0); + } else { + itemsLayout.addView(view); + } + + return true; + } + + return false; + } + + void refreshTextStatus(View view, int index) { + if (!(view instanceof TextView)) + return; + TextView textView = (TextView) view; + if (index == currentItem) { + textView.setTextColor(selectorColor); + } else { + textView.setTextColor(defaultColor); + } + } + + /** + * Checks whether intem index is valid + * + * @param index the item index + * @return true if item index is not out of bounds or the wheel is cyclic + */ + private boolean isValidItemIndex(int index) { + return viewAdapter != null && viewAdapter.getItemsCount() > 0 && + (isCyclic || index >= 0 && index < viewAdapter.getItemsCount()); + } + + /** + * Returns view for specified item + * + * @param index the item index + * @return item view or empty view if index is out of bounds + */ + private View getItemView(int index) { + if (viewAdapter == null || viewAdapter.getItemsCount() == 0) { + return null; + } + int count = viewAdapter.getItemsCount(); + if (!isValidItemIndex(index)) { + return viewAdapter.getEmptyItem(recycle.getEmptyItem(), itemsLayout); + } else { + while (index < 0) { + index = count + index; + } + } + + index %= count; + + View view = viewAdapter.getItem(index, recycle.getItem(), itemsLayout); + + + return view; + } + + /** + * Stops scrolling + */ + public void stopScrolling() { + scroller.stopScrolling(); + } +} diff --git a/TimePickerDialog/src/main/res/anim/slide_in_bottom.xml b/TimePickerDialog/src/main/res/anim/slide_in_bottom.xml new file mode 100644 index 0000000..ed1097d --- /dev/null +++ b/TimePickerDialog/src/main/res/anim/slide_in_bottom.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/anim/slide_out_bottom.xml b/TimePickerDialog/src/main/res/anim/slide_out_bottom.xml new file mode 100644 index 0000000..b58c645 --- /dev/null +++ b/TimePickerDialog/src/main/res/anim/slide_out_bottom.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/drawable/timepicker_divider_line.xml b/TimePickerDialog/src/main/res/drawable/timepicker_divider_line.xml new file mode 100644 index 0000000..b49a7d4 --- /dev/null +++ b/TimePickerDialog/src/main/res/drawable/timepicker_divider_line.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/TimePickerDialog/src/main/res/drawable/timepicker_sel_text_item.xml b/TimePickerDialog/src/main/res/drawable/timepicker_sel_text_item.xml new file mode 100644 index 0000000..9086b02 --- /dev/null +++ b/TimePickerDialog/src/main/res/drawable/timepicker_sel_text_item.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/drawable/wheel_bg.xml b/TimePickerDialog/src/main/res/drawable/wheel_bg.xml new file mode 100644 index 0000000..90e3e43 --- /dev/null +++ b/TimePickerDialog/src/main/res/drawable/wheel_bg.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/drawable/wheel_val.xml b/TimePickerDialog/src/main/res/drawable/wheel_val.xml new file mode 100644 index 0000000..10c4837 --- /dev/null +++ b/TimePickerDialog/src/main/res/drawable/wheel_val.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/TimePickerDialog/src/main/res/layout/timepicker_layout.xml b/TimePickerDialog/src/main/res/layout/timepicker_layout.xml new file mode 100644 index 0000000..3e871e1 --- /dev/null +++ b/TimePickerDialog/src/main/res/layout/timepicker_layout.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TimePickerDialog/src/main/res/layout/timepicker_line.xml b/TimePickerDialog/src/main/res/layout/timepicker_line.xml new file mode 100644 index 0000000..ead3095 --- /dev/null +++ b/TimePickerDialog/src/main/res/layout/timepicker_line.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/values/colors.xml b/TimePickerDialog/src/main/res/values/colors.xml new file mode 100644 index 0000000..ae57187 --- /dev/null +++ b/TimePickerDialog/src/main/res/values/colors.xml @@ -0,0 +1,7 @@ + + + #999999 + #e60012 + #80000000 + #e8e8e8 + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/values/dimens.xml b/TimePickerDialog/src/main/res/values/dimens.xml new file mode 100644 index 0000000..14919d8 --- /dev/null +++ b/TimePickerDialog/src/main/res/values/dimens.xml @@ -0,0 +1,10 @@ + + + 12sp + 60dp + 220dp + 5dp + 1dp + 15dp + 280dp + \ No newline at end of file diff --git a/TimePickerDialog/src/main/res/values/strings.xml b/TimePickerDialog/src/main/res/values/strings.xml new file mode 100644 index 0000000..7ff02f1 --- /dev/null +++ b/TimePickerDialog/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ + + 确定 + 取消 + 选择时间 + + + + + + + + diff --git a/TimePickerDialog/src/main/res/values/style.xml b/TimePickerDialog/src/main/res/values/style.xml new file mode 100644 index 0000000..ec94050 --- /dev/null +++ b/TimePickerDialog/src/main/res/values/style.xml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index a8cd593..ecdb111 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -59,8 +59,8 @@ android { buildTypes { debug { signingConfig signingConfigs.release -// buildConfigField "String", "DOMAIN", '"http://192.168.18.74:8080"'x - buildConfigField "String", "DOMAIN", '"http://47.109.205.240:8080"' + buildConfigField "String", "DOMAIN", '"http://192.168.18.74:8080"' +// buildConfigField "String", "DOMAIN", '"http://47.109.205.240:8080"' jniDebuggable false zipAlignEnabled false } @@ -130,4 +130,5 @@ dependencies { implementation 'com.github.li-xiaojun:XPopup:v2.2.23' implementation project(path: ':AlbumDialog') + implementation project(path: ':TimePickerDialog') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0e1d566..b74584a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -178,6 +178,26 @@ android:configChanges="orientation|screenSize|keyboardHidden" android:exported="false" android:screenOrientation="portrait" /> + + + + { .as(RxLife.asOnMain(this)) .subscribe(data -> { AppConfig.getInstance().setUserInfo(data); + setText(binding.userNameTv, data.getLandUserInfo().getGridMemberInfo().getMemberName()); + setText(binding.userDepartmentTv, data.getDepartmental()); + setText(binding.userTelTv, data.getPhone() + " " + data.getNo()); + GlideLoader.loadCircle(binding.userHeadIv, data.getHeadPic()); }, (OnError) error -> { showToast(error.getErrorMsg()); }); @@ -120,13 +124,7 @@ public class HomeFragment extends BaseFragment { private void initView(HomeEntity data) { setText(binding.tvTodoCount, data.getTodoCount().toString()); - setText(binding.userNameTv, data.getUserInfo().getUsername()); - setText(binding.userDepartmentTv, data.getUserInfo().getDepartmental()); - // setText(binding.userDepartmentTv, data.getUserInfo().getOrganization() + " - " + data.getUserInfo().getDepartmental()); - setText(binding.userTelTv, data.getUserInfo().getPhone() + " " + data.getUserInfo().getNo()); - GlideLoader.loadCircle(binding.userHeadIv, data.getUserInfo().getHeadPic()); funcAdapter.setNewData(data.getFunction()); - setText(binding.tudiCount, data.getDatas().getLandArea().getTotal().toString()); List datalist = new ArrayList<>(); for (HomeEntity.DatasEntity.LandAreaEntity.ListEntity entity : data.getDatas().getLandArea().getList()) { @@ -150,10 +148,9 @@ public class HomeFragment extends BaseFragment { //TODO setText(binding.zhutiCount, data.getDatas().getBusiness().getTotal().toString()); datalist.clear(); - datalist.add(new PieBean(24, "农企合作社")); - datalist.add(new PieBean(12, "农资企业")); - datalist.add(new PieBean(20, "加工企业")); - datalist.add(new PieBean(5, "种源企业")); + for (HomeEntity.DatasEntity.BusinessEntity.ListEntityXX entity : data.getDatas().getBusiness().getList()) { + datalist.add(new PieBean(entity.getCount(), entity.getName())); + } binding.zhutiChart.setLoading(false); binding.zhutiChart.setChartData(PieBean.class, "Numner", "Name", datalist, null); diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/home/entity/HomeEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/home/entity/HomeEntity.java index 3edffe2..63a181b 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/home/entity/HomeEntity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/home/entity/HomeEntity.java @@ -4,14 +4,11 @@ import java.io.Serializable; import java.util.List; import com.google.gson.annotations.SerializedName; -import com.tairui.gov_affairs_cloud.ui.my.entity.UserInfoEntity; public class HomeEntity implements Serializable { @SerializedName("todoCount") private Integer todoCount; - @SerializedName("userInfo") - private UserInfoEntity userInfo; @SerializedName("datas") private DatasEntity datas; @SerializedName("function") @@ -25,14 +22,6 @@ public class HomeEntity implements Serializable { this.todoCount = todoCount; } - public UserInfoEntity getUserInfo() { - return userInfo; - } - - public void setUserInfo(UserInfoEntity userInfo) { - this.userInfo = userInfo; - } - public DatasEntity getDatas() { return datas; } @@ -49,7 +38,6 @@ public class HomeEntity implements Serializable { this.function = function; } - public static class DatasEntity { @SerializedName("landArea") private LandAreaEntity landArea; diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddIllegalInformationActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddIllegalInformationActivity.java new file mode 100644 index 0000000..baeba06 --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddIllegalInformationActivity.java @@ -0,0 +1,291 @@ +package com.tairui.gov_affairs_cloud.ui.land; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.greenrobot.eventbus.EventBus; + +import com.bigkoo.pickerview.builder.OptionsPickerBuilder; +import com.bigkoo.pickerview.view.OptionsPickerView; +import com.jzxiang.pickerview.TimePickerDialog; +import com.jzxiang.pickerview.data.Type; +import com.jzxiang.pickerview.listener.OnDateSetListener; +import com.kongzue.albumdialog.PhotoAlbumDialog; +import com.kongzue.albumdialog.util.SelectPhotoCallback; +import com.kongzue.dialogx.dialogs.PopMenu; +import com.kongzue.dialogx.dialogs.PopTip; +import com.kongzue.dialogx.util.ItemDivider; +import com.rxjava.rxlife.RxLife; +import com.tairui.gov_affairs_cloud.R; +import com.tairui.gov_affairs_cloud.base.BaseActivity; +import com.tairui.gov_affairs_cloud.config.AppConfig; +import com.tairui.gov_affairs_cloud.databinding.ActivityAddIllegalInformationBinding; +import com.tairui.gov_affairs_cloud.entity.Api; +import com.tairui.gov_affairs_cloud.entity.EventConstant; +import com.tairui.gov_affairs_cloud.entity.EventMessage; +import com.tairui.gov_affairs_cloud.entity.UploadEntity; +import com.tairui.gov_affairs_cloud.http.OnError; +import com.tairui.gov_affairs_cloud.ui.land.entity.DictDataEntity; +import com.tairui.gov_affairs_cloud.ui.my.entity.UserInfoEntity; +import com.tairui.gov_affairs_cloud.util.DateUtils; +import com.tairui.gov_affairs_cloud.util.DensityUtils; +import com.tairui.gov_affairs_cloud.util.SingleClickListener; +import com.tairui.gov_affairs_cloud.util.glide.GlideLoader; + +import android.graphics.Color; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import rxhttp.RxHttp; +import rxhttp.RxHttpFormParam; +import rxhttp.RxHttpJsonParam; + +public class AddIllegalInformationActivity extends BaseActivity implements OnDateSetListener { + + private List typeData; + private DictDataEntity selectType; + private TimePickerDialog mDialogMonthDayHourMinute; + private OptionsPickerView landPickerView; + private OptionsPickerView landTypePickerView; + private UserInfoEntity.LandUserInfoEntity.LandListEntity selectLand; + private UserInfoEntity userInfo; + private String landImgPath; + private UploadEntity landImgEntity; + private String illegalTime; + private int isIllegal = -1; + private String inspectionId; + + @Override + protected Class getBindingClass() { + return ActivityAddIllegalInformationBinding.class; + } + + @Override + protected void onQueryArguments() { + inspectionId = getIntent().getStringExtra("id"); + userInfo = AppConfig.getInstance().getUserInfo(); + } + + @Override + protected void onFindView(Bundle savedInstanceState) { + mDialogMonthDayHourMinute = new TimePickerDialog.Builder() + .setType(Type.MONTH_DAY_HOUR_MIN) + .setTitleStringId("选择违法时间") + .setWheelItemTextSize(14) + .setCallBack(this) + .build(); + } + + @Override + protected void onBindListener() { + binding.btnBack.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + finish(); + } + }); + binding.btnSubmit.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + checkSubmit(); + } + }); + binding.layoutAction.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + showLandTypeDialog(); + } + }); + binding.layoutTime.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + mDialogMonthDayHourMinute.show(getSupportFragmentManager(), "month_day_hour_minute"); + } + }); + binding.layoutRegion.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + showLandDialog(); + } + }); + binding.btnSelectImg.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + selectImg(); + } + }); + binding.layoutIsIllegal.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + showIsIllegalMenu(); + } + }); + } + + private void showIsIllegalMenu() { + List menus = new ArrayList<>(); + menus.add("否"); + menus.add("是"); + PopMenu.show(binding.tvIsIllegal, menus) + .setBackgroundColorRes(R.color.white) + .setWidth(DensityUtils.dp2px(mContext, 100)) + .setOnMenuItemClickListener((dialog, text, index) -> { + isIllegal = index; + setText(binding.tvIsIllegal, text.toString()); + setGone(binding.illegalLayout, index == 1); + return false; + }).setItemDivider(new ItemDivider(15, 15, 1)); + } + + @Override + public void onDateSet(TimePickerDialog timePickerView, long millseconds) { + illegalTime = DateUtils.getDateToString(millseconds); + setText(binding.tvTime, illegalTime); + } + + private void showLandDialog() { + if (landPickerView == null) { + landPickerView = new OptionsPickerBuilder(this, (options1, options2, options3, v) -> { + selectLand = userInfo.getLandUserInfo().getLandList().get(options1); + setText(binding.tvRegion, selectLand.getLandName()); + }).setTitleText("地块选择").setContentTextSize(20) + .setSelectOptions(0) + .setTitleBgColor(Color.WHITE) + .isRestoreItem(true) + .isCenterLabel(false) + .setOutSideColor(0x00000000) + .build(); + + landPickerView.setPicker(userInfo.getLandUserInfo().getLandList()); + } + landPickerView.show(); + } + + private void showLandTypeDialog() { + if (landTypePickerView == null) { + landTypePickerView = new OptionsPickerBuilder(this, (options1, options2, options3, v) -> { + selectType = typeData.get(options1); + setText(binding.tvAction, selectType.getDictLabel()); + }).setTitleText("违法行为选择").setContentTextSize(20) + .setSelectOptions(0) + .setTitleBgColor(Color.WHITE) + .isRestoreItem(true) + .isCenterLabel(false) + .setOutSideColor(0x00000000) + .build(); + + landTypePickerView.setPicker(typeData); + } + landTypePickerView.show(); + } + + private void selectImg() { + PhotoAlbumDialog.build() + .setCompressQuality(90) //开启压缩并指定质量 90% + .setCompressPhoto(false) //是否压缩(开启回调格式为 jpg,不开启回调格式为 png) + .setMaxSelectPhotoCount(1) //最多选择三张照片 + .setClip(false) //开启裁剪模式 + .setMaxSize(1000) //最高分辨率 1000(宽或高大于 1000会被等比缩小到 1000内) + .setMaxWidth(1000) //最大宽度 + .setMaxHeight(1000) //最大高度 + .setCallback(new SelectPhotoCallback() { + @Override + public void selectedPhoto(String selectedPhotos) { + landImgPath = selectedPhotos; + GlideLoader.loadOriginal(binding.imgLand, selectedPhotos); + setGone(binding.imgLand, true); + setGone(binding.btnReSelectImg, true); + } + }) + .setDialogDialogImplCallback(dialog -> dialog.setRadius(DensityUtils.dp2px(mContext, 25))) + .show(this); + } + + @Override + protected void onApplyData() { + getIllegalTypeData(); + } + + private void getIllegalTypeData() { + RxHttp.get(Api.LAND_ILLEGAL_TYPE) + .asResponseList(DictDataEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + typeData = data; + }, (OnError) error -> showToast(error.getErrorMsg())); + } + + private void checkSubmit() { + if (selectLand == null) { + showError("请选择地块"); + return; + } + if (isIllegal == -1) { + showError("请选择是否违法"); + return; + } + if (isIllegal == 1) { + if (TextUtils.isEmpty(illegalTime)) { + showError("请选择违法时间"); + return; + } + if (selectType == null) { + showError("请选择违法行为"); + return; + } + String desc = binding.inputDesc.getText().toString().trim(); + if (TextUtils.isEmpty(desc)) { + showError("请填写违法行为描述"); + return; + } + if (TextUtils.isEmpty(landImgPath)) { + showError("请选择巡查相片"); + return; + } + showLoading(); + uploadLandImg(); + } else { + showLoading(); + doAddIllegal(); + } + } + + private void uploadLandImg() { + RxHttpFormParam http = RxHttp.postForm(Api.FILE_UPLOAD); + http.addFile("file", new File(landImgPath)); + http.asSingleUpload(UploadEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + landImgEntity = data; + doAddIllegal(); + }, (OnError) error -> { + PopTip.show("图片上传失败:" + error.getErrorMsg()).iconError(); + hideLoading(); + }); + } + + private void doAddIllegal() { + RxHttpJsonParam http = RxHttp.postJson(Api.ILLEGAL_ADD); + http.add("inspectionId", inspectionId).add("landId", selectLand.getId()).add("illegalFlag", isIllegal); + if (isIllegal == 1) { + http.add("illegalDate", illegalTime); + http.add("illegalTypeCode", selectType.getDictValue()); + String desc = binding.inputDesc.getText().toString().trim(); + http.add("desc", desc); + http.add("img", landImgEntity.getUrl()); + } + http.asResponse(Boolean.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + hideLoading(); + PopTip.show("巡查结果登记成功").iconSuccess(); + EventBus.getDefault().post(new EventMessage(EventConstant.REFRESH_LIST)); + binding.btnSubmit.postDelayed(() -> finish(), 1000); + }, (OnError) error -> { + PopTip.show(error.getErrorMsg()).iconError(); + hideLoading(); + }); + } + +} diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddInspectionActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddInspectionActivity.java index d52c661..e1d502f 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddInspectionActivity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/AddInspectionActivity.java @@ -24,6 +24,7 @@ import com.tairui.gov_affairs_cloud.entity.EventMessage; import com.tairui.gov_affairs_cloud.http.OnError; import com.tairui.gov_affairs_cloud.ui.land.entity.DictDataEntity; import com.tairui.gov_affairs_cloud.ui.land.entity.GridMemberEntity; +import com.tairui.gov_affairs_cloud.ui.land.entity.MemberListEntity; import com.tairui.gov_affairs_cloud.util.ArrayUtil; import com.tairui.gov_affairs_cloud.util.DensityUtils; import com.tairui.gov_affairs_cloud.util.SingleClickListener; @@ -38,8 +39,8 @@ import rxhttp.RxHttp; public class AddInspectionActivity extends BaseActivity { - private List membersData; - private List selectMembersData; + private List membersData; + private List selectMembersData; private List multiSelectMenuText; private int[] cacheSelectMenuIndexArray; private List selectMenuIndexArray = new ArrayList<>(); @@ -196,7 +197,7 @@ public class AddInspectionActivity extends BaseActivity { + private class MemberAdapter extends BaseQuickAdapter { public MemberAdapter() { super(R.layout.item_select_member); } @Override - protected void convert(@NonNull BaseViewHolder holder, GridMemberEntity.MemberListEntity entity) { + protected void convert(@NonNull BaseViewHolder holder, MemberListEntity entity) { holder.setText(R.id.tvName, entity.getMemberName()); holder.addOnClickListener(R.id.btnDelete); } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/EditInspectionActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/EditInspectionActivity.java new file mode 100644 index 0000000..a21740f --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/EditInspectionActivity.java @@ -0,0 +1,276 @@ +package com.tairui.gov_affairs_cloud.ui.land; + +import java.util.ArrayList; +import java.util.List; + +import org.greenrobot.eventbus.EventBus; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.google.gson.JsonArray; +import com.kongzue.dialogx.dialogs.BottomMenu; +import com.kongzue.dialogx.dialogs.MessageDialog; +import com.kongzue.dialogx.dialogs.PopMenu; +import com.kongzue.dialogx.dialogs.PopTip; +import com.kongzue.dialogx.interfaces.OnMenuButtonClickListener; +import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener; +import com.kongzue.dialogx.util.ItemDivider; +import com.rxjava.rxlife.RxLife; +import com.tairui.gov_affairs_cloud.R; +import com.tairui.gov_affairs_cloud.base.BaseActivity; +import com.tairui.gov_affairs_cloud.databinding.ActivityEditInspectionBinding; +import com.tairui.gov_affairs_cloud.entity.Api; +import com.tairui.gov_affairs_cloud.entity.EventConstant; +import com.tairui.gov_affairs_cloud.entity.EventMessage; +import com.tairui.gov_affairs_cloud.http.OnError; +import com.tairui.gov_affairs_cloud.ui.land.entity.DictDataEntity; +import com.tairui.gov_affairs_cloud.ui.land.entity.GridMemberEntity; +import com.tairui.gov_affairs_cloud.ui.land.entity.InspectionListEntity; +import com.tairui.gov_affairs_cloud.ui.land.entity.MemberListEntity; +import com.tairui.gov_affairs_cloud.util.ArrayUtil; +import com.tairui.gov_affairs_cloud.util.DensityUtils; +import com.tairui.gov_affairs_cloud.util.SingleClickListener; + +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import rxhttp.RxHttp; +import rxhttp.RxHttpJsonParam; + +public class EditInspectionActivity extends BaseActivity { + + private List membersData; + private List selectMembersData; + private List multiSelectMenuText; + private int[] cacheSelectMenuIndexArray; + private List selectMenuIndexArray = new ArrayList<>(); + private MemberAdapter memberAdapter; + private List typeData; + private DictDataEntity selectType; + + private InspectionListEntity.RecordsEntity mData; + + @Override + protected Class getBindingClass() { + return ActivityEditInspectionBinding.class; + } + + @Override + protected void onQueryArguments() { + mData = (InspectionListEntity.RecordsEntity) getIntent().getSerializableExtra("data"); + } + + @Override + protected void onFindView(Bundle savedInstanceState) { + binding.inputTaskCode.setHint(mData.getTaskCode()); + binding.inputTaskName.setHint(mData.getTaskName()); + binding.tvType.setHint(mData.getInspectionType()); + binding.tvMembers.setHint(mData.getTaskMembers()); + binding.inputTaskTarget.setHint(mData.getInspectionTarget()); + binding.inputTaskNotes.setHint(mData.getNotes()); + binding.membersRecycler.setLayoutManager(new LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, true)); + binding.membersRecycler.setHasFixedSize(true); + memberAdapter = new MemberAdapter(); + binding.membersRecycler.setAdapter(memberAdapter); + setGone(binding.membersRecycler, false); + setGone(binding.tvMembers, true); + } + + @Override + protected void onBindListener() { + binding.btnBack.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + finish(); + } + }); + binding.btnAddMember.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + showMemeberDialog(); + } + }); + binding.layoutType.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + showTypeMenu(); + } + }); + binding.btnSubmit.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + MessageDialog.show("修改", "确定执行修改吗?", "确定", "取消") + .setOkButton((baseDialog, v1) -> { + checkSubmit(); + return false; + }); + } + }); + memberAdapter.setOnItemChildClickListener((baseQuickAdapter, view, i) -> { + if (view.getId() == R.id.btnDelete) { + memberAdapter.remove(i); + selectMenuIndexArray.remove(i); + } + }); + } + + @Override + protected void onApplyData() { + getMemberList(); + getInspectionTypeData(); + } + + private void showTypeMenu() { + List menus = new ArrayList<>(); + for (DictDataEntity item : typeData) { + menus.add(item.getDictLabel()); + } + PopMenu.show(binding.tvType, menus) + .setBackgroundColorRes(R.color.white) + .setWidth(DensityUtils.dp2px(mContext, 100)) + .setOnMenuItemClickListener((dialog, text, index) -> { + selectType = typeData.get(index); + setText(binding.tvType, selectType.getDictLabel()); + return false; + }).setItemDivider(new ItemDivider(15, 15, 1)); + } + + private void getInspectionTypeData() { + RxHttp.get(Api.INSPECTION_TYPE) + .asResponseList(DictDataEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + typeData = data; + }, (OnError) error -> showToast(error.getErrorMsg())); + } + + private void getMemberList() { + RxHttp.get(Api.GRID_MEMBER) + .asResponse(GridMemberEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + membersData = data.getMemberList(); + multiSelectMenuText = new ArrayList<>(); + for (int i = 0; i < membersData.size(); i++) { + multiSelectMenuText.add(membersData.get(i).getMemberName()); + } + }, (OnError) error -> showToast(error.getErrorMsg())); + } + + private void showMemeberDialog() { + BottomMenu.show(multiSelectMenuText).setTitle("请选择任务成员") + .setOnMenuItemClickListener(new OnMenuItemSelectListener() { + @Override + public void onMultiItemSelect(BottomMenu dialog, CharSequence[] text, int[] indexArray) { + cacheSelectMenuIndexArray = indexArray; + } + }).setOkButton("确定", (OnMenuButtonClickListener) (dialog, v) -> { + if (cacheSelectMenuIndexArray.length > 3) { + showError("最多允许选择3名任务成员"); + } else if (cacheSelectMenuIndexArray.length <= 0) { + showError("至少选择1名任务成员"); + } else { + selectMenuIndexArray.clear(); + selectMembersData = new ArrayList<>(); + for (int i : cacheSelectMenuIndexArray) { + selectMenuIndexArray.add(i); + selectMembersData.add(membersData.get(i)); + } + cacheSelectMenuIndexArray = new int[1]; + memberAdapter.setNewData(selectMembersData); + setGone(binding.membersRecycler, true); + setGone(binding.tvMembers, false); + } + return false; + }).setSelection(selectMenuIndexArray); + } + + private void checkSubmit() { + boolean hasChanged = false; + RxHttpJsonParam http = RxHttp.putJson(Api.INSPECTION_EDIT); + http.add("id", mData.getId()); + String taskCode = binding.inputTaskCode.getText().toString().trim(); + if (!TextUtils.isEmpty(taskCode)) { + hasChanged = true; + http.add("taskCode", taskCode); + } + String taskName = binding.inputTaskName.getText().toString().trim(); + if (!TextUtils.isEmpty(taskName)) { + hasChanged = true; + http.add("taskName", taskName); + } + if (selectMembersData != null) { + if (ArrayUtil.size(selectMembersData) <= 0) { + showError("任务成员不能为空"); + return; + } else { + JsonArray memeberIds = new JsonArray(); + for (MemberListEntity selectMembersDatum : selectMembersData) { + memeberIds.add(selectMembersDatum.getId()); + } + hasChanged = true; + http.add("taskUserIds", memeberIds); + } + } + if (selectType != null) { + hasChanged = true; + http.add("inspectionTypeCode", selectType.getDictValue()); + } + String taskTarget = binding.inputTaskTarget.getText().toString().trim(); + if (!TextUtils.isEmpty(taskTarget)) { + hasChanged = true; + http.add("inspectionTarget", taskTarget); + } + String taskNotes = binding.inputTaskNotes.getText().toString().trim(); + if (!TextUtils.isEmpty(taskNotes)) { + hasChanged = true; + http.add("notes", taskNotes); + } + + if (hasChanged) { + showLoading(); + http.asResponse(Boolean.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> doChangeStatus(), (OnError) error -> { + PopTip.show(error.getErrorMsg()).iconError(); + hideLoading(); + }); + } else { + finish(); + } + } + + private void doChangeStatus() { + RxHttp.putJson(Api.INSPECTION_EDIT_STATUS) + .add("status", "-1") + .add("id", mData.getId()) + .asResponse(Object.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + hideLoading(); + PopTip.show("土地巡查信息修改成功").iconSuccess(); + EventBus.getDefault().post(new EventMessage(EventConstant.REFRESH_LIST)); + binding.btnSubmit.postDelayed(() -> finish(), 1000); + }, (OnError) error -> { + hideLoading(); + showToast(error.getErrorMsg()); + }); + } + + private class MemberAdapter extends BaseQuickAdapter { + + public MemberAdapter() { + super(R.layout.item_select_member); + } + + @Override + protected void convert(@NonNull BaseViewHolder holder, MemberListEntity entity) { + holder.setText(R.id.tvName, entity.getMemberName()); + holder.addOnClickListener(R.id.btnDelete); + } + } + +} diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalDetailActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalDetailActivity.java new file mode 100644 index 0000000..373345d --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalDetailActivity.java @@ -0,0 +1,68 @@ +package com.tairui.gov_affairs_cloud.ui.land; + +import com.rxjava.rxlife.RxLife; +import com.tairui.gov_affairs_cloud.R; +import com.tairui.gov_affairs_cloud.base.BaseActivity; +import com.tairui.gov_affairs_cloud.databinding.ActivityIllegalDetailBinding; +import com.tairui.gov_affairs_cloud.entity.Api; +import com.tairui.gov_affairs_cloud.http.OnError; +import com.tairui.gov_affairs_cloud.ui.land.entity.IllegalDetailEntity; +import com.tairui.gov_affairs_cloud.util.AppUtil; +import com.tairui.gov_affairs_cloud.util.SingleClickListener; +import com.tairui.gov_affairs_cloud.util.glide.GlideLoader; + +import android.os.Bundle; +import android.view.View; +import rxhttp.RxHttp; + +public class IllegalDetailActivity extends BaseActivity { + + private IllegalDetailEntity mData; + private String illegalId; + + @Override + protected Class getBindingClass() { + return ActivityIllegalDetailBinding.class; + } + + @Override + protected void onQueryArguments() { + illegalId = getIntent().getStringExtra("id"); + } + + @Override + protected void onFindView(Bundle savedInstanceState) { + } + + @Override + protected void onBindListener() { + binding.btnBack.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + finish(); + } + }); + } + + @Override + protected void onApplyData() { + RxHttp.get(Api.ILLEGAL_DETAIL + illegalId) + .asResponse(IllegalDetailEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + mData = data; + initView(); + }, (OnError) error -> showToast(error.getErrorMsg())); + } + + private void initView() { + setText(binding.tvStatus, mData.getStatus().equals("0") ? "待处理" : "已处理"); + binding.tvStatus.setTextColor(getResColor(mData.getStatus().equals("0") ? R.color.color_txt_green : R.color.color_txt_orange)); + setText(binding.tvTitle, mData.getLandName()); + setText(binding.tvIsIllegal, mData.getIllegalFlag().equals("0") ? "否" : "是"); + setText(binding.tvTime, mData.getIllegalDate()); + setText(binding.tvAction, mData.getIllegalTypeName()); + setText(binding.inputDesc, mData.getDesc()); + GlideLoader.loadOriginal(binding.imgLand, AppUtil.getImageUrl(mData.getImg())); + } +} diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalListActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalListActivity.java new file mode 100644 index 0000000..b037f5d --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/IllegalListActivity.java @@ -0,0 +1,206 @@ +package com.tairui.gov_affairs_cloud.ui.land; + +import java.util.ArrayList; +import java.util.List; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.kongzue.dialogx.dialogs.PopMenu; +import com.kongzue.dialogx.util.ItemDivider; +import com.rxjava.rxlife.RxLife; +import com.tairui.gov_affairs_cloud.R; +import com.tairui.gov_affairs_cloud.base.BaseActivity; +import com.tairui.gov_affairs_cloud.databinding.ActivityIllegalListBinding; +import com.tairui.gov_affairs_cloud.entity.Api; +import com.tairui.gov_affairs_cloud.entity.EventConstant; +import com.tairui.gov_affairs_cloud.entity.EventMessage; +import com.tairui.gov_affairs_cloud.http.OnError; +import com.tairui.gov_affairs_cloud.ui.land.entity.IllegalListEntity; +import com.tairui.gov_affairs_cloud.ui.land.entity.IllegalListParentEntity; +import com.tairui.gov_affairs_cloud.util.ArrayUtil; +import com.tairui.gov_affairs_cloud.util.DensityUtils; +import com.tairui.gov_affairs_cloud.util.IntentUtil; +import com.tairui.gov_affairs_cloud.util.SingleClickListener; +import com.tairui.gov_affairs_cloud.util.ToastUtil; +import com.tairui.gov_affairs_cloud.widget.RefreshRecyclerView; + +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import rxhttp.RxHttp; +import rxhttp.RxHttpNoBodyParam; + +public class IllegalListActivity extends BaseActivity { + + private IllegalListAdapter mAdapter; + private int currentPageIndex = 1; + private int status = -1; + + @Override + protected Class getBindingClass() { + return ActivityIllegalListBinding.class; + } + + @Override + protected void onQueryArguments() { + EventBus.getDefault().register(this); + } + + @Override + protected void onFindView(Bundle savedInstanceState) { + binding.refreshRecycler.setLayoutManager(new LinearLayoutManager(mContext)); + mAdapter = new IllegalListAdapter(); + binding.refreshRecycler.setAdapter(mAdapter); + } + + @Override + protected void onBindListener() { + binding.btnBack.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + finish(); + } + }); + binding.refreshRecycler.setRefreshRecyclerListener(new RefreshRecyclerView.RefreshRecyclerListener() { + @Override + public void onRefresh() { + currentPageIndex = 1; + requestData(false); + } + + @Override + public void onLoadmore() { + requestData(true); + } + + @Override + public void onBlankClick() { + binding.refreshRecycler.showLoading(); + currentPageIndex = 1; + requestData(false); + } + }); + mAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { + IllegalListEntity item = mAdapter.getItem(i); + Bundle bundle = new Bundle(); + bundle.putString("id", item.getId()); + IntentUtil.startActivity(mContext, IllegalDetailActivity.class, bundle); + }); + binding.layoutType.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + showStatusMenu(); + } + }); + } + + @Override + protected void onApplyData() { + binding.refreshRecycler.showLoading(); + currentPageIndex = 1; + requestData(false); + } + + private void showStatusMenu() { + List menus = new ArrayList<>(); + menus.add("全部"); + menus.add("待处理"); + menus.add("已处理"); + PopMenu.show(binding.layoutType, menus) + .setBackgroundColorRes(R.color.white) + .setWidth(DensityUtils.dp2px(mContext, 100)) + .setOnMenuItemClickListener((dialog, text, index) -> { + status = index; + setText(binding.tvType, text.toString()); +// binding.refreshRecycler.showLoading(); +// currentPageIndex = 1; +// requestData(false); + return false; + }).setItemDivider(new ItemDivider(15, 15, 1)); + } + + private void requestData(boolean loadmore) { + RxHttpNoBodyParam http = RxHttp.get(Api.ILLEGAL_LIST); + if (status != -1) { + // http.add("inspectionTypeCode", selectType.getDictValue()); + } + http.add("current", currentPageIndex) + .add("size", Api.SIZE_PAGE) + .asResponse(IllegalListParentEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + if (loadmore) { + binding.refreshRecycler.finishLoadMore(); + } + if (!ArrayUtil.isEmpty(data.getRecords())) { + if (loadmore) { + mAdapter.addData(data.getRecords()); + } else { + mAdapter.setNewData(data.getRecords()); + } + currentPageIndex += 1; + if (ArrayUtil.size(data.getRecords()) < Api.SIZE_PAGE) { + binding.refreshRecycler.setNoMoreData(true); + } else { + binding.refreshRecycler.setNoMoreData(false); + } + binding.refreshRecycler.showContent(); + } else { + binding.refreshRecycler.showError(); + binding.refreshRecycler.setNoMoreData(true); + } + }, (OnError) error -> { + binding.refreshRecycler.showError(); + binding.refreshRecycler.setNoMoreData(true); + ToastUtil.showLongToast(error.getErrorMsg()); + }); + } + + private class IllegalListAdapter extends BaseQuickAdapter { + + public IllegalListAdapter() { + super(R.layout.item_illegal_2); + } + + @Override + protected void convert(@NonNull BaseViewHolder holder, IllegalListEntity entity) { + holder.setText(R.id.tvLandName,entity.getLandName()); + holder.setText(R.id.tvIllegalType,entity.getIllegalTypeName()); + holder.setText(R.id.tvDate,entity.getIllegalDate()); + + if (entity.getStatus().equals("0")) { + holder.setText(R.id.tvStatus, "待处理"); + holder.setBackgroundRes(R.id.tvStatus, R.drawable.bg_container_light_green_raduis_2); + holder.setTextColor(R.id.tvStatus, getResColor(R.color.color_txt_green)); + } else { + holder.setText(R.id.tvStatus, "已处理"); + holder.setBackgroundRes(R.id.tvStatus, R.drawable.bg_container_light_orange_raduis_2); + holder.setTextColor(R.id.tvStatus, getResColor(R.color.color_txt_orange)); + } + + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onMessageReceive(EventMessage message) { + if (null != message && !TextUtils.isEmpty(message.getLabel())) { + if (EventConstant.REFRESH_LIST.equals(message.getLabel())) { + binding.refreshRecycler.showLoading(); + currentPageIndex = 1; + requestData(false); + } + } + } + + @Override + protected void onDestroy() { + EventBus.getDefault().unregister(this); + super.onDestroy(); + } +} diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionDetailActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionDetailActivity.java index 35f3a32..06fbf2e 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionDetailActivity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionDetailActivity.java @@ -1,17 +1,35 @@ package com.tairui.gov_affairs_cloud.ui.land; +import org.greenrobot.eventbus.EventBus; + +import com.kongzue.dialogx.dialogs.MessageDialog; +import com.rxjava.rxlife.RxLife; import com.tairui.gov_affairs_cloud.R; import com.tairui.gov_affairs_cloud.base.BaseActivity; +import com.tairui.gov_affairs_cloud.config.AppConfig; import com.tairui.gov_affairs_cloud.databinding.ActivityInspectionDetailBinding; +import com.tairui.gov_affairs_cloud.entity.Api; +import com.tairui.gov_affairs_cloud.entity.EventConstant; +import com.tairui.gov_affairs_cloud.entity.EventMessage; +import com.tairui.gov_affairs_cloud.http.OnError; +import com.tairui.gov_affairs_cloud.ui.land.adapter.IllegalListAdapter; import com.tairui.gov_affairs_cloud.ui.land.entity.InspectionListEntity; +import com.tairui.gov_affairs_cloud.ui.my.entity.UserInfoEntity; +import com.tairui.gov_affairs_cloud.util.ArrayUtil; +import com.tairui.gov_affairs_cloud.util.IntentUtil; import com.tairui.gov_affairs_cloud.util.SingleClickListener; import android.os.Bundle; import android.view.View; +import androidx.recyclerview.widget.LinearLayoutManager; +import rxhttp.RxHttp; public class InspectionDetailActivity extends BaseActivity { private InspectionListEntity.RecordsEntity mData; + private String mId; + private UserInfoEntity userInfo; + private IllegalListAdapter illegalListAdapter; @Override protected Class getBindingClass() { @@ -20,11 +38,38 @@ public class InspectionDetailActivity extends BaseActivity { + Bundle bundle = new Bundle(); + bundle.putString("id", illegalListAdapter.getData().get(i).getId()); + IntentUtil.startActivity(mContext, IllegalDetailActivity.class, bundle); + }); + } + + @Override + protected void onApplyData() { + RxHttp.get(Api.INSPECTION_DETAIL + mId) + .asResponse(InspectionListEntity.RecordsEntity.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + mData = data; + initView(); + }, (OnError) error -> { + hideLoading(); + showToast(error.getErrorMsg()); + }); + } + + private void initView() { setText(binding.tvTaskStatus, mData.getInspectionStatusName()); setText(binding.tvTaskCode, mData.getTaskCode()); setText(binding.tvTaskName, mData.getTaskName()); @@ -32,14 +77,41 @@ public class InspectionDetailActivity extends BaseActivity { + doUndo(); + return false; + }); + } + }); + binding.btnEdit.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + Bundle bundle = new Bundle(); + bundle.putSerializable("data", mData); + IntentUtil.startActivity(mContext, EditInspectionActivity.class, bundle); + finish(); + } + }); + binding.btnPublish.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + noticePublish(); + } + }); + binding.btnRePublish.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + noticePublish(); + } + }); + binding.btnRegisty.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + Bundle bundle = new Bundle(); + bundle.putSerializable("id", mData.getId()); + IntentUtil.startActivity(mContext, AddIllegalInformationActivity.class, bundle); + finish(); + } + }); + binding.btnSubmit.setOnClickListener(new SingleClickListener() { + @Override + protected void onSingleClick(View v) { + MessageDialog.show("完成", "确定要结束当前任务吗?", "确定", "取消") + .setOkButton((baseDialog, v1) -> { + doFinish(); + return false; + }); + } + }); + + } + + private void noticePublish() { + MessageDialog.show("发布", "确定要发布当前任务吗?", "确定", "取消") + .setOkButton((baseDialog, v1) -> { + doPublish(); + return false; + }); + } + + private void doUndo() { + showLoading(); + RxHttp.putJson(Api.INSPECTION_EDIT_STATUS) + .add("status", "02") + .add("id", mData.getId()) + .asResponse(Object.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + hideLoading(); + mData.setInspectionStatusName("已撤销"); + mData.setInspectionStatus("02"); + initView(); + EventBus.getDefault().post(new EventMessage(EventConstant.REFRESH_LIST)); + }, (OnError) error -> { + hideLoading(); + showToast(error.getErrorMsg()); + }); + } + + private void doFinish() { + showLoading(); + RxHttp.putJson(Api.INSPECTION_EDIT_STATUS) + .add("status", "01") + .add("id", mData.getId()) + .asResponse(Object.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + hideLoading(); + mData.setInspectionStatusName("已结束"); + mData.setInspectionStatus("01"); + initView(); + EventBus.getDefault().post(new EventMessage(EventConstant.REFRESH_LIST)); + }, (OnError) error -> { + hideLoading(); + showToast(error.getErrorMsg()); + }); + } + + private void doPublish() { + showLoading(); + RxHttp.putJson(Api.INSPECTION_EDIT_STATUS) + .add("status", "00") + .add("id", mData.getId()) + .asResponse(Object.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + hideLoading(); + mData.setInspectionStatusName("已发布"); + mData.setInspectionStatus("00"); + initView(); + EventBus.getDefault().post(new EventMessage(EventConstant.REFRESH_LIST)); + }, (OnError) error -> { + hideLoading(); + showToast(error.getErrorMsg()); + }); } } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionListActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionListActivity.java index cfa2656..d22251e 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionListActivity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/InspectionListActivity.java @@ -7,28 +7,21 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import com.bigkoo.pickerview.builder.OptionsPickerBuilder; -import com.bigkoo.pickerview.view.OptionsPickerView; import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseViewHolder; -import com.kongzue.dialogx.dialogs.MessageDialog; import com.kongzue.dialogx.dialogs.PopMenu; import com.kongzue.dialogx.util.ItemDivider; -import com.orhanobut.hawk.Hawk; import com.rxjava.rxlife.RxLife; import com.tairui.gov_affairs_cloud.R; import com.tairui.gov_affairs_cloud.base.BaseActivity; import com.tairui.gov_affairs_cloud.config.AppConfig; import com.tairui.gov_affairs_cloud.databinding.ActivityInspectionListBinding; import com.tairui.gov_affairs_cloud.entity.Api; -import com.tairui.gov_affairs_cloud.entity.Constant; import com.tairui.gov_affairs_cloud.entity.EventConstant; import com.tairui.gov_affairs_cloud.entity.EventMessage; import com.tairui.gov_affairs_cloud.http.OnError; import com.tairui.gov_affairs_cloud.ui.land.entity.DictDataEntity; import com.tairui.gov_affairs_cloud.ui.land.entity.InspectionListEntity; -import com.tairui.gov_affairs_cloud.ui.land.entity.LandAreaRegionEntity; -import com.tairui.gov_affairs_cloud.ui.land.entity.LandGridEntity; import com.tairui.gov_affairs_cloud.ui.my.entity.UserInfoEntity; import com.tairui.gov_affairs_cloud.util.ArrayUtil; import com.tairui.gov_affairs_cloud.util.DensityUtils; @@ -37,7 +30,6 @@ import com.tairui.gov_affairs_cloud.util.SingleClickListener; import com.tairui.gov_affairs_cloud.util.ToastUtil; import com.tairui.gov_affairs_cloud.widget.RefreshRecyclerView; -import android.graphics.Color; import android.os.Bundle; import android.text.TextUtils; import android.view.View; @@ -48,20 +40,11 @@ import rxhttp.RxHttpNoBodyParam; public class InspectionListActivity extends BaseActivity { - private LandAreaRegionEntity selectRegion; - private LandGridEntity.RecordsEntity selectGrid; private DictDataEntity selectType; - - private List landAreaRegionData; - private LandGridEntity landGridData; - - private OptionsPickerView landRegionPickerView; - private OptionsPickerView landGridPickerView; - private InspectionListAdapter mAdapter; private int currentPageIndex = 1; - private List typeData; + private UserInfoEntity userInfo; @Override protected Class getBindingClass() { @@ -71,12 +54,7 @@ public class InspectionListActivity extends BaseActivity { InspectionListEntity.RecordsEntity item = mAdapter.getItem(i); Bundle bundle = new Bundle(); - bundle.putSerializable("data", item); + bundle.putString("id", item.getId()); IntentUtil.startActivity(mContext, InspectionDetailActivity.class, bundle); }); binding.layoutType.setOnClickListener(new SingleClickListener() { @@ -145,36 +115,9 @@ public class InspectionListActivity extends BaseActivity { - landAreaRegionData = data; - if (selectRegion == null || selectGrid == null) { - showRegionNoticeMsg(); - } - }, (OnError) error -> showToast(error.getErrorMsg())); - } - - private void showRegionNoticeMsg() { - MessageDialog.show("选择区域", "请先选择网格区域信息", "确定", "取消") - .setOkButton((baseDialog, v1) -> { - showRegionDialog(); - return false; - }).setCancelButton((dialog, v) -> { - finish(); - return false; - }); + binding.refreshRecycler.showLoading(); + currentPageIndex = 1; + requestData(false); } private void getInspectionTypeData() { @@ -207,84 +150,6 @@ public class InspectionListActivity extends BaseActivity { - hideLoading(); - if (ArrayUtil.isEmpty(data.getRecords())) { - showToast("当前区域下没有网格,请重新选择"); - binding.layoutRegion.postDelayed(() -> showRegionDialog(), 500); - } else { - landGridData = data; - showLandGridDialog(); - } - }, (OnError) error -> showToast(error.getErrorMsg())); - } - - private void showRegionDialog() { - if (landRegionPickerView == null) { - List> subLandData = new ArrayList<>(); - for (LandAreaRegionEntity itemData : landAreaRegionData.get(0).getAreaChildVOS()) { - subLandData.add(itemData.getAreaChildVOS()); - } - - landRegionPickerView = new OptionsPickerBuilder(this, (options1, options2, options3, v) -> { - selectRegion = landAreaRegionData.get(0).getAreaChildVOS().get(options1).getAreaChildVOS().get(options2); - Hawk.put(Constant.SELECT_REGION, selectRegion); - selectGrid = null; - Hawk.delete(Constant.SELECT_GRID); - getGridData(); - }).setTitleText("土地区域选择").setContentTextSize(20) - .setSelectOptions(0, 0) - .setTitleBgColor(Color.WHITE) - .isRestoreItem(true) - .isCenterLabel(false) - .setOutSideColor(0x00000000) //设置外部遮罩颜色 - .addOnCancelClickListener(view -> finish()) - .build(); - - landRegionPickerView.setPicker(landAreaRegionData.get(0).getAreaChildVOS(), subLandData);//二级选择器 - } - landRegionPickerView.show(); - } - - private void showGridNoticeMsg() { - MessageDialog.show("选择网格", "不继续选择网格信息了吗?", "确定", "取消") - .setOkButton((baseDialog, v1) -> { - finish(); - return false; - }); - } - - private void showLandGridDialog() { - if (landGridPickerView == null) { - landGridPickerView = new OptionsPickerBuilder(this, (options1, options2, options3, v) -> { - selectGrid = landGridData.getRecords().get(options1); - Hawk.put(Constant.SELECT_GRID, selectGrid); - setText(binding.tvRegion, selectRegion.getAreaName() + "-" + selectGrid.getGridName()); - binding.refreshRecycler.showLoading(); - currentPageIndex = 1; - requestData(false); - }).setTitleText("土地网格选择").setContentTextSize(20) - .setSelectOptions(0) - .setTitleBgColor(Color.WHITE) - .isRestoreItem(true) - .isCenterLabel(false) - .setOutSideColor(0x00000000) - .addOnCancelClickListener(view -> { - if (selectGrid == null) { - showGridNoticeMsg(); - } - }).build(); - - landGridPickerView.setPicker(landGridData.getRecords()); - } - landGridPickerView.show(); - } - private void requestData(boolean loadmore) { UserInfoEntity userInfo = AppConfig.getInstance().getUserInfo(); RxHttpNoBodyParam http; @@ -296,7 +161,7 @@ public class InspectionListActivity extends BaseActivity { + + public IllegalListAdapter() { + super(R.layout.item_illegal); + } + + @Override + protected void convert(@NonNull BaseViewHolder holder, IllegalListEntity entity) { + ImageView img = holder.getView(R.id.img); + GlideLoader.loadOriginal(img, AppUtil.getImageUrl(entity.getImg())); + holder.setText(R.id.tvLandName, entity.getLandName()); + holder.setText(R.id.tvIllegalType, entity.getIllegalTypeName()); + holder.setText(R.id.tvIllegalTag, entity.getIllegalFlag().equals("0") ? "未违法" : "违法"); + holder.setTextColor(R.id.tvIllegalTag, + entity.getIllegalFlag().equals("0") ? mContext.getResources().getColor(R.color.color_txt_green) + : mContext.getResources().getColor(R.color.color_txt_red)); + } + +} + diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/DictDataEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/DictDataEntity.java index 94c47f9..9d69645 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/DictDataEntity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/DictDataEntity.java @@ -1,8 +1,9 @@ package com.tairui.gov_affairs_cloud.ui.land.entity; +import com.contrarywind.interfaces.IPickerViewData; import com.google.gson.annotations.SerializedName; -public class DictDataEntity { +public class DictDataEntity implements IPickerViewData { @SerializedName("createBy") private String createBy; @@ -94,4 +95,9 @@ public class DictDataEntity { public void setStatus(String status) { this.status = status; } + + @Override + public String getPickerViewText() { + return dictLabel; + } } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/GridMemberEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/GridMemberEntity.java index 86fe699..1b1a673 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/GridMemberEntity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/GridMemberEntity.java @@ -1,10 +1,11 @@ package com.tairui.gov_affairs_cloud.ui.land.entity; +import java.io.Serializable; import java.util.List; import com.google.gson.annotations.SerializedName; -public class GridMemberEntity { +public class GridMemberEntity implements Serializable { @SerializedName("gridMemberInfo") private Object gridMemberInfo; @@ -37,98 +38,6 @@ public class GridMemberEntity { this.landList = landList; } - public static class MemberListEntity { - @SerializedName("gridId") - private String gridId; - @SerializedName("memberName") - private String memberName; - @SerializedName("adminFlag") - private String adminFlag; - @SerializedName("phone") - private String phone; - @SerializedName("id") - private String id; - @SerializedName("status") - private String status; - @SerializedName("gridName") - private Object gridName; - @SerializedName("gridAreaName") - private Object gridAreaName; - @SerializedName("gridAreaCode") - private Object gridAreaCode; - - public String getGridId() { - return gridId; - } - - public void setGridId(String gridId) { - this.gridId = gridId; - } - - public String getMemberName() { - return memberName; - } - - public void setMemberName(String memberName) { - this.memberName = memberName; - } - - public String getAdminFlag() { - return adminFlag; - } - - public void setAdminFlag(String adminFlag) { - this.adminFlag = adminFlag; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Object getGridName() { - return gridName; - } - - public void setGridName(Object gridName) { - this.gridName = gridName; - } - - public Object getGridAreaName() { - return gridAreaName; - } - - public void setGridAreaName(Object gridAreaName) { - this.gridAreaName = gridAreaName; - } - - public Object getGridAreaCode() { - return gridAreaCode; - } - - public void setGridAreaCode(Object gridAreaCode) { - this.gridAreaCode = gridAreaCode; - } - } public static class LandListEntity { @SerializedName("id") diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalDetailEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalDetailEntity.java new file mode 100644 index 0000000..8e56341 --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalDetailEntity.java @@ -0,0 +1,127 @@ +package com.tairui.gov_affairs_cloud.ui.land.entity; + +import com.google.gson.annotations.SerializedName; + +public class IllegalDetailEntity { + + @SerializedName("inspectionId") + private String inspectionId; + @SerializedName("landId") + private String landId; + @SerializedName("illegalFlag") + private String illegalFlag; + @SerializedName("illegalDate") + private String illegalDate; + @SerializedName("illegalTypeCode") + private String illegalTypeCode; + @SerializedName("desc") + private String desc; + @SerializedName("img") + private String img; + @SerializedName("id") + private String id; + @SerializedName("landName") + private String landName; + @SerializedName("illegalTypeName") + private String illegalTypeName; + @SerializedName("inspectionTaskName") + private String inspectionTaskName; + @SerializedName("status") + private String status; + + public String getInspectionId() { + return inspectionId; + } + + public void setInspectionId(String inspectionId) { + this.inspectionId = inspectionId; + } + + public String getLandId() { + return landId; + } + + public void setLandId(String landId) { + this.landId = landId; + } + + public String getIllegalFlag() { + return illegalFlag; + } + + public void setIllegalFlag(String illegalFlag) { + this.illegalFlag = illegalFlag; + } + + public String getIllegalDate() { + return illegalDate; + } + + public void setIllegalDate(String illegalDate) { + this.illegalDate = illegalDate; + } + + public String getIllegalTypeCode() { + return illegalTypeCode; + } + + public void setIllegalTypeCode(String illegalTypeCode) { + this.illegalTypeCode = illegalTypeCode; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLandName() { + return landName; + } + + public void setLandName(String landName) { + this.landName = landName; + } + + public String getIllegalTypeName() { + return illegalTypeName; + } + + public void setIllegalTypeName(String illegalTypeName) { + this.illegalTypeName = illegalTypeName; + } + + public String getInspectionTaskName() { + return inspectionTaskName; + } + + public void setInspectionTaskName(String inspectionTaskName) { + this.inspectionTaskName = inspectionTaskName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListEntity.java new file mode 100644 index 0000000..2e8c1dc --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListEntity.java @@ -0,0 +1,129 @@ +package com.tairui.gov_affairs_cloud.ui.land.entity; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class IllegalListEntity implements Serializable { + + @SerializedName("inspectionId") + private String inspectionId; + @SerializedName("landId") + private String landId; + @SerializedName("illegalFlag") + private String illegalFlag; + @SerializedName("illegalDate") + private String illegalDate; + @SerializedName("illegalTypeCode") + private String illegalTypeCode; + @SerializedName("desc") + private String desc; + @SerializedName("img") + private String img; + @SerializedName("id") + private String id; + @SerializedName("landName") + private String landName; + @SerializedName("illegalTypeName") + private String illegalTypeName; + @SerializedName("inspectionTaskName") + private String inspectionTaskName; + @SerializedName("status") + private String status; + + public String getInspectionId() { + return inspectionId; + } + + public void setInspectionId(String inspectionId) { + this.inspectionId = inspectionId; + } + + public String getLandId() { + return landId; + } + + public void setLandId(String landId) { + this.landId = landId; + } + + public String getIllegalFlag() { + return illegalFlag; + } + + public void setIllegalFlag(String illegalFlag) { + this.illegalFlag = illegalFlag; + } + + public String getIllegalDate() { + return illegalDate; + } + + public void setIllegalDate(String illegalDate) { + this.illegalDate = illegalDate; + } + + public String getIllegalTypeCode() { + return illegalTypeCode; + } + + public void setIllegalTypeCode(String illegalTypeCode) { + this.illegalTypeCode = illegalTypeCode; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLandName() { + return landName; + } + + public void setLandName(String landName) { + this.landName = landName; + } + + public String getIllegalTypeName() { + return illegalTypeName; + } + + public void setIllegalTypeName(String illegalTypeName) { + this.illegalTypeName = illegalTypeName; + } + + public String getInspectionTaskName() { + return inspectionTaskName; + } + + public void setInspectionTaskName(String inspectionTaskName) { + this.inspectionTaskName = inspectionTaskName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListParentEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListParentEntity.java new file mode 100644 index 0000000..9209502 --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/IllegalListParentEntity.java @@ -0,0 +1,101 @@ +package com.tairui.gov_affairs_cloud.ui.land.entity; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class IllegalListParentEntity implements Serializable { + + @SerializedName("total") + private Integer total; + @SerializedName("size") + private Integer size; + @SerializedName("current") + private Integer current; + @SerializedName("optimizeCountSql") + private Boolean optimizeCountSql; + @SerializedName("searchCount") + private Boolean searchCount; + @SerializedName("maxLimit") + private Object maxLimit; + @SerializedName("countId") + private Object countId; + @SerializedName("pages") + private Integer pages; + @SerializedName("records") + private List records; + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public Integer getCurrent() { + return current; + } + + public void setCurrent(Integer current) { + this.current = current; + } + + public Boolean isOptimizeCountSql() { + return optimizeCountSql; + } + + public void setOptimizeCountSql(Boolean optimizeCountSql) { + this.optimizeCountSql = optimizeCountSql; + } + + public Boolean isSearchCount() { + return searchCount; + } + + public void setSearchCount(Boolean searchCount) { + this.searchCount = searchCount; + } + + public Object getMaxLimit() { + return maxLimit; + } + + public void setMaxLimit(Object maxLimit) { + this.maxLimit = maxLimit; + } + + public Object getCountId() { + return countId; + } + + public void setCountId(Object countId) { + this.countId = countId; + } + + public Integer getPages() { + return pages; + } + + public void setPages(Integer pages) { + this.pages = pages; + } + + public List getRecords() { + return records; + } + + public void setRecords(List records) { + this.records = records; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/InspectionListEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/InspectionListEntity.java index d8c7c3a..2cdb24b 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/InspectionListEntity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/InspectionListEntity.java @@ -7,340 +7,350 @@ import com.google.gson.annotations.SerializedName; public class InspectionListEntity { - @SerializedName("total") - private Integer total; - @SerializedName("size") - private Integer size; - @SerializedName("current") - private Integer current; - @SerializedName("optimizeCountSql") - private Boolean optimizeCountSql; - @SerializedName("searchCount") - private Boolean searchCount; - @SerializedName("maxLimit") - private Object maxLimit; - @SerializedName("countId") - private Object countId; - @SerializedName("pages") - private Integer pages; - @SerializedName("records") - private List records; - @SerializedName("orders") - private List orders; + @SerializedName("total") + private Integer total; + @SerializedName("size") + private Integer size; + @SerializedName("current") + private Integer current; + @SerializedName("optimizeCountSql") + private Boolean optimizeCountSql; + @SerializedName("searchCount") + private Boolean searchCount; + @SerializedName("maxLimit") + private Object maxLimit; + @SerializedName("countId") + private Object countId; + @SerializedName("pages") + private Integer pages; + @SerializedName("records") + private List records; + @SerializedName("orders") + private List orders; - public Integer getTotal() { - return total; - } + public Integer getTotal() { + return total; + } - public void setTotal(Integer total) { - this.total = total; - } + public void setTotal(Integer total) { + this.total = total; + } - public Integer getSize() { - return size; - } + public Integer getSize() { + return size; + } - public void setSize(Integer size) { - this.size = size; - } + public void setSize(Integer size) { + this.size = size; + } - public Integer getCurrent() { - return current; - } + public Integer getCurrent() { + return current; + } - public void setCurrent(Integer current) { - this.current = current; - } + public void setCurrent(Integer current) { + this.current = current; + } - public Boolean isOptimizeCountSql() { - return optimizeCountSql; - } + public Boolean isOptimizeCountSql() { + return optimizeCountSql; + } - public void setOptimizeCountSql(Boolean optimizeCountSql) { - this.optimizeCountSql = optimizeCountSql; - } + public void setOptimizeCountSql(Boolean optimizeCountSql) { + this.optimizeCountSql = optimizeCountSql; + } - public Boolean isSearchCount() { - return searchCount; - } + public Boolean isSearchCount() { + return searchCount; + } - public void setSearchCount(Boolean searchCount) { - this.searchCount = searchCount; - } + public void setSearchCount(Boolean searchCount) { + this.searchCount = searchCount; + } - public Object getMaxLimit() { - return maxLimit; - } + public Object getMaxLimit() { + return maxLimit; + } - public void setMaxLimit(Object maxLimit) { - this.maxLimit = maxLimit; - } + public void setMaxLimit(Object maxLimit) { + this.maxLimit = maxLimit; + } - public Object getCountId() { - return countId; - } + public Object getCountId() { + return countId; + } - public void setCountId(Object countId) { - this.countId = countId; - } + public void setCountId(Object countId) { + this.countId = countId; + } - public Integer getPages() { - return pages; - } + public Integer getPages() { + return pages; + } - public void setPages(Integer pages) { - this.pages = pages; - } + public void setPages(Integer pages) { + this.pages = pages; + } - public List getRecords() { - return records; - } + public List getRecords() { + return records; + } - public void setRecords(List records) { - this.records = records; - } + public void setRecords(List records) { + this.records = records; + } - public List getOrders() { - return orders; - } + public List getOrders() { + return orders; + } - public void setOrders(List orders) { - this.orders = orders; - } + public void setOrders(List orders) { + this.orders = orders; + } - public static class RecordsEntity implements Serializable { - @SerializedName("id") - private String id; - @SerializedName("taskCode") - private String taskCode; - @SerializedName("taskName") - private String taskName; - @SerializedName("taskMembers") - private String taskMembers; - @SerializedName("inspectionTypeCode") - private String inspectionTypeCode; - @SerializedName("inspectionType") - private String inspectionType; - @SerializedName("notes") - private String notes; - @SerializedName("inspectionTarget") - private String inspectionTarget; - @SerializedName("isIllegal") - private Object isIllegal; - @SerializedName("inspectionStatus") - private String inspectionStatus; - @SerializedName("inspectionStatusName") - private String inspectionStatusName; - @SerializedName("inspectionSituation") - private Object inspectionSituation; - @SerializedName("inspectionUsers") - private List inspectionUsers; + public static class RecordsEntity implements Serializable { + @SerializedName("id") + private String id; + @SerializedName("taskCode") + private String taskCode; + @SerializedName("taskName") + private String taskName; + @SerializedName("taskMembers") + private String taskMembers; + @SerializedName("inspectionTypeCode") + private String inspectionTypeCode; + @SerializedName("inspectionType") + private String inspectionType; + @SerializedName("notes") + private String notes; + @SerializedName("inspectionTarget") + private String inspectionTarget; + @SerializedName("isIllegal") + private Object isIllegal; + @SerializedName("inspectionStatus") + private String inspectionStatus; + @SerializedName("inspectionStatusName") + private String inspectionStatusName; + @SerializedName("inspectionSituation") + private Object inspectionSituation; + @SerializedName("inspectionUsers") + private List inspectionUsers; + @SerializedName("inspectionResults") + private List inspectionResults; - public String getId() { - return id; - } + public List getInspectionResults() { + return inspectionResults; + } - public void setId(String id) { - this.id = id; - } + public void setInspectionResults(List inspectionResults) { + this.inspectionResults = inspectionResults; + } - public String getTaskCode() { - return taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getTaskName() { - return taskName; - } - - public void setTaskName(String taskName) { - this.taskName = taskName; - } - - public String getTaskMembers() { - return taskMembers; - } - - public void setTaskMembers(String taskMembers) { - this.taskMembers = taskMembers; - } - - public String getInspectionTypeCode() { - return inspectionTypeCode; - } - - public void setInspectionTypeCode(String inspectionTypeCode) { - this.inspectionTypeCode = inspectionTypeCode; - } - - public String getInspectionType() { - return inspectionType; - } - - public void setInspectionType(String inspectionType) { - this.inspectionType = inspectionType; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public String getInspectionTarget() { - return inspectionTarget; - } - - public void setInspectionTarget(String inspectionTarget) { - this.inspectionTarget = inspectionTarget; - } - - public Object getIsIllegal() { - return isIllegal; - } - - public void setIsIllegal(Object isIllegal) { - this.isIllegal = isIllegal; - } - - public String getInspectionStatus() { - return inspectionStatus; - } - - public void setInspectionStatus(String inspectionStatus) { - this.inspectionStatus = inspectionStatus; - } - - public String getInspectionStatusName() { - return inspectionStatusName; - } - - public void setInspectionStatusName(String inspectionStatusName) { - this.inspectionStatusName = inspectionStatusName; - } - - public Object getInspectionSituation() { - return inspectionSituation; - } - - public void setInspectionSituation(Object inspectionSituation) { - this.inspectionSituation = inspectionSituation; - } - - public List getInspectionUsers() { - return inspectionUsers; - } - - public void setInspectionUsers(List inspectionUsers) { - this.inspectionUsers = inspectionUsers; - } - - public static class InspectionUsersEntity implements Serializable{ - @SerializedName("createTime") - private String createTime; - @SerializedName("createUser") - private String createUser; - @SerializedName("updateTime") - private Object updateTime; - @SerializedName("updateUser") - private Object updateUser; - @SerializedName("tenantId") - private Integer tenantId; - @SerializedName("id") - private Long id; - @SerializedName("inspectionId") - private Long inspectionId; - @SerializedName("userId") - private Long userId; - @SerializedName("userName") - private String userName; - @SerializedName("deleteFlag") - private String deleteFlag; - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getCreateUser() { - return createUser; - } - - public void setCreateUser(String createUser) { - this.createUser = createUser; - } - - public Object getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Object updateTime) { - this.updateTime = updateTime; - } - - public Object getUpdateUser() { - return updateUser; - } - - public void setUpdateUser(Object updateUser) { - this.updateUser = updateUser; - } - - public Integer getTenantId() { - return tenantId; - } - - public void setTenantId(Integer tenantId) { - this.tenantId = tenantId; - } - - public Long getId() { + public String getId() { return id; - } + } - public void setId(Long id) { + public void setId(String id) { this.id = id; - } + } - public Long getInspectionId() { - return inspectionId; - } + public String getTaskCode() { + return taskCode; + } - public void setInspectionId(Long inspectionId) { - this.inspectionId = inspectionId; - } + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } - public Long getUserId() { - return userId; - } + public String getTaskName() { + return taskName; + } - public void setUserId(Long userId) { - this.userId = userId; - } + public void setTaskName(String taskName) { + this.taskName = taskName; + } - public String getUserName() { - return userName; - } + public String getTaskMembers() { + return taskMembers; + } - public void setUserName(String userName) { - this.userName = userName; - } + public void setTaskMembers(String taskMembers) { + this.taskMembers = taskMembers; + } - public String getDeleteFlag() { - return deleteFlag; - } + public String getInspectionTypeCode() { + return inspectionTypeCode; + } - public void setDeleteFlag(String deleteFlag) { - this.deleteFlag = deleteFlag; - } - } - } + public void setInspectionTypeCode(String inspectionTypeCode) { + this.inspectionTypeCode = inspectionTypeCode; + } + + public String getInspectionType() { + return inspectionType; + } + + public void setInspectionType(String inspectionType) { + this.inspectionType = inspectionType; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public String getInspectionTarget() { + return inspectionTarget; + } + + public void setInspectionTarget(String inspectionTarget) { + this.inspectionTarget = inspectionTarget; + } + + public Object getIsIllegal() { + return isIllegal; + } + + public void setIsIllegal(Object isIllegal) { + this.isIllegal = isIllegal; + } + + public String getInspectionStatus() { + return inspectionStatus; + } + + public void setInspectionStatus(String inspectionStatus) { + this.inspectionStatus = inspectionStatus; + } + + public String getInspectionStatusName() { + return inspectionStatusName; + } + + public void setInspectionStatusName(String inspectionStatusName) { + this.inspectionStatusName = inspectionStatusName; + } + + public Object getInspectionSituation() { + return inspectionSituation; + } + + public void setInspectionSituation(Object inspectionSituation) { + this.inspectionSituation = inspectionSituation; + } + + public List getInspectionUsers() { + return inspectionUsers; + } + + public void setInspectionUsers(List inspectionUsers) { + this.inspectionUsers = inspectionUsers; + } + + public static class InspectionUsersEntity implements Serializable { + @SerializedName("createTime") + private String createTime; + @SerializedName("createUser") + private String createUser; + @SerializedName("updateTime") + private Object updateTime; + @SerializedName("updateUser") + private Object updateUser; + @SerializedName("tenantId") + private Integer tenantId; + @SerializedName("id") + private Long id; + @SerializedName("inspectionId") + private Long inspectionId; + @SerializedName("userId") + private Long userId; + @SerializedName("userName") + private String userName; + @SerializedName("deleteFlag") + private String deleteFlag; + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Object getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Object updateTime) { + this.updateTime = updateTime; + } + + public Object getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(Object updateUser) { + this.updateUser = updateUser; + } + + public Integer getTenantId() { + return tenantId; + } + + public void setTenantId(Integer tenantId) { + this.tenantId = tenantId; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getInspectionId() { + return inspectionId; + } + + public void setInspectionId(Long inspectionId) { + this.inspectionId = inspectionId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getDeleteFlag() { + return deleteFlag; + } + + public void setDeleteFlag(String deleteFlag) { + this.deleteFlag = deleteFlag; + } + } + } } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/MemberListEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/MemberListEntity.java new file mode 100644 index 0000000..5ead7c1 --- /dev/null +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/land/entity/MemberListEntity.java @@ -0,0 +1,98 @@ +package com.tairui.gov_affairs_cloud.ui.land.entity; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class MemberListEntity implements Serializable { + @SerializedName("gridId") + private String gridId; + @SerializedName("memberName") + private String memberName; + @SerializedName("adminFlag") + private String adminFlag; + @SerializedName("phone") + private String phone; + @SerializedName("id") + private String id; + @SerializedName("status") + private String status; + @SerializedName("gridName") + private Object gridName; + @SerializedName("gridAreaName") + private Object gridAreaName; + @SerializedName("gridAreaCode") + private Object gridAreaCode; + + public String getGridId() { + return gridId; + } + + public void setGridId(String gridId) { + this.gridId = gridId; + } + + public String getMemberName() { + return memberName; + } + + public void setMemberName(String memberName) { + this.memberName = memberName; + } + + public String getAdminFlag() { + return adminFlag; + } + + public void setAdminFlag(String adminFlag) { + this.adminFlag = adminFlag; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Object getGridName() { + return gridName; + } + + public void setGridName(Object gridName) { + this.gridName = gridName; + } + + public Object getGridAreaName() { + return gridAreaName; + } + + public void setGridAreaName(Object gridAreaName) { + this.gridAreaName = gridAreaName; + } + + public Object getGridAreaCode() { + return gridAreaCode; + } + + public void setGridAreaCode(Object gridAreaCode) { + this.gridAreaCode = gridAreaCode; + } +} diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/login/LoginActivity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/login/LoginActivity.java index 9c00618..b7ee80e 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/login/LoginActivity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/login/LoginActivity.java @@ -28,12 +28,8 @@ public class LoginActivity extends BaseActivity { @Override protected void onFindView(Bundle savedInstanceState) { // GlideLoader.loadOriginal(binding.ivVerifyCode, Api.CAPTCHA, -1); - // if (Hawk.contains(Constant.LOGIN_USER_NAME)) { - // setText(binding.inputUserName, Hawk.get(Constant.LOGIN_USER_NAME)); - // } - if (BuildConfig.DEBUG) { - setText(binding.inputUserName, "admin"); - setText(binding.inputUserPass, "admin123"); + if (Hawk.contains(Constant.LOGIN_USER_NAME) && !BuildConfig.DEBUG) { + setText(binding.inputUserName, Hawk.get(Constant.LOGIN_USER_NAME)); } } @@ -69,25 +65,37 @@ public class LoginActivity extends BaseActivity { } private void checkLogin() { - boolean agree = binding.agree.isChecked(); - String username = binding.inputUserName.getText().toString().trim(); - if (TextUtils.isEmpty(username)) { - showToast("用户名不能为空"); - return; - } - String userpass = binding.inputUserPass.getText().toString().trim(); - if (TextUtils.isEmpty(userpass)) { - showToast("密码不能为空"); - return; - } - String verifyCode = binding.inputVerifyCode.getText().toString().trim(); - // if (TextUtils.isEmpty(verifyCode)) { - // showToast("验证码不能为空"); - // return; - // } - if (!agree) { - showToast("请先阅读并同意《用户协议》和《隐私条款》"); - return; + String username = "", userpass = "", verifyCode = ""; + if (!BuildConfig.DEBUG) { + boolean agree = binding.agree.isChecked(); + username = binding.inputUserName.getText().toString().trim(); + if (TextUtils.isEmpty(username)) { + showToast("用户名不能为空"); + return; + } + userpass = binding.inputUserPass.getText().toString().trim(); + if (TextUtils.isEmpty(userpass)) { + showToast("密码不能为空"); + return; + } + verifyCode = binding.inputVerifyCode.getText().toString().trim(); + // if (TextUtils.isEmpty(verifyCode)) { + // showToast("验证码不能为空"); + // return; + // } + if (!agree) { + showToast("请先阅读并同意《用户协议》和《隐私条款》"); + return; + } + } else { + username = binding.inputUserName.getText().toString().trim(); + if (username.equals("a")) { + username = "admin"; + userpass = "admin123"; + } else if (username.equals("d")) { + username = "dev"; + userpass = "dev123"; + } } showLoading(); doLogin(username, userpass, verifyCode); diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/MyFragment.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/MyFragment.java index f63b036..2803aa6 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/MyFragment.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/MyFragment.java @@ -40,16 +40,29 @@ public class MyFragment extends BaseFragment { protected void onSingleClick(View v) { MessageDialog.show("安全退出", "确定要退出登录吗?", "确定", "取消") .setOkButton((baseDialog, v1) -> { - Hawk.delete(Constant.TOKEN); - Hawk.delete(Constant.USER_INFO); - IntentUtil.startActivity(mContext, LoginActivity.class, null); - getActivity().finish(); + doLogout(); return false; }); } }); } + private void doLogout() { + showLoading(); + RxHttp.deleteJson(Api.LOGOUT) + .asResponse(String.class) + .as(RxLife.asOnMain(this)) + .subscribe(data -> { + Hawk.delete(Constant.TOKEN); + Hawk.delete(Constant.USER_INFO); + IntentUtil.startActivity(mContext, LoginActivity.class, null); + getActivity().finish(); + }, (OnError) error -> { + hideLoading(); + showToast(error.getErrorMsg()); + }); + } + @Override protected void onApplyData() { if (AppConfig.getInstance().getUserInfo() == null) { @@ -75,7 +88,7 @@ public class MyFragment extends BaseFragment { private void initView(UserInfoEntity data) { setText(binding.tvTodoCount, data.getTodoCount().toString()); - setText(binding.userNameTv, data.getUsername()); + setText(binding.userNameTv, data.getLandUserInfo().getGridMemberInfo().getMemberName()); // setText(binding.userDepartmentTv, data.getOrganization() + " - " + data.getDepartmental()); setText(binding.userDepartmentTv, data.getDepartmental()); setText(binding.userTelTv, data.getPhone() + " " + data.getNo()); diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/entity/UserInfoEntity.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/entity/UserInfoEntity.java index 847c3f1..31c2768 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/entity/UserInfoEntity.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/my/entity/UserInfoEntity.java @@ -1,15 +1,15 @@ package com.tairui.gov_affairs_cloud.ui.my.entity; import java.io.Serializable; +import java.util.List; +import com.contrarywind.interfaces.IPickerViewData; import com.google.gson.annotations.SerializedName; public class UserInfoEntity implements Serializable { - @SerializedName("username") - private String username; @SerializedName("organization") - private Object organization; + private String organization; @SerializedName("departmental") private String departmental; @SerializedName("phone") @@ -25,29 +25,23 @@ public class UserInfoEntity implements Serializable { @SerializedName("todoCount") private Integer todoCount; @SerializedName("admin") - private boolean admin; + private Boolean admin; + @SerializedName("birth") + private String birth; + @SerializedName("province") + private String province; + @SerializedName("city") + private String city; + @SerializedName("address") + private String address; + @SerializedName("landUserInfo") + private LandUserInfoEntity landUserInfo; - public boolean isAdmin() { - return admin; - } - - public void setAdmin(boolean admin) { - this.admin = admin; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public Object getOrganization() { + public String getOrganization() { return organization; } - public void setOrganization(Object organization) { + public void setOrganization(String organization) { this.organization = organization; } @@ -106,4 +100,299 @@ public class UserInfoEntity implements Serializable { public void setTodoCount(Integer todoCount) { this.todoCount = todoCount; } + + public Boolean isAdmin() { + return admin; + } + + public void setAdmin(Boolean admin) { + this.admin = admin; + } + + public String getBirth() { + return birth; + } + + public void setBirth(String birth) { + this.birth = birth; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public LandUserInfoEntity getLandUserInfo() { + return landUserInfo; + } + + public void setLandUserInfo(LandUserInfoEntity landUserInfo) { + this.landUserInfo = landUserInfo; + } + + public static class LandUserInfoEntity { + @SerializedName("gridMemberInfo") + private GridMemberInfoEntity gridMemberInfo; + @SerializedName("memberList") + private List memberList; + @SerializedName("landList") + private List landList; + + public GridMemberInfoEntity getGridMemberInfo() { + return gridMemberInfo; + } + + public void setGridMemberInfo(GridMemberInfoEntity gridMemberInfo) { + this.gridMemberInfo = gridMemberInfo; + } + + public List getMemberList() { + return memberList; + } + + public void setMemberList(List memberList) { + this.memberList = memberList; + } + + public List getLandList() { + return landList; + } + + public void setLandList(List landList) { + this.landList = landList; + } + + public static class GridMemberInfoEntity { + @SerializedName("gridId") + private String gridId; + @SerializedName("memberName") + private String memberName; + @SerializedName("adminFlag") + private String adminFlag; + @SerializedName("phone") + private String phone; + @SerializedName("id") + private String id; + @SerializedName("status") + private String status; + @SerializedName("gridName") + private String gridName; + @SerializedName("gridAreaName") + private String gridAreaName; + @SerializedName("gridAreaCode") + private String gridAreaCode; + + public String getGridId() { + return gridId; + } + + public void setGridId(String gridId) { + this.gridId = gridId; + } + + public String getMemberName() { + return memberName; + } + + public void setMemberName(String memberName) { + this.memberName = memberName; + } + + public String getAdminFlag() { + return adminFlag; + } + + public void setAdminFlag(String adminFlag) { + this.adminFlag = adminFlag; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getGridName() { + return gridName; + } + + public void setGridName(String gridName) { + this.gridName = gridName; + } + + public String getGridAreaName() { + return gridAreaName; + } + + public void setGridAreaName(String gridAreaName) { + this.gridAreaName = gridAreaName; + } + + public String getGridAreaCode() { + return gridAreaCode; + } + + public void setGridAreaCode(String gridAreaCode) { + this.gridAreaCode = gridAreaCode; + } + } + + public static class MemberListEntity { + @SerializedName("gridId") + private String gridId; + @SerializedName("memberName") + private String memberName; + @SerializedName("adminFlag") + private String adminFlag; + @SerializedName("phone") + private String phone; + @SerializedName("id") + private String id; + @SerializedName("status") + private String status; + @SerializedName("gridName") + private String gridName; + @SerializedName("gridAreaName") + private String gridAreaName; + @SerializedName("gridAreaCode") + private String gridAreaCode; + + public String getGridId() { + return gridId; + } + + public void setGridId(String gridId) { + this.gridId = gridId; + } + + public String getMemberName() { + return memberName; + } + + public void setMemberName(String memberName) { + this.memberName = memberName; + } + + public String getAdminFlag() { + return adminFlag; + } + + public void setAdminFlag(String adminFlag) { + this.adminFlag = adminFlag; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getGridName() { + return gridName; + } + + public void setGridName(String gridName) { + this.gridName = gridName; + } + + public String getGridAreaName() { + return gridAreaName; + } + + public void setGridAreaName(String gridAreaName) { + this.gridAreaName = gridAreaName; + } + + public String getGridAreaCode() { + return gridAreaCode; + } + + public void setGridAreaCode(String gridAreaCode) { + this.gridAreaCode = gridAreaCode; + } + } + + public static class LandListEntity implements IPickerViewData { + @SerializedName("id") + private String id; + @SerializedName("landName") + private String landName; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLandName() { + return landName; + } + + public void setLandName(String landName) { + this.landName = landName; + } + + @Override + public String getPickerViewText() { + return landName; + } + } + } } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/todo/TodoFragment.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/todo/TodoFragment.java index ce17452..ec5453a 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/todo/TodoFragment.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/todo/TodoFragment.java @@ -108,7 +108,7 @@ public class TodoFragment extends BaseFragment { mAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { InspectionListEntity.RecordsEntity item = mAdapter.getItem(i); Bundle bundle = new Bundle(); - bundle.putSerializable("data", item); + bundle.putString("id", item.getId()); IntentUtil.startActivity(mContext, InspectionDetailActivity.class, bundle); }); } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/workspace/WorkSpaceFragment.java b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/workspace/WorkSpaceFragment.java index 35bda67..9981f8b 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/ui/workspace/WorkSpaceFragment.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/ui/workspace/WorkSpaceFragment.java @@ -9,6 +9,7 @@ import com.tairui.gov_affairs_cloud.R; import com.tairui.gov_affairs_cloud.base.BaseFragment; import com.tairui.gov_affairs_cloud.databinding.FragmentWorkspaceBinding; import com.tairui.gov_affairs_cloud.ui.land.GridInfoActivity; +import com.tairui.gov_affairs_cloud.ui.land.IllegalListActivity; import com.tairui.gov_affairs_cloud.ui.land.InspectionListActivity; import com.tairui.gov_affairs_cloud.ui.land.LandActivity; import com.tairui.gov_affairs_cloud.ui.land.LandResouceInfoActivity; @@ -72,6 +73,8 @@ public class WorkSpaceFragment extends BaseFragment { IntentUtil.startActivity(mContext, LandResouceInfoActivity.class); } else if (_id == 7) { IntentUtil.startActivity(mContext, InspectionListActivity.class); + } else if (_id == 5) { + IntentUtil.startActivity(mContext, IllegalListActivity.class); } }); } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/util/DateUtils.java b/app/src/main/java/com/tairui/gov_affairs_cloud/util/DateUtils.java index cf60190..8582a56 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/util/DateUtils.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/util/DateUtils.java @@ -1,6 +1,8 @@ package com.tairui.gov_affairs_cloud.util; +import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; public class DateUtils { @@ -8,5 +10,11 @@ public class DateUtils { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR); } + + public static String getDateToString(long time) { + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date d = new Date(time); + return sf.format(d); + } } diff --git a/app/src/main/java/com/tairui/gov_affairs_cloud/util/SingleClickListener.java b/app/src/main/java/com/tairui/gov_affairs_cloud/util/SingleClickListener.java index a1bdec5..b0249fa 100644 --- a/app/src/main/java/com/tairui/gov_affairs_cloud/util/SingleClickListener.java +++ b/app/src/main/java/com/tairui/gov_affairs_cloud/util/SingleClickListener.java @@ -31,3 +31,4 @@ public abstract class SingleClickListener implements View.OnClickListener { //protected abstract void onFastClick(); } + diff --git a/app/src/main/res/drawable/bg_container_red_border_raduis_2.xml b/app/src/main/res/drawable/bg_container_red_border_raduis_2.xml new file mode 100644 index 0000000..dc2b4e1 --- /dev/null +++ b/app/src/main/res/drawable/bg_container_red_border_raduis_2.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_add_illegal_information.xml b/app/src/main/res/layout/activity_add_illegal_information.xml new file mode 100644 index 0000000..6bcc607 --- /dev/null +++ b/app/src/main/res/layout/activity_add_illegal_information.xml @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_edit_inspection.xml b/app/src/main/res/layout/activity_edit_inspection.xml new file mode 100644 index 0000000..41e16d9 --- /dev/null +++ b/app/src/main/res/layout/activity_edit_inspection.xml @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_illegal_detail.xml b/app/src/main/res/layout/activity_illegal_detail.xml new file mode 100644 index 0000000..4608b63 --- /dev/null +++ b/app/src/main/res/layout/activity_illegal_detail.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_illegal_list.xml b/app/src/main/res/layout/activity_illegal_list.xml new file mode 100644 index 0000000..6454743 --- /dev/null +++ b/app/src/main/res/layout/activity_illegal_list.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_inspection_detail.xml b/app/src/main/res/layout/activity_inspection_detail.xml index 6b3123c..d18644e 100644 --- a/app/src/main/res/layout/activity_inspection_detail.xml +++ b/app/src/main/res/layout/activity_inspection_detail.xml @@ -49,294 +49,378 @@ - + android:scrollbars="none"> - + android:layout_height="match_parent" + android:orientation="vertical" + android:paddingLeft="16dp" + android:paddingRight="16dp"> - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + android:background="#EDEDED" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:background="@drawable/bg_container_white_raduis_5_border" + android:hint="请选择" + android:minHeight="120dp" + android:padding="6dp" + android:textColor="@color/color_txt_black" + android:textColorHint="@color/color_txt_label" + android:textSize="16sp" + tools:text="是否存在违法占地、乱搭乱建、未批先用、批而未用;是否存在改变土地用途(如耕地改为建设用地);检查耕地是否撂荒、弃耕或非法改变种植结构。" /> + + + + + + + + + + + + + + + + + + - + - + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_inspection_list.xml b/app/src/main/res/layout/activity_inspection_list.xml index 3ba96b8..d611264 100644 --- a/app/src/main/res/layout/activity_inspection_list.xml +++ b/app/src/main/res/layout/activity_inspection_list.xml @@ -49,68 +49,35 @@ - - - - - - - - - - - - + android:layout_marginRight="12dp" + android:gravity="center" + android:paddingTop="12dp" + android:paddingBottom="12dp"> - - + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_illegal_2.xml b/app/src/main/res/layout/item_illegal_2.xml new file mode 100644 index 0000000..f87d3cb --- /dev/null +++ b/app/src/main/res/layout/item_illegal_2.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-xxhdpi/ic_add_white_small.webp b/app/src/main/res/mipmap-xxhdpi/ic_add_white_small.webp new file mode 100644 index 0000000000000000000000000000000000000000..345416def02b4017412e56075414eb12de6f9619 GIT binary patch literal 666 zcmWIYbaR`;#J~{l>J$(bU=hK^z`$St#QI?5>FgYEf)U7NU_1dLS%6Zxc_l?b?oJ93 zkx>fl4;UDM5DXHNiwhtutRzs?w`&l!mvynKz%R&|l3JV$RPq6cRf>R?1KlJ7WQ(Lj z*cu>q5`=97VwaZ`lmOKPfY?PLLC!#S3XrXlj>JwvVkZ|AfzZ zZ((5Ab{-*y2$O=uqC~K9EI^VeEscTU({cs|-be-p;R_55T+v`TAc4be3P33tpu6&c zFr6WXA(cUa!IL46A(=rB$T9*(sv(0JFou1W02S)%AK(@!H~9bA{(qOUr&n|O4(lf# z4Ch{4*imu8p(aGbMLiV9{l3ERXGb&3Qgrk{78dD2?teJN;aiWKp!~5+$ zIeL1F{&(Fm3o4RsYjyXSq~iIpR2D>q^2G1nAo;jl@~frWw%ptE>hvaesj=Nw@dV0E tO8H;EOw{*G9nc*N3Px(KuJVFRA@u(nq85CStUMFoA(r6?$j2>g0bL?0p$(KJLfNK7qT&i}Gb>^t4tX=ctG#&E;s zo^zO4d;Rxbv-bbL))=|r?pFf00ds+AzuYgg2;&BzQvTAJB z>2zva0D6H};>X><6f^s+TMiVN$K5Z@qGe3nbHvQf3BYz`gZOconJq73v|HD@yCOuX z{dwRI;6*drA^@j>%fpeGX7+WroGLPpyUzpG09OIZTw3fE0+6OL<>j444A*^ato+l! zo5@^115cURH;o1m&OZkzthMqQ$AFiB_mpUw4&afD%52Ixuif~<%>ELZMgnm6k-@`0 z1xDvqzOUtcBLRf-55-~HVg`f4CVvhz>LGUb`+}3D&JPNkMgk}jHjM*NG;AsXaQEwg ztHn?|#g~ePO=$q`E~WNEcBot*r0>-#Aj*bKNPx>SJ#n^B8g=&vm4jmiq#1OeY%Bw! zO4tOgxC7`f3P3q|D{yC$o1Zl^iJ?NHY}mNF<`x0H0yt0zfIJKXp943C$2&6hHpk3< z{4WT~hE2=1yNfvsz`!U2K&RxKtWvQq9%kA366k5CBdUZ=#{k4Gh?~EhEx>DGSiGbU zP&nz?7;=;io77n49mp9ISD6)B`u9v|ECx2@AL^=MQzw9%f-TO7Qp};)1%=eW=tS7m z2|y(o6$L&>wCa9fhMDQV02Jaj?GiypLnvA0$APyK>bnhi0=N}uONrY#UE2=i3@?;U zjq;2{_jhq#+z{6dONpBTK$34Q@JuEFFUdJ2=ZB@ljQ|kwJ}yG$-o&Za$`4XfMV#(R z2;~kM6^U=p3-Gc|cNIYF#Qj-$em$@t72p>V0MQKB``g`MsyNhpW^;-+xD*$S4e;bW$sj4L^td=R2)QLFyV^Vzj(?O}u(o6x+s|6d> z@d#C=HtWW$CjWXnkzS|6IsPM(*b~%5^!yy~5ioC{Qy;s~59mS-wObWVAII(tE7WTS zp)%$q;IXV?eM{7WH02TCVU<_%uNtVbpt7MF-c1~81*rM{q?sw~|M9Yi(9Q?cU{L9# zNki%WGqGGVQ|25P`L|W{U6tp%vJ&D0fCRZdx7x7X2K1}ShgrL6OI8VdNAGW#*~!$2 Y^Nb68s=4p<$p8QV07*qoM6N<$f_Wer=l}o! literal 0 HcmV?d00001 diff --git a/settings.gradle b/settings.gradle index 70f1472..430f617 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,3 +3,4 @@ include ':AlbumDialog' include ':DialogX' include ':DialogXInterface' include ':DialogXMaterialYou' +include ':TimePickerDialog'