├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── yhy
│ │ └── widget
│ │ └── demo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── hybrid
│ │ │ └── hybrid.js
│ │ ├── img-url.txt
│ │ └── index.html
│ ├── java
│ │ └── com
│ │ │ └── yhy
│ │ │ └── widget
│ │ │ └── demo
│ │ │ ├── App.java
│ │ │ ├── DemoAppGlideModule.java
│ │ │ ├── MainActivity.java
│ │ │ ├── activity
│ │ │ ├── AdvActivity.java
│ │ │ ├── CheckBoxActivity.java
│ │ │ ├── CheckedRLActivity.java
│ │ │ ├── CheckedTVActivity.java
│ │ │ ├── ClearEditTextActivity.java
│ │ │ ├── ConstraintImageActivity.java
│ │ │ ├── ETVActivity.java
│ │ │ ├── FlowLayoutActivity.java
│ │ │ ├── GradientTextViewActivity.java
│ │ │ ├── InputDialogActivity.java
│ │ │ ├── LineTextViewActivity.java
│ │ │ ├── PickViewActivity.java
│ │ │ ├── PreviewImageActivity.java
│ │ │ ├── RIVActivity.java
│ │ │ ├── RvActivity.java
│ │ │ ├── SettingsActivity.java
│ │ │ ├── SliderActivity.java
│ │ │ ├── SquareIVActivity.java
│ │ │ ├── StatusDialogActivity.java
│ │ │ ├── StepActivity.java
│ │ │ ├── SwitchButtonActivity.java
│ │ │ ├── TagFlowActivity.java
│ │ │ ├── TitleActivity.java
│ │ │ ├── WebHybridActivity.java
│ │ │ └── base
│ │ │ │ └── BaseActivity.java
│ │ │ ├── adapter
│ │ │ └── RvTestAdapter.java
│ │ │ ├── entity
│ │ │ ├── ImgUrls.java
│ │ │ ├── TestEntity.java
│ │ │ └── TestStep.java
│ │ │ ├── status
│ │ │ ├── DefActivity.java
│ │ │ ├── HelperActivity.java
│ │ │ ├── LayoutActivity.java
│ │ │ └── StatusActivity.java
│ │ │ └── utils
│ │ │ ├── ImgUtils.java
│ │ │ └── ToastUtils.java
│ └── res
│ │ ├── anim
│ │ └── anim_alpha_image_load.xml
│ │ ├── drawable
│ │ ├── bg_checked_ctv_selector.xml
│ │ ├── cursor_bg_shape.xml
│ │ └── ic_delete.xml
│ │ ├── layout
│ │ ├── activity_adv.xml
│ │ ├── activity_check_box.xml
│ │ ├── activity_checked_relative_layout.xml
│ │ ├── activity_checked_textview.xml
│ │ ├── activity_clear_edit_text.xml
│ │ ├── activity_constraint_image_view.xml
│ │ ├── activity_etv.xml
│ │ ├── activity_flow_layout.xml
│ │ ├── activity_gradient_text_view.xml
│ │ ├── activity_input_dialog.xml
│ │ ├── activity_line_text_view.xml
│ │ ├── activity_main.xml
│ │ ├── activity_pick_view.xml
│ │ ├── activity_preview_image.xml
│ │ ├── activity_riv.xml
│ │ ├── activity_rv.xml
│ │ ├── activity_settings.xml
│ │ ├── activity_slider.xml
│ │ ├── activity_square_imageview.xml
│ │ ├── activity_status.xml
│ │ ├── activity_status_def.xml
│ │ ├── activity_status_dialog.xml
│ │ ├── activity_status_helper.xml
│ │ ├── activity_status_layout.xml
│ │ ├── activity_step_view_vertical.xml
│ │ ├── activity_switch_button.xml
│ │ ├── activity_tag_flow.xml
│ │ ├── activity_title.xml
│ │ ├── activity_web_hybrid.xml
│ │ ├── item_square_iv_rv.xml
│ │ ├── item_step_horizontal.xml
│ │ ├── item_step_vertical.xml
│ │ └── item_tag_flow.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── d.jpeg
│ │ ├── e.jpeg
│ │ ├── ic_arrow_right.png
│ │ ├── ic_avatar.jpg
│ │ ├── ic_back.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_logo.jpg
│ │ ├── ic_more.png
│ │ ├── ic_notice.png
│ │ ├── ic_settings.png
│ │ └── ic_step_finished.png
│ │ ├── mipmap-xxhdpi
│ │ ├── bg_main.jpg
│ │ ├── ic_clear.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── img_pager_1.jpg
│ │ ├── img_pager_2.jpg
│ │ ├── img_pager_3.jpg
│ │ └── img_pager_4.jpg
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values
│ │ ├── arrays.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── network_security_config.xml
│ └── test
│ └── java
│ └── com
│ └── yhy
│ └── widget
│ └── demo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── imgs
└── download_qr.png
├── jitpack.yml
├── settings.gradle
└── widget
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── yhy
│ └── widget
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── yhy
│ │ └── widget
│ │ ├── component
│ │ ├── downloader
│ │ │ ├── FilenameGenerator.java
│ │ │ └── WidgetDownloader.java
│ │ ├── helper
│ │ │ ├── CookieHelper.java
│ │ │ └── ImageViewScaleMatrixHelper.java
│ │ └── provider
│ │ │ └── WidgetFileProvider.java
│ │ ├── core
│ │ ├── adv
│ │ │ ├── AdvView.java
│ │ │ └── adapter
│ │ │ │ ├── AdvAdapter.java
│ │ │ │ ├── SimpleAdvAdapter.java
│ │ │ │ └── TextAdvAdapter.java
│ │ ├── checked
│ │ │ ├── CheckBox.java
│ │ │ └── CheckedTextView.java
│ │ ├── dialog
│ │ │ ├── InputDialogView.java
│ │ │ └── status
│ │ │ │ ├── StatusDialogManager.java
│ │ │ │ ├── abs
│ │ │ │ ├── AbsStatusDialog.java
│ │ │ │ └── AbsUnableCancelStatusDialog.java
│ │ │ │ └── dialog
│ │ │ │ ├── ErrorDialog.java
│ │ │ │ ├── FailedDialog.java
│ │ │ │ ├── LoadingDialog.java
│ │ │ │ └── SuccessDialog.java
│ │ ├── exptext
│ │ │ └── ExpandTextView.java
│ │ ├── img
│ │ │ ├── ConstraintImageView.java
│ │ │ ├── SquareImageView.java
│ │ │ └── round
│ │ │ │ ├── CircleImageView.java
│ │ │ │ ├── RoundImageView.java
│ │ │ │ └── abs
│ │ │ │ └── AbsRoundImageView.java
│ │ ├── loading
│ │ │ ├── Indicator.java
│ │ │ ├── LoadingView.java
│ │ │ └── indicator
│ │ │ │ ├── BallBeatIndicator.java
│ │ │ │ ├── BallClipRotateIndicator.java
│ │ │ │ ├── BallClipRotateMultipleIndicator.java
│ │ │ │ ├── BallClipRotatePulseIndicator.java
│ │ │ │ ├── BallGridBeatIndicator.java
│ │ │ │ ├── BallGridPulseIndicator.java
│ │ │ │ ├── BallPulseIndicator.java
│ │ │ │ ├── BallPulseRiseIndicator.java
│ │ │ │ ├── BallPulseSyncIndicator.java
│ │ │ │ ├── BallRotateIndicator.java
│ │ │ │ ├── BallScaleIndicator.java
│ │ │ │ ├── BallScaleMultipleIndicator.java
│ │ │ │ ├── BallScaleRippleIndicator.java
│ │ │ │ ├── BallScaleRippleMultipleIndicator.java
│ │ │ │ ├── BallSpinFadeLoaderIndicator.java
│ │ │ │ ├── BallTrianglePathIndicator.java
│ │ │ │ ├── BallZigZagDeflectIndicator.java
│ │ │ │ ├── BallZigZagIndicator.java
│ │ │ │ ├── CubeTransitionIndicator.java
│ │ │ │ ├── LineScaleIndicator.java
│ │ │ │ ├── LineScalePartyIndicator.java
│ │ │ │ ├── LineScalePulseOutIndicator.java
│ │ │ │ ├── LineScalePulseOutRapidIndicator.java
│ │ │ │ ├── LineSpinFadeLoaderIndicator.java
│ │ │ │ ├── PacmanIndicator.java
│ │ │ │ ├── SemiCircleSpinIndicator.java
│ │ │ │ ├── SquareSpinIndicator.java
│ │ │ │ └── TriangleSkewSpinIndicator.java
│ │ ├── pager
│ │ │ └── HackyViewPager.java
│ │ ├── picker
│ │ │ └── PickerView.java
│ │ ├── preview
│ │ │ ├── ImgPreCfg.java
│ │ │ ├── ImgPreHelper.java
│ │ │ ├── PreImgActivity.java
│ │ │ ├── PreImgAdapter.java
│ │ │ └── PreviewModel.java
│ │ ├── recycler
│ │ │ ├── RecyclerScrollView.java
│ │ │ ├── div
│ │ │ │ └── RvDivider.java
│ │ │ └── layout
│ │ │ │ └── WrapContentLayoutManager.java
│ │ ├── settings
│ │ │ └── SettingsItemView.java
│ │ ├── step
│ │ │ ├── StepView.java
│ │ │ ├── adapter
│ │ │ │ └── StepAdapter.java
│ │ │ ├── entity
│ │ │ │ ├── StepAble.java
│ │ │ │ └── StepNode.java
│ │ │ └── indicator
│ │ │ │ └── StepIndicator.java
│ │ ├── text
│ │ │ ├── ClearEditText.java
│ │ │ ├── GradientTextView.java
│ │ │ └── LineTextView.java
│ │ ├── title
│ │ │ └── TitleBar.java
│ │ ├── toggle
│ │ │ └── SwitchButton.java
│ │ └── web
│ │ │ ├── HybridWebView.java
│ │ │ ├── bridge
│ │ │ └── HybridBridge.java
│ │ │ ├── client
│ │ │ ├── ChromeClient.java
│ │ │ └── WebClient.java
│ │ │ ├── helper
│ │ │ └── DownHelper.java
│ │ │ └── listener
│ │ │ ├── OnWebEventListener.java
│ │ │ ├── OnWebLoadListener.java
│ │ │ ├── SimpleOnWebEventListener.java
│ │ │ └── SimpleOnWebLoadListener.java
│ │ ├── layout
│ │ ├── checked
│ │ │ ├── CheckedFrameLayout.java
│ │ │ ├── CheckedLayout.java
│ │ │ ├── CheckedLinearLayout.java
│ │ │ └── CheckedRelativeLayout.java
│ │ ├── flow
│ │ │ ├── FlowLayout.java
│ │ │ └── tag
│ │ │ │ ├── TagContainer.java
│ │ │ │ ├── TagFlowAdapter.java
│ │ │ │ └── TagFlowLayout.java
│ │ ├── slider
│ │ │ └── SlideLayout.java
│ │ └── status
│ │ │ ├── StatusLayout.java
│ │ │ ├── handler
│ │ │ └── StaHandler.java
│ │ │ ├── helper
│ │ │ ├── DefLayoutHelper.java
│ │ │ ├── StaLayoutHelper.java
│ │ │ └── StaLayoutHelperBuilder.java
│ │ │ ├── listener
│ │ │ └── OnStatusRetryListener.java
│ │ │ └── view
│ │ │ ├── StaEmptyView.java
│ │ │ ├── StaErrorView.java
│ │ │ └── StaLoadingView.java
│ │ └── utils
│ │ └── WidgetCoreUtils.java
└── res
│ ├── anim
│ ├── adv_in.xml
│ └── adv_out.xml
│ ├── drawable
│ ├── bg_input_dialog_enable_selector.xml
│ ├── icon_status_dialog_loading.xml
│ ├── img_status_empty.xml
│ ├── img_status_error.xml
│ └── widget_status_dialog_shape.xml
│ ├── layout
│ ├── widget_activity_pre_img.xml
│ ├── widget_input_dialog.xml
│ ├── widget_item_pager_per_img.xml
│ ├── widget_settings_item_view.xml
│ ├── widget_status_dialog.xml
│ ├── widget_status_empty.xml
│ ├── widget_status_error.xml
│ ├── widget_status_loading.xml
│ ├── widget_step_view.xml
│ └── widget_titb_bar.xml
│ ├── mipmap-xhdpi
│ ├── ic_def_download.png
│ └── img_def_loading.jpg
│ ├── mipmap-xxhdpi
│ ├── ic_def_download.png
│ ├── icon_status_dialog_error.png
│ ├── icon_status_dialog_failed.png
│ ├── icon_status_dialog_loading.png
│ └── icon_status_dialog_success.png
│ ├── values
│ ├── arrays.xml
│ ├── attrs.xml
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ ├── network_security_config.xml
│ └── widget_file_provider_paths.xml
└── test
└── java
└── com
└── yhy
└── widget
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | .idea/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # Intellij
38 | *.iml
39 | .idea/
40 |
41 | # Keystore files
42 | *.jks
43 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | }
5 |
6 | java {
7 | toolchain {
8 | languageVersion = JavaLanguageVersion.of(11)
9 | }
10 | }
11 |
12 | android {
13 | namespace 'com.yhy.widget.demo'
14 | compileSdkVersion 33
15 |
16 | defaultConfig {
17 | applicationId "com.yhy.widget.demo"
18 | minSdkVersion 24
19 | targetSdkVersion 33
20 | versionCode 1
21 | versionName "1.0"
22 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
23 |
24 | // 开启多分包
25 | multiDexEnabled true
26 | }
27 |
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 |
35 |
36 | compileOptions {
37 | sourceCompatibility JavaVersion.VERSION_11
38 | targetCompatibility JavaVersion.VERSION_11
39 | }
40 | lint {
41 | abortOnError false
42 | checkReleaseBuilds false
43 | }
44 |
45 | // 打包apk自动生成名称
46 | android.applicationVariants.all { variant ->
47 | variant.outputs.all { output ->
48 | outputFileName = "Widget.apk"
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 | implementation 'androidx.appcompat:appcompat:1.6.1'
55 | implementation 'androidx.recyclerview:recyclerview:1.3.0'
56 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
57 | implementation 'com.github.bumptech.glide:glide:4.14.2'
58 | implementation 'com.squareup.picasso:picasso:2.71828'
59 | implementation 'androidx.annotation:annotation:1.6.0'
60 | implementation "androidx.multidex:multidex:2.0.1"
61 | implementation 'androidx.core:core-ktx:1.10.1'
62 |
63 | testImplementation 'junit:junit:4.13.2'
64 |
65 | implementation project(':widget')
66 |
67 | annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
68 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
69 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
70 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/yhy/widget/demo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo;
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 | * Instrumentation 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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yhy.widget.demo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/assets/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 首页
6 |
21 |
22 |
88 |
89 |
90 | 点击试试
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/DemoAppGlideModule.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.annotation.NonNull;
6 |
7 | import com.bumptech.glide.GlideBuilder;
8 | import com.bumptech.glide.annotation.GlideModule;
9 | import com.bumptech.glide.load.DecodeFormat;
10 | import com.bumptech.glide.load.resource.gif.GifOptions;
11 | import com.bumptech.glide.module.AppGlideModule;
12 | import com.bumptech.glide.request.RequestOptions;
13 |
14 | /**
15 | * Created on 2022-10-26 11:01
16 | *
17 | * @author 颜洪毅
18 | * @version 1.0.0
19 | * @since 1.0.0
20 | */
21 | @GlideModule
22 | public class DemoAppGlideModule extends AppGlideModule {
23 | @Override
24 | public boolean isManifestParsingEnabled() {
25 | return false;
26 | }
27 |
28 | @Override
29 | public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
30 | RequestOptions options = new RequestOptions()
31 | .format(DecodeFormat.PREFER_RGB_565)
32 | .set(GifOptions.DECODE_FORMAT, DecodeFormat.DEFAULT);
33 | builder.setDefaultRequestOptions(options);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/CheckBoxActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 |
6 | import com.yhy.widget.core.checked.CheckBox;
7 | import com.yhy.widget.demo.R;
8 | import com.yhy.widget.demo.activity.base.BaseActivity;
9 |
10 | /**
11 | * author : 颜洪毅
12 | * e-mail : yhyzgn@gmail.com
13 | * time : 2018-06-06 16:45
14 | * version: 1.0.0
15 | * desc :
16 | */
17 | public class CheckBoxActivity extends BaseActivity {
18 |
19 | private CheckBox cbDef;
20 | private CheckBox cbTest;
21 | private CheckBox cbCancel;
22 | private TextView tvCancel;
23 |
24 | @Override
25 | protected int getLayout() {
26 | return R.layout.activity_check_box;
27 | }
28 |
29 | @Override
30 | protected void initView() {
31 | cbDef = $(R.id.cb_def);
32 | cbTest = $(R.id.cb_test);
33 | cbCancel = $(R.id.cb_cancel);
34 | tvCancel = $(R.id.tv_cancel);
35 | }
36 |
37 | @Override
38 | protected void initData() {
39 | }
40 |
41 | @Override
42 | protected void initEvent() {
43 | cbDef.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
44 | @Override
45 | public void onCheckedChanged(CheckBox checkBox, boolean isChecked) {
46 | toast("第一个是否选中:" + isChecked);
47 | }
48 | });
49 |
50 | cbTest.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
51 | @Override
52 | public void onCheckedChanged(CheckBox checkBox, boolean isChecked) {
53 | toast("第二个是否选中:" + isChecked);
54 | }
55 | });
56 |
57 | cbCancel.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
58 | @Override
59 | public void onCheckedChanged(CheckBox checkBox, boolean isChecked) {
60 | toast("第三个是否选中:" + isChecked);
61 | }
62 | });
63 |
64 | tvCancel.setOnClickListener(new View.OnClickListener() {
65 | @Override
66 | public void onClick(View v) {
67 | // 切换
68 | cbCancel.toggle();
69 | }
70 | });
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/CheckedRLActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 |
6 | import com.yhy.widget.layout.checked.CheckedRelativeLayout;
7 | import com.yhy.widget.demo.R;
8 | import com.yhy.widget.demo.activity.base.BaseActivity;
9 |
10 | /**
11 | * author : 颜洪毅
12 | * e-mail : yhyzgn@gmail.com
13 | * time : 2017-12-08 10:04
14 | * version: 1.0.0
15 | * desc :
16 | */
17 | public class CheckedRLActivity extends BaseActivity {
18 |
19 | private TextView tvTest;
20 | private CheckedRelativeLayout crlTest;
21 |
22 | @Override
23 | protected int getLayout() {
24 | return R.layout.activity_checked_relative_layout;
25 | }
26 |
27 | @Override
28 | protected void initView() {
29 | crlTest = $(R.id.crl_test);
30 | tvTest = $(R.id.tv_test);
31 |
32 | crlTest.setChecked(true);
33 | }
34 |
35 | @Override
36 | protected void initData() {
37 |
38 | }
39 |
40 | @Override
41 | protected void initEvent() {
42 | tvTest.setOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | toast("点击了TextView");
46 | }
47 | });
48 |
49 | crlTest.setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | toast("点击");
53 | }
54 | });
55 |
56 | crlTest.setOnCheckedChangeListener(new CheckedRelativeLayout.OnCheckedChangeListener() {
57 | @Override
58 | public void onChanged(CheckedRelativeLayout crl, boolean isChecked) {
59 | toast("isChecked = " + isChecked);
60 | }
61 | });
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/CheckedTVActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.view.View;
4 |
5 | import com.yhy.widget.core.checked.CheckedTextView;
6 | import com.yhy.widget.demo.R;
7 | import com.yhy.widget.demo.activity.base.BaseActivity;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2017-12-07 17:44
13 | * version: 1.0.0
14 | * desc :
15 | */
16 | public class CheckedTVActivity extends BaseActivity {
17 |
18 | private CheckedTextView ctvDef;
19 | private CheckedTextView ctvPrev;
20 |
21 | @Override
22 | protected int getLayout() {
23 | return R.layout.activity_checked_textview;
24 | }
25 |
26 | @Override
27 | protected void initView() {
28 | ctvDef = findViewById(R.id.ctv_def);
29 | ctvPrev = findViewById(R.id.ctv_prev);
30 | }
31 |
32 | @Override
33 | protected void initData() {
34 | }
35 |
36 | @Override
37 | protected void initEvent() {
38 | ctvDef.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View v) {
41 | toast("我的click被阻止了");
42 | }
43 | });
44 |
45 | ctvDef.setOnLongClickListener(new View.OnLongClickListener() {
46 | @Override
47 | public boolean onLongClick(View v) {
48 | toast("我的longClick被阻止了");
49 | return true;
50 | }
51 | });
52 |
53 | ctvDef.setOnCheckedChangeListener(new CheckedTextView.OnCheckedChangeListener() {
54 | @Override
55 | public void onChanged(CheckedTextView ctv, boolean isChecked) {
56 | toast("isChecked = " + isChecked);
57 | }
58 | });
59 |
60 | ctvPrev.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | toast("我的click未被阻止");
64 | }
65 | });
66 |
67 | ctvPrev.setOnLongClickListener(new View.OnLongClickListener() {
68 | @Override
69 | public boolean onLongClick(View v) {
70 | toast("我的longClick未被阻止");
71 | return true;
72 | }
73 | });
74 |
75 | ctvPrev.setOnCheckedChangeListener(new CheckedTextView.OnCheckedChangeListener() {
76 | @Override
77 | public void onChanged(CheckedTextView ctv, boolean isChecked) {
78 | toast("isChecked = " + isChecked);
79 | }
80 | });
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/ClearEditTextActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import com.yhy.widget.demo.R;
4 | import com.yhy.widget.demo.activity.base.BaseActivity;
5 |
6 | /**
7 | * Created on 2022-09-27 11:22
8 | *
9 | * @author 颜洪毅
10 | * @version 1.0.0
11 | * @since 1.0.0
12 | */
13 | public class ClearEditTextActivity extends BaseActivity {
14 | @Override
15 | protected int getLayout() {
16 | return R.layout.activity_clear_edit_text;
17 | }
18 |
19 | @Override
20 | protected void initView() {
21 |
22 | }
23 |
24 | @Override
25 | protected void initData() {
26 |
27 | }
28 |
29 | @Override
30 | protected void initEvent() {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/ConstraintImageActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.view.View;
4 |
5 | import com.yhy.widget.core.img.ConstraintImageView;
6 | import com.yhy.widget.demo.R;
7 | import com.yhy.widget.demo.activity.base.BaseActivity;
8 | import com.yhy.widget.demo.entity.ImgUrls;
9 | import com.yhy.widget.demo.utils.ImgUtils;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2018-06-06 15:16
15 | * version: 1.0.0
16 | * desc :
17 | */
18 | public class ConstraintImageActivity extends BaseActivity {
19 |
20 | private ConstraintImageView civWidth;
21 | private ConstraintImageView civHeight;
22 | private ConstraintImageView civA;
23 | private ConstraintImageView civB;
24 | private ConstraintImageView civC;
25 | private ConstraintImageView civD;
26 | private ConstraintImageView civTest;
27 | private ConstraintImageView civTestRatio;
28 |
29 | @Override
30 | protected int getLayout() {
31 | return R.layout.activity_constraint_image_view;
32 | }
33 |
34 | @Override
35 | protected void initView() {
36 | civWidth = $(R.id.civ_width);
37 | civHeight = $(R.id.civ_height);
38 | civA = $(R.id.civ_a);
39 | civB = $(R.id.civ_b);
40 | civC = $(R.id.civ_c);
41 | civD = $(R.id.civ_d);
42 | civTest = $(R.id.civ_test);
43 | civTestRatio = $(R.id.civ_test_ratio);
44 | }
45 |
46 | @Override
47 | protected void initData() {
48 | ImgUtils.load(this, civWidth, ImgUrls.getAImgUrl());
49 | ImgUtils.load(this, civHeight, ImgUrls.getAImgUrl());
50 | ImgUtils.load(this, civA, ImgUrls.getAImgUrl());
51 | ImgUtils.load(this, civB, ImgUrls.getAImgUrl());
52 | ImgUtils.load(this, civC, ImgUrls.getAImgUrl());
53 | ImgUtils.load(this, civD, ImgUrls.getAImgUrl());
54 | ImgUtils.load(this, civTest, ImgUrls.getAImgUrl());
55 | ImgUtils.load(this, civTestRatio, ImgUrls.getAImgUrl());
56 | }
57 |
58 | @Override
59 | protected void initEvent() {
60 | civWidth.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | civWidth.setRatio(1.5f);
64 | civHeight.setRatio("250:300");
65 | civTest.setRatio(400, 400);
66 | }
67 | });
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/ETVActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.widget.TextView;
4 |
5 | import com.yhy.widget.core.exptext.ExpandTextView;
6 | import com.yhy.widget.demo.R;
7 | import com.yhy.widget.demo.activity.base.BaseActivity;
8 |
9 | public class ETVActivity extends BaseActivity {
10 |
11 | private ExpandTextView etvContent;
12 |
13 | @Override
14 | protected int getLayout() {
15 | return R.layout.activity_etv;
16 | }
17 |
18 | @Override
19 | protected void initView() {
20 | etvContent = findViewById(R.id.etv_content);
21 | etvContent.mapViewId(R.id.tv_content, R.id.tv_expand);
22 | }
23 |
24 | @Override
25 | protected void initData() {
26 | etvContent.setText("哈哈哈哈哈哈啊哈哈哈哈");
27 | etvContent.setText("测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本");
28 | }
29 |
30 | @Override
31 | protected void initEvent() {
32 | etvContent.setOnExpandStateChangeListener(new ExpandTextView.OnExpandStateChangeListener() {
33 | @Override
34 | public void onExpandStateChanged(TextView textView, boolean isExpanded) {
35 | toast(isExpanded ? "展开了" : "收起了");
36 | }
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/FlowLayoutActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import com.yhy.widget.demo.R;
4 | import com.yhy.widget.demo.activity.base.BaseActivity;
5 |
6 | /**
7 | * author : 颜洪毅
8 | * e-mail : yhyzgn@gmail.com
9 | * time : 2017-12-08 16:51
10 | * version: 1.0.0
11 | * desc :
12 | */
13 | public class FlowLayoutActivity extends BaseActivity {
14 | @Override
15 | protected int getLayout() {
16 | return R.layout.activity_flow_layout;
17 | }
18 |
19 | @Override
20 | protected void initView() {
21 | }
22 |
23 | @Override
24 | protected void initData() {
25 | }
26 |
27 | @Override
28 | protected void initEvent() {
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/GradientTextViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import com.yhy.widget.demo.R;
4 | import com.yhy.widget.demo.activity.base.BaseActivity;
5 |
6 | /**
7 | * author : 颜洪毅
8 | * e-mail : yhyzgn@gmail.com
9 | * time : 2018-06-06 16:45
10 | * version: 1.0.0
11 | * desc :
12 | */
13 | public class GradientTextViewActivity extends BaseActivity {
14 | @Override
15 | protected int getLayout() {
16 | return R.layout.activity_gradient_text_view;
17 | }
18 |
19 | @Override
20 | protected void initView() {
21 |
22 | }
23 |
24 | @Override
25 | protected void initData() {
26 |
27 | }
28 |
29 | @Override
30 | protected void initEvent() {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/LineTextViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import com.yhy.widget.demo.R;
4 | import com.yhy.widget.demo.activity.base.BaseActivity;
5 |
6 | /**
7 | * author : 颜洪毅
8 | * e-mail : yhyzgn@gmail.com
9 | * time : 2018-06-06 16:45
10 | * version: 1.0.0
11 | * desc :
12 | */
13 | public class LineTextViewActivity extends BaseActivity {
14 | @Override
15 | protected int getLayout() {
16 | return R.layout.activity_line_text_view;
17 | }
18 |
19 | @Override
20 | protected void initView() {
21 | }
22 |
23 | @Override
24 | protected void initData() {
25 | }
26 |
27 | @Override
28 | protected void initEvent() {
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/PickViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import com.yhy.widget.core.picker.PickerView;
4 | import com.yhy.widget.demo.R;
5 | import com.yhy.widget.demo.activity.base.BaseActivity;
6 | import com.yhy.widget.demo.entity.TestEntity;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2017-09-08 19:58
15 | * version: 1.0.0
16 | * desc :
17 | */
18 | public class PickViewActivity extends BaseActivity {
19 |
20 | private PickerView pvTest;
21 |
22 | @Override
23 | protected int getLayout() {
24 | return R.layout.activity_pick_view;
25 | }
26 |
27 | @Override
28 | protected void initView() {
29 | pvTest = findViewById(R.id.pv_test);
30 | }
31 |
32 | @Override
33 | protected void initData() {
34 | List testList = new ArrayList<>();
35 | for (int i = 1; i <= 40; i++) {
36 | testList.add(new TestEntity(i, "Data " + i));
37 | }
38 |
39 | pvTest.setData(testList, new PickerView.ItemProvider() {
40 | @Override
41 | public String getItem(TestEntity data, int position) {
42 | return data.name;
43 | }
44 | }).setOnSelectListener(new PickerView.OnSelectListener() {
45 | @Override
46 | public void onSelect(TestEntity data) {
47 | toast(data.name);
48 | }
49 | });
50 | }
51 |
52 | @Override
53 | protected void initEvent() {
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/PreviewImageActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.widget.ImageView;
4 |
5 | import com.yhy.widget.core.preview.ImgPreCfg;
6 | import com.yhy.widget.core.preview.PreImgActivity;
7 | import com.yhy.widget.core.preview.PreviewModel;
8 | import com.yhy.widget.demo.R;
9 | import com.yhy.widget.demo.activity.base.BaseActivity;
10 | import com.yhy.widget.demo.entity.ImgUrls;
11 | import com.yhy.widget.demo.utils.ImgUtils;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class PreviewImageActivity extends BaseActivity {
17 |
18 | private ImageView ivA;
19 | private ImageView ivB;
20 |
21 | @Override
22 | protected int getLayout() {
23 | return R.layout.activity_preview_image;
24 | }
25 |
26 | @Override
27 | protected void initView() {
28 | ivA = findViewById(R.id.iv_a);
29 | ivB = findViewById(R.id.iv_b);
30 | }
31 |
32 | @Override
33 | protected void initData() {
34 | ImgUtils.load(this, ivB, "/storage/emulated/0/Download/103340rc8v3xuddce27y8w.jpg");
35 | }
36 |
37 | @Override
38 | protected void initEvent() {
39 | ivA.setOnClickListener(v -> preview(ivA));
40 |
41 | ivB.setOnClickListener(v -> {
42 | ImgPreCfg cfg = new ImgPreCfg(v, new PreviewModel().setUrl(ImgUrls.getAImgUrl()).setType(PreviewModel.TYPE_IMAGE));
43 | // cfg.setDownloadable(false);
44 | PreImgActivity.preview(PreviewImageActivity.this, cfg);
45 | });
46 | }
47 |
48 | private void preview(ImageView iv) {
49 | List list = new ArrayList<>();
50 | for (int i = 0; i < 4; i++) {
51 | list.add(new PreviewModel().setName("图片" + (i + 1)).setUrl(ImgUrls.getAImgUrl()).setType(PreviewModel.TYPE_IMAGE));
52 | }
53 | list.add(new PreviewModel().setName("GG").setUrl("http://rbv01.ku6.com/omtSn0z_PTREtneb3GRtGg.mp4").setType(PreviewModel.TYPE_VIDEO).setThumbnail(ImgUrls.getAImgUrl()));
54 | list.add(new PreviewModel().setName("图片--1234").setUrl(ImgUrls.getAImgUrl()).setType(PreviewModel.TYPE_IMAGE));
55 | list.add(new PreviewModel().setName("SIN_TEL").setUrl("http://rbv01.ku6.com/7lut5JlEO-v6a8K3X9xBNg.mp4").setType(PreviewModel.TYPE_VIDEO).setThumbnail(ImgUrls.getAImgUrl()));
56 | list.add(new PreviewModel().setName("图片--34234").setUrl(ImgUrls.getAImgUrl()).setType(PreviewModel.TYPE_IMAGE));
57 | list.add(new PreviewModel().setName("试试").setUrl("/storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4").setType(PreviewModel.TYPE_VIDEO).setThumbnail("/storage/emulated/0/Download/v2-2af194dc7206f39c80bbb209bafbae28_r.jpg"));
58 | ImgPreCfg cfg = new ImgPreCfg(iv, list, 8);
59 | // cfg.setDownloadable(false);
60 | // cfg.setDownloadIconId(R.mipmap.ic_def_download);
61 | PreImgActivity.preview(this, cfg);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/RIVActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.widget.ImageView;
4 |
5 | import com.yhy.widget.core.img.round.CircleImageView;
6 | import com.yhy.widget.core.img.round.RoundImageView;
7 | import com.yhy.widget.demo.R;
8 | import com.yhy.widget.demo.activity.base.BaseActivity;
9 | import com.yhy.widget.demo.entity.ImgUrls;
10 | import com.yhy.widget.demo.utils.ImgUtils;
11 |
12 | public class RIVActivity extends BaseActivity {
13 |
14 | private CircleImageView civAvatar;
15 | private RoundImageView rivA;
16 | private RoundImageView rivB;
17 | private RoundImageView rivC;
18 | private RoundImageView rivD;
19 | private RoundImageView rivTest;
20 | private ImageView ivTest;
21 |
22 | @Override
23 | protected int getLayout() {
24 | return R.layout.activity_riv;
25 | }
26 |
27 | @Override
28 | protected void initView() {
29 | civAvatar = findViewById(R.id.civ_avatar);
30 | rivA = findViewById(R.id.riv_a);
31 | rivB = findViewById(R.id.riv_b);
32 | rivC = findViewById(R.id.riv_c);
33 | rivD = findViewById(R.id.riv_d);
34 | rivTest = findViewById(R.id.riv_test);
35 | ivTest = findViewById(R.id.iv_test);
36 | }
37 |
38 | @Override
39 | protected void initData() {
40 | ImgUtils.load(this, civAvatar, ImgUrls.getAImgUrl());
41 | ImgUtils.load(this, rivA, ImgUrls.getAImgUrl());
42 | ImgUtils.load(this, rivB, ImgUrls.getAImgUrl());
43 | // ImgUtils.load(this, rivC, "https://fanyi-cdn.cdn.bcebos.com/webStatic/translation/asset/wechat-icon.194f5b65.png");
44 | ImgUtils.load(this, rivD, ImgUrls.getAImgUrl());
45 |
46 | String testUrl = ImgUrls.getAImgUrl();
47 | ImgUtils.load(this, rivTest, testUrl);
48 | ImgUtils.load(this, ivTest, testUrl);
49 | }
50 |
51 | @Override
52 | protected void initEvent() {
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/RvActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import androidx.recyclerview.widget.GridLayoutManager;
4 | import androidx.recyclerview.widget.LinearLayoutManager;
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import com.yhy.widget.core.recycler.div.RvDivider;
8 | import com.yhy.widget.demo.R;
9 | import com.yhy.widget.demo.activity.base.BaseActivity;
10 | import com.yhy.widget.demo.adapter.RvTestAdapter;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | public class RvActivity extends BaseActivity {
16 | private final List TEST_STR_LIST = new ArrayList<>();
17 | private RecyclerView rvContent;
18 | private RvDivider mDivider;
19 |
20 | @Override
21 | protected int getLayout() {
22 | return R.layout.activity_rv;
23 | }
24 |
25 | @Override
26 | protected void initView() {
27 | rvContent = findViewById(R.id.rv_content);
28 | }
29 |
30 | @Override
31 | protected void initData() {
32 | TEST_STR_LIST.add("Test 1");
33 | TEST_STR_LIST.add("Test 2");
34 | TEST_STR_LIST.add("Test 3");
35 | TEST_STR_LIST.add("Test 4");
36 | TEST_STR_LIST.add("Test 5");
37 | TEST_STR_LIST.add("Test 6");
38 | TEST_STR_LIST.add("Test 7");
39 |
40 | mDivider = new RvDivider.Builder(this)
41 | .widthDp(30)
42 | .color(getResources().getColor(R.color.colorPrimary))
43 | .type(RvDivider.DividerType.TYPE_WITH_START_END)
44 | .build();
45 |
46 | // horizontal();
47 |
48 | // vertical();
49 |
50 | gridview();
51 | }
52 |
53 | @Override
54 | protected void initEvent() {
55 |
56 | }
57 |
58 | private void gridview() {
59 | rvContent.setLayoutManager(new GridLayoutManager(this, 4));
60 |
61 | rvContent.setAdapter(new RvTestAdapter(this, TEST_STR_LIST));
62 | rvContent.addItemDecoration(mDivider);
63 | }
64 |
65 | private void vertical() {
66 | rvContent.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
67 |
68 | rvContent.setAdapter(new RvTestAdapter(this, TEST_STR_LIST));
69 | rvContent.addItemDecoration(mDivider);
70 | }
71 |
72 | private void horizontal() {
73 | rvContent.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
74 |
75 | rvContent.setAdapter(new RvTestAdapter(this, TEST_STR_LIST));
76 | rvContent.addItemDecoration(mDivider);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.widget.Toast;
5 |
6 | import com.yhy.widget.core.settings.SettingsItemView;
7 | import com.yhy.widget.core.toggle.SwitchButton;
8 | import com.yhy.widget.demo.R;
9 | import com.yhy.widget.demo.activity.base.BaseActivity;
10 |
11 | public class SettingsActivity extends BaseActivity {
12 |
13 | private SettingsItemView sivSwitch;
14 |
15 | @Override
16 | protected int getLayout() {
17 | return R.layout.activity_settings;
18 | }
19 |
20 | @Override
21 | protected void initView() {
22 | sivSwitch = (SettingsItemView) findViewById(R.id.siv_switch);
23 | }
24 |
25 | @Override
26 | protected void initData() {
27 |
28 | }
29 |
30 | @Override
31 | protected void initEvent() {
32 | sivSwitch.setOnSwitchStateChangeListener(new SettingsItemView.OnSwitchStateChangeListener() {
33 | @Override
34 | public void onStateChanged(SettingsItemView siv, SwitchButton sb, boolean isOn) {
35 | toast(siv.getName() + " :: isOn = " + isOn);
36 | }
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/StatusDialogActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.os.Handler;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.yhy.widget.core.dialog.status.StatusDialogManager;
8 | import com.yhy.widget.demo.R;
9 | import com.yhy.widget.demo.activity.base.BaseActivity;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2018-06-06 17:53
15 | * version: 1.0.0
16 | * desc :
17 | */
18 | public class StatusDialogActivity extends BaseActivity {
19 |
20 | private TextView tvLoading;
21 | private TextView tvSuccess;
22 | private TextView tvFailed;
23 | private TextView tvError;
24 |
25 | private StatusDialogManager mManager;
26 |
27 | @Override
28 | protected int getLayout() {
29 | return R.layout.activity_status_dialog;
30 | }
31 |
32 | @Override
33 | protected void initView() {
34 | tvLoading = $(R.id.tv_loading);
35 | tvSuccess = $(R.id.tv_success);
36 | tvFailed = $(R.id.tv_failed);
37 | tvError = $(R.id.tv_error);
38 |
39 | mManager = StatusDialogManager
40 | .with(this)
41 | .loadingText("正在加载...")
42 | .successText("成功啦")
43 | .failedText("失败咯")
44 | .errorText("出错啦")
45 | .enableLoadingCancel(true)
46 | .duration(3000)
47 | .create();
48 | }
49 |
50 | @Override
51 | protected void initData() {
52 | }
53 |
54 | @Override
55 | protected void initEvent() {
56 | tvLoading.setOnClickListener(new View.OnClickListener() {
57 | @Override
58 | public void onClick(View v) {
59 | mManager.loading();
60 | new Handler().postDelayed(new Runnable() {
61 | @Override
62 | public void run() {
63 | mManager.dismiss();
64 | }
65 | }, 10000);
66 | }
67 | });
68 |
69 | tvSuccess.setOnClickListener(new View.OnClickListener() {
70 | @Override
71 | public void onClick(View v) {
72 | mManager.success();
73 | }
74 | });
75 |
76 | tvFailed.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | mManager.failed();
80 | }
81 | });
82 |
83 | tvError.setOnClickListener(new View.OnClickListener() {
84 | @Override
85 | public void onClick(View v) {
86 | mManager.error();
87 | }
88 | });
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/SwitchButtonActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import com.yhy.widget.core.toggle.SwitchButton;
4 | import com.yhy.widget.demo.R;
5 | import com.yhy.widget.demo.activity.base.BaseActivity;
6 |
7 | public class SwitchButtonActivity extends BaseActivity {
8 |
9 | private SwitchButton switchButton;
10 |
11 | @Override
12 | protected int getLayout() {
13 | return R.layout.activity_switch_button;
14 | }
15 |
16 | @Override
17 | protected void initView() {
18 | switchButton = (SwitchButton) findViewById(R.id.switch_button);
19 |
20 | switchButton.onOrOff(true);
21 | switchButton.isOn();
22 | switchButton.toggle(); //switch state
23 | switchButton.toggle(false);//switch without animation
24 | switchButton.setShadowEffect(true);//disable shadow effect
25 | switchButton.setEnabled(true);//disable button
26 | switchButton.setEnableEffect(false);//disable the switch animation
27 | }
28 |
29 | @Override
30 | protected void initData() {
31 |
32 | }
33 |
34 | @Override
35 | protected void initEvent() {
36 | switchButton.setOnStateChangeListener(new SwitchButton.OnStateChangeListener() {
37 | @Override
38 | public void onCheckedChanged(SwitchButton view, boolean isOn) {
39 | toast("isOn = " + isOn);
40 | }
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/WebHybridActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity;
2 |
3 | import android.app.AlertDialog;
4 | import android.webkit.JavascriptInterface;
5 | import android.webkit.JsResult;
6 | import android.widget.Button;
7 | import android.widget.Toast;
8 |
9 | import com.yhy.widget.core.web.HybridWebView;
10 | import com.yhy.widget.core.web.bridge.HybridBridge;
11 | import com.yhy.widget.core.web.listener.SimpleOnWebEventListener;
12 | import com.yhy.widget.demo.R;
13 | import com.yhy.widget.demo.activity.base.BaseActivity;
14 |
15 | /**
16 | * author : 颜洪毅
17 | * e-mail : yhyzgn@gmail.com
18 | * time : 2018-05-25 15:26
19 | * version: 1.0.0
20 | * desc :
21 | */
22 | public class WebHybridActivity extends BaseActivity {
23 |
24 | private HybridWebView hwvContent;
25 | private Button btnTest;
26 |
27 | @Override
28 | protected int getLayout() {
29 | return R.layout.activity_web_hybrid;
30 | }
31 |
32 | @Override
33 | protected void initView() {
34 | hwvContent = $(R.id.hwv_content);
35 | btnTest = $(R.id.btn_test);
36 | }
37 |
38 | @Override
39 | protected void initData() {
40 | // 注册交互桥梁
41 | hwvContent.register(new TestBridge());
42 | // 加载页面
43 | hwvContent.loadUrl("file:///android_asset/index.html");
44 | }
45 |
46 | @Override
47 | protected void initEvent() {
48 | hwvContent.setOnWebEventListener(new SimpleOnWebEventListener() {
49 | @Override
50 | public boolean onJsAlert(HybridWebView view, String url, String message, final JsResult result) {
51 | AlertDialog.Builder builder = new AlertDialog.Builder(WebHybridActivity.this);
52 | builder
53 | .setTitle("标题")
54 | .setMessage(message)
55 | .setPositiveButton("确定", (dialog, which) -> result.confirm())
56 | .show();
57 | //返回true表示不再往下传递弹窗事件,即不再使用原本WebView的弹窗,否则会弹出两次弹窗
58 | return true;
59 | }
60 | });
61 |
62 | btnTest.setOnClickListener(v -> {
63 | // 调用js中的test函数
64 | // hwvContent.js("test", "小姐姐");
65 | hwvContent.js("noArg");
66 | });
67 | }
68 |
69 | /**
70 | * 交互桥梁,必须是HybridBridge的子类
71 | */
72 | public class TestBridge extends HybridBridge {
73 |
74 | @JavascriptInterface
75 | public String test(String json) {
76 | Toast.makeText(WebHybridActivity.this, json, Toast.LENGTH_LONG).show();
77 | return "Android接收到数据啦";
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/activity/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.activity.base;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.Nullable;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2017-12-08 10:06
13 | * version: 1.0.0
14 | * desc :
15 | */
16 | public abstract class BaseActivity extends AppCompatActivity {
17 |
18 | @Override
19 | protected void onCreate(@Nullable Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(getLayout());
22 | initView();
23 | initData();
24 | initEvent();
25 | }
26 |
27 | protected abstract int getLayout();
28 |
29 | protected abstract void initView();
30 |
31 | protected abstract void initData();
32 |
33 | protected abstract void initEvent();
34 |
35 | public T $(int id) {
36 | return findViewById(id);
37 | }
38 |
39 | public void toast(CharSequence text) {
40 | Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/adapter/RvTestAdapter.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import androidx.recyclerview.widget.RecyclerView;
6 | import android.view.Gravity;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * Created by HongYi Yan on 2017/4/12 13:39.
15 | */
16 | public class RvTestAdapter extends RecyclerView.Adapter {
17 | private Context mCtx;
18 | private List mDataList;
19 | private OnItemClickListener mItemClickListener;
20 |
21 | public RvTestAdapter(Context ctx, List dataList) {
22 | mCtx = ctx;
23 | mDataList = dataList;
24 | }
25 |
26 | @Override
27 | public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
28 | return new ViewHolder(new TextView(mCtx));
29 | }
30 |
31 | @Override
32 | public void onBindViewHolder(final ViewHolder viewHolder, int position) {
33 | viewHolder.mTv.setText(mDataList.get(position));
34 | viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | if (null != mItemClickListener) {
38 | mItemClickListener.onItemClick(v, RvTestAdapter.this, viewHolder.getAdapterPosition());
39 | }
40 | }
41 | });
42 | }
43 |
44 | @Override
45 | public int getItemCount() {
46 | return null != mDataList ? mDataList.size() : 0;
47 | }
48 |
49 | public void setOnItemClickListener(OnItemClickListener listener) {
50 | mItemClickListener = listener;
51 | }
52 |
53 | public class ViewHolder extends RecyclerView.ViewHolder {
54 | public TextView mTv;
55 | private RecyclerView.LayoutParams mParams = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
56 |
57 | public ViewHolder(View itemView) {
58 | super(itemView);
59 | mTv = (TextView) itemView;
60 | mParams.topMargin = 12;
61 | mParams.bottomMargin = 12;
62 | mTv.setLayoutParams(mParams);
63 | mTv.setTextSize(16);
64 | mTv.setBackgroundColor(Color.WHITE);
65 | mTv.setGravity(Gravity.CENTER);
66 | mTv.setPadding(24, 24, 24, 24);
67 | }
68 | }
69 |
70 | public interface OnItemClickListener {
71 | void onItemClick(View view, RecyclerView.Adapter adapter, int position);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/entity/ImgUrls.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.entity;
2 |
3 | import android.content.Context;
4 |
5 | import java.io.BufferedReader;
6 | import java.io.InputStream;
7 | import java.io.InputStreamReader;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 | import java.util.Random;
11 | import java.util.stream.Collectors;
12 |
13 | /**
14 | * author : 颜洪毅
15 | * e-mail : yhyzgn@gmail.com
16 | * time : 2018-01-08 13:14
17 | * version: 1.0.0
18 | * desc :
19 | */
20 | public class ImgUrls {
21 | private static final Random RAND = new Random(System.currentTimeMillis());
22 | private static final List IMG_URL_LIST = new ArrayList<>();
23 |
24 | public static void init(Context context) {
25 | try {
26 | InputStream is = context.getAssets().open("img-url.txt");
27 | BufferedReader reader = new BufferedReader(new InputStreamReader(is));
28 | List tempList = reader.lines().collect(Collectors.toList());
29 | if (!tempList.isEmpty()) {
30 | IMG_URL_LIST.addAll(tempList);
31 | }
32 | } catch (Exception e) {
33 | e.printStackTrace();
34 | }
35 | }
36 |
37 | public static String getAImgUrl() {
38 | if (IMG_URL_LIST.size() == 0) {
39 | throw new IllegalStateException("请先初始化 ImgUrls 类");
40 | }
41 | int index = RAND.nextInt(IMG_URL_LIST.size());
42 | return IMG_URL_LIST.get(index);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/entity/TestEntity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.entity;
2 |
3 | /**
4 | * author : 颜洪毅
5 | * e-mail : yhyzgn@gmail.com
6 | * time : 2017-09-08 20:01
7 | * version: 1.0.0
8 | * desc :
9 | */
10 | public class TestEntity {
11 | public int id;
12 | public String name;
13 |
14 | public TestEntity(int id, String name) {
15 | this.id = id;
16 | this.name = name;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/entity/TestStep.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.entity;
2 |
3 | import com.yhy.widget.core.step.entity.StepAble;
4 |
5 | /**
6 | * author : 颜洪毅
7 | * e-mail : yhyzgn@gmail.com
8 | * time : 2018-04-14 13:24
9 | * version: 1.0.0
10 | * desc :
11 | */
12 | public class TestStep implements StepAble {
13 |
14 | public String text;
15 | public Status status;
16 |
17 | public TestStep(String text) {
18 | this(text, Status.COMPLETE);
19 | }
20 |
21 | public TestStep(String text, Status status) {
22 | this.text = text;
23 | this.status = status;
24 | }
25 |
26 | @Override
27 | public Status getStatus() {
28 | return status;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/status/DefActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.status;
2 |
3 | import android.os.Bundle;
4 | import android.os.SystemClock;
5 | import androidx.annotation.Nullable;
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Toast;
9 |
10 | import com.yhy.widget.layout.status.StatusLayout;
11 | import com.yhy.widget.layout.status.listener.OnStatusRetryListener;
12 | import com.yhy.widget.demo.R;
13 |
14 | /**
15 | * author : 颜洪毅
16 | * e-mail : yhyzgn@gmail.com
17 | * time : 2017-10-13 15:19
18 | * version: 1.0.0
19 | * desc :
20 | */
21 | public class DefActivity extends AppCompatActivity {
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_status_def);
27 |
28 | final StatusLayout slContent = (StatusLayout) findViewById(R.id.sl_content);
29 |
30 | findViewById(R.id.btn_loading).setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View view) {
33 | slContent.showLoading();
34 | }
35 | });
36 |
37 | findViewById(R.id.btn_success).setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View view) {
40 | slContent.showSuccess();
41 | }
42 | });
43 |
44 | findViewById(R.id.btn_error).setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View view) {
47 | slContent.showError();
48 | }
49 | });
50 |
51 | findViewById(R.id.btn_empty).setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View view) {
54 | slContent.showEmpty();
55 | }
56 | });
57 |
58 | slContent.setOnStatusRetryListener(new OnStatusRetryListener() {
59 | @Override
60 | public void onRetry() {
61 | Toast.makeText(DefActivity.this, "重试加载...", Toast.LENGTH_SHORT).show();
62 | new Thread() {
63 | @Override
64 | public void run() {
65 | SystemClock.sleep(1000);
66 | slContent.showSuccess();
67 | }
68 | }.start();
69 | }
70 | });
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/status/LayoutActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.status;
2 |
3 | import android.os.Bundle;
4 | import android.os.SystemClock;
5 | import androidx.annotation.Nullable;
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Toast;
9 |
10 | import com.yhy.widget.layout.status.StatusLayout;
11 | import com.yhy.widget.layout.status.listener.OnStatusRetryListener;
12 | import com.yhy.widget.demo.R;
13 |
14 | /**
15 | * author : 颜洪毅
16 | * e-mail : yhyzgn@gmail.com
17 | * time : 2017-10-13 15:19
18 | * version: 1.0.0
19 | * desc :
20 | */
21 | public class LayoutActivity extends AppCompatActivity {
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_status_layout);
27 |
28 | final StatusLayout slContent = (StatusLayout) findViewById(R.id.sl_content);
29 |
30 | findViewById(R.id.btn_loading).setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View view) {
33 | slContent.showLoading();
34 | }
35 | });
36 |
37 | findViewById(R.id.btn_success).setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View view) {
40 | slContent.showSuccess();
41 | }
42 | });
43 |
44 | findViewById(R.id.btn_error).setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View view) {
47 | slContent.showError();
48 | }
49 | });
50 |
51 | findViewById(R.id.btn_empty).setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View view) {
54 | slContent.showEmpty();
55 | }
56 | });
57 |
58 | slContent.setOnStatusRetryListener(new OnStatusRetryListener() {
59 | @Override
60 | public void onRetry() {
61 | Toast.makeText(LayoutActivity.this, "重试加载...", Toast.LENGTH_SHORT).show();
62 | new Thread() {
63 | @Override
64 | public void run() {
65 | SystemClock.sleep(1000);
66 | slContent.showSuccess();
67 | }
68 | }.start();
69 | }
70 | });
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/status/StatusActivity.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.status;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import androidx.annotation.Nullable;
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import android.view.View;
8 |
9 | import com.yhy.widget.demo.R;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2017-10-13 15:14
15 | * version: 1.0.0
16 | * desc :
17 | */
18 | public class StatusActivity extends AppCompatActivity {
19 |
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_status);
24 |
25 | findViewById(R.id.btn_layout).setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View view) {
28 | startActivity(new Intent(StatusActivity.this, LayoutActivity.class));
29 | }
30 | });
31 |
32 | findViewById(R.id.btn_helper).setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View view) {
35 | startActivity(new Intent(StatusActivity.this, HelperActivity.class));
36 | }
37 | });
38 |
39 | findViewById(R.id.btn_def).setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View view) {
42 | startActivity(new Intent(StatusActivity.this, DefActivity.class));
43 | }
44 | });
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/utils/ImgUtils.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | /**
7 | * Created by HongYi Yan on 2017/4/6 16:48.
8 | */
9 | public class ImgUtils {
10 |
11 | private static ImgLoader mLoader;
12 |
13 | private ImgUtils() {
14 | throw new RuntimeException("Can not instantiate ImgUtils.");
15 | }
16 |
17 | public static void init(ImgLoader loader) {
18 | mLoader = loader;
19 | }
20 |
21 | public static void load(Context ctx, ImageView iv, T model) {
22 | if (null != mLoader) {
23 | mLoader.load(ctx, iv, model);
24 | }
25 | }
26 |
27 | /**
28 | * 图片加载器
29 | */
30 | @FunctionalInterface
31 | public interface ImgLoader {
32 | void load(Context ctx, ImageView iv, T model);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/yhy/widget/demo/utils/ToastUtils.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Toast工具类
8 | */
9 | public class ToastUtils {
10 | private static Context ctx;
11 |
12 | private ToastUtils() {
13 | throw new UnsupportedOperationException("Can not create instance for class ToastUtils.");
14 | }
15 |
16 | /**
17 | * 初始化,在Application中
18 | *
19 | * @param ctx 上下文对象
20 | */
21 | public static void init(Context ctx) {
22 | ToastUtils.ctx = ctx;
23 | }
24 |
25 | /**
26 | * 短时间显示
27 | *
28 | * @param text 提示的内容
29 | */
30 | public static void shortT(CharSequence text) {
31 | toast(false, text);
32 | }
33 |
34 | /**
35 | * 长时间显示
36 | *
37 | * @param text 提示的内容
38 | */
39 | public static void longT(CharSequence text) {
40 | toast(true, text);
41 | }
42 |
43 | /**
44 | * 短时间显示
45 | *
46 | * @param resId 提示的内容资源id
47 | */
48 | public static void shortT(int resId) {
49 | toast(false, ctx.getResources().getString(resId));
50 | }
51 |
52 | /**
53 | * 长时间显示
54 | *
55 | * @param resId 提示的内容资源id
56 | */
57 | public static void longT(int resId) {
58 | toast(true, ctx.getResources().getString(resId));
59 | }
60 |
61 | /**
62 | * toast显示
63 | *
64 | * @param longToast 是否是长提显示
65 | * @param text 显示内容
66 | */
67 | private static void toast(boolean longToast, CharSequence text) {
68 | Toast.makeText(ctx, text, longToast ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/anim_alpha_image_load.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_checked_ctv_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cursor_bg_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_adv.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_checked_relative_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
22 |
23 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_checked_textview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
30 |
31 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_clear_edit_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_etv.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
28 |
29 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_gradient_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_input_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_line_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
34 |
35 |
44 |
45 |
56 |
57 |
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pick_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_preview_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rv.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_slider.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
25 |
26 |
27 |
32 |
33 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_square_imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_status.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_status_def.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
27 |
28 |
34 |
35 |
41 |
42 |
43 |
48 |
49 |
50 |
56 |
57 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_status_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
26 |
27 |
36 |
37 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_step_view_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
19 |
20 |
26 |
27 |
28 |
33 |
34 |
38 |
39 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_switch_button.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
20 |
21 |
27 |
28 |
34 |
35 |
45 |
46 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tag_flow.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
19 |
20 |
26 |
27 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_hybrid.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_square_iv_rv.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_step_horizontal.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_step_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_tag_flow.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/d.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/d.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/e.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/e.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_arrow_right.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_avatar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_avatar.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_logo.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_more.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_notice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_notice.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_step_finished.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xhdpi/ic_step_finished.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/bg_main.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/bg_main.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/ic_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/img_pager_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/img_pager_1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/img_pager_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/img_pager_2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/img_pager_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/img_pager_3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/img_pager_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxhdpi/img_pager_4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - @color/red
6 | - @color/red_light
7 | - @color/orange
8 | - @color/red_light
9 | - @color/red
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #000000
7 |
8 | @color/colorAccent
9 |
10 | #ff2200
11 | #ff6600
12 | @android:color/holo_orange_dark
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Widgets
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/test/java/com/yhy/widget/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.demo;
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() throws Exception {
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 | plugins {
3 | id 'com.android.application' version '8.0.2' apply false
4 | id 'com.android.library' version '8.0.2' apply false
5 | id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
6 | }
--------------------------------------------------------------------------------
/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 | --illegal-access=warn
17 | --add-opens=java.base/java.io=ALL-UNNAMED
18 | android.defaults.buildfeatures.buildconfig=true
19 | android.nonTransitiveRClass=false
20 | android.nonFinalResIds=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 20 15:04:13 CST 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/imgs/download_qr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/imgs/download_qr.png
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | #jdk:
2 | # - openjdk11
3 |
4 | before_install:
5 | - source "$HOME/.sdkman/bin/sdkman-init.sh"
6 | - sdk update
7 | - sdk install java 11.0.2-open
8 | - sdk use java 11.0.2-open
9 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | mavenLocal()
4 | maven { url 'https://jitpack.io' }
5 | maven { url "https://maven.aliyun.com/repository/public" }
6 | mavenCentral()
7 | google()
8 | gradlePluginPortal()
9 | }
10 | }
11 | dependencyResolutionManagement {
12 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
13 | repositories {
14 | mavenLocal()
15 | maven { url 'https://jitpack.io' }
16 | maven { url "https://maven.aliyun.com/repository/public" }
17 | mavenCentral()
18 | google()
19 | gradlePluginPortal()
20 | }
21 | }
22 |
23 | rootProject.name = "Widgets"
24 | include ':widget'
25 | include ':app'
--------------------------------------------------------------------------------
/widget/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/widget/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | }
4 |
5 | android {
6 | namespace 'com.yhy.widget'
7 | compileSdkVersion 33
8 |
9 | defaultConfig {
10 | minSdkVersion 19
11 | targetSdkVersion 33
12 |
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | // 已包含 viewBinding 的所有功能
24 | dataBinding {
25 | enabled true
26 | }
27 |
28 |
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_11
31 | targetCompatibility JavaVersion.VERSION_11
32 | }
33 |
34 | testOptions {
35 | unitTests.returnDefaultValues = true
36 | }
37 | lint {
38 | abortOnError false
39 | checkReleaseBuilds false
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation 'androidx.appcompat:appcompat:1.6.1'
45 | implementation 'androidx.recyclerview:recyclerview:1.3.0'
46 | implementation 'com.google.android.material:material:1.9.0'
47 |
48 | api 'com.github.chrisbanes:PhotoView:2.3.0'
49 | api 'com.nineoldandroids:library:2.4.0'
50 | api 'com.github.ybq:Android-SpinKit:1.4.0'
51 |
52 | // 完整版引入
53 | api 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer:v8.3.4-release-jitpack'
54 |
55 | api 'com.guolindev.permissionx:permissionx:1.7.1'
56 |
57 | testImplementation 'junit:junit:4.13.2'
58 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
59 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
60 | }
--------------------------------------------------------------------------------
/widget/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/widget/src/androidTest/java/com/yhy/widget/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget;
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 | * Instrumentation 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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yhy.widget.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/widget/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
9 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
28 |
29 |
35 |
36 |
41 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/component/downloader/FilenameGenerator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.component.downloader;
2 |
3 | import android.text.TextUtils;
4 |
5 | import com.yhy.widget.utils.WidgetCoreUtils;
6 |
7 | /**
8 | * Created on 2022-10-28 16:21
9 | *
10 | * @author 颜洪毅
11 | * @version 1.0.0
12 | * @since 1.0.0
13 | */
14 | public class FilenameGenerator {
15 |
16 | /**
17 | * 生成文件名
18 | *
19 | * @param filepath 原始路径
20 | * @return 文件名
21 | */
22 | public static String generate(String filepath) {
23 | if (!TextUtils.isEmpty(filepath)) {
24 | String md5 = WidgetCoreUtils.md5(filepath);
25 | String ext = WidgetCoreUtils.getExt(filepath);
26 | if (!TextUtils.isEmpty(ext)) {
27 | filepath = md5 + "." + ext;
28 | }
29 | }
30 | return filepath;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/component/provider/WidgetFileProvider.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.component.provider;
2 |
3 | import androidx.core.content.FileProvider;
4 |
5 | /**
6 | * Created on 2022-10-24 10:54
7 | *
8 | * @author 颜洪毅
9 | * @version 1.0.0
10 | * @since 1.0.0
11 | */
12 | public class WidgetFileProvider extends FileProvider {
13 | }
14 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/adv/adapter/AdvAdapter.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.adv.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2017-09-21 14:18
13 | * version: 1.0.0
14 | * desc :
15 | */
16 | public abstract class AdvAdapter {
17 |
18 | protected Context mCtx;
19 | private LayoutInflater mLayoutInflater;
20 | protected List mData;
21 |
22 | public AdvAdapter(Context context, List list) {
23 | mCtx = context;
24 | mData = list;
25 | mLayoutInflater = LayoutInflater.from(context);
26 | }
27 |
28 | /**
29 | * 提供数据集合的大小
30 | *
31 | * @return 数据集合的大小
32 | */
33 | public int getCount() {
34 | if (mData == null) {
35 | return 0;
36 | }
37 | return mData.size();
38 | }
39 |
40 | /**
41 | * 获取数据条目
42 | *
43 | * @param position 索引
44 | * @return 具体的一条数据
45 | */
46 | public T getItem(int position) {
47 | return mData.get(position);
48 | }
49 |
50 | /**
51 | * 获得 item 根 View
52 | *
53 | * @param layoutID item 布局 ID
54 | * @return item 根 View
55 | */
56 | protected View getRootView(int layoutID) {
57 | return mLayoutInflater.inflate(layoutID, null);
58 | }
59 |
60 | /**
61 | * 提供具体的 View
62 | *
63 | * @param position view 所在的索引
64 | * @return 具体的 View
65 | */
66 | public abstract View getView(int position);
67 | }
68 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/adv/adapter/TextAdvAdapter.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.adv.adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.text.TextUtils;
6 | import android.view.Gravity;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * author : 颜洪毅
15 | * e-mail : yhyzgn@gmail.com
16 | * time : 2017-09-21 14:18
17 | * version: 1.0.0
18 | * desc :
19 | */
20 | public class TextAdvAdapter extends AdvAdapter {
21 | private Context mCtx;
22 | private List mDataList;
23 | private ViewGroup.LayoutParams mParams;
24 |
25 | public TextAdvAdapter(Context ctx, List list) {
26 | super(ctx, list);
27 | mCtx = ctx;
28 | mDataList = list;
29 | mParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
30 | }
31 |
32 | @Override
33 | public View getView(int position) {
34 | return createTextView(getItem(position));
35 | }
36 |
37 | protected TextView createTextView(String text) {
38 | TextView tv = new TextView(mCtx);
39 | tv.setLayoutParams(mParams);
40 | tv.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
41 | tv.setText(text);
42 | tv.setTextColor(Color.DKGRAY);
43 | tv.setTextSize(14);
44 | tv.setSingleLine();
45 | tv.setEllipsize(TextUtils.TruncateAt.END);
46 | return tv;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/dialog/status/abs/AbsUnableCancelStatusDialog.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.dialog.status.abs;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.os.Handler;
6 |
7 | import androidx.annotation.NonNull;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2019-04-02 17:11
13 | * version: 1.0.0
14 | * desc : 禁止取消的抽象类弹窗
15 | */
16 | public abstract class AbsUnableCancelStatusDialog extends AbsStatusDialog {
17 | // 默认显示时间为1s
18 | private static final long DURATION = 1000;
19 | private long mDuration;
20 |
21 | public AbsUnableCancelStatusDialog(@NonNull Context context) {
22 | this(context, "Text");
23 | }
24 |
25 | public AbsUnableCancelStatusDialog(@NonNull Context context, CharSequence text) {
26 | this(context, text, DURATION);
27 | }
28 |
29 | public AbsUnableCancelStatusDialog(@NonNull Context context, CharSequence text, long duration) {
30 | super(context, text);
31 | mDuration = duration;
32 | setOnShowListener();
33 | }
34 |
35 | /**
36 | * 设置显示时长,单位:ms
37 | *
38 | * @param duration 显示时长
39 | * @return 当前对象
40 | */
41 | public final AbsUnableCancelStatusDialog setDuration(long duration) {
42 | mDuration = duration;
43 | setOnShowListener();
44 | return this;
45 | }
46 |
47 | @Override
48 | public final AbsStatusDialog setCancelable(boolean cancelable, boolean canceledOnTouchOutside) {
49 | return super.setCancelable(false, false);
50 | }
51 |
52 | @Override
53 | public final void setCancelable(boolean flag) {
54 | super.setCancelable(false);
55 | }
56 |
57 | @Override
58 | public final void setCanceledOnTouchOutside(boolean cancel) {
59 | super.setCanceledOnTouchOutside(false);
60 | }
61 |
62 | private void setOnShowListener() {
63 | // 显示后设置回调,定时隐藏
64 | setOnShowListener(new OnShowListener() {
65 | @Override
66 | public void onShow(DialogInterface dialog) {
67 | new Handler().postDelayed(new Runnable() {
68 | @Override
69 | public void run() {
70 | AbsUnableCancelStatusDialog.this.dismiss();
71 | }
72 | }, mDuration);
73 | }
74 | });
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/dialog/status/dialog/ErrorDialog.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.dialog.status.dialog;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 |
7 | import com.yhy.widget.R;
8 | import com.yhy.widget.core.dialog.status.abs.AbsUnableCancelStatusDialog;
9 |
10 | import androidx.annotation.NonNull;
11 |
12 | /**
13 | * author : 颜洪毅
14 | * e-mail : yhyzgn@gmail.com
15 | * time : 2019-04-02 16:55
16 | * version: 1.0.0
17 | * desc : 错误状态弹窗提示
18 | */
19 | public class ErrorDialog extends AbsUnableCancelStatusDialog {
20 |
21 | public ErrorDialog(@NonNull Context context) {
22 | super(context);
23 | }
24 |
25 | public ErrorDialog(@NonNull Context context, CharSequence text) {
26 | super(context, text);
27 | }
28 |
29 | public ErrorDialog(@NonNull Context context, CharSequence text, long duration) {
30 | super(context, text, duration);
31 | }
32 |
33 | @Override
34 | protected View statusView() {
35 | return defaultView();
36 | }
37 |
38 | /**
39 | * 默认view
40 | *
41 | * @return 默认view
42 | */
43 | private View defaultView() {
44 | ImageView img = new ImageView(getContext());
45 | img.setImageResource(R.mipmap.icon_status_dialog_error);
46 | return img;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/dialog/status/dialog/FailedDialog.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.dialog.status.dialog;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 |
7 | import com.yhy.widget.R;
8 | import com.yhy.widget.core.dialog.status.abs.AbsUnableCancelStatusDialog;
9 |
10 | import androidx.annotation.NonNull;
11 |
12 | /**
13 | * author : 颜洪毅
14 | * e-mail : yhyzgn@gmail.com
15 | * time : 2019-04-02 16:55
16 | * version: 1.0.0
17 | * desc : 失败状态弹窗提示
18 | */
19 | public class FailedDialog extends AbsUnableCancelStatusDialog {
20 |
21 | public FailedDialog(@NonNull Context context) {
22 | super(context);
23 | }
24 |
25 | public FailedDialog(@NonNull Context context, CharSequence text) {
26 | super(context, text);
27 | }
28 |
29 | public FailedDialog(@NonNull Context context, CharSequence text, long duration) {
30 | super(context, text, duration);
31 | }
32 |
33 | @Override
34 | protected View statusView() {
35 | return defaultView();
36 | }
37 |
38 | /**
39 | * 默认view
40 | *
41 | * @return 默认view
42 | */
43 | private View defaultView() {
44 | ImageView img = new ImageView(getContext());
45 | img.setImageResource(R.mipmap.icon_status_dialog_failed);
46 | return img;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/dialog/status/dialog/LoadingDialog.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.dialog.status.dialog;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ProgressBar;
8 |
9 | import com.yhy.widget.R;
10 | import com.yhy.widget.core.dialog.status.abs.AbsStatusDialog;
11 | import com.yhy.widget.utils.WidgetCoreUtils;
12 |
13 | import androidx.annotation.NonNull;
14 |
15 | /**
16 | * author : 颜洪毅
17 | * e-mail : yhyzgn@gmail.com
18 | * time : 2018-01-06 14:37
19 | * version: 1.0.0
20 | * desc : 加载中进度弹窗
21 | */
22 | public class LoadingDialog extends AbsStatusDialog {
23 |
24 | public LoadingDialog(@NonNull Context context) {
25 | this(context, "Loading...");
26 | }
27 |
28 | public LoadingDialog(@NonNull Context context, CharSequence text) {
29 | super(context, text);
30 | }
31 |
32 | @Override
33 | protected View statusView() {
34 | return defaultView();
35 | }
36 |
37 | /**
38 | * 默认view
39 | *
40 | * @return 默认view
41 | */
42 | private View defaultView() {
43 | ProgressBar pbLoading = new ProgressBar(getContext());
44 | pbLoading.setLayoutParams(new ViewGroup.LayoutParams(WidgetCoreUtils.dp2px(getContext(), 60), WidgetCoreUtils.dp2px(getContext(), 60)));
45 | pbLoading.setIndeterminateDrawable(getContext().getResources().getDrawable(R.drawable.icon_status_dialog_loading));
46 | pbLoading.setIndeterminate(true);
47 | return pbLoading;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/dialog/status/dialog/SuccessDialog.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.dialog.status.dialog;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 |
7 | import com.yhy.widget.R;
8 | import com.yhy.widget.core.dialog.status.abs.AbsUnableCancelStatusDialog;
9 |
10 | import androidx.annotation.NonNull;
11 |
12 | /**
13 | * author : 颜洪毅
14 | * e-mail : yhyzgn@gmail.com
15 | * time : 2019-04-02 16:55
16 | * version: 1.0.0
17 | * desc : 成功状态弹窗提示
18 | */
19 | public class SuccessDialog extends AbsUnableCancelStatusDialog {
20 |
21 | public SuccessDialog(@NonNull Context context) {
22 | super(context);
23 | }
24 |
25 | public SuccessDialog(@NonNull Context context, CharSequence text) {
26 | super(context, text);
27 | }
28 |
29 | public SuccessDialog(@NonNull Context context, CharSequence text, long duration) {
30 | super(context, text, duration);
31 | }
32 |
33 | @Override
34 | protected View statusView() {
35 | return defaultView();
36 | }
37 |
38 | /**
39 | * 默认view
40 | *
41 | * @return 默认view
42 | */
43 | private View defaultView() {
44 | ImageView img = new ImageView(getContext());
45 | img.setImageResource(R.mipmap.icon_status_dialog_success);
46 | return img;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/img/round/CircleImageView.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.img.round;
2 |
3 | import android.content.Context;
4 | import android.graphics.Path;
5 | import android.util.AttributeSet;
6 |
7 | import com.yhy.widget.core.img.round.abs.AbsRoundImageView;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2017-09-21 14:19
13 | * version: 1.0.0
14 | * desc : 圆形图片
15 | */
16 | public class CircleImageView extends AbsRoundImageView {
17 |
18 | public CircleImageView(Context context) {
19 | this(context, null, 0);
20 | }
21 |
22 | public CircleImageView(Context context, AttributeSet attrs) {
23 | this(context, attrs, 0);
24 | }
25 |
26 | public CircleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
27 | super(context, attrs, defStyleAttr);
28 | }
29 |
30 | @Override
31 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
32 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
33 | int size = Math.max(getMeasuredWidth(), getMeasuredHeight());
34 | setMeasuredDimension(size, size);
35 | }
36 |
37 | @Override
38 | protected void initRoundPath() {
39 | mRoundPath.reset();
40 | final int width = getWidth();
41 | final int height = getHeight();
42 | final float cx = width * 0.5f;
43 | final float cy = height * 0.5f;
44 | final float radius = Math.min(width, height) * 0.5f;
45 | mRoundPath.addCircle(cx, cy, radius, Path.Direction.CW);
46 | }
47 |
48 | @Override
49 | protected void initFillPath() {
50 | mFillPath.reset();
51 | final int width = getWidth();
52 | final int height = getHeight();
53 | final float cx = width * 0.5f;
54 | final float cy = height * 0.5f;
55 | final float radius = Math.min(width, height) * 0.5f;
56 | mFillPath.addCircle(cx, cy, radius, Path.Direction.CW);
57 | }
58 |
59 | @Override
60 | protected void initBorderPath() {
61 | mBorderPath.reset();
62 | final float halfBorderWidth = mBorderWidth * 0.5f;
63 | final int width = getWidth();
64 | final int height = getHeight();
65 | final float cx = width * 0.5f;
66 | final float cy = height * 0.5f;
67 | final float radius = Math.min(width, height) * 0.5f;
68 | mBorderPath.addCircle(cx, cy, radius - halfBorderWidth, Path.Direction.CW);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallClipRotateIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.yhy.widget.core.loading.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/16.
14 | */
15 | public class BallClipRotateIndicator extends Indicator {
16 |
17 | float scaleFloat = 1, degrees;
18 |
19 | @Override
20 | public void draw(Canvas canvas, Paint paint) {
21 | paint.setStyle(Paint.Style.STROKE);
22 | paint.setStrokeWidth(3);
23 |
24 | float circleSpacing = 12;
25 | float x = (getWidth()) / 2;
26 | float y = (getHeight()) / 2;
27 | canvas.translate(x, y);
28 | canvas.scale(scaleFloat, scaleFloat);
29 | canvas.rotate(degrees);
30 | RectF rectF = new RectF(-x + circleSpacing, -y + circleSpacing, 0 + x - circleSpacing, 0 + y - circleSpacing);
31 | canvas.drawArc(rectF, -45, 270, false, paint);
32 | }
33 |
34 | @Override
35 | public ArrayList onCreateAnimators() {
36 | ArrayList animators = new ArrayList<>();
37 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.6f, 0.5f, 1);
38 | scaleAnim.setDuration(750);
39 | scaleAnim.setRepeatCount(-1);
40 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
41 | @Override
42 | public void onAnimationUpdate(ValueAnimator animation) {
43 | scaleFloat = (float) animation.getAnimatedValue();
44 | postInvalidate();
45 | }
46 | });
47 | ValueAnimator rotateAnim = ValueAnimator.ofFloat(0, 180, 360);
48 | rotateAnim.setDuration(750);
49 | rotateAnim.setRepeatCount(-1);
50 | addUpdateListener(rotateAnim, new ValueAnimator.AnimatorUpdateListener() {
51 | @Override
52 | public void onAnimationUpdate(ValueAnimator animation) {
53 | degrees = (float) animation.getAnimatedValue();
54 | postInvalidate();
55 | }
56 | });
57 | animators.add(scaleAnim);
58 | animators.add(rotateAnim);
59 | return animators;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallGridBeatIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.yhy.widget.core.loading.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/20.
13 | */
14 | public class BallGridBeatIndicator extends Indicator {
15 |
16 | public static final int ALPHA = 255;
17 |
18 | int[] alphas = new int[]{ALPHA,
19 | ALPHA,
20 | ALPHA,
21 | ALPHA,
22 | ALPHA,
23 | ALPHA,
24 | ALPHA,
25 | ALPHA,
26 | ALPHA};
27 |
28 | @Override
29 | public void draw(Canvas canvas, Paint paint) {
30 | float circleSpacing = 4;
31 | float radius = (getWidth() - circleSpacing * 4) / 6;
32 | float x = getWidth() / 2 - (radius * 2 + circleSpacing);
33 | float y = getWidth() / 2 - (radius * 2 + circleSpacing);
34 |
35 | for (int i = 0; i < 3; i++) {
36 | for (int j = 0; j < 3; j++) {
37 | canvas.save();
38 | float translateX = x + (radius * 2) * j + circleSpacing * j;
39 | float translateY = y + (radius * 2) * i + circleSpacing * i;
40 | canvas.translate(translateX, translateY);
41 | paint.setAlpha(alphas[3 * i + j]);
42 | canvas.drawCircle(0, 0, radius, paint);
43 | canvas.restore();
44 | }
45 | }
46 | }
47 |
48 | @Override
49 | public ArrayList onCreateAnimators() {
50 | ArrayList animators = new ArrayList<>();
51 |
52 | int[] durations = {960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
53 | int[] delays = {360, 400, 680, 410, 710, -150, -120, 10, 320};
54 |
55 | for (int i = 0; i < 9; i++) {
56 | final int index = i;
57 | ValueAnimator alphaAnim = ValueAnimator.ofInt(255, 168, 255);
58 | alphaAnim.setDuration(durations[i]);
59 | alphaAnim.setRepeatCount(-1);
60 | alphaAnim.setStartDelay(delays[i]);
61 | addUpdateListener(alphaAnim, new ValueAnimator.AnimatorUpdateListener() {
62 | @Override
63 | public void onAnimationUpdate(ValueAnimator animation) {
64 | alphas[index] = (int) animation.getAnimatedValue();
65 | postInvalidate();
66 | }
67 | });
68 | animators.add(alphaAnim);
69 | }
70 | return animators;
71 | }
72 |
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallPulseIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.yhy.widget.core.loading.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/16.
13 | */
14 | public class BallPulseIndicator extends Indicator {
15 |
16 | public static final float SCALE = 1.0f;
17 |
18 | //scale x ,y
19 | private float[] scaleFloats = new float[]{SCALE,
20 | SCALE,
21 | SCALE};
22 |
23 | @Override
24 | public void draw(Canvas canvas, Paint paint) {
25 | float circleSpacing = 4;
26 | float radius = (Math.min(getWidth(), getHeight()) - circleSpacing * 2) / 6;
27 | float x = getWidth() / 2 - (radius * 2 + circleSpacing);
28 | float y = getHeight() / 2;
29 | for (int i = 0; i < 3; i++) {
30 | canvas.save();
31 | float translateX = x + (radius * 2) * i + circleSpacing * i;
32 | canvas.translate(translateX, y);
33 | canvas.scale(scaleFloats[i], scaleFloats[i]);
34 | canvas.drawCircle(0, 0, radius, paint);
35 | canvas.restore();
36 | }
37 | }
38 |
39 | @Override
40 | public ArrayList onCreateAnimators() {
41 | ArrayList animators = new ArrayList<>();
42 | int[] delays = new int[]{120, 240, 360};
43 | for (int i = 0; i < 3; i++) {
44 | final int index = i;
45 |
46 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);
47 |
48 | scaleAnim.setDuration(750);
49 | scaleAnim.setRepeatCount(-1);
50 | scaleAnim.setStartDelay(delays[i]);
51 |
52 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
53 | @Override
54 | public void onAnimationUpdate(ValueAnimator animation) {
55 | scaleFloats[index] = (float) animation.getAnimatedValue();
56 | postInvalidate();
57 | }
58 | });
59 | animators.add(scaleAnim);
60 | }
61 | return animators;
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallPulseRiseIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Camera;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.view.animation.LinearInterpolator;
9 |
10 | import com.yhy.widget.core.loading.Indicator;
11 |
12 | import java.util.ArrayList;
13 |
14 | /**
15 | * Created by Jack on 2015/10/17.
16 | */
17 | public class BallPulseRiseIndicator extends Indicator {
18 |
19 | private Camera mCamera;
20 | private Matrix mMatrix;
21 |
22 | private float degress;
23 |
24 | public BallPulseRiseIndicator() {
25 | mCamera = new Camera();
26 | mMatrix = new Matrix();
27 | }
28 |
29 | @Override
30 | public void draw(Canvas canvas, Paint paint) {
31 |
32 | mMatrix.reset();
33 | mCamera.save();
34 | mCamera.rotateX(degress);
35 | mCamera.getMatrix(mMatrix);
36 | mCamera.restore();
37 |
38 | mMatrix.preTranslate(-centerX(), -centerY());
39 | mMatrix.postTranslate(centerX(), centerY());
40 | canvas.concat(mMatrix);
41 |
42 | float radius = getWidth() / 10;
43 | canvas.drawCircle(getWidth() / 4, radius * 2, radius, paint);
44 | canvas.drawCircle(getWidth() * 3 / 4, radius * 2, radius, paint);
45 |
46 | canvas.drawCircle(radius, getHeight() - 2 * radius, radius, paint);
47 | canvas.drawCircle(getWidth() / 2, getHeight() - 2 * radius, radius, paint);
48 | canvas.drawCircle(getWidth() - radius, getHeight() - 2 * radius, radius, paint);
49 | }
50 |
51 | @Override
52 | public ArrayList onCreateAnimators() {
53 | ArrayList animators = new ArrayList<>();
54 | ValueAnimator animator = ValueAnimator.ofFloat(0, 360);
55 | addUpdateListener(animator, new ValueAnimator.AnimatorUpdateListener() {
56 | @Override
57 | public void onAnimationUpdate(ValueAnimator animation) {
58 | degress = (float) animation.getAnimatedValue();
59 | postInvalidate();
60 | }
61 | });
62 | animator.setInterpolator(new LinearInterpolator());
63 | animator.setRepeatCount(-1);
64 | animator.setDuration(1500);
65 | animators.add(animator);
66 | return animators;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallPulseSyncIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.yhy.widget.core.loading.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/19.
13 | */
14 | public class BallPulseSyncIndicator extends Indicator {
15 |
16 | float[] translateYFloats = new float[3];
17 |
18 | @Override
19 | public void draw(Canvas canvas, Paint paint) {
20 | float circleSpacing = 4;
21 | float radius = (getWidth() - circleSpacing * 2) / 6;
22 | float x = getWidth() / 2 - (radius * 2 + circleSpacing);
23 | for (int i = 0; i < 3; i++) {
24 | canvas.save();
25 | float translateX = x + (radius * 2) * i + circleSpacing * i;
26 | canvas.translate(translateX, translateYFloats[i]);
27 | canvas.drawCircle(0, 0, radius, paint);
28 | canvas.restore();
29 | }
30 | }
31 |
32 | @Override
33 | public ArrayList onCreateAnimators() {
34 | ArrayList animators = new ArrayList<>();
35 | float circleSpacing = 4;
36 | float radius = (getWidth() - circleSpacing * 2) / 6;
37 | int[] delays = new int[]{70, 140, 210};
38 | for (int i = 0; i < 3; i++) {
39 | final int index = i;
40 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(getHeight() / 2, getHeight() / 2 - radius * 2, getHeight() / 2);
41 | scaleAnim.setDuration(600);
42 | scaleAnim.setRepeatCount(-1);
43 | scaleAnim.setStartDelay(delays[i]);
44 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
45 | @Override
46 | public void onAnimationUpdate(ValueAnimator animation) {
47 | translateYFloats[index] = (float) animation.getAnimatedValue();
48 | postInvalidate();
49 | }
50 | });
51 | animators.add(scaleAnim);
52 | }
53 | return animators;
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallScaleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import com.yhy.widget.core.loading.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class BallScaleIndicator extends Indicator {
16 |
17 | float scale = 1;
18 | int alpha = 255;
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | float circleSpacing = 4;
23 | paint.setAlpha(alpha);
24 | canvas.scale(scale, scale, getWidth() / 2, getHeight() / 2);
25 | paint.setAlpha(alpha);
26 | canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 2 - circleSpacing, paint);
27 | }
28 |
29 | @Override
30 | public ArrayList onCreateAnimators() {
31 | ArrayList animators = new ArrayList<>();
32 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
33 | scaleAnim.setInterpolator(new LinearInterpolator());
34 | scaleAnim.setDuration(1000);
35 | scaleAnim.setRepeatCount(-1);
36 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator animation) {
39 | scale = (float) animation.getAnimatedValue();
40 | postInvalidate();
41 | }
42 | });
43 |
44 | ValueAnimator alphaAnim = ValueAnimator.ofInt(255, 0);
45 | alphaAnim.setInterpolator(new LinearInterpolator());
46 | alphaAnim.setDuration(1000);
47 | alphaAnim.setRepeatCount(-1);
48 | addUpdateListener(alphaAnim, new ValueAnimator.AnimatorUpdateListener() {
49 | @Override
50 | public void onAnimationUpdate(ValueAnimator animation) {
51 | alpha = (int) animation.getAnimatedValue();
52 | postInvalidate();
53 | }
54 | });
55 | animators.add(scaleAnim);
56 | animators.add(alphaAnim);
57 | return animators;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallScaleMultipleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import com.yhy.widget.core.loading.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class BallScaleMultipleIndicator extends Indicator {
16 |
17 | float[] scaleFloats = new float[]{1, 1, 1};
18 | int[] alphaInts = new int[]{255, 255, 255};
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | float circleSpacing = 4;
23 | for (int i = 0; i < 3; i++) {
24 | paint.setAlpha(alphaInts[i]);
25 | canvas.scale(scaleFloats[i], scaleFloats[i], getWidth() / 2, getHeight() / 2);
26 | canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 2 - circleSpacing, paint);
27 | }
28 | }
29 |
30 | @Override
31 | public ArrayList onCreateAnimators() {
32 | ArrayList animators = new ArrayList<>();
33 | long[] delays = new long[]{0, 200, 400};
34 | for (int i = 0; i < 3; i++) {
35 | final int index = i;
36 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
37 | scaleAnim.setInterpolator(new LinearInterpolator());
38 | scaleAnim.setDuration(1000);
39 | scaleAnim.setRepeatCount(-1);
40 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
41 | @Override
42 | public void onAnimationUpdate(ValueAnimator animation) {
43 | scaleFloats[index] = (float) animation.getAnimatedValue();
44 | postInvalidate();
45 | }
46 | });
47 | scaleAnim.setStartDelay(delays[i]);
48 |
49 | ValueAnimator alphaAnim = ValueAnimator.ofInt(255, 0);
50 | alphaAnim.setInterpolator(new LinearInterpolator());
51 | alphaAnim.setDuration(1000);
52 | alphaAnim.setRepeatCount(-1);
53 | addUpdateListener(alphaAnim, new ValueAnimator.AnimatorUpdateListener() {
54 | @Override
55 | public void onAnimationUpdate(ValueAnimator animation) {
56 | alphaInts[index] = (int) animation.getAnimatedValue();
57 | postInvalidate();
58 | }
59 | });
60 | scaleAnim.setStartDelay(delays[i]);
61 |
62 | animators.add(scaleAnim);
63 | animators.add(alphaAnim);
64 | }
65 | return animators;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallScaleRippleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Created by Jack on 2015/10/19.
12 | */
13 | public class BallScaleRippleIndicator extends BallScaleIndicator {
14 |
15 |
16 | @Override
17 | public void draw(Canvas canvas, Paint paint) {
18 | paint.setStyle(Paint.Style.STROKE);
19 | paint.setStrokeWidth(3);
20 | super.draw(canvas, paint);
21 | }
22 |
23 | @Override
24 | public ArrayList onCreateAnimators() {
25 | ArrayList animators = new ArrayList<>();
26 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
27 | scaleAnim.setInterpolator(new LinearInterpolator());
28 | scaleAnim.setDuration(1000);
29 | scaleAnim.setRepeatCount(-1);
30 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
31 | @Override
32 | public void onAnimationUpdate(ValueAnimator animation) {
33 | scale = (float) animation.getAnimatedValue();
34 | postInvalidate();
35 | }
36 | });
37 |
38 | ValueAnimator alphaAnim = ValueAnimator.ofInt(0, 255);
39 | alphaAnim.setInterpolator(new LinearInterpolator());
40 | alphaAnim.setDuration(1000);
41 | alphaAnim.setRepeatCount(-1);
42 | addUpdateListener(alphaAnim, new ValueAnimator.AnimatorUpdateListener() {
43 | @Override
44 | public void onAnimationUpdate(ValueAnimator animation) {
45 | alpha = (int) animation.getAnimatedValue();
46 | postInvalidate();
47 | }
48 | });
49 |
50 | animators.add(scaleAnim);
51 | animators.add(alphaAnim);
52 | return animators;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallScaleRippleMultipleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Created by Jack on 2015/10/19.
12 | */
13 | public class BallScaleRippleMultipleIndicator extends BallScaleMultipleIndicator {
14 |
15 |
16 | @Override
17 | public void draw(Canvas canvas, Paint paint) {
18 | paint.setStyle(Paint.Style.STROKE);
19 | paint.setStrokeWidth(3);
20 | super.draw(canvas, paint);
21 | }
22 |
23 | @Override
24 | public ArrayList onCreateAnimators() {
25 | ArrayList animators = new ArrayList<>();
26 | long[] delays = new long[]{0, 200, 400};
27 | for (int i = 0; i < 3; i++) {
28 | final int index = i;
29 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
30 | scaleAnim.setInterpolator(new LinearInterpolator());
31 | scaleAnim.setDuration(1000);
32 | scaleAnim.setRepeatCount(-1);
33 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
34 | @Override
35 | public void onAnimationUpdate(ValueAnimator animation) {
36 | scaleFloats[index] = (float) animation.getAnimatedValue();
37 | postInvalidate();
38 | }
39 | });
40 | scaleAnim.setStartDelay(delays[i]);
41 |
42 | ValueAnimator alphaAnim = ValueAnimator.ofInt(0, 255);
43 | scaleAnim.setInterpolator(new LinearInterpolator());
44 | alphaAnim.setDuration(1000);
45 | alphaAnim.setRepeatCount(-1);
46 | addUpdateListener(alphaAnim, new ValueAnimator.AnimatorUpdateListener() {
47 | @Override
48 | public void onAnimationUpdate(ValueAnimator animation) {
49 | alphaInts[index] = (int) animation.getAnimatedValue();
50 | postInvalidate();
51 | }
52 | });
53 | scaleAnim.setStartDelay(delays[i]);
54 |
55 | animators.add(scaleAnim);
56 | animators.add(alphaAnim);
57 | }
58 | return animators;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/BallZigZagDeflectIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 |
4 | import android.animation.ValueAnimator;
5 | import android.view.animation.LinearInterpolator;
6 |
7 | import java.util.ArrayList;
8 |
9 | /**
10 | * Created by Jack on 2015/10/19.
11 | */
12 | public class BallZigZagDeflectIndicator extends BallZigZagIndicator {
13 |
14 |
15 | @Override
16 | public ArrayList onCreateAnimators() {
17 | ArrayList animators = new ArrayList<>();
18 | float startX = getWidth() / 6;
19 | float startY = getWidth() / 6;
20 | for (int i = 0; i < 2; i++) {
21 | final int index = i;
22 | ValueAnimator translateXAnim = ValueAnimator.ofFloat(startX, getWidth() - startX, startX, getWidth() - startX, startX);
23 | if (i == 1) {
24 | translateXAnim = ValueAnimator.ofFloat(getWidth() - startX, startX, getWidth() - startX, startX, getWidth() - startX);
25 | }
26 | ValueAnimator translateYAnim = ValueAnimator.ofFloat(startY, startY, getHeight() - startY, getHeight() - startY, startY);
27 | if (i == 1) {
28 | translateYAnim = ValueAnimator.ofFloat(getHeight() - startY, getHeight() - startY, startY, startY, getHeight() - startY);
29 | }
30 |
31 | translateXAnim.setDuration(2000);
32 | translateXAnim.setInterpolator(new LinearInterpolator());
33 | translateXAnim.setRepeatCount(-1);
34 | addUpdateListener(translateXAnim, new ValueAnimator.AnimatorUpdateListener() {
35 | @Override
36 | public void onAnimationUpdate(ValueAnimator animation) {
37 | translateX[index] = (float) animation.getAnimatedValue();
38 | postInvalidate();
39 | }
40 | });
41 |
42 | translateYAnim.setDuration(2000);
43 | translateYAnim.setInterpolator(new LinearInterpolator());
44 | translateYAnim.setRepeatCount(-1);
45 | addUpdateListener(translateYAnim, new ValueAnimator.AnimatorUpdateListener() {
46 | @Override
47 | public void onAnimationUpdate(ValueAnimator animation) {
48 | translateY[index] = (float) animation.getAnimatedValue();
49 | postInvalidate();
50 | }
51 | });
52 |
53 | animators.add(translateXAnim);
54 | animators.add(translateYAnim);
55 | }
56 | return animators;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/LineScaleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.yhy.widget.core.loading.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class LineScaleIndicator extends Indicator {
16 |
17 | public static final float SCALE = 1.0f;
18 |
19 | float[] scaleYFloats = new float[]{SCALE,
20 | SCALE,
21 | SCALE,
22 | SCALE,
23 | SCALE,};
24 |
25 | @Override
26 | public void draw(Canvas canvas, Paint paint) {
27 | float translateX = getWidth() / 11;
28 | float translateY = getHeight() / 2;
29 | for (int i = 0; i < 5; i++) {
30 | canvas.save();
31 | canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
32 | canvas.scale(SCALE, scaleYFloats[i]);
33 | RectF rectF = new RectF(-translateX / 2, -getHeight() / 2.5f, translateX / 2, getHeight() / 2.5f);
34 | canvas.drawRoundRect(rectF, 5, 5, paint);
35 | canvas.restore();
36 | }
37 | }
38 |
39 | @Override
40 | public ArrayList onCreateAnimators() {
41 | ArrayList animators = new ArrayList<>();
42 | long[] delays = new long[]{100, 200, 300, 400, 500};
43 | for (int i = 0; i < 5; i++) {
44 | final int index = i;
45 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.4f, 1);
46 | scaleAnim.setDuration(1000);
47 | scaleAnim.setRepeatCount(-1);
48 | scaleAnim.setStartDelay(delays[i]);
49 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
50 | @Override
51 | public void onAnimationUpdate(ValueAnimator animation) {
52 | scaleYFloats[index] = (float) animation.getAnimatedValue();
53 | postInvalidate();
54 | }
55 | });
56 | animators.add(scaleAnim);
57 | }
58 | return animators;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/LineScalePartyIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.yhy.widget.core.loading.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class LineScalePartyIndicator extends Indicator {
16 |
17 | public static final float SCALE = 1.0f;
18 |
19 | float[] scaleFloats = new float[]{SCALE,
20 | SCALE,
21 | SCALE,
22 | SCALE,
23 | SCALE,};
24 |
25 | @Override
26 | public void draw(Canvas canvas, Paint paint) {
27 | float translateX = getWidth() / 9;
28 | float translateY = getHeight() / 2;
29 | for (int i = 0; i < 4; i++) {
30 | canvas.save();
31 | canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
32 | canvas.scale(scaleFloats[i], scaleFloats[i]);
33 | RectF rectF = new RectF(-translateX / 2, -getHeight() / 2.5f, translateX / 2, getHeight() / 2.5f);
34 | canvas.drawRoundRect(rectF, 5, 5, paint);
35 | canvas.restore();
36 | }
37 | }
38 |
39 |
40 | @Override
41 | public ArrayList onCreateAnimators() {
42 | ArrayList animators = new ArrayList<>();
43 | long[] durations = new long[]{1260, 430, 1010, 730};
44 | long[] delays = new long[]{770, 290, 280, 740};
45 | for (int i = 0; i < 4; i++) {
46 | final int index = i;
47 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.4f, 1);
48 | scaleAnim.setDuration(durations[i]);
49 | scaleAnim.setRepeatCount(-1);
50 | scaleAnim.setStartDelay(delays[i]);
51 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
52 | @Override
53 | public void onAnimationUpdate(ValueAnimator animation) {
54 | scaleFloats[index] = (float) animation.getAnimatedValue();
55 | postInvalidate();
56 | }
57 | });
58 | animators.add(scaleAnim);
59 | }
60 | return animators;
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/LineScalePulseOutIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 |
4 | import android.animation.ValueAnimator;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by Jack on 2015/10/19.
10 | */
11 | public class LineScalePulseOutIndicator extends LineScaleIndicator {
12 |
13 | @Override
14 | public ArrayList onCreateAnimators() {
15 | ArrayList animators = new ArrayList<>();
16 | long[] delays = new long[]{500, 250, 0, 250, 500};
17 | for (int i = 0; i < 5; i++) {
18 | final int index = i;
19 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);
20 | scaleAnim.setDuration(900);
21 | scaleAnim.setRepeatCount(-1);
22 | scaleAnim.setStartDelay(delays[i]);
23 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
24 | @Override
25 | public void onAnimationUpdate(ValueAnimator animation) {
26 | scaleYFloats[index] = (float) animation.getAnimatedValue();
27 | postInvalidate();
28 | }
29 | });
30 | animators.add(scaleAnim);
31 | }
32 | return animators;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/LineScalePulseOutRapidIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 |
4 | import android.animation.ValueAnimator;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by Jack on 2015/10/19.
10 | */
11 | public class LineScalePulseOutRapidIndicator extends LineScaleIndicator {
12 |
13 | @Override
14 | public ArrayList onCreateAnimators() {
15 | ArrayList animators = new ArrayList<>();
16 | long[] delays = new long[]{400, 200, 0, 200, 400};
17 | for (int i = 0; i < 5; i++) {
18 | final int index = i;
19 | ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.4f, 1);
20 | scaleAnim.setDuration(1000);
21 | scaleAnim.setRepeatCount(-1);
22 | scaleAnim.setStartDelay(delays[i]);
23 | addUpdateListener(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
24 | @Override
25 | public void onAnimationUpdate(ValueAnimator animation) {
26 | scaleYFloats[index] = (float) animation.getAnimatedValue();
27 | postInvalidate();
28 | }
29 | });
30 | animators.add(scaleAnim);
31 | }
32 | return animators;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/LineSpinFadeLoaderIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 |
7 | /**
8 | * Created by Jack on 2015/10/24.
9 | * Email:81813780@qq.com
10 | */
11 | public class LineSpinFadeLoaderIndicator extends BallSpinFadeLoaderIndicator {
12 |
13 |
14 | @Override
15 | public void draw(Canvas canvas, Paint paint) {
16 | float radius = getWidth() / 10;
17 | for (int i = 0; i < 8; i++) {
18 | canvas.save();
19 | Point point = circleAt(getWidth(), getHeight(), getWidth() / 2.5f - radius, i * (Math.PI / 4));
20 | canvas.translate(point.x, point.y);
21 | canvas.scale(scaleFloats[i], scaleFloats[i]);
22 | canvas.rotate(i * 45);
23 | paint.setAlpha(alphas[i]);
24 | RectF rectF = new RectF(-radius, -radius / 1.5f, 1.5f * radius, radius / 1.5f);
25 | canvas.drawRoundRect(rectF, 5, 5, paint);
26 | canvas.restore();
27 | }
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/SemiCircleSpinIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.yhy.widget.core.loading.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/20.
14 | */
15 | public class SemiCircleSpinIndicator extends Indicator {
16 |
17 | private float degress;
18 |
19 | @Override
20 | public void draw(Canvas canvas, Paint paint) {
21 | canvas.rotate(degress, centerX(), centerY());
22 | RectF rectF = new RectF(0, 0, getWidth(), getHeight());
23 | canvas.drawArc(rectF, -60, 120, false, paint);
24 | }
25 |
26 | @Override
27 | public ArrayList onCreateAnimators() {
28 | ArrayList animators = new ArrayList<>();
29 | ValueAnimator rotateAnim = ValueAnimator.ofFloat(0, 180, 360);
30 | addUpdateListener(rotateAnim, new ValueAnimator.AnimatorUpdateListener() {
31 | @Override
32 | public void onAnimationUpdate(ValueAnimator animation) {
33 | degress = (float) animation.getAnimatedValue();
34 | postInvalidate();
35 | }
36 | });
37 | rotateAnim.setDuration(600);
38 | rotateAnim.setRepeatCount(-1);
39 | animators.add(rotateAnim);
40 | return animators;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/loading/indicator/SquareSpinIndicator.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.loading.indicator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Camera;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.graphics.RectF;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.yhy.widget.core.loading.Indicator;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by Jack on 2015/10/16.
17 | */
18 | public class SquareSpinIndicator extends Indicator {
19 |
20 | private float rotateX;
21 | private float rotateY;
22 |
23 | private Camera mCamera;
24 | private Matrix mMatrix;
25 |
26 | public SquareSpinIndicator() {
27 | mCamera = new Camera();
28 | mMatrix = new Matrix();
29 | }
30 |
31 | @Override
32 | public void draw(Canvas canvas, Paint paint) {
33 |
34 | mMatrix.reset();
35 | mCamera.save();
36 | mCamera.rotateX(rotateX);
37 | mCamera.rotateY(rotateY);
38 | mCamera.getMatrix(mMatrix);
39 | mCamera.restore();
40 |
41 | mMatrix.preTranslate(-centerX(), -centerY());
42 | mMatrix.postTranslate(centerX(), centerY());
43 | canvas.concat(mMatrix);
44 |
45 | canvas.drawRect(new RectF(getWidth() / 5, getHeight() / 5, getWidth() * 4 / 5, getHeight() * 4 / 5), paint);
46 | }
47 |
48 | @Override
49 | public ArrayList onCreateAnimators() {
50 | ArrayList animators = new ArrayList<>();
51 | ValueAnimator animator = ValueAnimator.ofFloat(0, 180, 180, 0, 0);
52 | addUpdateListener(animator, new ValueAnimator.AnimatorUpdateListener() {
53 | @Override
54 | public void onAnimationUpdate(ValueAnimator animation) {
55 | rotateX = (float) animation.getAnimatedValue();
56 | postInvalidate();
57 | }
58 | });
59 | animator.setInterpolator(new LinearInterpolator());
60 | animator.setRepeatCount(-1);
61 | animator.setDuration(2500);
62 |
63 | ValueAnimator animator1 = ValueAnimator.ofFloat(0, 0, 180, 180, 0);
64 | addUpdateListener(animator1, new ValueAnimator.AnimatorUpdateListener() {
65 | @Override
66 | public void onAnimationUpdate(ValueAnimator animation) {
67 | rotateY = (float) animation.getAnimatedValue();
68 | postInvalidate();
69 | }
70 | });
71 | animator1.setInterpolator(new LinearInterpolator());
72 | animator1.setRepeatCount(-1);
73 | animator1.setDuration(2500);
74 |
75 | animators.add(animator);
76 | animators.add(animator1);
77 | return animators;
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/pager/HackyViewPager.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.pager;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | import androidx.viewpager.widget.ViewPager;
9 |
10 | /**
11 | * author : 颜洪毅
12 | * e-mail : yhyzgn@gmail.com
13 | * time : 2017-09-21 14:21
14 | * version: 1.0.0
15 | * desc : 修复图片在ViewPager控件中缩放报错的BUG
16 | */
17 | public class HackyViewPager extends ViewPager {
18 |
19 | public HackyViewPager(Context context) {
20 | super(context);
21 | }
22 |
23 | public HackyViewPager(Context context, AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | @SuppressLint("ClickableViewAccessibility")
28 | @Override
29 | public boolean onTouchEvent(MotionEvent ev) {
30 | try {
31 | return super.onTouchEvent(ev);
32 | } catch (IllegalArgumentException ex) {
33 | ex.printStackTrace();
34 | }
35 | return false;
36 | }
37 |
38 | @Override
39 | public boolean onInterceptTouchEvent(MotionEvent ev) {
40 | try {
41 | return super.onInterceptTouchEvent(ev);
42 | } catch (IllegalArgumentException ex) {
43 | ex.printStackTrace();
44 | }
45 | return false;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/preview/PreviewModel.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.preview;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created on 2022-10-25 21:45
7 | *
8 | * @author 颜洪毅
9 | * @version 1.0.0
10 | * @since 1.0.0
11 | */
12 | public class PreviewModel implements Serializable {
13 | public static final int TYPE_IMAGE = 0;
14 | public static final int TYPE_VIDEO = 1;
15 |
16 | private String name;
17 | private String url;
18 | private int type;
19 | private String thumbnail;
20 |
21 | public String getName() {
22 | return name;
23 | }
24 |
25 | public PreviewModel setName(String name) {
26 | this.name = name;
27 | return this;
28 | }
29 |
30 | public String getUrl() {
31 | return url;
32 | }
33 |
34 | public PreviewModel setUrl(String url) {
35 | this.url = url;
36 | return this;
37 | }
38 |
39 | public int getType() {
40 | return type;
41 | }
42 |
43 | public PreviewModel setType(int type) {
44 | if (type != TYPE_IMAGE && type != TYPE_VIDEO) {
45 | throw new IllegalArgumentException("未知的预览文件类型");
46 | }
47 | this.type = type;
48 | return this;
49 | }
50 |
51 | public String getThumbnail() {
52 | return thumbnail;
53 | }
54 |
55 | public PreviewModel setThumbnail(String thumbnail) {
56 | this.thumbnail = thumbnail;
57 | return this;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/recycler/RecyclerScrollView.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.recycler;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 | import android.view.ViewConfiguration;
7 | import android.widget.ScrollView;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2017-09-21 14:19
13 | * version: 1.0.0
14 | * desc : 用来嵌套RecyclerView的ScrollView
15 | */
16 | public class RecyclerScrollView extends ScrollView {
17 | private int downX;
18 | private int downY;
19 | private int mTouchSlop;
20 | private OnScrollListener mListener;
21 |
22 | public RecyclerScrollView(Context context) {
23 | super(context);
24 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
25 | }
26 |
27 | public RecyclerScrollView(Context context, AttributeSet attrs) {
28 | super(context, attrs);
29 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
30 | }
31 |
32 | public RecyclerScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
33 | super(context, attrs, defStyleAttr);
34 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
35 | }
36 |
37 | @Override
38 | public boolean onInterceptTouchEvent(MotionEvent e) {
39 | int action = e.getAction();
40 | switch (action) {
41 | case MotionEvent.ACTION_DOWN:
42 | downX = (int) e.getRawX();
43 | downY = (int) e.getRawY();
44 | // 调用一下父类方法,解决“Invalid pointerId=-1 in onTouchEvent”问题
45 | super.onInterceptTouchEvent(e);
46 | break;
47 | case MotionEvent.ACTION_MOVE:
48 | int moveY = (int) e.getRawY();
49 | if (Math.abs(moveY - downY) > mTouchSlop) {
50 | return true;
51 | }
52 | }
53 | return super.onInterceptTouchEvent(e);
54 | }
55 |
56 | @Override
57 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
58 | super.onScrollChanged(l, t, oldl, oldt);
59 | if (null != mListener) {
60 | mListener.onScroll(this, l, t, oldl, oldt);
61 | }
62 | }
63 |
64 | /**
65 | * 设置滚动监听器
66 | *
67 | * @param listener 滚动监听器
68 | */
69 | public void setOnScrollListener(OnScrollListener listener) {
70 | mListener = listener;
71 | }
72 |
73 | /**
74 | * 滚动监听器
75 | */
76 | public interface OnScrollListener {
77 |
78 | /**
79 | * 当ScrollView发生滚动时回调
80 | *
81 | * @param view 当前控件
82 | * @param x x方向当前值
83 | * @param y y方向当前值
84 | * @param oldX x方向前一次值
85 | * @param oldY y方向前一次值
86 | */
87 | void onScroll(RecyclerScrollView view, int x, int y, int oldX, int oldY);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/recycler/layout/WrapContentLayoutManager.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.recycler.layout;
2 |
3 | import android.content.Context;
4 | import androidx.recyclerview.widget.LinearLayoutManager;
5 | import androidx.recyclerview.widget.RecyclerView;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 |
9 | /**
10 | * author : 颜洪毅
11 | * e-mail : yhyzgn@gmail.com
12 | * time : 2018-03-30 13:09
13 | * version: 1.0.0
14 | * desc : RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter 解决方案
15 | */
16 | public class WrapContentLayoutManager extends LinearLayoutManager {
17 | public WrapContentLayoutManager(Context context) {
18 | super(context);
19 | }
20 |
21 | public WrapContentLayoutManager(Context context, int orientation, boolean reverseLayout) {
22 | super(context, orientation, reverseLayout);
23 | }
24 |
25 | public WrapContentLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
26 | super(context, attrs, defStyleAttr, defStyleRes);
27 | }
28 |
29 | @Override
30 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
31 | try {
32 | super.onLayoutChildren(recycler, state);
33 | } catch (IndexOutOfBoundsException e) {
34 | Log.e("ContentLayoutManager", "meet a IOOBE in RecyclerView");
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/step/adapter/StepAdapter.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.step.adapter;
2 |
3 | import android.view.View;
4 |
5 | import com.yhy.widget.core.step.StepView;
6 | import com.yhy.widget.core.step.entity.StepAble;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * author : 颜洪毅
12 | * e-mail : yhyzgn@gmail.com
13 | * time : 2018-04-14 11:04
14 | * version: 1.0.0
15 | * desc : StepView适配器
16 | */
17 | public abstract class StepAdapter {
18 | // 数据集
19 | protected List mDataList;
20 | // 当前适配器所属的StepView
21 | protected StepView mView;
22 | // 数据改变监听
23 | private OnDataChangedListener mListener;
24 |
25 | /**
26 | * 构造函数
27 | *
28 | * @param dataList 数据集
29 | */
30 | public StepAdapter(List dataList) {
31 | mDataList = dataList;
32 | }
33 |
34 | /**
35 | * 数据集数量
36 | *
37 | * @return 数据集数量
38 | */
39 | public int getCount() {
40 | return null == mDataList ? 0 : mDataList.size();
41 | }
42 |
43 | /**
44 | * 获取每个条目的view
45 | *
46 | * @param stepView 当前StepView
47 | * @param position 索引
48 | * @param data 索引对应的数据
49 | * @return itemView
50 | */
51 | public abstract View getItem(StepView stepView, int position, T data);
52 |
53 | /**
54 | * 绑定StepView
55 | *
56 | * @param stepView 设置了改适配器的StepView
57 | */
58 | public void bindStepView(StepView stepView) {
59 | mView = stepView;
60 | mListener = mView;
61 | }
62 |
63 | /**
64 | * 获取数据集
65 | *
66 | * @return 数据集
67 | */
68 | public List getDataList() {
69 | return mDataList;
70 | }
71 |
72 | /**
73 | * 刷新数据到页面
74 | */
75 | public void notifiedDataChanged() {
76 | mListener.onDataChanged();
77 | }
78 |
79 | /**
80 | * 数据发生改变的监听器
81 | */
82 | public interface OnDataChangedListener {
83 | /**
84 | * 当数据改变时回调
85 | */
86 | void onDataChanged();
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/step/entity/StepAble.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.step.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * author : 颜洪毅
7 | * e-mail : yhyzgn@gmail.com
8 | * time : 2018-04-14 11:09
9 | * version: 1.0.0
10 | * desc : 可步骤化实体需要实现该接口,用于识别每个步骤的状态
11 | */
12 | public interface StepAble extends Serializable {
13 |
14 | // 状态枚举
15 | enum Status {
16 | // 完成,当前,默认
17 | COMPLETE, CURRENT, DEFAULT
18 | }
19 |
20 | /**
21 | * 获取当前对象的状态
22 | *
23 | * @return 当前对象状态
24 | */
25 | Status getStatus();
26 | }
27 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/step/entity/StepNode.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.step.entity;
2 |
3 | import android.graphics.PointF;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * author : 颜洪毅
9 | * e-mail : yhyzgn@gmail.com
10 | * time : 2018-04-14 14:20
11 | * version: 1.0.0
12 | * desc : 步骤节点
13 | */
14 | public class StepNode implements Serializable {
15 | private static final long serialVersionUID = 8961443525468360517L;
16 |
17 | // 节点圆心
18 | public PointF center;
19 | // 节点半径
20 | public float radius;
21 | // 节点状态
22 | public StepAble.Status status;
23 | // 节点类型【开头,中间,末尾】
24 | public NodeType nodeType;
25 |
26 | /**
27 | * 节点类型枚举
28 | */
29 | public enum NodeType {
30 | // 开头,中间,末尾
31 | START, MIDDLE, END
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/web/bridge/HybridBridge.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.web.bridge;
2 |
3 | /**
4 | * author : 颜洪毅
5 | * e-mail : yhyzgn@gmail.com
6 | * time : 2018-05-25 10:21
7 | * version: 1.0.0
8 | * desc : js调用原生的桥梁基类
9 | */
10 | public class HybridBridge {
11 | }
12 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/web/listener/OnWebEventListener.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.web.listener;
2 |
3 | import android.net.Uri;
4 | import android.webkit.JsPromptResult;
5 | import android.webkit.JsResult;
6 | import android.webkit.ValueCallback;
7 | import android.webkit.WebChromeClient;
8 |
9 | import com.yhy.widget.core.web.HybridWebView;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2018-05-25 10:36
15 | * version: 1.0.0
16 | * desc : HybridWebView事件监听器
17 | */
18 | public interface OnWebEventListener {
19 |
20 | /**
21 | * 当WebView获取到焦点是回调
22 | *
23 | * @param view 当前HybridWebView
24 | */
25 | void onRequestFocus(HybridWebView view);
26 |
27 | /**
28 | * 当窗口关闭时回调
29 | *
30 | * @param window 当前HybridWebView
31 | */
32 | void onCloseWindow(HybridWebView window);
33 |
34 | /**
35 | * 当js中弹出alert时回调
36 | *
37 | * @param view 当前HybridWebView
38 | * @param url url
39 | * @param message 弹出信息
40 | * @param result 弹窗对象
41 | * @return 是否消费当前事件
42 | */
43 | boolean onJsAlert(HybridWebView view, String url, String message, JsResult result);
44 |
45 | /**
46 | * 当js弹出confirm类型的弹窗时回调
47 | *
48 | * @param view 当前HybridWebView
49 | * @param url url
50 | * @param message 弹出信息
51 | * @param result 弹窗对象
52 | * @return 是否消费当前事件
53 | */
54 | boolean onJsConfirm(HybridWebView view, String url, String message, JsResult result);
55 |
56 | /**
57 | * 当js弹出prompt弹窗时回调
58 | *
59 | * @param view 当前HybridWebView
60 | * @param url url
61 | * @param message 弹出信息
62 | * @param defaultValue 默认值
63 | * @param result 弹窗对象
64 | * @return 是否消费当前事件
65 | */
66 | boolean onJsPrompt(HybridWebView view, String url, String message, String defaultValue, JsPromptResult result);
67 |
68 | /**
69 | * WebView上传文件前回调
70 | *
71 | * @param view 当前HybridWebView
72 | * @param url url
73 | * @param message 弹出信息
74 | * @param result 弹窗对象
75 | * @return 是否消费当前事件
76 | */
77 | boolean onJsBeforeUnload(HybridWebView view, String url, String message, JsResult result);
78 |
79 | /**
80 | * 当控制台有信息输出时回调
81 | *
82 | * @param message 具体信息
83 | * @param lineNumber 行号
84 | * @param sourceID 信息id
85 | */
86 | void onConsoleMessage(String message, int lineNumber, String sourceID);
87 |
88 | /**
89 | * 当需要选择文件时回调
90 | *
91 | * @param webView 当前HybridWebView
92 | * @param filePathCallback 用来接收最终的文件选择结果
93 | * @param fileChooserParams 网页上传过来的相关参数
94 | * @return 是否消费当前事件
95 | */
96 | boolean onShowFileChooser(HybridWebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams);
97 | }
98 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/web/listener/OnWebLoadListener.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.web.listener;
2 |
3 | import android.graphics.Bitmap;
4 | import android.net.http.SslError;
5 | import android.webkit.SslErrorHandler;
6 | import android.webkit.WebResourceRequest;
7 | import android.webkit.WebResourceResponse;
8 | import android.webkit.WebView;
9 |
10 | import com.yhy.widget.core.web.HybridWebView;
11 |
12 | /**
13 | * author : 颜洪毅
14 | * e-mail : yhyzgn@gmail.com
15 | * time : 2018-05-25 10:22
16 | * version: 1.0.0
17 | * desc : HybridWebView加载过程监听器
18 | */
19 | public interface OnWebLoadListener {
20 |
21 | /**
22 | * 开始加载
23 | *
24 | * @param view 当前HybridWebView
25 | * @param url url
26 | * @param favicon 图标
27 | */
28 | void onStart(HybridWebView view, String url, Bitmap favicon);
29 |
30 | /**
31 | * 加载进度
32 | *
33 | * @param view 当前HybridWebView
34 | * @param newProgress 加载进度
35 | */
36 | void onProgress(HybridWebView view, int newProgress);
37 |
38 | /**
39 | * 加载结束
40 | *
41 | * @param view 当前HybridWebView
42 | * @param url url
43 | */
44 | void onFinish(HybridWebView view, String url);
45 |
46 | /**
47 | * 接收到标题
48 | *
49 | * @param view 当前HybridWebView
50 | * @param title 标题
51 | */
52 | void onReceivedTitle(HybridWebView view, String title);
53 |
54 | /**
55 | * 接收到图标
56 | *
57 | * @param view 当前HybridWebView
58 | * @param icon 图标
59 | */
60 | void onReceivedIcon(HybridWebView view, Bitmap icon);
61 |
62 | /**
63 | * 加载资源,如加载图片
64 | *
65 | * @param view 当前HybridWebView
66 | * @param url 资源url
67 | */
68 | void onLoadResource(HybridWebView view, String url);
69 |
70 | /**
71 | * 接收到错误
72 | *
73 | * @param view 当前HybridWebView
74 | * @param errorCode 错误码
75 | * @param description 错误信息
76 | * @param failingUrl 错误url
77 | */
78 | void onReceivedError(HybridWebView view, int errorCode, String description, String failingUrl);
79 |
80 | /**
81 | * 接收到http错误
82 | *
83 | * @param view 当前HybridWebView
84 | * @param request 请求
85 | * @param errorResponse 错误
86 | */
87 | void onReceivedHttpError(HybridWebView view, WebResourceRequest request, WebResourceResponse errorResponse);
88 |
89 | /**
90 | * 接收到ssl错误
91 | *
92 | * @param view 当前HybridWebView
93 | * @param handler Handler
94 | * @param error 错误信息
95 | */
96 | void onReceivedSslError(HybridWebView view, SslErrorHandler handler, SslError error);
97 | }
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/web/listener/SimpleOnWebEventListener.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.web.listener;
2 |
3 | import android.net.Uri;
4 | import android.webkit.JsPromptResult;
5 | import android.webkit.JsResult;
6 | import android.webkit.ValueCallback;
7 | import android.webkit.WebChromeClient;
8 |
9 | import com.yhy.widget.core.web.HybridWebView;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2018-05-25 11:20
15 | * version: 1.0.0
16 | * desc : 默认的简化版OnWebEventListener
17 | */
18 | public class SimpleOnWebEventListener implements OnWebEventListener {
19 | @Override
20 | public void onRequestFocus(HybridWebView view) {
21 | }
22 |
23 | @Override
24 | public void onCloseWindow(HybridWebView window) {
25 | }
26 |
27 | @Override
28 | public boolean onJsAlert(HybridWebView view, String url, String message, JsResult result) {
29 | return false;
30 | }
31 |
32 | @Override
33 | public boolean onJsConfirm(HybridWebView view, String url, String message, JsResult result) {
34 | return false;
35 | }
36 |
37 | @Override
38 | public boolean onJsPrompt(HybridWebView view, String url, String message, String defaultValue, JsPromptResult result) {
39 | return false;
40 | }
41 |
42 | @Override
43 | public boolean onJsBeforeUnload(HybridWebView view, String url, String message, JsResult result) {
44 | return false;
45 | }
46 |
47 | @Override
48 | public void onConsoleMessage(String message, int lineNumber, String sourceID) {
49 | }
50 |
51 | @Override
52 | public boolean onShowFileChooser(HybridWebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
53 | return false;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/core/web/listener/SimpleOnWebLoadListener.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.core.web.listener;
2 |
3 | import android.graphics.Bitmap;
4 | import android.net.http.SslError;
5 | import android.webkit.SslErrorHandler;
6 | import android.webkit.WebResourceRequest;
7 | import android.webkit.WebResourceResponse;
8 |
9 | import com.yhy.widget.core.web.HybridWebView;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2018-05-25 11:20
15 | * version: 1.0.0
16 | * desc : 默认简化版OnWebLoadListener
17 | */
18 | public class SimpleOnWebLoadListener implements OnWebLoadListener {
19 | @Override
20 | public void onStart(HybridWebView view, String url, Bitmap favicon) {
21 | }
22 |
23 | @Override
24 | public void onProgress(HybridWebView view, int newProgress) {
25 | }
26 |
27 | @Override
28 | public void onFinish(HybridWebView view, String url) {
29 | }
30 |
31 | @Override
32 | public void onReceivedTitle(HybridWebView view, String title) {
33 | }
34 |
35 | @Override
36 | public void onReceivedIcon(HybridWebView view, Bitmap icon) {
37 | }
38 |
39 | @Override
40 | public void onLoadResource(HybridWebView view, String url) {
41 | }
42 |
43 | @Override
44 | public void onReceivedError(HybridWebView view, int errorCode, String description, String failingUrl) {
45 | }
46 |
47 | @Override
48 | public void onReceivedHttpError(HybridWebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
49 | }
50 |
51 | @Override
52 | public void onReceivedSslError(HybridWebView view, SslErrorHandler handler, SslError error) {
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/layout/status/helper/DefLayoutHelper.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.layout.status.helper;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.LinearLayout;
7 |
8 | import com.yhy.widget.layout.status.StatusLayout;
9 | import com.yhy.widget.layout.status.view.StaEmptyView;
10 | import com.yhy.widget.layout.status.view.StaErrorView;
11 | import com.yhy.widget.layout.status.view.StaLoadingView;
12 |
13 | /**
14 | * author : 颜洪毅
15 | * e-mail : yhyzgn@gmail.com
16 | * time : 2017-10-13 17:42
17 | * version: 1.0.0
18 | * desc : 默认的状态布局助手构造器
19 | */
20 | public class DefLayoutHelper {
21 | // 布局参数
22 | private static ViewGroup.LayoutParams mParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
23 |
24 | // 私有化构造方法
25 | private DefLayoutHelper() {
26 | throw new IllegalStateException("Can not be instantiated.");
27 | }
28 |
29 | /**
30 | * 创建默认助手
31 | *
32 | * @param layout 当前状态布局
33 | * @return 默认助手
34 | */
35 | public static StaLayoutHelper create(StatusLayout layout) {
36 | Context ctx = layout.getContext();
37 | // 创建助手,并配置助手各状态页面
38 | StaLayoutHelperBuilder builder = new StaLayoutHelperBuilder.Builder(layout).setLoadingLayout(createLoadingView(ctx)).setErrorLayout(createErrorView(ctx)).setEmptyLayout(createEmptyView(ctx)).build();
39 | return builder.getHelper();
40 | }
41 |
42 | /**
43 | * 创建[加载中]界面
44 | *
45 | * @param ctx 上下文对象
46 | * @return [加载中]界面
47 | */
48 | private static View createLoadingView(Context ctx) {
49 | StaLoadingView slv = new StaLoadingView(ctx);
50 | slv.setLayoutParams(mParams);
51 | // 配置tag
52 | slv.setTag(StatusLayout.Status.LOADING.getStatus());
53 | return slv;
54 | }
55 |
56 | /**
57 | * 创建[错误]界面
58 | *
59 | * @param ctx 上下文对象
60 | * @return [错误]界面
61 | */
62 | private static View createErrorView(Context ctx) {
63 | StaErrorView sev = new StaErrorView(ctx);
64 | sev.setLayoutParams(mParams);
65 | // 配置tag
66 | sev.setTag(StatusLayout.Status.ERROR.getStatus());
67 | return sev;
68 | }
69 |
70 | /**
71 | * 创建[无数据]界面
72 | *
73 | * @param ctx 上下文对象
74 | * @return [无数据]界面
75 | */
76 | private static View createEmptyView(Context ctx) {
77 | StaEmptyView sev = new StaEmptyView(ctx);
78 | sev.setLayoutParams(mParams);
79 | // 配置tag
80 | sev.setTag(StatusLayout.Status.EMPTY.getStatus());
81 | return sev;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/layout/status/listener/OnStatusRetryListener.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.layout.status.listener;
2 |
3 | /**
4 | * author : 颜洪毅
5 | * e-mail : yhyzgn@gmail.com
6 | * time : 2017-10-13 14:09
7 | * version: 1.0.0
8 | * desc : 点击重试事件监听器
9 | */
10 | public interface OnStatusRetryListener {
11 | /**
12 | * 点击重试
13 | */
14 | void onRetry();
15 | }
16 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/layout/status/view/StaEmptyView.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.layout.status.view;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.widget.LinearLayout;
8 |
9 | import com.yhy.widget.R;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2017-10-13 16:28
15 | * version: 1.0.0
16 | * desc : 默认[无数据]界面
17 | */
18 | public class StaEmptyView extends LinearLayout {
19 | public StaEmptyView(Context context) {
20 | this(context, null);
21 | }
22 |
23 | public StaEmptyView(Context context, @Nullable AttributeSet attrs) {
24 | this(context, attrs, 0);
25 | }
26 |
27 | public StaEmptyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | LayoutInflater.from(getContext()).inflate(R.layout.widget_status_empty, this);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/layout/status/view/StaErrorView.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.layout.status.view;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.widget.LinearLayout;
8 |
9 | import com.yhy.widget.R;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2017-10-13 16:28
15 | * version: 1.0.0
16 | * desc : 默认[错误]界面
17 | */
18 | public class StaErrorView extends LinearLayout {
19 | public StaErrorView(Context context) {
20 | this(context, null);
21 | }
22 |
23 | public StaErrorView(Context context, @Nullable AttributeSet attrs) {
24 | this(context, attrs, 0);
25 | }
26 |
27 | public StaErrorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | LayoutInflater.from(getContext()).inflate(R.layout.widget_status_error, this);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/widget/src/main/java/com/yhy/widget/layout/status/view/StaLoadingView.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget.layout.status.view;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.widget.LinearLayout;
8 |
9 | import com.yhy.widget.R;
10 |
11 | /**
12 | * author : 颜洪毅
13 | * e-mail : yhyzgn@gmail.com
14 | * time : 2017-10-13 16:28
15 | * version: 1.0.0
16 | * desc : 默认[加载中]界面
17 | */
18 | public class StaLoadingView extends LinearLayout {
19 | public StaLoadingView(Context context) {
20 | this(context, null);
21 | }
22 |
23 | public StaLoadingView(Context context, @Nullable AttributeSet attrs) {
24 | this(context, attrs, 0);
25 | }
26 |
27 | public StaLoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | LayoutInflater.from(getContext()).inflate(R.layout.widget_status_loading, this);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/widget/src/main/res/anim/adv_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
--------------------------------------------------------------------------------
/widget/src/main/res/anim/adv_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
--------------------------------------------------------------------------------
/widget/src/main/res/drawable/bg_input_dialog_enable_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/widget/src/main/res/drawable/icon_status_dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/widget/src/main/res/drawable/img_status_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
--------------------------------------------------------------------------------
/widget/src/main/res/drawable/img_status_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
13 |
16 |
--------------------------------------------------------------------------------
/widget/src/main/res/drawable/widget_status_dialog_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_activity_pre_img.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
21 |
22 |
31 |
32 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_item_pager_per_img.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
17 |
18 |
25 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_status_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
23 |
24 |
32 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_status_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
29 |
30 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_status_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
29 |
30 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_status_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
24 |
--------------------------------------------------------------------------------
/widget/src/main/res/layout/widget_step_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xhdpi/ic_def_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xhdpi/ic_def_download.png
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xhdpi/img_def_loading.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xhdpi/img_def_loading.jpg
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xxhdpi/ic_def_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xxhdpi/ic_def_download.png
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_error.png
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_failed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_failed.png
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_loading.png
--------------------------------------------------------------------------------
/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yhyzgn/Widgets/1f802bb6e411c384e7ee8e52a3fcc38e9ba853d1/widget/src/main/res/mipmap-xxhdpi/icon_status_dialog_success.png
--------------------------------------------------------------------------------
/widget/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @color/colorPrimary
5 | - @android:color/holo_orange_dark
6 | - @color/colorPrimary
7 |
8 |
--------------------------------------------------------------------------------
/widget/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #01aca8
4 | #fe4365
5 | #113e3c
6 | #eeeeee
7 | #ababab
8 | #999999
9 | #1d294c
10 | #24211c
11 | #aa000000
12 | #88ffffff
13 | @color/colorAccent
14 |
--------------------------------------------------------------------------------
/widget/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | widget
3 |
4 | %d / %d
5 |
6 | 正在加载 ...
7 | 出错啦,点击重试
8 | 数据被外星人绑架啦
9 |
10 |
--------------------------------------------------------------------------------
/widget/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widget/src/main/res/xml/widget_file_provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/widget/src/test/java/com/yhy/widget/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yhy.widget;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import com.danikula.videocache.file.Md5FileNameGenerator;
6 | import com.yhy.widget.component.downloader.FilenameGenerator;
7 |
8 | import org.junit.Test;
9 |
10 | /**
11 | * Example local unit test, which will execute on the development machine (host).
12 | *
13 | * @see Testing documentation
14 | */
15 | public class ExampleUnitTest {
16 |
17 | @Test
18 | public void addition_isCorrect() throws Exception {
19 | assertEquals(4, 2 + 2);
20 | }
21 |
22 | @Test
23 | public void testFilename() {
24 | String filename = "https://upload-images.jianshu.io/upload_images/5809200-a99419bb94924e6d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
25 | System.out.println(new Md5FileNameGenerator().generate(filename));
26 | System.out.println(FilenameGenerator.generate(filename));
27 | System.out.println(FilenameGenerator.generate("https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7a5971ea24504d2b89179e33499f4dff~tplv-k3u1fbpfcp-zoom-in-crop-mark:4536:0:0:0.awebp"));
28 |
29 | System.out.println(isInternetFile(filename));
30 | System.out.println(isInternetFile("http://p3-juejin.byteimg.com/storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4"));
31 | System.out.println(isInternetFile("ftps://p3-juejin.byteimg.com/storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4"));
32 | System.out.println(isInternetFile("ftp://p3-juejin.byteimg.com/storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4"));
33 | System.out.println(isInternetFile("storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4"));
34 | System.out.println(isInternetFile("/storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4"));
35 | System.out.println(isInternetFile("file:///storage/emulated/0/Download/视频_2022-5-1_18-56-3.mp4"));
36 | }
37 |
38 | private boolean isInternetFile(String url) {
39 | return url.matches("^((http)|(ftp)s?://).+");
40 | }
41 | }
--------------------------------------------------------------------------------