├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── compiler.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── debug
│ ├── app-debug.apk
│ └── output.json
├── miwatch.zip
├── proguard-rules.pro
├── release
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── yxc
│ │ └── barchart
│ │ └── ExampleInstrumentedTest.java
│ ├── debug
│ └── res
│ │ └── values
│ │ └── google_maps_api.xml
│ ├── main
│ ├── AndroidManifest.xml
│ ├── aidl
│ │ └── com
│ │ │ └── yxc
│ │ │ └── barchart
│ │ │ └── map
│ │ │ └── location
│ │ │ └── service
│ │ │ ├── ILocationHelperServiceAIDL.aidl
│ │ │ └── ILocationServiceAIDL.aidl
│ ├── java
│ │ ├── com
│ │ │ └── yxc
│ │ │ │ └── barchart
│ │ │ │ ├── ChartApplication.java
│ │ │ │ ├── EcgTestData.java
│ │ │ │ ├── RateTestData.java
│ │ │ │ ├── TestData.java
│ │ │ │ ├── formatter
│ │ │ │ ├── BarChartValueFormatter.java
│ │ │ │ ├── ChartValueMarkFormatter.java
│ │ │ │ ├── DayHighLightMarkValueFormatter.java
│ │ │ │ ├── XAxisDayFormatter.java
│ │ │ │ ├── XAxisHrmFormatter.java
│ │ │ │ ├── XAxisMonthFormatter.java
│ │ │ │ ├── XAxisWeekFormatter.java
│ │ │ │ ├── XAxisYearFormatter.java
│ │ │ │ └── YearHighLightMarkValueFormatter.java
│ │ │ │ ├── map
│ │ │ │ ├── location
│ │ │ │ │ ├── LocationActivity.java
│ │ │ │ │ ├── MapboxShowActivity.java
│ │ │ │ │ ├── RecordCorrectShowActivity.java
│ │ │ │ │ ├── RecordListActivity.java
│ │ │ │ │ ├── RecordShowActivity.java
│ │ │ │ │ ├── database
│ │ │ │ │ │ ├── LocationDBHelper.java
│ │ │ │ │ │ └── RealmDbHelper.java
│ │ │ │ │ ├── event
│ │ │ │ │ │ └── LocationEvent.java
│ │ │ │ │ ├── recycler
│ │ │ │ │ │ ├── RecordAdapter.java
│ │ │ │ │ │ └── RecordItemDecoration.java
│ │ │ │ │ ├── service
│ │ │ │ │ │ ├── LocalLocationService.java
│ │ │ │ │ │ ├── LocationHelperService.java
│ │ │ │ │ │ ├── LocationService.java
│ │ │ │ │ │ ├── LocationStatusManager.java
│ │ │ │ │ │ ├── NotiService.java
│ │ │ │ │ │ └── android
│ │ │ │ │ │ │ └── AndroidLocationComputeUtil.java
│ │ │ │ │ ├── tracereplay
│ │ │ │ │ │ └── TraceRePlay.java
│ │ │ │ │ └── util
│ │ │ │ │ │ ├── Gps.java
│ │ │ │ │ │ ├── IWifiAutoCloseDelegate.java
│ │ │ │ │ │ ├── LocationComputeUtil.java
│ │ │ │ │ │ ├── LocationConstants.java
│ │ │ │ │ │ ├── LocationStatusManager.java
│ │ │ │ │ │ ├── NetUtil.java
│ │ │ │ │ │ ├── PositionUtil.java
│ │ │ │ │ │ ├── PowerManagerUtil.java
│ │ │ │ │ │ ├── Utils.java
│ │ │ │ │ │ └── WifiAutoCloseDelegate.java
│ │ │ │ ├── model
│ │ │ │ │ ├── Record.java
│ │ │ │ │ ├── RecordCorrect.java
│ │ │ │ │ ├── RecordLocation.java
│ │ │ │ │ └── RecordLocationSerializer.java
│ │ │ │ └── util
│ │ │ │ │ ├── Constants.java
│ │ │ │ │ └── SensorEventHelper.java
│ │ │ │ ├── tab
│ │ │ │ ├── FragmentChangeManager.java
│ │ │ │ ├── OnTabSelectListener.java
│ │ │ │ └── TopTabLayout.java
│ │ │ │ ├── ui
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── Person.java
│ │ │ │ ├── base
│ │ │ │ │ ├── BaseChartFragment.java
│ │ │ │ │ └── BaseFragment.java
│ │ │ │ ├── bezier
│ │ │ │ │ ├── BaseBezierFragment.java
│ │ │ │ │ ├── BezierActivity.java
│ │ │ │ │ ├── DayBezierFragment.java
│ │ │ │ │ ├── MonthBezierFragment.java
│ │ │ │ │ ├── WeekBezierFragment.java
│ │ │ │ │ └── YearBezierFragment.java
│ │ │ │ ├── hrm
│ │ │ │ │ ├── EcgDayFragment.java
│ │ │ │ │ ├── EcgLandScapeActivity.java
│ │ │ │ │ ├── HrmActivity.java
│ │ │ │ │ ├── HrmDayFragment.java
│ │ │ │ │ └── HrmLandScapeActivity.java
│ │ │ │ ├── line
│ │ │ │ │ ├── BaseLineFragment.java
│ │ │ │ │ ├── DayLineFragment.java
│ │ │ │ │ ├── LineActivity.java
│ │ │ │ │ ├── MonthLineFragment.java
│ │ │ │ │ ├── WeekLineFragment.java
│ │ │ │ │ └── YearLineFragment.java
│ │ │ │ ├── rainbow
│ │ │ │ │ └── RainbowActivity.java
│ │ │ │ ├── sleep
│ │ │ │ │ ├── SleepActivity.java
│ │ │ │ │ ├── SleepFragment.java
│ │ │ │ │ └── SleepTestData.java
│ │ │ │ ├── step
│ │ │ │ │ ├── BaseStepFragment.java
│ │ │ │ │ ├── StepActivity.java
│ │ │ │ │ ├── StepDayFragment.java
│ │ │ │ │ ├── StepMonthFragment.java
│ │ │ │ │ ├── StepWeekFragment.java
│ │ │ │ │ └── StepYearFragment.java
│ │ │ │ └── waterdrop
│ │ │ │ │ └── WaterDropActivity.java
│ │ │ │ ├── util
│ │ │ │ ├── BaseFileUtil.java
│ │ │ │ ├── CommonUtil.java
│ │ │ │ ├── ScrollCapture.kt
│ │ │ │ ├── ScrollHorizontalCapture.kt
│ │ │ │ ├── ShareUtil.kt
│ │ │ │ ├── ToastUtil.java
│ │ │ │ └── Util.java
│ │ │ │ └── view
│ │ │ │ ├── BezierCircle.java
│ │ │ │ ├── BezierCircleModel.java
│ │ │ │ ├── HPoint.java
│ │ │ │ ├── LocationMarker.java
│ │ │ │ ├── PathMeasureModel.java
│ │ │ │ ├── PathModel.java
│ │ │ │ ├── QuadModel.java
│ │ │ │ ├── Rainbow.java
│ │ │ │ ├── RainbowCircle.java
│ │ │ │ ├── RainbowModel.java
│ │ │ │ ├── RainbowView.java
│ │ │ │ ├── ThreeTargetConstant.java
│ │ │ │ ├── ThreeTargetModel.java
│ │ │ │ ├── ThreeTargetView.java
│ │ │ │ ├── ThreeTargetView2.java
│ │ │ │ ├── ThreeTargetView3.java
│ │ │ │ ├── VPoint.java
│ │ │ │ └── WaterDrop.java
│ │ └── rx
│ │ │ └── Observable.java
│ ├── jniLibs
│ │ ├── arm64-v8a
│ │ │ └── libAMapSDK_MAP_v6_5_0.so
│ │ ├── armeabi-v7a
│ │ │ └── libAMapSDK_MAP_v6_5_0.so
│ │ ├── armeabi
│ │ │ └── libAMapSDK_MAP_v6_5_0.so
│ │ ├── x86
│ │ │ └── libAMapSDK_MAP_v6_5_0.so
│ │ └── x86_64
│ │ │ └── libAMapSDK_MAP_v6_5_0.so
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xhdpi
│ │ ├── icon_location.png
│ │ └── walk.png
│ │ ├── drawable-xxhdpi
│ │ ├── back_btn_image.png
│ │ ├── end.png
│ │ ├── gps.png
│ │ ├── grasp_flag.png
│ │ ├── grasp_trace_line.png
│ │ ├── location.png
│ │ ├── marker.png
│ │ ├── point.png
│ │ ├── point5.png
│ │ ├── start.png
│ │ ├── test.png
│ │ └── title_background.9.png
│ │ ├── drawable
│ │ ├── border_bg.9.png
│ │ ├── btn_map_poi.xml
│ │ ├── custom_info_bubble.9.png
│ │ ├── direct_mapsearch.9.png
│ │ ├── direct_mapsearch_pressed.9.png
│ │ ├── ic_chevron_left_black_30dp.xml
│ │ ├── ic_chevron_left_white_45dp.xml
│ │ ├── ic_chevron_right_black_30dp.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_mile_post_24dp.xml
│ │ ├── ic_navigate_back_24dp.xml
│ │ ├── ic_navigation_left_black_45dp.xml
│ │ ├── shape_data_item_bg_white.xml
│ │ └── title_background.9.png
│ │ ├── layout
│ │ ├── abroadmap_activity.xml
│ │ ├── activity_bar_animator.xml
│ │ ├── activity_bezier.xml
│ │ ├── activity_hrm.xml
│ │ ├── activity_main.xml
│ │ ├── activity_maps.xml
│ │ ├── activity_maps_google.xml
│ │ ├── activity_rainbow.xml
│ │ ├── activity_rainbow2.xml
│ │ ├── activity_record_item.xml
│ │ ├── activity_record_mapbox.xml
│ │ ├── activity_sleep.xml
│ │ ├── activity_step.xml
│ │ ├── activity_touch.xml
│ │ ├── activity_two_map.xml
│ │ ├── activity_water_drop.xml
│ │ ├── animatecamera_activity.xml
│ │ ├── arc_activity.xml
│ │ ├── barchart_main.xml
│ │ ├── basemap_fragment_activity.xml
│ │ ├── basic_location_map_activity.xml
│ │ ├── basicmap_activity.xml
│ │ ├── camera_activity.xml
│ │ ├── circle_activity.xml
│ │ ├── content_barchart.xml
│ │ ├── content_main.xml
│ │ ├── custom_info_contents.xml
│ │ ├── custom_info_window.xml
│ │ ├── custom_location_view.xml
│ │ ├── custommarker_activity.xml
│ │ ├── events_activity.xml
│ │ ├── fragment_day_bezier.xml
│ │ ├── fragment_day_ecg.xml
│ │ ├── fragment_day_hrm.xml
│ │ ├── fragment_day_line.xml
│ │ ├── fragment_day_step.xml
│ │ ├── fragment_month_bezier.xml
│ │ ├── fragment_month_line.xml
│ │ ├── fragment_month_step.xml
│ │ ├── fragment_sleep.xml
│ │ ├── fragment_week_bezier.xml
│ │ ├── fragment_week_line.xml
│ │ ├── fragment_week_step.xml
│ │ ├── fragment_year_bezier.xml
│ │ ├── fragment_year_line.xml
│ │ ├── fragment_year_step.xml
│ │ ├── gesture_settings_activity.xml
│ │ ├── groundoverlay_activity.xml
│ │ ├── item_layout_barchart.xml
│ │ ├── layers_activity.xml
│ │ ├── layout_record_item.xml
│ │ ├── layout_step_bottom_desc.xml
│ │ ├── layout_step_date_title.xml
│ │ ├── layout_tab_segment.xml
│ │ ├── locationmodesource_activity.xml
│ │ ├── locationsource_activity.xml
│ │ ├── logo_settings_activity.xml
│ │ ├── marker_activity.xml
│ │ ├── osmmap_activity.xml
│ │ ├── polygon_activity.xml
│ │ ├── polyline_activity.xml
│ │ ├── recorddisplay_activity.xml
│ │ ├── recordlist.xml
│ │ ├── screenshot_activity.xml
│ │ ├── ui_settings_activity.xml
│ │ ├── view_item.xml
│ │ └── zoom_activity.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── arrow.png
│ │ ├── badge_sa.png
│ │ ├── badge_wa.png
│ │ ├── gps_point.png
│ │ ├── groundoverlay.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── location_marker.png
│ │ └── navi_map_gps_locked.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── release
│ └── res
│ │ └── values
│ │ └── google_maps_api.xml
│ └── test
│ └── java
│ └── com
│ └── yxc
│ └── barchart
│ └── ExampleUnitTest.java
├── barchartlib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── yxc
│ │ └── chartlib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── yxc
│ │ │ └── chartlib
│ │ │ └── recyclerchart
│ │ │ ├── attrs
│ │ │ ├── BarChartAttrs.java
│ │ │ ├── BaseChartAttrs.java
│ │ │ ├── BezierChartAttrs.java
│ │ │ ├── ChartAttrsUtil.java
│ │ │ ├── LineChartAttrs.java
│ │ │ └── SleepChartAttrs.java
│ │ │ ├── barchart
│ │ │ ├── BarChartAdapter.java
│ │ │ ├── BaseBarChartAdapter.java
│ │ │ ├── SleepChartDayAdapter.java
│ │ │ └── SpeedRatioLayoutManager.java
│ │ │ ├── bezier
│ │ │ └── ControlPoint.java
│ │ │ ├── component
│ │ │ ├── AxisBase.java
│ │ │ ├── BaseYAxis.java
│ │ │ ├── ChartRectF.java
│ │ │ ├── ComponentBase.java
│ │ │ ├── DistanceCompare.java
│ │ │ ├── HrmYAxis.java
│ │ │ ├── LimitLine.java
│ │ │ ├── XAxis.java
│ │ │ └── YAxis.java
│ │ │ ├── entrys
│ │ │ ├── BarChart.java
│ │ │ ├── BarEntry.java
│ │ │ ├── BaseEntry.java
│ │ │ ├── BubbleEntry.java
│ │ │ ├── CandleEntry.java
│ │ │ ├── EcgEntry.java
│ │ │ ├── Entry.java
│ │ │ ├── PieEntry.java
│ │ │ ├── RadarEntry.java
│ │ │ ├── SleepEntry.java
│ │ │ ├── SleepItemEntry.java
│ │ │ ├── YAxisMaxEntries.java
│ │ │ └── model
│ │ │ │ ├── SleepItemTime.java
│ │ │ │ └── SleepTime.java
│ │ │ ├── formatter
│ │ │ ├── DefaultAxisValueFormatter.java
│ │ │ ├── DefaultBarChartValueFormatter.java
│ │ │ ├── DefaultHighLightMarkValueFormatter.java
│ │ │ ├── DefaultValueFormatter.java
│ │ │ └── ValueFormatter.java
│ │ │ ├── itemdecoration
│ │ │ ├── BarChartItemDecoration.java
│ │ │ ├── BezierChartItemDecoration.java
│ │ │ ├── EcgChartItemDecoration.java
│ │ │ ├── HrmChartItemDecoration.java
│ │ │ ├── LineChartDrawable.java
│ │ │ ├── LineChartItemDecoration.java
│ │ │ └── SleepChartDayItemDecoration.java
│ │ │ ├── listener
│ │ │ ├── RecyclerItemGestureListener.java
│ │ │ └── SimpleItemGestureListener.java
│ │ │ ├── render
│ │ │ ├── BarBoardRender.java
│ │ │ ├── BarChartRender.java
│ │ │ ├── BaseChartRender.java
│ │ │ ├── BezierChartRender.java
│ │ │ ├── EcgLineChartRender.java
│ │ │ ├── HrmBarBoardRender.java
│ │ │ ├── HrmLineChartRender.java
│ │ │ ├── HrmXAxisRender.java
│ │ │ ├── HrmYAxisRender.java
│ │ │ ├── LineChartRender.java
│ │ │ ├── SleepChartDayRender.java
│ │ │ ├── SleepChartRender.java
│ │ │ ├── SleepChartRenderBack.java
│ │ │ ├── XAxisRender.java
│ │ │ └── YAxisRender.java
│ │ │ ├── sleepchart
│ │ │ ├── SleepChartAdapter.java
│ │ │ └── SleepChartItemDecoration.java
│ │ │ ├── util
│ │ │ ├── CanvasUtil.java
│ │ │ ├── ChartComputeUtil.java
│ │ │ ├── DecimalUtil.java
│ │ │ ├── FSize.java
│ │ │ ├── MPPointD.java
│ │ │ ├── MPPointF.java
│ │ │ ├── ObjectPool.java
│ │ │ ├── RoundRectType.java
│ │ │ └── Utils.java
│ │ │ └── view
│ │ │ ├── AnimatedDecorator.java
│ │ │ ├── AnimatedDecoratorDrawable.java
│ │ │ ├── BarChartRecyclerView.java
│ │ │ ├── BaseChartRecyclerView.java
│ │ │ ├── BezierChartRecyclerView.java
│ │ │ ├── CustomAnimatedDecorator.java
│ │ │ ├── LineChartRecyclerView.java
│ │ │ └── SleepChartRecyclerView.java
│ └── res
│ │ ├── drawable
│ │ └── marker2.png
│ │ ├── layout
│ │ └── item_layout_barchart.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── yxc
│ └── chartlib
│ └── ExampleUnitTest.java
├── build.gradle
├── chart.jks
├── commonlib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── yxc
│ │ └── commonlib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── yxc
│ │ │ └── commonlib
│ │ │ ├── time
│ │ │ └── Hour12.java
│ │ │ └── util
│ │ │ ├── ColorUtil.java
│ │ │ ├── DisplayUtil.java
│ │ │ ├── PathUtil.java
│ │ │ ├── TextUtil.java
│ │ │ └── TimeDateUtil.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── yxc
│ └── commonlib
│ └── ExampleUnitTest.java
├── device-2019-04-25-115017.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── widgetlib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── yxc
│ └── widgetlib
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── yxc
│ │ └── widgetlib
│ │ ├── calendar
│ │ ├── entity
│ │ │ ├── Lunar.java
│ │ │ └── NDate.java
│ │ ├── listener
│ │ │ ├── OnCalendarChangedListener.java
│ │ │ ├── OnCalendarStateChangedListener.java
│ │ │ ├── OnClickDayViewListener.java
│ │ │ ├── OnClickDisableDateListener.java
│ │ │ ├── OnClickMonthViewListener.java
│ │ │ ├── OnClickWeekViewListener.java
│ │ │ ├── OnMonthAnimatorListener.java
│ │ │ ├── OnMonthSelectListener.java
│ │ │ ├── OnWeekSelectListener.java
│ │ │ └── OnYearItemSelectListener.java
│ │ ├── painter
│ │ │ ├── CalendarPainter.java
│ │ │ ├── CalendarWeekPainter.java
│ │ │ ├── InnerMonthPainter.java
│ │ │ └── InnerPainter.java
│ │ ├── utils
│ │ │ ├── AttrsUtil.java
│ │ │ ├── CalendarAttrs.java
│ │ │ ├── HolidayUtil.java
│ │ │ ├── LunarUtil.java
│ │ │ ├── SolarTermUtil.java
│ │ │ └── Util.java
│ │ └── view
│ │ │ ├── CalendarBar.java
│ │ │ ├── ChildLayout.java
│ │ │ ├── DayCalendarView.java
│ │ │ ├── MonthCalendar.java
│ │ │ ├── MonthCalendarView.java
│ │ │ ├── MyAnimatorListener.java
│ │ │ └── WeekCalendarView.java
│ │ └── viewpager2
│ │ ├── AnimateLayoutChangeDetector.java
│ │ ├── CompositeOnPageChangeCallback.java
│ │ ├── FakeDrag.java
│ │ ├── PageTransformerAdapter.java
│ │ ├── ScrollEventAdapter.java
│ │ └── ViewPager2.java
└── res
│ ├── layout
│ ├── cbc_layout_calendar_year_view.xml
│ ├── cbc_layout_item_month.xml
│ └── item_layout_barchart.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ └── strings.xml
└── test
└── java
└── com
└── yxc
└── widgetlib
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RecyclerBarChart
2 | 基于Recyclerview实现 动态X/Y轴的运动步数 柱状图
3 |
4 | "RecyclerView柱状图:1.动态无线滑动;2、根据显示中的柱状图动态改变Y坐标 3.通过RecyclerView的Decoration画纵坐标、横坐标、柱状图、value值;"
5 |
6 | 1.动态无线滑动, 接口动态添加数据 ;
7 | 2、根据显示中的柱状图动态改变Y坐标;(已完成)
8 | 3.通过RecyclerView的Decoration画纵坐标、横坐标、柱状图、value值;(已完成)
9 |
10 | 目前需要完成的:
11 | 4. 需要动态添加 边框,左Y轴、右Y轴,顶部的value的文字显示、柱状图颜色、DisplayNumbers, Y坐标、X坐标的自定义。(已完成)
12 | 5. Y轴变化的时候,添加动画。
13 | 6. Canvas画仅顶部为圆角的 RoundRect。
14 | 7. GridLine的控制是否显示 (已完成)
15 | 8. Item的 触摸 事件。
16 | 9. 封装 View。
17 | 10. 画 周、日的 X 轴 (已完成)
18 | 12. 参照 MPAndroidChart 自定义 X 坐标、Y坐标。(已完成 X 轴,完成一半)
19 | 13. Item 中柱状图所占的 比率,也就是 Space的宽度。(已完成)
20 | 14. X轴刻度坐标左右的显示跟 iOS不一样。(已处理,itemDecoration 靠左。)
21 | 15. 底部 X轴左边的 边界显示问题。(已修复)
22 | 16. 周、月、日、年的统计问题,获取当前显示中的 柱状图的 日期跨度 在顶部显示。(已完成)
23 | 17. Recyclerview左右预留空的,并带滑动 阻尼效果
24 | 18. 左滑、右滑 ScrollToPosition是不一样的。
25 | 19. 判断惯性滑动的速度超过某一个值的时候就 进行微调、否则就不调整。(方案调整)
26 | 20. Override Recyclerview 的 fling 方法,降低惯性速度。(已修改)
27 | 21. 超出一个 child width的 value文字显示的时候,有bug ,边界右滑有问题。(已修改,分离画柱状图跟文字的函数,各自单独处理)
28 | 22. Y轴坐标变换,在临界点来回的变动,导致无法准确的改变 ,偶现的。(需要微调后,在继续计算Y轴刻度)
29 | 23. 左右边界进入,颜色渐变动画,丝滑般的进入显示页面。需要处理的,Barchart柱体本身,X轴刻度文字,BarChart 的value文字。(待优化)
30 | 24. 保留原始 RecyclerView的 paddingLeft, paddingRight。todo这里注意Padding是否会因为重绘而累加, 自定义padding属性,动态加入。(已完成)
31 | 25. 自定义 CustomerRecyclerView的 xml attribute列表,解析为 Attrs 类中的静态值,对应代码中的 BarChartConfig,传给ItemDecoration使用。(已完成)
32 | 26. 控制是否 显示的一些元素的 switch, 转移到BarChartConfig,到时候也可以直接用 attribute xml来控制。(完成)
33 | 27. 调整滑动策略,滑动停止处于idle状态时,位置处于右边 1/3 往靠近右边刻度滑,处于左边 1/3往 靠近左边刻度滑动,处于中间 1/3 的保持不动,进行微调(22点处的方案微调), 所有的滑动用 scrollToPosition,不用 smoothScrollToPosition。
34 | 28. 控制是否 scrollToPosition的参数,customerRecyclerView的参数 放入到 attribute xml中?(完成)
35 | 29. 如何自定义 Y轴,参照MPAndroidChart.
36 | 30. 边界处的 lastVisiblePosition跟 FirstVisiblePosition需要 细心处理,目前存在bug。(完成)
37 | 31. 抽取BarChartRecycler的Attrs, 修改部分属性为float,添加工具类 进行 float的 == 比较。(完成)
38 | 32. YAxis、Xaxis 中的属性也要到 Attrs中设置。(已完成)
39 | 33. 右边的 barChart 滑入有问题,没有渐渐消失。(已完成)
40 | 34. 显示顶部的时间间断, 统计步数。(已完成)
41 | 35. 底部有个浮动的 Date的标志, ItemDecoration添加。
42 |
43 |
44 | 微调方案:试图在ItemDecoration中进行微调,根据child的getRight、getLeft跟parentLeft、parentRight的位置来主动判断,
45 | 真正的显示边界(completeDisplayVisibleItemPosition),取到displayEntries;
46 | 通过 XAxis传递给 ItemDecoration 进行微调。
47 | 存在难点:需要在 ItemDecoration本身的onDraw、onDrawOver中的 recycleView 用getChildAt(index)拿到的 child才不为null。
48 |
49 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'realm-android'
3 | apply plugin: 'kotlin-android'
4 |
5 | android {
6 | // signingConfigs {
7 | // debug {
8 | // storeFile file('/Users/xiuchengyin/Documents/opensource/RecyclerBarChart/chart.jks')
9 | // storePassword '861014'
10 | // keyAlias = 'chart'
11 | // keyPassword '861014'
12 | // }
13 | // release {
14 | // storeFile file('/Users/xiuchengyin/Documents/opensource/RecyclerBarChart/chart.jks')
15 | // storePassword '861014'
16 | // keyAlias = 'chart'
17 | // keyPassword '861014'
18 | // }
19 | // }
20 | compileSdkVersion 32
21 | defaultConfig {
22 | applicationId "com.yxc.barchart"
23 | minSdkVersion 24
24 | targetSdkVersion 32
25 | versionCode 1
26 | versionName "1.0"
27 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28 | externalNativeBuild{
29 | cmake{
30 |
31 | }
32 | }
33 |
34 | ndk{
35 | //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
36 | abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
37 | }
38 | }
39 | buildTypes {
40 | release {
41 | minifyEnabled true
42 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
43 | }
44 | }
45 | }
46 |
47 | dependencies {
48 | implementation fileTree(include: ['*.jar'], dir: 'libs')
49 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
50 | implementation 'androidx.appcompat:appcompat:1.5.1'
51 |
52 | implementation 'com.google.android.material:material:1.6.1'
53 | implementation 'org.greenrobot:eventbus:3.1.1'
54 | api 'com.amap.api:3dmap:9.3.0'
55 | api "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
56 | api "androidx.lifecycle:lifecycle-common-java8:2.5.1"
57 | api "androidx.core:core-ktx:1.5.0"
58 | implementation 'com.google.code.gson:gson:2.8.9'
59 |
60 | testImplementation 'junit:junit:4.13.2'
61 | androidTestImplementation 'androidx.test:runner:1.4.0'
62 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
63 |
64 | implementation project(':barchartlib')
65 | implementation project(':widgetlib')
66 | }
67 |
--------------------------------------------------------------------------------
/app/debug/app-debug.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/debug/app-debug.apk
--------------------------------------------------------------------------------
/app/debug/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-debug.apk","fullName":"debug","baseName":"debug"},"path":"app-debug.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/miwatch.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/miwatch.zip
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | # 2D地图
24 | -keep class com.amap.api.maps2d.**{*;}
25 | -keep class com.amap.api.mapcore2d.**{*;}
26 |
27 | # 3D地图 V5.0.0之后
28 | -keep class com.amap.api.maps.**{*;}
29 | -keep class com.autonavi.**{*;}
30 | -keep class com.amap.api.trace.**{*;}
31 |
32 | # 定位
33 | -keep class com.amap.api.location.**{*;}
34 | -keep class com.amap.api.fence.**{*;}
35 | -keep class com.autonavi.aps.amapapi.model.**{*;}
36 |
37 | # 搜索
38 | -keep class com.amap.api.services.**{*;}
39 |
40 | # 导航
41 | -keep class com.amap.api.navi.**{*;}
42 | -keep class com.autonavi.**{*;}
43 |
44 |
45 | -dontwarn org.joda.convert.**
46 | -dontwarn org.joda.time.**
47 | -keep class org.joda.time.** { *; }
48 | -keep interface org.joda.time.** { *; }
49 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/yxc/barchart/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yxc.barchart", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/debug/res/values/google_maps_api.xml:
--------------------------------------------------------------------------------
1 |
2 |
23 | AIzaSyDO2U_8s0b_oKGVe92DuybykfC0lYzfz7A
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/aidl/com/yxc/barchart/map/location/service/ILocationHelperServiceAIDL.aidl:
--------------------------------------------------------------------------------
1 | // ILocationHelperServiceAIDL.aidl
2 | package com.yxc.barchart.map.location.service;
3 |
4 | // Declare any non-default types here with import statements
5 |
6 | interface ILocationHelperServiceAIDL {
7 |
8 | /**
9 | * 定位service绑定完毕后,会通知helperservice自己绑定的notiId
10 | * @param notiId 定位service的notiId
11 | */
12 | void onFinishBind(int notiId);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/aidl/com/yxc/barchart/map/location/service/ILocationServiceAIDL.aidl:
--------------------------------------------------------------------------------
1 | // ILocationServiceAIDL.aidl
2 | package com.yxc.barchart.map.location.service;
3 |
4 | // Declare any non-default types here with import statements
5 |
6 | interface ILocationServiceAIDL {
7 | /** hook when other service has already binded on it */
8 | void onFinishBind();
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ChartApplication.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart;
2 |
3 | import android.app.Application;
4 |
5 | import androidx.appcompat.app.AppCompatActivity;
6 |
7 | import com.yxc.barchart.map.location.database.RealmDbHelper;
8 | import com.yxc.barchart.util.CommonUtil;
9 |
10 | import java.lang.ref.WeakReference;
11 |
12 | public class ChartApplication extends Application {
13 |
14 | private static ChartApplication sApplication;
15 | private WeakReference mCurrentActivity;
16 | private int mActivityCount = 0;
17 |
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 | sApplication = this;
23 |
24 | // service process need not following initialization
25 | if (!CommonUtil.isMainProcess(this)) {
26 | return;
27 | }
28 | //db
29 | RealmDbHelper.init("chartdb", 1);
30 | }
31 |
32 | public static ChartApplication getInstance() {
33 | return sApplication;
34 | }
35 |
36 | public AppCompatActivity getCurrentActivity() {
37 | if (mCurrentActivity != null && mCurrentActivity.get() != null) {
38 | return mCurrentActivity.get();
39 | }
40 | return null;
41 | }
42 |
43 | /**
44 | * app是否在前台
45 | *
46 | * @return true前台,false后台
47 | */
48 | public boolean isForeground() {
49 | return mActivityCount > 0;
50 | }
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/BarChartValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.DefaultBarChartValueFormatter;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/14
9 | */
10 | public class BarChartValueFormatter extends DefaultBarChartValueFormatter {
11 | /**
12 | * Constructor that specifies to how many digits the value should be
13 | * formatted.
14 | */
15 | public BarChartValueFormatter() {
16 | super(0);
17 | }
18 |
19 | @Override
20 | public String getBarLabel(BarEntry barEntry) {
21 | return super.getBarLabel(barEntry);
22 | // return barEntry.getY() > 0 ? TimeUtil.getDateStr(barEntry.timestamp, "MM-dd") : "";
23 | }
24 |
25 | @Override
26 | public String getFormattedValue(float value) {
27 | return super.getFormattedValue(value);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/ChartValueMarkFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.DefaultBarChartValueFormatter;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/14
9 | */
10 | public class ChartValueMarkFormatter extends DefaultBarChartValueFormatter {
11 | /**
12 | * Constructor that specifies to how many digits the value should be
13 | * formatted.
14 | */
15 | public ChartValueMarkFormatter() {
16 | super(0);
17 | }
18 |
19 | @Override
20 | public String getBarLabel(BarEntry barEntry) {
21 | return super.getBarLabel(barEntry);
22 | // return barEntry.getY() > 0 ? TimeUtil.getDateStr(barEntry.timestamp, "MM-dd") : "";
23 | }
24 |
25 | @Override
26 | public String getFormattedValue(float value) {
27 | return super.getFormattedValue(value);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/DayHighLightMarkValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.DefaultHighLightMarkValueFormatter;
5 | import com.yxc.commonlib.util.TimeDateUtil;
6 |
7 | /**
8 | * @author yxc
9 | * @date 2019/4/24
10 | */
11 | public class DayHighLightMarkValueFormatter extends DefaultHighLightMarkValueFormatter {
12 | /**
13 | * Constructor that specifies to how many digits the value should be
14 | * formatted.
15 | *
16 | * @param digits
17 | */
18 | public DayHighLightMarkValueFormatter(int digits) {
19 | super(digits);
20 | }
21 |
22 |
23 | @Override
24 | public String getBarLabel(BarEntry barEntry) {
25 | String str1 = TimeDateUtil.getDateStr(barEntry.timestamp, "M月d日");
26 | String str2 = TimeDateUtil.get12HourOfTheDayStr(barEntry.timestamp);
27 | String str3 = getFormattedValue(barEntry.getY());
28 | String resultStr = str1 + CONNECT_STR + str2 + CONNECT_STR + str3;
29 | return barEntry.getY() > 0 ? resultStr : "";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/XAxisDayFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.ValueFormatter;
5 | import com.yxc.commonlib.util.TimeDateUtil;
6 |
7 | /**
8 | * @author yxc
9 | * @date 2019/4/11
10 | */
11 | public class XAxisDayFormatter extends ValueFormatter {
12 |
13 | @Override
14 | public String getBarLabel(BarEntry barEntry) {
15 | if (barEntry.type == BarEntry.TYPE_XAXIS_SECOND
16 | || barEntry.type == BarEntry.TYPE_XAXIS_SPECIAL) {
17 | return TimeDateUtil.getHourOfTheDay(barEntry.timestamp) + "时";
18 | } else {
19 | return "";
20 | }
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/XAxisHrmFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.ValueFormatter;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/11
9 | */
10 | public class XAxisHrmFormatter extends ValueFormatter {
11 |
12 | @Override
13 | public String getBarLabel(BarEntry barEntry) {
14 | if (barEntry.type == BarEntry.TYPE_XAXIS_FIRST || barEntry.type == BarEntry.TYPE_XAXIS_SPECIAL) {
15 | int index = (int)barEntry.getX();
16 | return index/25 + "秒";
17 | } else {
18 | return "";
19 | }
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/XAxisMonthFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import android.content.Context;
4 |
5 | import com.yxc.barchart.R;
6 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
7 | import com.yxc.chartlib.recyclerchart.formatter.ValueFormatter;
8 |
9 | import org.joda.time.LocalDate;
10 |
11 | /**
12 | * @author yxc
13 | * @date 2019/4/11
14 | */
15 | public class XAxisMonthFormatter extends ValueFormatter {
16 |
17 | private Context mContext;
18 |
19 | public XAxisMonthFormatter(Context context){
20 | this.mContext = context;
21 | }
22 |
23 | @Override
24 | public String getBarLabel(BarEntry barEntry) {
25 | LocalDate localDate = barEntry.localDate;
26 | if (barEntry.type == BarEntry.TYPE_XAXIS_SPECIAL || barEntry.type == BarEntry.TYPE_XAXIS_SECOND){
27 | return String.format(mContext.getString(R.string.str_month_formatter), localDate.getDayOfMonth());
28 | }
29 | return "";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/XAxisWeekFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.ValueFormatter;
5 | import com.yxc.commonlib.util.TimeDateUtil;
6 |
7 | import org.joda.time.LocalDate;
8 |
9 | /**
10 | * @author yxc
11 | * @date 2019/4/11
12 | */
13 | public class XAxisWeekFormatter extends ValueFormatter {
14 |
15 | @Override
16 | public String getBarLabel(BarEntry barEntry) {
17 | LocalDate localDate = barEntry.localDate;
18 | // return TimeUtil.getDateStr(barEntry.timestamp, "MM-dd");
19 | return TimeDateUtil.getWeekStr(localDate.getDayOfWeek());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/XAxisYearFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.ValueFormatter;
5 |
6 | import org.joda.time.LocalDate;
7 |
8 | /**
9 | * @author yxc
10 | * @date 2019/4/11
11 | */
12 | public class XAxisYearFormatter extends ValueFormatter {
13 |
14 | @Override
15 | public String getBarLabel(BarEntry barEntry) {
16 | LocalDate localDate = barEntry.localDate;
17 | return Integer.toString(localDate.getMonthOfYear());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/formatter/YearHighLightMarkValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.chartlib.recyclerchart.formatter.DefaultHighLightMarkValueFormatter;
5 | import com.yxc.commonlib.util.TimeDateUtil;
6 |
7 | /**
8 | * @author yxc
9 | * @date 2019/4/24
10 | */
11 | public class YearHighLightMarkValueFormatter extends DefaultHighLightMarkValueFormatter {
12 | /**
13 | * Constructor that specifies to how many digits the value should be
14 | * formatted.
15 | *
16 | * @param digits
17 | */
18 | public YearHighLightMarkValueFormatter(int digits) {
19 | super(digits);
20 | }
21 |
22 | @Override
23 | public String getFormattedValue(float value) {
24 | return super.getFormattedValue(value);
25 | }
26 |
27 | @Override
28 | public String getBarLabel(BarEntry barEntry) {
29 | String str1 = TimeDateUtil.getDateStr(barEntry.timestamp, "M月");
30 | String str2 = TimeDateUtil.getDateStr(barEntry.timestamp, "yyyy年");
31 | String str3 = "日均";
32 | String str4 = getFormattedValue(barEntry.getY());
33 | String resultStr = str1 + CONNECT_STR + str2 + CONNECT_STR + str3 + CONNECT_STR + str4;
34 | return barEntry.getY() > 0 ?resultStr:"";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/event/LocationEvent.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.event;
2 |
3 | import android.location.Location;
4 |
5 | import com.amap.api.location.AMapLocation;
6 | import com.yxc.barchart.map.model.RecordLocation;
7 |
8 | /**
9 | * @author yxc
10 | * @date 2019-06-14
11 | */
12 | public class LocationEvent {
13 |
14 | public AMapLocation mapLocation;
15 |
16 | public final RecordLocation recordLocation;
17 |
18 | public Location location;
19 |
20 | public LocationEvent(AMapLocation mapLocation, RecordLocation recordLocation){
21 | this.mapLocation = mapLocation;
22 | this.recordLocation = recordLocation;
23 | }
24 |
25 | public LocationEvent(Location mapLocation, RecordLocation recordLocation){
26 | this.location = mapLocation;
27 | this.recordLocation = recordLocation;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/recycler/RecordItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.recycler;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Color;
5 | import android.graphics.Paint;
6 | import android.view.View;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | /**
12 | * @author yxc
13 | * @date 2019-06-20
14 | */
15 | public class RecordItemDecoration extends RecyclerView.ItemDecoration {
16 |
17 | Paint mLinePaint;
18 |
19 | public RecordItemDecoration(){
20 | initPaint();
21 | }
22 |
23 | private void initPaint(){
24 | mLinePaint = new Paint();
25 | mLinePaint.reset();
26 | mLinePaint.setAntiAlias(true);
27 | mLinePaint.setStyle(Paint.Style.STROKE);
28 | mLinePaint.setStrokeWidth(1);
29 | mLinePaint.setColor(Color.GRAY);
30 | }
31 |
32 | @Override
33 | public void onDrawOver(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
34 | super.onDrawOver(canvas, parent, state);
35 | int childCount = parent.getChildCount();
36 |
37 | for (int i = 0; i < childCount; i++) {
38 | View child = parent.getChildAt(i);
39 | canvas.drawLine(parent.getLeft(), child.getBottom(), parent.getRight(), child.getBottom(), mLinePaint);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/util/Gps.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.util;
2 |
3 | /**
4 | * @author yxc
5 | * @since 2019-08-30
6 | */
7 | public class Gps {
8 |
9 | private double latitude;
10 | private double longitude;
11 | private double altitude;
12 |
13 | public Gps(double latitude, double longitude) {
14 | setLatitude(latitude);
15 | setLongitude(longitude);
16 | }
17 |
18 | public Gps(double latitude, double longitude, double altitude) {
19 | this(latitude, longitude);
20 | this.altitude = altitude;
21 | }
22 |
23 | public double getLatitude() {
24 | return latitude;
25 | }
26 |
27 | public void setLatitude(double latitude) {
28 | this.latitude = latitude;
29 | }
30 |
31 | public double getLongitude() {
32 | return longitude;
33 | }
34 |
35 | public void setLongitude(double longitude) {
36 | this.longitude = longitude;
37 | }
38 |
39 | public double getAltitude() {
40 | return altitude;
41 | }
42 |
43 |
44 | @Override
45 | public String toString() {
46 | return latitude + "," + longitude + "," + altitude;
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/util/IWifiAutoCloseDelegate.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.util;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by liangchao_suxun on 17/1/19.
7 | * 代理类,用于处理息屏造成wifi被关掉时再重新点亮屏幕的逻辑
8 | */
9 |
10 | public interface IWifiAutoCloseDelegate {
11 |
12 |
13 | /**
14 | * 判断在该机型下此逻辑是否有效。目前已知的系统是小米系统存在(用户自助设置的)息屏断掉wifi的功能。
15 | *
16 | * @param context
17 | * @return
18 | */
19 | public boolean isUseful(Context context);
20 |
21 |
22 | /**
23 | * 点亮屏幕的服务有可能被重启。此处进行初始化
24 | *
25 | * @param context
26 | * @return
27 | */
28 | public void initOnServiceStarted(Context context);
29 |
30 |
31 | /**
32 | * 定位成功时,如果移动网络无法访问,而且屏幕是点亮状态,则对状态进行保存
33 | */
34 | public void onLocateSuccess(Context context, boolean isScreenOn, boolean isMobileable);
35 |
36 | /**
37 | * 对定位失败情况的处理
38 | */
39 | public void onLocateFail(Context context, int errorCode, boolean isScreenOn, boolean isWifiable);
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/util/LocationConstants.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.util;
2 |
3 | /**
4 | * @author yxc
5 | * @since 2019-06-11
6 | */
7 | public class LocationConstants {
8 |
9 | public static final int SPORT_TYPE_STEP = 1; //走路
10 |
11 | public static final int SPORT_TYPE_RUNNING = 2; //走路
12 |
13 | public static final int SPORT_TYPE_RIDE = 3;//骑车
14 |
15 | public static final int SPORT_TYPE_DRIVE = 4;//驾驶
16 |
17 | public static final long DEFAULT_INTERVAL_TIME = 2 * 1000;
18 |
19 | public static final String KEY_RECORD_TYPE = "recordType";//
20 |
21 | public static final String KEY_RECORD_ID = "recordId";//
22 |
23 | public static final String ACTION_LOCATION_BACKGROUND = "location_in_background";
24 |
25 | public static final long MILE_POST_ONE_KILOMETRE = 1000;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/util/NetUtil.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.util;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | /**
8 | * Created by liangchao_suxun on 17/1/16.
9 | * 用于判断设备是否可以访问网络。
10 | */
11 |
12 | public class NetUtil {
13 |
14 | private static class Holder {
15 | public static NetUtil instance = new NetUtil();
16 | }
17 |
18 | public static NetUtil getInstance() {
19 | return Holder.instance;
20 | }
21 |
22 | /**
23 | * 是否手机信号可连接
24 | * @param context
25 | * @return
26 | */
27 | public boolean isMobileAva(Context context) {
28 |
29 | boolean hasMobileCon = false;
30 |
31 | ConnectivityManager cm = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
32 | NetworkInfo[] netInfos = cm.getAllNetworkInfo();
33 | for (NetworkInfo net : netInfos) {
34 |
35 | String type = net.getTypeName();
36 | if (type.equalsIgnoreCase("MOBILE")) {
37 | if (net.isConnected()) {
38 | hasMobileCon = true;
39 | }
40 | }
41 | }
42 | return hasMobileCon;
43 | }
44 |
45 |
46 | /**
47 | * 是否wifi可连接
48 | * @param context
49 | * @return
50 | */
51 | public boolean isWifiCon(Context context) {
52 | boolean hasWifoCon = false;
53 |
54 | ConnectivityManager cm = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
55 | NetworkInfo[] netInfos = cm.getAllNetworkInfo();
56 | for (NetworkInfo net : netInfos) {
57 |
58 | String type = net.getTypeName();
59 | if (type.equalsIgnoreCase("WIFI")) {
60 | if (net.isConnected()) {
61 | hasWifoCon = true;
62 | }
63 | }
64 |
65 | }
66 | return hasWifoCon;
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/location/util/WifiAutoCloseDelegate.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.location.util;
2 |
3 | import android.content.Context;
4 |
5 | import com.amap.api.location.AMapLocation;
6 |
7 | import java.util.regex.Matcher;
8 | import java.util.regex.Pattern;
9 |
10 | public class WifiAutoCloseDelegate implements IWifiAutoCloseDelegate {
11 |
12 | /**
13 | * 请根据后台数据自行添加。此处只针对小米手机
14 | * @param context
15 | * @return
16 | */
17 | @Override
18 | public boolean isUseful(Context context) {
19 | String manName = Utils.getManufacture(context);
20 | Pattern pattern = Pattern.compile("xiaomi", Pattern.CASE_INSENSITIVE);
21 | Matcher m = pattern.matcher(manName);
22 | return m.find();
23 | }
24 |
25 | @Override
26 | public void initOnServiceStarted(Context context) {
27 | LocationStatusManager.getInstance().initStateFromPreference(context);
28 | }
29 |
30 | @Override
31 | public void onLocateSuccess(Context context, boolean isScreenOn, boolean isMobileable) {
32 | LocationStatusManager.getInstance().onLocationSuccess(context, isScreenOn, isMobileable);
33 | }
34 |
35 | @Override
36 | public void onLocateFail(Context context, int errorCode, boolean isScreenOn, boolean isWifiable) {
37 |
38 | //如果屏幕点亮情况下,因为断网失败,则表示不是屏幕点亮造成的断网失败,并修改参照值
39 | if (isScreenOn && errorCode == AMapLocation.ERROR_CODE_FAILURE_CONNECTION && !isWifiable) {
40 | LocationStatusManager.getInstance().resetToInit(context);
41 | return;
42 | }
43 |
44 | if (!LocationStatusManager.getInstance().isFailOnScreenOff(context, errorCode, isScreenOn, isWifiable)) {
45 | return;
46 | }
47 | PowerManagerUtil.getInstance().wakeUpScreen(context);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/model/RecordLocationSerializer.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.model;
2 |
3 | import com.google.gson.JsonElement;
4 | import com.google.gson.JsonObject;
5 | import com.google.gson.JsonSerializationContext;
6 | import com.google.gson.JsonSerializer;
7 |
8 | import java.lang.reflect.Type;
9 |
10 | /**
11 | * @author yxc
12 | * @date 2019-06-14
13 | */
14 | public class RecordLocationSerializer implements JsonSerializer {
15 | @Override
16 | public JsonElement serialize(RecordLocation src, Type typeOfSrc, JsonSerializationContext context) {
17 | final JsonObject jsonObject = new JsonObject();
18 | jsonObject.addProperty("timestamp", src.getTimestamp());
19 | jsonObject.addProperty("endTime", src.getEndTime());
20 | jsonObject.addProperty("duration", src.getDuration());
21 | jsonObject.addProperty("longitude", src.getLongitude());
22 | jsonObject.addProperty("latitude", src.getLatitude());
23 | jsonObject.addProperty("speed", src.getSpeed());
24 | jsonObject.addProperty("itemDistance", src.getItemDistance());
25 | jsonObject.addProperty("distance", src.getDistance());
26 | jsonObject.addProperty("recordId", src.getRecordId());
27 | jsonObject.addProperty("recordType", src.getRecordType());
28 | jsonObject.addProperty("locationStr", src.getLocationStr());
29 | jsonObject.addProperty("milePost", src.getMilePost());
30 | return jsonObject;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/map/util/Constants.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.map.util;
2 |
3 |
4 | import com.amap.api.maps.model.LatLng;
5 |
6 | public class Constants {
7 |
8 | public static final int ERROR = 1001;// 网络异常
9 | public static final int ROUTE_START_SEARCH = 2000;
10 | public static final int ROUTE_END_SEARCH = 2001;
11 | public static final int ROUTE_BUS_RESULT = 2002;// 路径规划中公交模式
12 | public static final int ROUTE_DRIVING_RESULT = 2003;// 路径规划中驾车模式
13 | public static final int ROUTE_WALK_RESULT = 2004;// 路径规划中步行模式
14 | public static final int ROUTE_NO_RESULT = 2005;// 路径规划没有搜索到结果
15 |
16 | public static final int GEOCODER_RESULT = 3000;// 地理编码或者逆地理编码成功
17 | public static final int GEOCODER_NO_RESULT = 3001;// 地理编码或者逆地理编码没有数据
18 |
19 | public static final int POISEARCH = 4000;// poi搜索到结果
20 | public static final int POISEARCH_NO_RESULT = 4001;// poi没有搜索到结果
21 | public static final int POISEARCH_NEXT = 5000;// poi搜索下一页
22 |
23 | public static final int BUSLINE_LINE_RESULT = 6001;// 公交线路查询
24 | public static final int BUSLINE_id_RESULT = 6002;// 公交id查询
25 | public static final int BUSLINE_NO_RESULT = 6003;// 异常情况
26 |
27 | public static final LatLng BEIJING = new LatLng(39.90403, 116.407525);// 北京市经纬度
28 | public static final LatLng ZHONGGUANCUN = new LatLng(39.983456, 116.3154950);// 北京市中关村经纬度
29 | public static final LatLng SHANGHAI = new LatLng(31.238068, 121.501654);// 上海市经纬度
30 | public static final LatLng FANGHENG = new LatLng(39.989614, 116.481763);// 方恒国际中心经纬度
31 | public static final LatLng CHENGDU = new LatLng(30.679879, 104.064855);// 成都市经纬度
32 | public static final LatLng XIAN = new LatLng(34.341568, 108.940174);// 西安市经纬度
33 | public static final LatLng ZHENGZHOU = new LatLng(34.7466, 113.625367);// 郑州市经纬度
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/tab/FragmentChangeManager.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.tab;
2 |
3 | import androidx.fragment.app.Fragment;
4 | import androidx.fragment.app.FragmentManager;
5 | import androidx.fragment.app.FragmentTransaction;
6 |
7 | import java.util.ArrayList;
8 |
9 | public class FragmentChangeManager {
10 | private FragmentManager mFragmentManager;
11 | private int mContainerViewId;
12 | /** Fragment切换数组 */
13 | private ArrayList mFragments;
14 | /** 当前选中的Tab */
15 | private int mCurrentTab;
16 |
17 | public FragmentChangeManager(FragmentManager fm, int containerViewId, ArrayList fragments) {
18 | this.mFragmentManager = fm;
19 | this.mContainerViewId = containerViewId;
20 | this.mFragments = fragments;
21 | initFragments();
22 | }
23 |
24 | /** 初始化fragments */
25 | private void initFragments() {
26 | for (Fragment fragment : mFragments) {
27 | mFragmentManager.beginTransaction().add(mContainerViewId, fragment).hide(fragment).commit();
28 | }
29 |
30 | setFragments(0);
31 | }
32 |
33 | /** 界面切换控制 */
34 | public void setFragments(int index) {
35 | for (int i = 0; i < mFragments.size(); i++) {
36 | FragmentTransaction ft = mFragmentManager.beginTransaction();
37 | Fragment fragment = mFragments.get(i);
38 | if (i == index) {
39 | ft.show(fragment);
40 | } else {
41 | ft.hide(fragment);
42 | }
43 | ft.commit();
44 | }
45 | mCurrentTab = index;
46 | }
47 |
48 | public int getCurrentTab() {
49 | return mCurrentTab;
50 | }
51 |
52 | public Fragment getCurrentFragment() {
53 | return mFragments.get(mCurrentTab);
54 | }
55 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/tab/OnTabSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.tab;
2 |
3 | public interface OnTabSelectListener {
4 | void onTabSelect(int position);
5 | void onTabReselect(int position);
6 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ui/base/BaseChartFragment.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.ui.base;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019-05-07
6 | */
7 | public abstract class BaseChartFragment extends BaseFragment{
8 | public abstract void resetSelectedEntry();
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ui/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.ui.base;
2 |
3 | import androidx.fragment.app.Fragment;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019/4/26
8 | */
9 | public class BaseFragment extends Fragment {
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ui/bezier/BaseBezierFragment.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.ui.bezier;
2 |
3 | import android.view.View;
4 |
5 | import com.yxc.barchart.ui.base.BaseChartFragment;
6 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
7 | import com.yxc.chartlib.recyclerchart.listener.RecyclerItemGestureListener;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * @author yxc
14 | * @since 2019-05-13
15 | */
16 | public abstract class BaseBezierFragment extends BaseChartFragment {
17 |
18 | protected List visibleEntries;
19 |
20 | protected OnRateSelectChangedListener mRateSelectChangedListener;
21 |
22 | protected RecyclerItemGestureListener mItemGestureListener;
23 |
24 | public interface OnRateSelectChangedListener {
25 |
26 | void onDayChanged(List visibleEntries);
27 |
28 | void onMonthChanged(List visibleEntries);
29 |
30 | void onWeekSelectChanged(List visibleEntries);
31 |
32 | void onYearSelectChanged(List visibleEntries);
33 | }
34 |
35 | public void setOnRateSelectChangedListener(OnRateSelectChangedListener listener) {
36 | this.mRateSelectChangedListener = listener;
37 | }
38 |
39 | //防止 Fragment重叠
40 | @Override
41 | public void setMenuVisibility(boolean menuVisible) {
42 | super.setMenuVisibility(menuVisible);
43 | if (this.getView() != null) {
44 | this.getView().setVisibility(menuVisible ? View.VISIBLE : View.GONE);
45 | }
46 | }
47 |
48 | protected void setVisibleEntries(List barEntries) {
49 | if (null == visibleEntries) {
50 | visibleEntries = new ArrayList<>();
51 | } else {
52 | visibleEntries.clear();
53 | }
54 | visibleEntries.addAll(barEntries);
55 | displayDateAndRate();
56 | }
57 |
58 | public void resetSelectedEntry(){
59 | if (mItemGestureListener != null){
60 | mItemGestureListener.resetSelectedBarEntry();
61 | }
62 | }
63 |
64 | public abstract void displayDateAndRate();
65 |
66 | public abstract void scrollToCurrentCycle();//回到当前周期
67 |
68 |
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ui/line/BaseLineFragment.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.ui.line;
2 |
3 | import android.view.View;
4 |
5 | import com.yxc.barchart.ui.base.BaseChartFragment;
6 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
7 | import com.yxc.chartlib.recyclerchart.listener.RecyclerItemGestureListener;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * @author yxc
14 | * @since 2019-05-13
15 | */
16 | public abstract class BaseLineFragment extends BaseChartFragment {
17 |
18 | protected List visibleEntries;
19 |
20 | protected OnRateSelectChangedListener mRateSelectChangedListener;
21 |
22 | protected RecyclerItemGestureListener mItemGestureListener;
23 |
24 | public interface OnRateSelectChangedListener {
25 |
26 | void onDayChanged(List visibleEntries);
27 |
28 | void onMonthChanged(List visibleEntries);
29 |
30 | void onWeekSelectChanged(List visibleEntries);
31 |
32 | void onYearSelectChanged(List visibleEntries);
33 | }
34 |
35 | public void setOnRateSelectChangedListener(OnRateSelectChangedListener listener) {
36 | this.mRateSelectChangedListener = listener;
37 | }
38 |
39 | //防止 Fragment重叠
40 | @Override
41 | public void setMenuVisibility(boolean menuVisible) {
42 | super.setMenuVisibility(menuVisible);
43 | if (this.getView() != null) {
44 | this.getView().setVisibility(menuVisible ? View.VISIBLE : View.GONE);
45 | }
46 | }
47 |
48 | protected void setVisibleEntries(List barEntries) {
49 | if (null == visibleEntries) {
50 | visibleEntries = new ArrayList<>();
51 | } else {
52 | visibleEntries.clear();
53 | }
54 | visibleEntries.addAll(barEntries);
55 | displayDateAndRate();
56 | }
57 |
58 | public void resetSelectedEntry(){
59 | if (mItemGestureListener != null){
60 | mItemGestureListener.resetSelectedBarEntry();
61 | }
62 | }
63 |
64 | public abstract void displayDateAndRate();
65 |
66 | public abstract void scrollToCurrentCycle();//回到当前周期
67 |
68 |
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ui/rainbow/RainbowActivity.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.ui.rainbow;
2 |
3 | import android.os.Bundle;
4 | import android.view.MenuItem;
5 | import android.view.View;
6 | import android.widget.Button;
7 |
8 | import androidx.annotation.Nullable;
9 | import androidx.appcompat.app.AppCompatActivity;
10 | import androidx.appcompat.widget.Toolbar;
11 |
12 | import com.yxc.barchart.R;
13 | import com.yxc.barchart.view.Rainbow;
14 | import com.yxc.commonlib.util.ColorUtil;
15 | import com.yxc.commonlib.util.TimeDateUtil;
16 |
17 | import org.joda.time.LocalDate;
18 |
19 | /**
20 | * @author yxc
21 | * @since 2019/4/26
22 | */
23 | public class RainbowActivity extends AppCompatActivity {
24 |
25 | Toolbar toolbar;
26 | Rainbow mContainer;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_rainbow2);
32 | initView();
33 | }
34 |
35 | private void initView() {
36 | toolbar = findViewById(R.id.toolBar);
37 | toolbar.setTitle(TimeDateUtil.getDateStr(TimeDateUtil.localDateToTimestamp(LocalDate.now()), "M月dd日"));
38 | toolbar.setNavigationIcon(R.drawable.ic_chevron_left_white_45dp);
39 | toolbar.setTitleTextColor(ColorUtil.getResourcesColor(this, R.color.white));
40 | setSupportActionBar(toolbar);
41 | mContainer = findViewById(R.id.rainbow);
42 | }
43 |
44 | @Override
45 | public boolean onOptionsItemSelected(MenuItem item) {
46 | if(item.getItemId()==android.R.id.home){
47 | finish();
48 | return true;
49 | }
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/ui/step/BaseStepFragment.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.ui.step;
2 |
3 | import android.view.View;
4 |
5 | import com.yxc.barchart.ui.base.BaseChartFragment;
6 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
7 | import com.yxc.chartlib.recyclerchart.listener.RecyclerItemGestureListener;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * @author yxc
14 | * @since 2019-05-13
15 | */
16 | public abstract class BaseStepFragment extends BaseChartFragment {
17 |
18 | protected List visibleEntries;
19 |
20 | protected OnRateSelectChangedListener mRateSelectChangedListener;
21 |
22 | protected RecyclerItemGestureListener mItemGestureListener;
23 |
24 | public interface OnRateSelectChangedListener {
25 |
26 | void onDayChanged(List visibleEntries);
27 |
28 | void onMonthChanged(List visibleEntries);
29 |
30 | void onWeekSelectChanged(List visibleEntries);
31 |
32 | void onYearSelectChanged(List visibleEntries);
33 | }
34 |
35 | public void setOnRateSelectChangedListener(OnRateSelectChangedListener listener) {
36 | this.mRateSelectChangedListener = listener;
37 | }
38 |
39 | //防止 Fragment重叠
40 | @Override
41 | public void setMenuVisibility(boolean menuVisible) {
42 | super.setMenuVisibility(menuVisible);
43 | if (this.getView() != null) {
44 | this.getView().setVisibility(menuVisible ? View.VISIBLE : View.GONE);
45 | }
46 | }
47 |
48 | protected void setVisibleEntries(List barEntries) {
49 | if (null == visibleEntries) {
50 | visibleEntries = new ArrayList<>();
51 | } else {
52 | visibleEntries.clear();
53 | }
54 | visibleEntries.addAll(barEntries);
55 | displayDateAndRate();
56 | }
57 |
58 | public void resetSelectedEntry(){
59 | if (mItemGestureListener != null){
60 | mItemGestureListener.resetSelectedBarEntry();
61 | }
62 | }
63 |
64 | public abstract void displayDateAndRate();
65 |
66 | public abstract void scrollToCurrentCycle();//回到当前周期
67 |
68 |
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/BezierCircleModel.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | public class BezierCircleModel {
4 |
5 | public VPoint p2;
6 | public VPoint p4;
7 | public HPoint p1;
8 | public HPoint p3;
9 |
10 | public BezierCircleModel(HPoint p1, HPoint p3, VPoint p2, VPoint p4){
11 | this.p1 = p1;
12 | this.p2 = p2;
13 | this.p3 = p3;
14 | this.p4 = p4;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/HPoint.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | import android.graphics.PointF;
4 |
5 | public class HPoint {
6 | public float x;
7 | public float y;
8 | public PointF left = new PointF();
9 | public PointF right = new PointF();
10 |
11 | public void setY(float y) {
12 | this.y = y;
13 | left.y = y;
14 | right.y = y;
15 | }
16 |
17 | public void adjustAllX(float offset) {
18 | this.x += offset;
19 | left.x += offset;
20 | right.x += offset;
21 | }
22 |
23 | public void adjustAllY(float offset) {
24 | this.y += offset;
25 | left.y += offset;
26 | right.y += offset;
27 | }
28 |
29 | public void adjustAllXY(float x, float y) {
30 | adjustAllX(x);
31 | adjustAllY(y);
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/PathMeasureModel.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | public class PathMeasureModel {
4 |
5 | float firstPointLength;
6 | float endPointLength;
7 |
8 | public void setFirstPointLength(float firstPointLength) {
9 | this.firstPointLength = firstPointLength;
10 | }
11 |
12 | public void setEndPointLength(float endPointLength) {
13 | this.endPointLength = endPointLength;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/PathModel.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | import android.graphics.Path;
4 | import android.graphics.PointF;
5 | import android.graphics.RectF;
6 |
7 | public class PathModel {
8 | PointF startPointF;
9 | PointF endPointF;
10 | Path pathArc;
11 | Path startPathArc;
12 | Path endPathArc;
13 | RectF startSmallRectF;
14 | RectF endSmallRectF;
15 | float halfSquareWidth;
16 |
17 | public PathModel(PointF startPointF, PointF endPointF, Path pathArc) {
18 | this.startPointF = startPointF;
19 | this.endPointF = endPointF;
20 | this.pathArc = pathArc;
21 | }
22 |
23 | public void setEndPathArc(Path endPathArc) {
24 | this.endPathArc = endPathArc;
25 | }
26 |
27 | public void setStartPathArc(Path startPathArc) {
28 | this.startPathArc = startPathArc;
29 | }
30 |
31 | public void setStartSmallRectF(RectF startSmallRectF) {
32 | this.startSmallRectF = startSmallRectF;
33 | }
34 |
35 | public void setEndSmallRectF(RectF endSmallRectF) {
36 | this.endSmallRectF = endSmallRectF;
37 | }
38 |
39 | public void setHalfSquareWidth(float halfSquareWidth) {
40 | this.halfSquareWidth = halfSquareWidth;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/QuadModel.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | import android.graphics.Path;
4 | import android.graphics.PathMeasure;
5 | import android.graphics.PointF;
6 | import android.graphics.RectF;
7 |
8 | public class QuadModel {
9 |
10 | public PointF startPointF;
11 | public PointF endPointF;
12 | public PointF ctrlPointF;
13 | public PointF centerPointF;
14 |
15 | Path quadPath;
16 |
17 | public Path createQuadPath(){
18 | quadPath = new Path();
19 | quadPath.moveTo(startPointF.x, startPointF.y);
20 | quadPath.quadTo(ctrlPointF.x, ctrlPointF.y, endPointF.x, endPointF.y);
21 | quadPath.lineTo(centerPointF.x, centerPointF.y);
22 | quadPath.close();
23 | return quadPath;
24 | }
25 |
26 | public PointF createCommonPoint(RectF rectF, float sweepAngel) {
27 | float radius = rectF.width() / 2;
28 | float halfCircleLength = (float) (Math.PI * radius);
29 | Path pathOriginal = new Path();
30 | pathOriginal.moveTo(rectF.left, (rectF.top + rectF.bottom) / 2);
31 | pathOriginal.arcTo(rectF, 180, 180, false);
32 | PathMeasure pathMeasure = new PathMeasure(pathOriginal, false);
33 | float[] points = new float[2];
34 | float pointLength = halfCircleLength * sweepAngel / 180.f;
35 | pathMeasure.getPosTan(pointLength, points, null);
36 | return new PointF(points[0], points[1]);
37 | }
38 |
39 | public PointF createEndPoint(RectF rectF, float sweepAngel) {
40 | float radius = rectF.width() / 2;
41 | float halfCircleLength = (float) (Math.PI * radius);
42 | Path pathOriginal = new Path();
43 | pathOriginal.moveTo(rectF.right, (rectF.top + rectF.bottom) / 2);
44 | pathOriginal.arcTo(rectF, 0, -180, false);
45 | PathMeasure pathMeasure = new PathMeasure(pathOriginal, false);
46 | float[] points = new float[2];
47 | float pointLength = halfCircleLength * sweepAngel / 180.f;
48 | pathMeasure.getPosTan(pointLength, points, null);
49 | return new PointF(points[0], points[1]);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/ThreeTargetConstant.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | import com.yxc.commonlib.util.DisplayUtil;
4 |
5 | public class ThreeTargetConstant {
6 |
7 | public static float RESIZE = DisplayUtil.dip2px(0.14285712688f);
8 | public static int TRANSPARENT_VALUE = (int) (255 * 0.4);
9 |
10 | public static float FIRST_WRAPPER_FIX_ANGLE = 2.05f;
11 | public static float FIRST_INNER_FIX_ANGLE = 2.7f;
12 |
13 | public static float SECOND_WRAPPER_FIX_ANGLE = 3f;
14 | public static float SECOND_INNER_FIX_ANGLE = 4.7f;
15 |
16 | public static float THIRD_WRAPPER_FIX_ANGLE = 3.8f;
17 | public static float THIRD_INNER_FIX_ANGLE = 15f;
18 |
19 | public static int TARGET_FIRST_TYPE = 1;
20 | public static int TARGET_SECOND_TYPE = 2;
21 | public static int TARGET_THIRD_TYPE = 3;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yxc/barchart/view/VPoint.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart.view;
2 |
3 | import android.graphics.PointF;
4 |
5 | public class VPoint {
6 | public float x;
7 | public float y;
8 | public PointF top = new PointF();
9 | public PointF bottom = new PointF();
10 |
11 | public void setX(float x) {
12 | this.x = x;
13 | top.x = x;
14 | bottom.x = x;
15 | }
16 |
17 | public void adjustY(float offset) {
18 | top.y -= offset;
19 | bottom.y += offset;
20 | }
21 |
22 | public void adjustAllX(float offset) {
23 | this.x += offset;
24 | top.x += offset;
25 | bottom.x += offset;
26 | }
27 |
28 | public void adjustAllY(float offset) {
29 | this.y += offset;
30 | top.y += offset;
31 | bottom.y += offset;
32 | }
33 |
34 | public void adjustAllXY(float x, float y) {
35 | adjustAllX(x);
36 | adjustAllY(y);
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/rx/Observable.java:
--------------------------------------------------------------------------------
1 | package rx;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019-06-14
6 | */
7 | public class Observable {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/jniLibs/arm64-v8a/libAMapSDK_MAP_v6_5_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/jniLibs/arm64-v8a/libAMapSDK_MAP_v6_5_0.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libAMapSDK_MAP_v6_5_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/jniLibs/armeabi-v7a/libAMapSDK_MAP_v6_5_0.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libAMapSDK_MAP_v6_5_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/jniLibs/armeabi/libAMapSDK_MAP_v6_5_0.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libAMapSDK_MAP_v6_5_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/jniLibs/x86/libAMapSDK_MAP_v6_5_0.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86_64/libAMapSDK_MAP_v6_5_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/jniLibs/x86_64/libAMapSDK_MAP_v6_5_0.so
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xhdpi/icon_location.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xhdpi/walk.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/back_btn_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/back_btn_image.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/end.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/end.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/gps.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/grasp_flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/grasp_flag.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/grasp_trace_line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/grasp_trace_line.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/location.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/point.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/point.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/point5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/point5.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/start.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/test.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/title_background.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable-xxhdpi/title_background.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable/border_bg.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_map_poi.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_info_bubble.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable/custom_info_bubble.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/direct_mapsearch.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable/direct_mapsearch.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/direct_mapsearch_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable/direct_mapsearch_pressed.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_chevron_left_black_30dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_chevron_left_white_45dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_chevron_right_black_30dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_mile_post_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_navigate_back_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_navigation_left_black_45dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_data_item_bg_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/title_background.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/drawable/title_background.9.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/abroadmap_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
28 |
29 |
30 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_bar_animator.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_bezier.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_hrm.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
29 |
30 |
34 |
35 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_maps.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_maps_google.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rainbow.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
28 |
29 |
30 |
35 |
36 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rainbow2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
28 |
29 |
30 |
35 |
36 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_sleep.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
27 |
28 |
29 |
33 |
34 |
41 |
42 |
50 |
51 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_step.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
29 |
30 |
34 |
35 |
50 |
51 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_touch.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
20 |
21 |
22 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_two_map.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/arc_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/basemap_fragment_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/camera_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
19 |
23 |
24 |
29 |
30 |
35 |
36 |
37 |
38 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/circle_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_barchart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_info_contents.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
19 |
20 |
30 |
31 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_info_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
19 |
20 |
30 |
31 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_location_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/events_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_day_ecg.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
17 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_sleep.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gesture_settings_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
24 |
25 |
32 |
33 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/groundoverlay_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_layout_barchart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layers_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
20 |
21 |
22 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_record_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
25 |
26 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_step_bottom_desc.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_step_date_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
28 |
29 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_tab_segment.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/locationsource_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/marker_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
15 |
16 |
23 |
24 |
27 |
28 |
34 |
35 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/osmmap_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/polygon_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/polyline_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/screenshot_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
20 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/zoom_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
24 |
25 |
26 |
27 |
28 |
34 |
35 |
43 |
44 |
53 |
54 |
55 |
56 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/badge_sa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/badge_sa.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/badge_wa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/badge_wa.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/gps_point.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/gps_point.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/groundoverlay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/groundoverlay.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/location_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/location_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/navi_map_gps_locked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxhdpi/navi_map_gps_locked.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #ff3300
7 |
8 |
9 |
10 | #000000
11 | #CD000000
12 | #B3000000
13 | #A0000000
14 | #80000000
15 | #66000000
16 | #60000000
17 | #30000000
18 | #27000000
19 | #1A000000
20 | #10000000
21 | #08000000
22 | #00000000
23 |
24 | #FFF76E6E
25 | #FFF76E6E
26 | #d5d5d5
27 | #ffffff
28 | #00000000
29 |
30 |
31 | #bebfc1
32 | #fd7546
33 | #fc5d21
34 |
35 | #12BE7A
36 | #38CF8A
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/release/res/values/google_maps_api.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 | AIzaSyCkzjXUTDxqpXIPB7STK7RF400KFl7tpiA
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/yxc/barchart/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.barchart;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/barchartlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/barchartlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 32
5 |
6 | defaultConfig {
7 | minSdkVersion 24
8 | targetSdkVersion 32
9 | versionCode 1
10 | versionName "1.0"
11 |
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 |
28 | implementation 'androidx.appcompat:appcompat:1.0.0'
29 | testImplementation 'junit:junit:4.12'
30 | androidTestImplementation 'androidx.test:runner:1.1.0'
31 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
32 |
33 | implementation 'androidx.appcompat:appcompat:1.0.0'
34 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
35 | implementation 'com.google.android.material:material:1.0.0'
36 | implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
37 | api project(':commonlib')
38 | }
39 |
--------------------------------------------------------------------------------
/barchartlib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/barchartlib/src/androidTest/java/com/yxc/chartlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yxc.barchartlib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/barchartlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/attrs/BarChartAttrs.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.attrs;
2 |
3 | /**
4 | * @author yxc
5 | * @since 2019/4/9
6 | *
7 | */
8 | public class BarChartAttrs extends BaseChartAttrs{
9 |
10 | public float barChartRoundRectRadiusRatio;//圆角矩形半径占宽度的比率
11 | public float barChartValuePaddingBottom;//柱状图顶部value文字据柱状图的padding
12 | public int barChartValueTxtColor;//柱状图顶部value文字的颜色
13 | public float barChartValueTxtSize;//柱状图顶部value文字的大小
14 | public float barChartValuePaddingLeft;//柱状图顶部value文字不居中时据左的padding
15 | public float barChartValueTxtMaskSize;//value 顶部popup的文字大小
16 | public int barChartValueTxtMaskColor;//value 顶部popup的文字颜色
17 | public boolean averageDisplay;//画柱子时剩余的宽度分给部分柱子
18 |
19 | public int rateChartLightColor;
20 | public int rateChartDarkColor;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/attrs/BezierChartAttrs.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.attrs;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019-06-25
6 | */
7 | public class BezierChartAttrs extends BaseChartAttrs {
8 |
9 | public float bezierIntensity;//bezier curve intensity
10 | public boolean enableBezierLineFill;//
11 | public int bezierFillColor;
12 | public int bezierFillAlpha;
13 | public int bezierLinePaintColor;
14 | public float bezierLinePaintStrokeWidth;
15 | }
16 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/attrs/LineChartAttrs.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.attrs;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019-06-25
6 | */
7 | public class LineChartAttrs extends BaseChartAttrs {
8 | public static final int HIGH_LIGHT_LINE_BOTTOM = 1;//高亮线从bottom处开始画
9 | public static final int HIGH_LIGHT_LINE_Y = 2;//高亮线从y值处开始画
10 | public static final int HIGH_LIGHT_LINE_BOTTOM_Y = 3;//高亮线从bottom处开始画,到Y值处
11 |
12 | public float linePointRadius;//point的
13 | public float linePointSelectRadius;//选中的 SelectRadius
14 | public float linePointSelectStrokeWidth;//选中的点外层圈的 paint的strokeWidth。
15 | public int lineColor;//线的颜色
16 | public int lineHighLightType;//分从底部开始画,从y值处开始画。
17 | }
18 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/attrs/SleepChartAttrs.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.attrs;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019/4/26
6 | */
7 | public class SleepChartAttrs extends BaseChartAttrs {
8 |
9 | public int deepSleepColor;//
10 | public int slumberColor;//
11 | public int eyeMoveColor;//
12 | public int weakColor; //
13 | public float sleepItemHeight;//睡眠block的高度
14 | }
15 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/barchart/SpeedRatioLayoutManager.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.barchart;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 |
7 | import androidx.recyclerview.widget.LinearLayoutManager;
8 | import androidx.recyclerview.widget.RecyclerView;
9 |
10 | import com.yxc.chartlib.recyclerchart.attrs.BaseChartAttrs;
11 |
12 | /**
13 | * @author yxc
14 | * @since 2019/4/11
15 | */
16 | public class SpeedRatioLayoutManager extends LinearLayoutManager {
17 |
18 | private BaseChartAttrs mAttrs;
19 |
20 | private double ratioSpeed;
21 |
22 | public SpeedRatioLayoutManager(Context context, BaseChartAttrs attrs) {
23 | super(context);
24 | this.mAttrs = attrs;
25 | setOrientation(mAttrs.layoutManagerOrientation);
26 | setReverseLayout(mAttrs.layoutManagerReverseLayout);
27 | ratioSpeed = mAttrs.ratioSpeed;
28 | }
29 |
30 | public SpeedRatioLayoutManager(Context context, int orientation, boolean reverseLayout) {
31 | super(context, orientation, reverseLayout);
32 | }
33 |
34 | public SpeedRatioLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
35 | super(context, attrs, defStyleAttr, defStyleRes);
36 | }
37 |
38 | @Override
39 | public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
40 | //屏蔽之后无滑动效果,证明滑动的效果就是由这个函数实现
41 | int a = super.scrollHorizontallyBy((int) (ratioSpeed * dx), recycler, state);
42 | if (a == (int) (ratioSpeed * dx)) {
43 | Log.d("GestureListener", "set RatioSpeed dx: " + a);
44 | return dx;
45 | }
46 | return a;
47 | }
48 |
49 | public double getRatioSpeed() {
50 | return ratioSpeed;
51 | }
52 |
53 | public void setRatioSpeed(double ratioSpeed) {
54 | this.ratioSpeed = ratioSpeed;
55 | }
56 |
57 | public void resetRatioSpeed(){
58 | this.ratioSpeed = mAttrs.ratioSpeed;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/component/ChartRectF.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.component;
2 |
3 | import android.graphics.RectF;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019/4/8
8 | * 想做属性动画,包装的一个类
9 | */
10 | public class ChartRectF extends RectF {
11 |
12 | public float getLeft() {
13 | return left;
14 | }
15 |
16 | public void setLeft(float left) {
17 | this.left = left;
18 | }
19 |
20 | public float getTop() {
21 | return top;
22 | }
23 |
24 | public void setTop(float top) {
25 | this.top = top;
26 | }
27 |
28 | public float getRight() {
29 | return right;
30 | }
31 |
32 | public void setRight(float right) {
33 | this.right = right;
34 | }
35 |
36 | public float getBottom() {
37 | return bottom;
38 | }
39 |
40 | public void setBottom(float bottom) {
41 | this.bottom = bottom;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/component/DistanceCompare.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.component;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 |
5 | /**
6 | * @author yxc
7 | * @since 2019/4/9
8 | *
9 | */
10 | public class DistanceCompare {
11 |
12 | public int distanceLeft;
13 | public int distanceRight;
14 | public int position;
15 | public T barEntry;
16 |
17 | public DistanceCompare(int distanceLeft, int distanceRight){
18 | this.distanceLeft = distanceLeft;
19 | this.distanceRight = distanceRight;
20 | }
21 |
22 | //月线靠近左边
23 | public boolean isNearLeft(){
24 | return distanceLeft < distanceRight;
25 | }
26 |
27 | //月线靠近左边
28 | public boolean isNearRight(){
29 | return distanceLeft > distanceRight;
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return "DistanceCompare{" +
35 | "distanceLeft=" + distanceLeft +
36 | ", distanceRight=" + distanceRight +
37 | ", position=" + position +
38 | '}';
39 | }
40 |
41 |
42 | public void setPosition(int position) {
43 | this.position = position;
44 | }
45 |
46 | public void setBarEntry(T barEntry) {
47 | this.barEntry = barEntry;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/component/XAxis.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.component;
2 |
3 | import com.yxc.chartlib.recyclerchart.attrs.BaseChartAttrs;
4 | import com.yxc.chartlib.recyclerchart.formatter.ValueFormatter;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/8
9 | */
10 | public class XAxis extends AxisBase {
11 |
12 | public int displayNumbers;
13 | public int firstDividerColor;
14 | public int secondDividerColor;
15 | public int thirdDividerColor;
16 |
17 | public float labelTxtPadding;
18 |
19 | public XAxis(T attrs, int displayNumbers, ValueFormatter valueFormatter) {
20 | this(attrs, displayNumbers);
21 | setValueFormatter(valueFormatter);
22 | }
23 |
24 | public XAxis(T attrs, int displayNumbers) {
25 | this.displayNumbers = displayNumbers;
26 | setTextColor(attrs.xAxisTxtColor);
27 | setTextSize(attrs.xAxisTxtSize);
28 | this.firstDividerColor = attrs.xAxisFirstDividerColor;
29 | this.secondDividerColor = attrs.xAxisSecondDividerColor;
30 | this.thirdDividerColor = attrs.xAxisThirdDividerColor;
31 | this.labelTxtPadding = attrs.xAxisLabelTxtPadding;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/BarChart.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import android.graphics.RectF;
4 |
5 | import com.yxc.chartlib.recyclerchart.view.CustomAnimatedDecorator;
6 |
7 | import java.util.Objects;
8 |
9 | /**
10 | * @author yxc
11 | * @date 2019/4/18
12 | *
13 | */
14 | public class BarChart {
15 |
16 | public BarEntry mBayEntry;
17 |
18 | public RectF rectF;
19 |
20 | public boolean isSelected;
21 |
22 | public CustomAnimatedDecorator customAnimatedDecorator;
23 |
24 | public BarChart(BarEntry barEntry){
25 | this.mBayEntry = barEntry;
26 | }
27 |
28 |
29 | public BarEntry getBayEntry() {
30 | return mBayEntry;
31 | }
32 |
33 | public void setBayEntry(BarEntry mBayEntry) {
34 | this.mBayEntry = mBayEntry;
35 | }
36 |
37 |
38 | public RectF getRectF() {
39 | return rectF;
40 | }
41 |
42 | public void setRectF(RectF rectF) {
43 | this.rectF = rectF;
44 | }
45 |
46 | @Override
47 | public boolean equals(Object o) {
48 | if (this == o) return true;
49 | if (o == null || getClass() != o.getClass()) return false;
50 | BarChart barChart = (BarChart) o;
51 | return isSelected == barChart.isSelected &&
52 | Objects.equals(mBayEntry, barChart.mBayEntry) &&
53 | Objects.equals(rectF, barChart.rectF);
54 | }
55 |
56 | @Override
57 | public int hashCode() {
58 | return Objects.hash(mBayEntry, rectF, isSelected);
59 | }
60 |
61 |
62 | public CustomAnimatedDecorator getCustomAnimatedDecorator() {
63 | return customAnimatedDecorator;
64 | }
65 |
66 | public void setCustomAnimatedDecorator(CustomAnimatedDecorator customAnimatedDecorator) {
67 | this.customAnimatedDecorator = customAnimatedDecorator;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/BarEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import androidx.annotation.NonNull;
4 | import com.yxc.chartlib.recyclerchart.view.CustomAnimatedDecorator;
5 | import org.joda.time.LocalDate;
6 |
7 | import java.util.Objects;
8 |
9 | /**
10 | * @author yxc
11 | * @since 2019/4/6
12 | */
13 | public class BarEntry extends Entry implements Comparable {
14 |
15 | public static final int TYPE_XAXIS_FIRST = 1;//一个月
16 |
17 | public static final int TYPE_XAXIS_SECOND = 2;//7天的线,需要drawText
18 |
19 | public static final int TYPE_XAXIS_THIRD = 3;//最小刻度的线
20 |
21 | public static final int TYPE_XAXIS_SPECIAL = 4;//同时是月线以及7日分隔线
22 |
23 | public long timestamp;
24 |
25 | public int type;
26 |
27 | public LocalDate localDate;
28 |
29 | public CustomAnimatedDecorator getDrawable() {
30 | return drawable;
31 | }
32 |
33 | public void setDrawable(CustomAnimatedDecorator drawable) {
34 | this.drawable = drawable;
35 | }
36 |
37 | public CustomAnimatedDecorator drawable;
38 |
39 | public BarEntry() {
40 | }
41 |
42 | public BarEntry(float x, float y, long timestamp, int type){
43 | super(x, y);
44 | this.timestamp = timestamp;
45 | this.type = type;
46 | }
47 |
48 | @Override
49 | public int compareTo(@NonNull BarEntry o) {
50 | return (int) (o.timestamp - timestamp);
51 | }
52 |
53 |
54 | @Override
55 | public boolean equals(Object o) {
56 | if (this == o) return true;
57 | if (o == null || getClass() != o.getClass()) return false;
58 | BarEntry barEntry = (BarEntry) o;
59 | return timestamp == barEntry.timestamp &&
60 | type == barEntry.type &&
61 | Objects.equals(localDate, barEntry.localDate);
62 | }
63 |
64 | @Override
65 | public int hashCode() {
66 | return Objects.hash(timestamp, type, localDate);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/BaseEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | /**
6 | * Created by Philipp Jahoda on 02/06/16.
7 | */
8 | public abstract class BaseEntry {
9 |
10 | /** the y value */
11 | private float y = 0f;
12 |
13 | /** optional spot for additional data this Entry represents */
14 | private Object mData = null;
15 |
16 | /** optional icon image */
17 | private Drawable mIcon = null;
18 |
19 | public BaseEntry() {
20 |
21 | }
22 |
23 | public BaseEntry(float y) {
24 | this.y = y;
25 | }
26 |
27 | public BaseEntry(float y, Object data) {
28 | this(y);
29 | this.mData = data;
30 | }
31 |
32 | public BaseEntry(float y, Drawable icon) {
33 | this(y);
34 | this.mIcon = icon;
35 | }
36 |
37 | public BaseEntry(float y, Drawable icon, Object data) {
38 | this(y);
39 | this.mIcon = icon;
40 | this.mData = data;
41 | }
42 |
43 | /**
44 | * Returns the y value of this Entry.
45 | *
46 | * @return
47 | */
48 | public float getY() {
49 | return y;
50 | }
51 |
52 | /**
53 | * Sets the icon drawable
54 | *
55 | * @param icon
56 | */
57 | public void setIcon(Drawable icon) {
58 | this.mIcon = icon;
59 | }
60 |
61 | /**
62 | * Returns the icon of this Entry.
63 | *
64 | * @return
65 | */
66 | public Drawable getIcon() {
67 | return mIcon;
68 | }
69 |
70 | /**
71 | * Sets the y-value for the Entry.
72 | *
73 | * @param y
74 | */
75 | public void setY(float y) {
76 | this.y = y;
77 | }
78 |
79 | /**
80 | * Returns the data, additional information that this Entry represents, or
81 | * null, if no data has been specified.
82 | *
83 | * @return
84 | */
85 | public Object getData() {
86 | return mData;
87 | }
88 |
89 | /**
90 | * Sets additional data this Entry should represent.
91 | *
92 | * @param data
93 | */
94 | public void setData(Object data) {
95 | this.mData = data;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/BubbleEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019/4/11
6 | */
7 | public class BubbleEntry {
8 | float size;
9 |
10 | public float getSize() {
11 | return size;
12 | }
13 |
14 | public void setSize(float size) {
15 | this.size = size;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/CandleEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019/4/11
6 | */
7 | public class CandleEntry {
8 |
9 | float high;
10 |
11 | public float getHigh() {
12 | return high;
13 | }
14 |
15 | public void setHigh(float high){
16 | this.high = high;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/EcgEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class EcgEntry extends BarEntry{
7 | public List values = new ArrayList<>();
8 |
9 | public EcgEntry(int i, float value, long timestamp, int type) {
10 | super(i, value, timestamp, type);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/PieEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019/4/11
6 | */
7 | public class PieEntry {
8 | }
9 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/RadarEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019/4/11
6 | */
7 | public class RadarEntry extends Entry {
8 | }
9 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/SleepEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.model.SleepTime;
4 |
5 | /**
6 | * @author yxc
7 | * @since 2019/4/6
8 | */
9 | public class SleepEntry extends BarEntry {
10 |
11 |
12 | public SleepTime sleepTime;
13 |
14 |
15 | public SleepEntry() {
16 | }
17 |
18 | public SleepEntry(float x, float y, long timestamp, int type) {
19 | super(x, y, timestamp, type);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/SleepItemEntry.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.model.SleepItemTime;
4 |
5 | /**
6 | * @author yxc
7 | * @since 2019/4/6
8 | */
9 | public class SleepItemEntry extends BarEntry {
10 |
11 |
12 | public SleepItemTime sleepItemTime;
13 |
14 |
15 | public SleepItemEntry() {
16 | }
17 |
18 | public SleepItemEntry(float x, float y, long timestamp, int type) {
19 | super(x, y, timestamp, type);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/YAxisMaxEntries.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019-05-13
8 | */
9 | public class YAxisMaxEntries {
10 |
11 | public YAxisMaxEntries(float yAxisMaximum, List visibleEntries) {
12 | this.yAxisMaximum = yAxisMaximum;
13 | this.visibleEntries = visibleEntries;
14 | }
15 |
16 | public float yAxisMaximum;
17 | public List visibleEntries;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/entrys/model/SleepTime.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.entrys.model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author yxc
7 | * @since 2019-05-09
8 | */
9 | public class SleepTime {
10 |
11 | public List sleepItemList;
12 |
13 | public long startTimestamp;//入睡时间点
14 | public long endTimestamp;//醒来时间点
15 |
16 | public long sleepTime;//睡的时间
17 |
18 | public SleepTime(List sleepTimeList) {
19 | this.sleepItemList = sleepTimeList;
20 | }
21 |
22 | public long getSleepTime() {
23 | return endTimestamp - startTimestamp;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/formatter/DefaultAxisValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.formatter;
2 |
3 | import java.text.DecimalFormat;
4 |
5 | /**
6 | * Created by philipp on 02/06/16.
7 | */
8 | public class DefaultAxisValueFormatter extends ValueFormatter
9 | {
10 |
11 | /**
12 | * decimalformat for formatting
13 | */
14 | protected DecimalFormat mFormat;
15 |
16 | /**
17 | * the number of decimal digits this formatter uses
18 | */
19 | protected int digits;
20 |
21 | /**
22 | * Constructor that specifies to how many digits the value should be
23 | * formatted.
24 | *
25 | * @param digits
26 | */
27 | public DefaultAxisValueFormatter(int digits) {
28 | this.digits = digits;
29 |
30 | StringBuffer b = new StringBuffer();
31 | for (int i = 0; i < digits; i++) {
32 | if (i == 0)
33 | b.append(".");
34 | b.append("0");
35 | }
36 |
37 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString());
38 | }
39 |
40 | @Override
41 | public String getFormattedValue(float value) {
42 | // avoid memory allocations here (for performance)
43 | return mFormat.format(value);
44 | }
45 |
46 | /**
47 | * Returns the number of decimal digits this formatter uses or -1, if unspecified.
48 | *
49 | * @return
50 | */
51 | public int getDecimalDigits() {
52 | return digits;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/formatter/DefaultBarChartValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019/4/13
8 | */
9 | public class DefaultBarChartValueFormatter extends DefaultValueFormatter {
10 | /**
11 | * Constructor that specifies to how many digits the value should be
12 | * formatted.
13 | *
14 | * @param digits
15 | */
16 | public DefaultBarChartValueFormatter(int digits) {
17 | super(digits);
18 | }
19 |
20 |
21 | @Override
22 | public String getFormattedValue(float value) {
23 | return super.getFormattedValue(value);
24 | }
25 |
26 | @Override
27 | public String getBarLabel(BarEntry barEntry) {
28 | return barEntry.getY() > 0 ?getFormattedValue(barEntry.getY()):"";
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/formatter/DefaultHighLightMarkValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.formatter;
2 |
3 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
4 | import com.yxc.commonlib.util.TimeDateUtil;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/24
9 | */
10 | public class DefaultHighLightMarkValueFormatter extends DefaultValueFormatter {
11 | public static final String CONNECT_STR = "&";
12 | /**
13 | * Constructor that specifies to how many digits the value should be
14 | * formatted.
15 | *
16 | * @param digits
17 | */
18 | public DefaultHighLightMarkValueFormatter(int digits) {
19 | super(digits);
20 | }
21 |
22 | @Override
23 | public String getFormattedValue(float value) {
24 | return super.getFormattedValue(value);
25 | }
26 |
27 | @Override
28 | public String getBarLabel(BarEntry barEntry) {
29 | String str1 = TimeDateUtil.getDateStr(barEntry.timestamp, "M月d日");
30 | String str2 = TimeDateUtil.getDateStr(barEntry.timestamp, "yyyy年");
31 | String str3 = getFormattedValue(barEntry.getY());
32 | String resultStr = str1 + CONNECT_STR + str2 + CONNECT_STR + str3;
33 | return barEntry.getY() > 0 ? resultStr : "";
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/formatter/DefaultValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.formatter;
2 |
3 | import java.text.DecimalFormat;
4 |
5 | /**
6 | * Default formatter used for formatting values inside the chart. Uses a DecimalFormat with
7 | * pre-calculated number of digits (depending on max and min value).
8 | *
9 | * @author Philipp Jahoda
10 | */
11 | public class DefaultValueFormatter extends ValueFormatter
12 | {
13 |
14 | /**
15 | * DecimalFormat for formatting
16 | */
17 | protected DecimalFormat mFormat;
18 |
19 | protected int mDecimalDigits;
20 |
21 | /**
22 | * Constructor that specifies to how many digits the value should be
23 | * formatted.
24 | *
25 | * @param digits
26 | */
27 | public DefaultValueFormatter(int digits) {
28 | setup(digits);
29 | }
30 |
31 | /**
32 | * Sets up the formatter with a given number of decimal digits.
33 | *
34 | * @param digits
35 | */
36 | public void setup(int digits) {
37 |
38 | this.mDecimalDigits = digits;
39 |
40 | StringBuffer b = new StringBuffer();
41 | for (int i = 0; i < digits; i++) {
42 | if (i == 0)
43 | b.append(".");
44 | b.append("0");
45 | }
46 |
47 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString());
48 | }
49 |
50 | @Override
51 | public String getFormattedValue(float value) {
52 |
53 | // put more logic here ...
54 | // avoid memory allocations here (for performance reasons)
55 |
56 | return mFormat.format(value);
57 | }
58 |
59 | /**
60 | * Returns the number of decimal digits this formatter uses.
61 | *
62 | * @return
63 | */
64 | public int getDecimalDigits() {
65 | return mDecimalDigits;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/itemdecoration/LineChartDrawable.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.itemdecoration;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.ColorFilter;
5 | import android.graphics.Paint;
6 | import android.graphics.Path;
7 | import android.graphics.PixelFormat;
8 | import android.graphics.drawable.Drawable;
9 | import androidx.annotation.NonNull;
10 | import androidx.annotation.Nullable;
11 |
12 | /**
13 | * @author yxc
14 | * @since 2019/4/21
15 | */
16 | public class LineChartDrawable extends Drawable {
17 |
18 | Paint mPaint;
19 | Path path;
20 |
21 | public LineChartDrawable(Paint paint, Path path){
22 | this.mPaint = copyPaint(paint);
23 | this.path = path;
24 | setAlpha(20);
25 | }
26 |
27 | private Paint copyPaint(Paint paint) {
28 | Paint mPaint = new Paint();
29 | mPaint.reset();
30 | mPaint.setAntiAlias(true);
31 | mPaint.setStyle(Paint.Style.FILL);
32 | mPaint.setColor(paint.getColor());
33 | return mPaint;
34 | }
35 |
36 | @Override
37 | public void draw( @NonNull Canvas canvas) {
38 | canvas.drawPath(path, mPaint);
39 | }
40 |
41 | @Override
42 | public void setAlpha(int alpha) {
43 | mPaint.setAlpha(alpha);
44 | }
45 |
46 | @Override
47 | public void setColorFilter(@Nullable ColorFilter colorFilter) {
48 | mPaint.setColorFilter(colorFilter);
49 | invalidateSelf();
50 | }
51 |
52 | @Override
53 | public int getOpacity() {
54 | return PixelFormat.TRANSLUCENT;
55 | }
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/listener/SimpleItemGestureListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.listener;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 | import android.view.View;
5 |
6 | import com.yxc.chartlib.recyclerchart.entrys.BarEntry;
7 |
8 | /**
9 | * @author yxc
10 | * @date 2019/4/24
11 | */
12 | public class SimpleItemGestureListener implements RecyclerItemGestureListener.OnItemGestureListener {
13 | @Override
14 | public void onItemClick(View view, int position) {
15 |
16 | }
17 |
18 | @Override
19 | public void onLongItemClick(View view, int position) {
20 |
21 | }
22 |
23 | @Override
24 | public void onItemSelected(BarEntry barEntry, int position) {
25 |
26 | }
27 |
28 | @Override
29 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
30 |
31 | }
32 |
33 | @Override
34 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/render/BarBoardRender.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.render;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.recyclerview.widget.RecyclerView;
9 | import com.yxc.chartlib.recyclerchart.attrs.BaseChartAttrs;
10 |
11 | /**
12 | * @author yxc
13 | * @date 2019/4/14
14 | */
15 | final public class BarBoardRender {
16 |
17 | T mBarChartAttrs;
18 | Paint mBarBorderPaint;
19 |
20 | public BarBoardRender(T attrs) {
21 | this.mBarChartAttrs = attrs;
22 | initBarBorderPaint();
23 | }
24 |
25 | private void initBarBorderPaint() {
26 | mBarBorderPaint = new Paint();
27 | mBarBorderPaint.reset();
28 | mBarBorderPaint.setAntiAlias(true);
29 | mBarBorderPaint.setStyle(Paint.Style.STROKE);
30 | mBarBorderPaint.setStrokeWidth(mBarChartAttrs.barBorderWidth);
31 | mBarBorderPaint.setColor(mBarChartAttrs.barBorderColor);
32 | }
33 |
34 | final public void drawBarBorder(@NonNull Canvas canvas, @NonNull RecyclerView parent) {
35 | if (mBarChartAttrs.enableBarBorder) {
36 | RectF rectF = new RectF();
37 | float start = parent.getPaddingLeft();
38 | float top = parent.getPaddingTop();
39 | float end = parent.getRight() - parent.getPaddingRight();
40 | //底部有0的刻度是不是不用画,就画折线了。
41 | float bottom = parent.getHeight() - parent.getPaddingBottom() - mBarChartAttrs.contentPaddingBottom;
42 |
43 | rectF.set(start, top, end, bottom);
44 | mBarBorderPaint.setStrokeWidth(mBarChartAttrs.barBorderWidth);
45 | canvas.drawRect(rectF, mBarBorderPaint);
46 | }
47 | }
48 |
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/render/HrmBarBoardRender.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.render;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.recyclerview.widget.RecyclerView;
9 |
10 | import com.yxc.chartlib.recyclerchart.attrs.BaseChartAttrs;
11 |
12 | /**
13 | * @author yxc
14 | * @date 2019/4/14
15 | */
16 | final public class HrmBarBoardRender {
17 |
18 | T mBarChartAttrs;
19 | Paint mBarBorderPaint;
20 | Paint mBgPaint;
21 |
22 | public HrmBarBoardRender(T attrs) {
23 | this.mBarChartAttrs = attrs;
24 | initBarBorderPaint();
25 | }
26 |
27 | private void initBarBorderPaint() {
28 | mBarBorderPaint = new Paint();
29 | mBarBorderPaint.reset();
30 | mBarBorderPaint.setAntiAlias(true);
31 | mBarBorderPaint.setStyle(Paint.Style.STROKE);
32 | mBarBorderPaint.setStrokeWidth(mBarChartAttrs.barBorderWidth);
33 | mBarBorderPaint.setColor(mBarChartAttrs.barBorderColor);
34 |
35 | mBgPaint = new Paint();
36 | mBgPaint.reset();
37 | mBgPaint.setAntiAlias(true);
38 | mBgPaint.setAlpha((int)(255 * 0.2));
39 | mBgPaint.setColor(mBarChartAttrs.barBorderBgColor);
40 | }
41 |
42 | final public void drawBarBorder(@NonNull Canvas canvas, @NonNull RecyclerView parent) {
43 | if (mBarChartAttrs.enableBarBorder) {
44 | RectF rectF = new RectF();
45 | float start = parent.getPaddingLeft();
46 | float top = parent.getPaddingTop();
47 | float end = parent.getRight() - parent.getPaddingRight();
48 | //底部有0的刻度是不是不用画,就画折线了。
49 | float bottom = parent.getHeight() - parent.getPaddingBottom() - mBarChartAttrs.contentPaddingBottom;
50 | rectF.set(start, top, end, bottom);
51 | mBarBorderPaint.setStrokeWidth(mBarChartAttrs.barBorderWidth);
52 | canvas.drawRect(rectF, mBarBorderPaint);
53 |
54 | canvas.drawRect(rectF, mBgPaint);
55 | }
56 | }
57 |
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/util/CanvasUtil.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.util;
2 |
3 | import android.graphics.Path;
4 | import android.graphics.RectF;
5 |
6 | /**
7 | * @author yxc
8 | * @since 2019/4/20
9 | */
10 | public class CanvasUtil {
11 |
12 | public static Path createRectRoundPath(RectF rectF, float radius, int type) {
13 | Path path = new Path();
14 | //指定四个圆角不同大小
15 | float radii[] = RoundRectType.getRoundValues(type, radius);
16 | path.addRoundRect(rectF, radii, Path.Direction.CCW);
17 | return path;
18 | }
19 |
20 | public static Path createRectRoundPath(RectF rectF, float radius) {
21 | return createRectRoundPath(rectF, radius, RoundRectType.TYPE_TOP);
22 | }
23 |
24 | public static Path createRectPath(RectF rectF) {
25 | Path path = new Path();
26 | //指定四个圆角不同大小
27 | float radii[] = {0, 0, 0, 0, 0, 0, 0, 0};
28 | path.addRoundRect(rectF, radii, Path.Direction.CCW);
29 | return path;
30 | }
31 |
32 |
33 |
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/util/FSize.java:
--------------------------------------------------------------------------------
1 |
2 | package com.yxc.chartlib.recyclerchart.util;
3 |
4 | import java.util.List;
5 |
6 | /**
7 | * Class for describing width and height dimensions in some arbitrary
8 | * unit. Replacement for the android.Util.SizeF which is available only on API >= 21.
9 | */
10 | public final class FSize extends ObjectPool.Poolable{
11 |
12 | // TODO : Encapsulate width & height
13 |
14 | public float width;
15 | public float height;
16 |
17 | private static ObjectPool pool;
18 |
19 | static {
20 | pool = ObjectPool.create(256, new FSize(0,0));
21 | pool.setReplenishPercentage(0.5f);
22 | }
23 |
24 |
25 | protected ObjectPool.Poolable instantiate(){
26 | return new FSize(0,0);
27 | }
28 |
29 | public static FSize getInstance(final float width, final float height){
30 | FSize result = pool.get();
31 | result.width = width;
32 | result.height = height;
33 | return result;
34 | }
35 |
36 | public static void recycleInstance(FSize instance){
37 | pool.recycle(instance);
38 | }
39 |
40 | public static void recycleInstances(List instances){
41 | pool.recycle(instances);
42 | }
43 |
44 | public FSize() {
45 | }
46 |
47 | public FSize(final float width, final float height) {
48 | this.width = width;
49 | this.height = height;
50 | }
51 |
52 | @Override
53 | public boolean equals(final Object obj) {
54 | if (obj == null) {
55 | return false;
56 | }
57 | if (this == obj) {
58 | return true;
59 | }
60 | if (obj instanceof FSize) {
61 | final FSize other = (FSize) obj;
62 | return width == other.width && height == other.height;
63 | }
64 | return false;
65 | }
66 |
67 | @Override
68 | public String toString() {
69 | return width + "x" + height;
70 | }
71 |
72 | /**
73 | * {@inheritDoc}
74 | */
75 | @Override
76 | public int hashCode() {
77 | return Float.floatToIntBits(width) ^ Float.floatToIntBits(height);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/util/MPPointD.java:
--------------------------------------------------------------------------------
1 |
2 | package com.yxc.chartlib.recyclerchart.util;
3 |
4 | import java.util.List;
5 |
6 | /**
7 | * Point encapsulating two double values.
8 | *
9 | * @author Philipp Jahoda
10 | */
11 | public class MPPointD extends ObjectPool.Poolable {
12 |
13 | private static ObjectPool pool;
14 |
15 | static {
16 | pool = ObjectPool.create(64, new MPPointD(0,0));
17 | pool.setReplenishPercentage(0.5f);
18 | }
19 |
20 | public static MPPointD getInstance(double x, double y){
21 | MPPointD result = pool.get();
22 | result.x = x;
23 | result.y = y;
24 | return result;
25 | }
26 |
27 | public static void recycleInstance(MPPointD instance){
28 | pool.recycle(instance);
29 | }
30 |
31 | public static void recycleInstances(List instances){
32 | pool.recycle(instances);
33 | }
34 |
35 | public double x;
36 | public double y;
37 |
38 | protected ObjectPool.Poolable instantiate(){
39 | return new MPPointD(0,0);
40 | }
41 |
42 | private MPPointD(double x, double y) {
43 | this.x = x;
44 | this.y = y;
45 | }
46 |
47 | /**
48 | * returns a string representation of the object
49 | */
50 | public String toString() {
51 | return "MPPointD, x: " + x + ", y: " + y;
52 | }
53 | }
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/util/RoundRectType.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.util;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019-10-11
6 | */
7 | public class RoundRectType {
8 |
9 | public static final int TYPE_ALL = 0;
10 | public static final int TYPE_TOP = 1;
11 | public static final int TYPE_BOTTOM = 2;
12 | public static final int TYPE_LEFT = 3;
13 | public static final int TYPE_RIGHT = 4;
14 | public static final int TYPE_LEFT_TOP = 5;
15 | public static final int TYPE_LEFT_BOTTOM = 6;
16 | public static final int TYPE_RIGHT_TOP = 7;
17 | public static final int TYPE_RIGHT_BOTTOM = 8;
18 |
19 | public static float[] getRoundValues(int type, float radius) {
20 | switch (type) {
21 | case TYPE_ALL:
22 | return new float[]{radius, radius, radius, radius, radius, radius, radius, radius};
23 | case TYPE_BOTTOM:
24 | return new float[]{0, 0, 0, 0, radius, radius, radius, radius};
25 | case TYPE_LEFT:
26 | return new float[]{radius, radius, 0, 0, 0, 0, radius, radius};
27 | case TYPE_RIGHT:
28 | return new float[]{0, 0, radius, radius, radius, radius, 0, 0};
29 | case TYPE_LEFT_TOP:
30 | return new float[]{radius, radius, 0, 0, 0, 0, 0, 0};
31 | case TYPE_LEFT_BOTTOM:
32 | return new float[]{0, 0, 0, 0, 0, 0, radius, radius};
33 | case TYPE_RIGHT_TOP:
34 | return new float[]{0, 0, radius, radius, 0, 0, 0, 0};
35 | case TYPE_RIGHT_BOTTOM:
36 | return new float[]{0, 0, 0, 0, radius, radius, 0, 0};
37 | case TYPE_TOP:
38 | default:
39 | return new float[]{radius, radius, radius, radius, 0, 0, 0, 0};
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/util/Utils.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.util;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019-06-04
6 | */
7 | public class Utils {
8 |
9 | public static String getActionName(int action){
10 | switch (action){
11 | case 0:
12 | return "ACTION_DOWN";
13 | case 1:
14 | return "ACTION_UP";
15 | case 2:
16 | return "ACTION_MOVE";
17 | case 3:
18 | return "ACTION_CANCEL";
19 | default:
20 | return "ACTION_DOWN";
21 | }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/AnimatedDecorator.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Color;
5 | import android.graphics.Paint;
6 | import androidx.annotation.NonNull;
7 | import androidx.recyclerview.widget.RecyclerView;
8 | import android.view.View;
9 |
10 | import java.util.HashMap;
11 |
12 | /**
13 | * @author yxc
14 | * @date 2019/4/18
15 | */
16 | public class AnimatedDecorator extends RecyclerView.ItemDecoration {
17 | HashMap mAnimatorMap;
18 | Paint mBarChartPaint;
19 | public AnimatedDecorator(HashMap map) {
20 | this.mAnimatorMap = map;
21 | initPaint();
22 | }
23 |
24 | private void initPaint() {
25 | mBarChartPaint = new Paint();
26 | mBarChartPaint.reset();
27 | mBarChartPaint.setAntiAlias(true);
28 | mBarChartPaint.setStyle(Paint.Style.FILL);
29 | mBarChartPaint.setColor(Color.RED);
30 | }
31 |
32 | @Override
33 | public void onDrawOver(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
34 | boolean mustInvalidate = false;
35 | if (parent != null && parent.getChildCount() > 0) {
36 | for (int i = 0; i < parent.getChildCount(); i++) {
37 | View child = parent.getChildAt(i);
38 | int position = parent.getChildAdapterPosition(child);
39 | CustomAnimatedDecorator mDrawable = mAnimatorMap.get(position);
40 | if (position != RecyclerView.NO_POSITION) {
41 | mustInvalidate = true;
42 | drawView(canvas, mDrawable, child, mBarChartPaint);
43 | }
44 | }
45 | if (mustInvalidate) parent.invalidate();
46 | }
47 | }
48 |
49 |
50 | private void drawView(Canvas canvas, AnimatedDecoratorDrawable drawable, View child, Paint paint) {
51 | canvas.save();
52 | canvas.translate(child.getLeft(), child.getTop());
53 | drawable.draw(canvas, paint);
54 | canvas.restore();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/AnimatedDecoratorDrawable.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/17
9 | */
10 | abstract public class AnimatedDecoratorDrawable {
11 |
12 | abstract public void draw(Canvas canvas, Paint paint);
13 |
14 | public float height = 0;
15 | public float width = 0;
16 |
17 | public AnimatedDecoratorDrawable(float width, float height) {
18 | this.width = width;
19 | this.height = height;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/BarChartRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import com.yxc.chartlib.recyclerchart.attrs.BarChartAttrs;
10 | import com.yxc.chartlib.recyclerchart.attrs.ChartAttrsUtil;
11 | import com.yxc.commonlib.util.DisplayUtil;
12 |
13 | /**
14 | * @author yxc
15 | * @since 2019/4/10
16 | */
17 | public class BarChartRecyclerView extends BaseChartRecyclerView {
18 |
19 | public BarChartAttrs mAttrs;
20 |
21 | public BarChartRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
22 | super(context, attrs);
23 | this.mAttrs = ChartAttrsUtil.getBarChartRecyclerAttrs(context, attrs);
24 | setRecyclerViewDefaultPadding();
25 | }
26 |
27 | private void setRecyclerViewDefaultPadding() {
28 | int paddingLeft = getPaddingLeft();
29 | int paddingRight = getPaddingRight();
30 | if (mAttrs.enableRightYAxisLabel) {
31 | paddingRight = DisplayUtil.dip2px(36);
32 | }
33 | if (mAttrs.enableLeftYAxisLabel) {
34 | paddingLeft = DisplayUtil.dip2px(36);
35 | }
36 | setPadding(paddingLeft, getPaddingTop(), paddingRight, getPaddingBottom());
37 | }
38 |
39 |
40 | @Override
41 | public boolean fling(int velocityX, int velocityY) {
42 | velocityX *= mAttrs.ratioVelocity;
43 | velocityY *= mAttrs.ratioVelocity;
44 | return super.fling(velocityX, velocityY);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/BaseChartRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | /**
12 | * @author yxc
13 | * @since 2019-05-10
14 | *
15 | */
16 | public class BaseChartRecyclerView extends RecyclerView {
17 |
18 | public OnChartTouchListener onChartTouchListener;
19 |
20 | public BaseChartRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | @Override
25 | public boolean onTouchEvent(MotionEvent e) {
26 | if (e.getActionMasked() == MotionEvent.ACTION_DOWN) {
27 | if (onChartTouchListener != null){
28 | onChartTouchListener.onChartGestureStart(e);
29 | }
30 | } else if (e.getAction() == MotionEvent.ACTION_UP
31 | || e.getAction() == MotionEvent.ACTION_CANCEL) {
32 | if (onChartTouchListener != null) {
33 | onChartTouchListener.onChartGestureEnd(e);
34 | }
35 | } else if (e.getActionMasked() == MotionEvent.ACTION_MOVE){
36 | if (onChartTouchListener != null) {
37 | onChartTouchListener.onChartGestureMovingOn(e);
38 | }
39 | }
40 | return super.onTouchEvent(e);
41 | }
42 |
43 |
44 |
45 |
46 | public void setOnChartTouchListener(OnChartTouchListener onChartTouchListener) {
47 | this.onChartTouchListener = onChartTouchListener;
48 | }
49 |
50 | public interface OnChartTouchListener {
51 |
52 | void onChartGestureStart(MotionEvent e);
53 |
54 | void onChartGestureEnd(MotionEvent e);
55 |
56 | void onChartGestureMovingOn(MotionEvent e);
57 | }
58 |
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/BezierChartRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import com.yxc.chartlib.recyclerchart.attrs.BezierChartAttrs;
10 | import com.yxc.chartlib.recyclerchart.attrs.ChartAttrsUtil;
11 | import com.yxc.commonlib.util.DisplayUtil;
12 |
13 | /**
14 | * @author yxc
15 | * @since 2019/4/10
16 | *
17 | */
18 | public class BezierChartRecyclerView extends BaseChartRecyclerView {
19 |
20 | public BezierChartAttrs mAttrs;
21 |
22 | public BezierChartRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
23 | super(context, attrs);
24 | this.mAttrs = ChartAttrsUtil.getBezierChartAttrs(context, attrs);
25 | setRecyclerViewDefaultPadding();
26 | }
27 |
28 | private void setRecyclerViewDefaultPadding() {
29 | int paddingLeft = getPaddingLeft();
30 | int paddingRight = getPaddingRight();
31 | if (mAttrs.enableRightYAxisLabel) {
32 | paddingRight = DisplayUtil.dip2px(36);
33 | }
34 | if (mAttrs.enableLeftYAxisLabel) {
35 | paddingLeft = DisplayUtil.dip2px(36);
36 | }
37 | setPadding(paddingLeft, getPaddingTop(), paddingRight, getPaddingBottom());
38 | }
39 |
40 |
41 | @Override
42 | public boolean fling(int velocityX, int velocityY) {
43 | velocityX *= mAttrs.ratioVelocity;
44 | velocityY *= mAttrs.ratioVelocity;
45 | return super.fling(velocityX, velocityY);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/CustomAnimatedDecorator.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 | import android.util.Log;
7 |
8 | /**
9 | * @author yxc
10 | * @date 2019/4/17
11 | */
12 | public class CustomAnimatedDecorator extends AnimatedDecoratorDrawable {
13 |
14 | RectF rect;
15 | public float start;
16 | public float end;
17 | public float current;
18 | public int changeNumber = 20;
19 | private float distance;
20 | private float itemDistance;
21 |
22 | public CustomAnimatedDecorator(float width, float height){
23 | super(width, height);
24 | rect = new RectF();
25 | }
26 |
27 | public CustomAnimatedDecorator(float width, float height, float start, float end) {
28 | super(width, height);
29 | rect = new RectF();
30 | bindData(width, height, start, end);
31 | }
32 |
33 | public void bindData(float width, float height, float start, float end){
34 | // rect = new RectF(0, height, width, height);
35 | rect.set(0, height, width, height);
36 | this.start = start;
37 | this.end = end;
38 | this.current = height - start;
39 | distance = height - end;
40 | itemDistance = distance / changeNumber;
41 | }
42 |
43 | @Override
44 | public void draw(Canvas canvas, Paint paint) {
45 | if (current > end + 1) {
46 | Log.d("Decorator", "currentTop.end:" + end + " currentTop.current:" + current);
47 | rect.set(rect.left, getValue(), rect.right, rect.bottom);
48 | }
49 | canvas.drawRect(rect, paint);
50 | }
51 |
52 | private float getValue() {
53 | if (current > 0) {
54 | Log.d("Decorator", "FORWARD , current:" + current);
55 | current = current - itemDistance;
56 | }
57 | return current;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/barchartlib/src/main/java/com/yxc/chartlib/recyclerchart/view/LineChartRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib.recyclerchart.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import com.yxc.chartlib.recyclerchart.attrs.ChartAttrsUtil;
10 | import com.yxc.chartlib.recyclerchart.attrs.LineChartAttrs;
11 | import com.yxc.commonlib.util.DisplayUtil;
12 |
13 | /**
14 | * @author yxc
15 | * @since 2019/4/10
16 | */
17 | public class LineChartRecyclerView extends BaseChartRecyclerView {
18 |
19 | public LineChartAttrs mAttrs;
20 |
21 | public LineChartRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
22 | super(context, attrs);
23 | this.mAttrs = ChartAttrsUtil.getLineChartRecyclerAttrs(context, attrs);
24 | setRecyclerViewDefaultPadding();
25 | }
26 |
27 | private void setRecyclerViewDefaultPadding() {
28 | int paddingLeft = getPaddingLeft();
29 | int paddingRight = getPaddingRight();
30 | if (mAttrs.enableRightYAxisLabel) {
31 | paddingRight = DisplayUtil.dip2px(36);
32 | }
33 | if (mAttrs.enableLeftYAxisLabel) {
34 | paddingLeft = DisplayUtil.dip2px(36);
35 | }
36 | setPadding(paddingLeft, getPaddingTop(), paddingRight, getPaddingBottom());
37 | }
38 |
39 | public float contentHeight(){
40 | int top = getPaddingTop();
41 | int bottom = getMeasuredHeight() - getPaddingBottom();
42 | float topLocation = top + mAttrs.contentPaddingTop;
43 | float containerHeight = bottom - mAttrs.contentPaddingBottom - topLocation;
44 | return containerHeight;
45 | }
46 |
47 | public float contentWidth(){
48 | float contentWidth = getMeasuredWidth() - getPaddingStart() - getPaddingEnd();
49 | return contentWidth;
50 | }
51 |
52 |
53 | @Override
54 | public boolean fling(int velocityX, int velocityY) {
55 | velocityX *= mAttrs.ratioVelocity;
56 | velocityY *= mAttrs.ratioVelocity;
57 | return super.fling(velocityX, velocityY);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/barchartlib/src/main/res/drawable/marker2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/barchartlib/src/main/res/drawable/marker2.png
--------------------------------------------------------------------------------
/barchartlib/src/main/res/layout/item_layout_barchart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
--------------------------------------------------------------------------------
/barchartlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | barchartlib
3 |
4 |
--------------------------------------------------------------------------------
/barchartlib/src/test/java/com/yxc/chartlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.chartlib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | kotlin_version = '1.5.0'
6 | }
7 | repositories {
8 | maven { url "https://maven.aliyun.com/repository/public" }
9 | maven { url 'https://maven.aliyun.com/repository/google' }
10 | google()
11 | mavenCentral()
12 | }
13 | dependencies {
14 | classpath 'com.android.tools.build:gradle:4.2.2'
15 | classpath "io.realm:realm-gradle-plugin:6.1.0"
16 | classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
17 |
18 | // NOTE: Do not place your application dependencies here; they belong
19 | // in the individual module build.gradle files
20 | }
21 | }
22 |
23 | allprojects {
24 | repositories {
25 | maven { url "https://maven.aliyun.com/repository/public" }
26 | maven { url 'https://maven.aliyun.com/repository/google' }
27 | maven { url 'https://jitpack.io' }
28 | google()
29 | mavenCentral()
30 | }
31 | }
32 |
33 | task clean(type: Delete) {
34 | delete rootProject.buildDir
35 | }
36 |
--------------------------------------------------------------------------------
/chart.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/chart.jks
--------------------------------------------------------------------------------
/commonlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/commonlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 24
10 | targetSdkVersion 28
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 |
30 | implementation 'androidx.appcompat:appcompat:1.0.0'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'androidx.test:runner:1.1.0'
33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
34 |
35 | api 'joda-time:joda-time:2.10.1'
36 | }
37 |
--------------------------------------------------------------------------------
/commonlib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/commonlib/src/androidTest/java/com/yxc/commonlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.commonlib;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yxc.commonlib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/commonlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/yxc/commonlib/time/Hour12.java:
--------------------------------------------------------------------------------
1 | package com.yxc.commonlib.time;
2 |
3 | /**
4 | * @author yxc
5 | * @date 2019/4/24
6 | */
7 | public class Hour12 {
8 | public int hour;
9 | public boolean isAnte = true; // 默认上午;
10 |
11 | public String getHour12String(){
12 | return isAnte?"上午" + hour + "时":"下午" + hour + "时";
13 | }
14 |
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/yxc/commonlib/util/ColorUtil.java:
--------------------------------------------------------------------------------
1 | package com.yxc.commonlib.util;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019/3/1
8 | */
9 | public class ColorUtil {
10 |
11 | /**
12 | * 获取资源中的颜色
13 | * @param color
14 | * @return
15 | */
16 | public static int getResourcesColor(Context context, int color) {
17 |
18 | int ret = 0x00ffffff;
19 | try {
20 | ret = context.getResources().getColor(color);
21 | } catch (Exception e) {
22 | }
23 |
24 | return ret;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/yxc/commonlib/util/PathUtil.java:
--------------------------------------------------------------------------------
1 | package com.yxc.commonlib.util;
2 |
3 | import android.graphics.Path;
4 | import android.graphics.PointF;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/4/28
9 | */
10 | public class PathUtil {
11 |
12 | public static void moveTo(Path path, PointF startPoint) {
13 | path.moveTo(startPoint.x, startPoint.y);
14 | }
15 |
16 | public static void cubicTo(Path path, PointF control1, PointF control2, PointF pointf) {
17 | path.cubicTo(control1.x, control1.y, control2.x, control2.y, pointf.x, pointf.y);
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/commonlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | commonlib
3 |
4 |
--------------------------------------------------------------------------------
/commonlib/src/test/java/com/yxc/commonlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.commonlib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/device-2019-04-25-115017.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/device-2019-04-25-115017.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx1536m
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 | googlePlayServicesVersion=12.0.1
17 |
18 |
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinxiucheng/RecyclerBarChart/29b4fc9ce0a37ef63631a6b0c04df79e757dcc32/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Apr 08 15:20:27 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':barchartlib', ':widgetlib', ':commonlib'
2 |
--------------------------------------------------------------------------------
/widgetlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/widgetlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 32
5 | defaultConfig {
6 | minSdkVersion 24
7 | targetSdkVersion 32
8 | versionCode 1
9 | versionName "1.0"
10 |
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 |
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | }
23 |
24 | dependencies {
25 | implementation fileTree(dir: 'libs', include: ['*.jar'])
26 |
27 | testImplementation 'junit:junit:4.13.2'
28 | androidTestImplementation 'androidx.test:runner:1.4.0'
29 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
30 |
31 | api 'androidx.appcompat:appcompat:1.5.1'
32 | api 'androidx.legacy:legacy-support-v4:1.0.0'
33 | api 'com.google.android.material:material:1.6.1'
34 | api 'androidx.viewpager2:viewpager2:1.1.0-beta01'
35 |
36 | api project(':commonlib')
37 | }
38 |
--------------------------------------------------------------------------------
/widgetlib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/widgetlib/src/androidTest/java/com/yxc/widgetlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yxc.widgetlib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/widgetlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/entity/Lunar.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.entity;
2 |
3 | /**
4 | * 农历
5 | */
6 | public class Lunar {
7 |
8 | public boolean isLeap;
9 | public int lunarDay;
10 | public int lunarMonth;
11 | public int lunarYear;
12 | public int leapMonth;
13 |
14 | public String lunarDayStr;
15 | public String lunarMonthStr;
16 | public String lunarYearStr;
17 | public String animals;//生肖
18 | public String chineseEra;//天干地支
19 |
20 | public String lunarDrawStr;//农历绘制的文字
21 | }
22 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/entity/NDate.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.entity;
2 |
3 | import org.joda.time.LocalDate;
4 |
5 | import java.io.Serializable;
6 |
7 |
8 | /**
9 | * 公历
10 | */
11 | public class NDate implements Serializable {
12 | public LocalDate localDate;//公历日期
13 | public Lunar lunar;
14 | public String solarHoliday;//公历节日
15 | public String lunarHoliday;//农历节日
16 | public String solarTerm;//节气
17 |
18 | public NDate(LocalDate localDate) {
19 | this.localDate = localDate;
20 | }
21 |
22 | public NDate() {
23 |
24 | }
25 |
26 |
27 | @Override
28 | public boolean equals(Object obj) {
29 | if (obj instanceof NDate) {
30 | NDate date = (NDate) obj;
31 | return localDate.equals(date.localDate);
32 | } else {
33 | return false;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnCalendarChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 |
4 | import com.yxc.widgetlib.calendar.entity.NDate;
5 |
6 | public interface OnCalendarChangedListener {
7 | void onCalendarDateChanged(NDate date, boolean isClick);
8 |
9 | void onCalendarStateChanged(boolean isMonthSate);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnCalendarStateChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 | /**
4 | * Created by necer on 2018/11/12.
5 | */
6 | public interface OnCalendarStateChangedListener {
7 |
8 | void onCalendarStateChanged(boolean isMonthState);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnClickDayViewListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 |
4 | import org.joda.time.LocalDate;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/2/26
9 | */
10 | public interface OnClickDayViewListener {
11 |
12 | void onClickCurrentDay(LocalDate nDate);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnClickDisableDateListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 |
4 | import com.yxc.widgetlib.calendar.entity.NDate;
5 |
6 | public interface OnClickDisableDateListener {
7 | void onClickDisableDate(NDate nDate);
8 | }
9 |
10 |
11 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnClickMonthViewListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 | import org.joda.time.LocalDate;
4 |
5 |
6 | public interface OnClickMonthViewListener {
7 |
8 | void onClickCurrentMonth(LocalDate localDate);
9 |
10 | void onClickLastMonth(LocalDate localDate);
11 |
12 | void onClickNextMonth(LocalDate localDate);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnClickWeekViewListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 | import org.joda.time.LocalDate;
4 |
5 |
6 | public interface OnClickWeekViewListener {
7 |
8 | void onClickCurrentWeek(LocalDate localDate);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnMonthAnimatorListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 | public interface OnMonthAnimatorListener {
4 | void onMonthAnimatorChanged(int offset);
5 | }
6 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnMonthSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 |
4 | import com.yxc.widgetlib.calendar.entity.NDate;
5 |
6 | public interface OnMonthSelectListener {
7 | void onMonthSelect(NDate date, boolean isClick);
8 | }
9 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnWeekSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 |
4 | import com.yxc.widgetlib.calendar.entity.NDate;
5 |
6 | public interface OnWeekSelectListener {
7 | void onWeekSelect(NDate date, boolean isClick);
8 | }
9 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/listener/OnYearItemSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.listener;
2 |
3 |
4 | import com.yxc.widgetlib.calendar.view.MonthCalendar;
5 |
6 | /**
7 | * @author yxc
8 | * @date 2019/3/18
9 | */
10 | public interface OnYearItemSelectListener {
11 | void onSelect(MonthCalendar yearCalendar, int oldPosition, int newPosition);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/painter/CalendarPainter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.painter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import org.joda.time.LocalDate;
7 |
8 |
9 | public interface CalendarPainter {
10 |
11 |
12 | /**
13 | * 绘制今天的日期
14 | *
15 | * @param canvas
16 | * @param rect
17 | * @param nDate
18 | * @param isSelect 今天是否被选中
19 | */
20 | void onDrawToday(Canvas canvas, Rect rect, LocalDate nDate, boolean isSelect);
21 |
22 | /**
23 | * 绘制当前月或周的日期
24 | *
25 | * @param canvas
26 | * @param rect
27 | * @param nDate
28 | * @param isSelect 是否选中
29 | */
30 | void onDrawCurrentMonthOrWeek(Canvas canvas, Rect rect, LocalDate nDate, boolean isSelect);
31 |
32 | /**
33 | * 绘制上一月,下一月的日期,周日历不须实现
34 | *
35 | * @param canvas
36 | * @param rect
37 | * @param nDate
38 | */
39 | void onDrawNotCurrentMonth(Canvas canvas, Rect rect, LocalDate nDate);
40 |
41 |
42 | /**
43 | * 绘制不可用的日期,和方法setDateInterval(startFormatDate, endFormatDate)对应
44 | *
45 | * @param canvas
46 | * @param rect
47 | * @param nDate
48 | */
49 | void onDrawDisableDate(Canvas canvas, Rect rect, LocalDate nDate);
50 |
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/painter/CalendarWeekPainter.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.painter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.RectF;
5 |
6 |
7 | public interface CalendarWeekPainter extends CalendarPainter {
8 |
9 | void onDrawWeekBg(Canvas canvas, RectF rectF, int roundX, int roundY, boolean isTodayWeek);
10 |
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/view/MonthCalendar.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.view;
2 |
3 | import org.joda.time.LocalDate;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019/3/8
8 | *
9 | */
10 | public class MonthCalendar {
11 |
12 | public LocalDate localDate;
13 |
14 | public boolean isFuture;//未来的月,灰色不可点击
15 |
16 | public boolean isCurrent;//当前月
17 |
18 | public boolean isSelected;//选中月
19 |
20 | public MonthCalendar(){}
21 |
22 | public MonthCalendar(LocalDate localDate) {
23 |
24 | this.localDate = localDate;
25 | }
26 |
27 | public LocalDate getLocalDate() {
28 | return localDate;
29 | }
30 |
31 | public void setLocalDate(LocalDate localDate) {
32 | this.localDate = localDate;
33 | }
34 |
35 | public boolean isFuture() {
36 | return isFuture;
37 | }
38 |
39 | public void setFuture(boolean future) {
40 | isFuture = future;
41 | }
42 |
43 | public boolean isCurrent() {
44 | return isCurrent;
45 | }
46 |
47 | public void setCurrent(boolean current) {
48 | isCurrent = current;
49 | }
50 |
51 | public boolean isSelected() {
52 | return isSelected;
53 | }
54 |
55 | public void setSelected(boolean selected) {
56 | isSelected = selected;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/widgetlib/src/main/java/com/yxc/widgetlib/calendar/view/MyAnimatorListener.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib.calendar.view;
2 |
3 | import android.animation.Animator;
4 |
5 | /**
6 | * @author yxc
7 | * @date 2019/3/21
8 | */
9 | public class MyAnimatorListener implements Animator.AnimatorListener {
10 |
11 | @Override
12 | public void onAnimationStart(Animator animation) {
13 |
14 | }
15 |
16 | @Override
17 | public void onAnimationEnd(Animator animation) {
18 |
19 | }
20 |
21 | @Override
22 | public void onAnimationCancel(Animator animation) {
23 |
24 | }
25 |
26 | @Override
27 | public void onAnimationRepeat(Animator animation) {
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/widgetlib/src/main/res/layout/cbc_layout_calendar_year_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/widgetlib/src/main/res/layout/cbc_layout_item_month.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/widgetlib/src/main/res/layout/item_layout_barchart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
--------------------------------------------------------------------------------
/widgetlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ultiviewlib
3 | factual_scroll_view
4 | 月
5 | %d日
6 |
7 |
--------------------------------------------------------------------------------
/widgetlib/src/test/java/com/yxc/widgetlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yxc.widgetlib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------