diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 7021716..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - 1.8 - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 925cf0e..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index bee7dad..b96c5b5 100644 --- a/README.md +++ b/README.md @@ -376,8 +376,6 @@ CSDN:http://blog.csdn.net/Hubert_bing 掘金:https://juejin.im/user/57bb1fdcc4c971006152d7b0/posts -**本人正在考虑新的工作机会,如果有上海的公司,欢迎内推我,联系邮箱654360340@qq.com或者微信h139x726845** - ## License diff --git a/app/build.gradle b/app/build.gradle index 7c436d5..1d9ae80 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 26 - buildToolsVersion '27.0.3' + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "com.app.hubert.newbieguide" minSdkVersion 14 - targetSdkVersion 26 + targetSdkVersion 29 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -23,14 +23,14 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation project(':guide') -// implementation ('com.github.huburt-Hu:NewbieGuide:v2.3.0') - implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion" - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - implementation "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion" +// implementation ('com.github.huburt-Hu:NewbieGuide:v2.4.4') + implementation "androidx.appcompat:appcompat:$rootProject.ext.supportLibraryVersion" + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation "androidx.recyclerview:recyclerview:$rootProject.ext.supportLibraryVersion" implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.28' implementation("com.jaeger.statusbarutil:library:1.4.0") { exclude group: 'com.android.support' @@ -38,13 +38,13 @@ dependencies { testImplementation 'junit:junit:4.12' // Lifecycles, LiveData 和 ViewModel - implementation 'android.arch.lifecycle:runtime:1.0.3' - implementation 'android.arch.lifecycle:extensions:1.0.0' - annotationProcessor "android.arch.lifecycle:compiler:1.0.0" + implementation 'androidx.lifecycle:lifecycle-runtime:2.1.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' + annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.1.0' // Room - implementation 'android.arch.persistence.room:runtime:1.0.0' - annotationProcessor "android.arch.persistence.room:compiler:1.0.0" + implementation 'androidx.room:room-runtime:2.2.3' + annotationProcessor 'androidx.room:room-compiler:2.2.3' - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.1' releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index db0b6fe..27123f1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,8 @@ + + \ No newline at end of file diff --git a/app/src/main/java/com/app/hubert/newbieguide/AbcFragment.java b/app/src/main/java/com/app/hubert/newbieguide/AbcFragment.java index fad61ea..66c4bfb 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/AbcFragment.java +++ b/app/src/main/java/com/app/hubert/newbieguide/AbcFragment.java @@ -1,13 +1,16 @@ package com.app.hubert.newbieguide; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import com.app.hubert.guide.core.Controller; +import com.app.hubert.guide.listener.OnGuideChangedListener; import com.app.hubert.guide.model.GuidePage; import com.app.hubert.guide.model.HighLight; import com.app.hubert.guide.NewbieGuide; @@ -53,6 +56,17 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { NewbieGuide.with(this)//传入fragment .setLabel("guide2")//设置引导层标示,必传!否则报错 .alwaysShow(true) + .setOnGuideChangedListener(new OnGuideChangedListener() { + @Override + public void onShowed(Controller controller) { + + } + + @Override + public void onRemoved(Controller controller) { + Log.e("tag", "onRemoved"); + } + }) .addGuidePage(GuidePage.newInstance() .addHighLight(textView, HighLight.Shape.CIRCLE)//添加需要高亮的view .setLayoutRes(R.layout.view_guide)//自定义的提示layout,不要添加背景色,引导层背景色通过setBackgroundColor()设置 diff --git a/app/src/main/java/com/app/hubert/newbieguide/App.java b/app/src/main/java/com/app/hubert/newbieguide/App.java index 5247d62..d7347c0 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/App.java +++ b/app/src/main/java/com/app/hubert/newbieguide/App.java @@ -1,37 +1,22 @@ package com.app.hubert.newbieguide; import android.app.Application; -import android.content.Context; - -import com.squareup.leakcanary.LeakCanary; -import com.squareup.leakcanary.RefWatcher; /** * Created by hubert on 2018/5/2. */ public class App extends Application { - private RefWatcher refWatcher; private static App instance; @Override public void onCreate() { super.onCreate(); instance = this; - if (LeakCanary.isInAnalyzerProcess(this)) { - // This process is dedicated to LeakCanary for heap analysis. - // You should not init your app in this process. - return; - } - refWatcher = LeakCanary.install(this); // Normal app init code... } public static App getInstance() { return instance; } - - public RefWatcher getRefWatcher() { - return refWatcher; - } } diff --git a/app/src/main/java/com/app/hubert/newbieguide/FirstActivity.java b/app/src/main/java/com/app/hubert/newbieguide/FirstActivity.java index 60ef150..a398670 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/FirstActivity.java +++ b/app/src/main/java/com/app/hubert/newbieguide/FirstActivity.java @@ -5,8 +5,8 @@ import android.graphics.DashPathEffect; import android.graphics.Paint; import android.graphics.RectF; -import android.support.annotation.IntDef; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.IntDef; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.Gravity; import android.view.View; @@ -23,10 +23,6 @@ import com.app.hubert.guide.model.HighLight; import com.app.hubert.guide.model.HighlightOptions; import com.app.hubert.guide.model.RelativeGuide; -import com.app.hubert.guide.util.ViewUtils; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; public class FirstActivity extends AppCompatActivity { @@ -34,6 +30,7 @@ public class FirstActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first); + //简单使用 final Button btnSimple = (Button) findViewById(R.id.btn_simple); btnSimple.setOnClickListener(new View.OnClickListener() { @Override @@ -49,6 +46,7 @@ public void onClick(View v) { .show(); } }); + //对话框形式 final Button btnDialog = (Button) findViewById(R.id.btn_dialog); btnDialog.setOnClickListener(new View.OnClickListener() { @Override @@ -71,7 +69,7 @@ public void onLayoutInflated(View view, Controller controller) { .show(); } }); - + //设置anchor 及 自定义绘制图形 final View anchorView = findViewById(R.id.ll_anchor); final Button btnAnchor = (Button) findViewById(R.id.btn_anchor); btnAnchor.setOnClickListener(new View.OnClickListener() { @@ -100,7 +98,7 @@ public void onHighlightDrew(Canvas canvas, RectF rectF) { .show(); } }); - + //监听 final Button btnListener = findViewById(R.id.btn_listener); btnListener.setOnClickListener(new View.OnClickListener() { @Override @@ -138,6 +136,12 @@ public void onClick(View v) { RecyclerViewActivity.start(FirstActivity.this); } }); + findViewById(R.id.btn_scroll).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ScrollViewActivity.start(FirstActivity.this); + } + }); final View btnRelative = findViewById(R.id.btn_relative); btnRelative.setOnClickListener(new View.OnClickListener() { @@ -146,7 +150,7 @@ public void onClick(View v) { HighlightOptions options = new HighlightOptions.Builder() .setRelativeGuide(new RelativeGuide(R.layout.view_relative_guide, Gravity.LEFT, 100) { @Override - protected void onLayoutInflated(View view) { + protected void onLayoutInflated(View view, Controller controller) { TextView textView = view.findViewById(R.id.tv); textView.setText("inflated"); } diff --git a/app/src/main/java/com/app/hubert/newbieguide/GridViewActivity.java b/app/src/main/java/com/app/hubert/newbieguide/GridViewActivity.java index 8b7de8e..e156863 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/GridViewActivity.java +++ b/app/src/main/java/com/app/hubert/newbieguide/GridViewActivity.java @@ -2,7 +2,7 @@ import android.content.Context; import android.content.Intent; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.GridView; diff --git a/app/src/main/java/com/app/hubert/newbieguide/MainActivity.java b/app/src/main/java/com/app/hubert/newbieguide/MainActivity.java index 09680e7..daf8b63 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/MainActivity.java +++ b/app/src/main/java/com/app/hubert/newbieguide/MainActivity.java @@ -3,7 +3,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.View; diff --git a/app/src/main/java/com/app/hubert/newbieguide/ObservableScrollView.java b/app/src/main/java/com/app/hubert/newbieguide/ObservableScrollView.java new file mode 100644 index 0000000..fce9297 --- /dev/null +++ b/app/src/main/java/com/app/hubert/newbieguide/ObservableScrollView.java @@ -0,0 +1,38 @@ +package com.app.hubert.newbieguide; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ScrollView; + +public class ObservableScrollView extends ScrollView { + + private OnScrollChangeListener scrollChangeListener = null; + + public ObservableScrollView(Context context) { + super(context); + } + + public ObservableScrollView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public ObservableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public void setScrollViewListener(OnScrollChangeListener onScrollChangeListener) { + this.scrollChangeListener = onScrollChangeListener; + } + + @Override + protected void onScrollChanged(int x, int y, int oldx, int oldy) { + super.onScrollChanged(x, y, oldx, oldy); + if (scrollChangeListener != null) { + scrollChangeListener.onScrollChanged(this, x, y, oldx, oldy); + } + } + + public interface OnScrollChangeListener { + void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy); + } +} diff --git a/app/src/main/java/com/app/hubert/newbieguide/RecyclerViewActivity.java b/app/src/main/java/com/app/hubert/newbieguide/RecyclerViewActivity.java index 1b3c720..e96238c 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/RecyclerViewActivity.java +++ b/app/src/main/java/com/app/hubert/newbieguide/RecyclerViewActivity.java @@ -3,11 +3,10 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.widget.TextView; diff --git a/app/src/main/java/com/app/hubert/newbieguide/ScrollViewActivity.java b/app/src/main/java/com/app/hubert/newbieguide/ScrollViewActivity.java new file mode 100644 index 0000000..0effe59 --- /dev/null +++ b/app/src/main/java/com/app/hubert/newbieguide/ScrollViewActivity.java @@ -0,0 +1,63 @@ +package com.app.hubert.newbieguide; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Rect; +import android.os.Bundle; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import android.view.View; + +import com.app.hubert.guide.NewbieGuide; +import com.app.hubert.guide.core.Controller; +import com.app.hubert.guide.model.GuidePage; +import com.app.hubert.guide.model.HighlightOptions; + +/** + * Created by hubert on 2018/12/11. + */ +public class ScrollViewActivity extends AppCompatActivity { + + private Controller controller; + + public static void start(Context context) { + Intent starter = new Intent(context, ScrollViewActivity.class); + context.startActivity(starter); + } + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scroll_view); + final View light = findViewById(R.id.v_light); + final View lightNext = findViewById(R.id.v_light_next); + + HighlightOptions options = new HighlightOptions.Builder() + .isFetchLocationEveryTime(true) + .build(); + controller = NewbieGuide.with(ScrollViewActivity.this) + .setLabel("scroll1") + .alwaysShow(true) + .addGuidePage(GuidePage.newInstance() + .addHighLightWithOptions(light, options)) + .build(); + ObservableScrollView scrollView = findViewById(R.id.scrollView); + scrollView.setScrollViewListener(new ObservableScrollView.OnScrollChangeListener() { + @Override + public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) { +// if (scrollView.getScrollY() + scrollView.getHeight() - +// scrollView.getPaddingTop() - scrollView.getPaddingBottom() +// == scrollView.getChildAt(0).getHeight()) {//判断滑动到底部 +// LogUtil.i("call show"); +// controller.show(); +// } + + Rect scrollBounds = new Rect(); + scrollView.getHitRect(scrollBounds); + if (lightNext.getLocalVisibleRect(scrollBounds)) { + controller.show(); + } + } + }); + } +} diff --git a/app/src/main/java/com/app/hubert/newbieguide/TestFragmentActivity.java b/app/src/main/java/com/app/hubert/newbieguide/TestFragmentActivity.java index c37bbfa..8670fc7 100644 --- a/app/src/main/java/com/app/hubert/newbieguide/TestFragmentActivity.java +++ b/app/src/main/java/com/app/hubert/newbieguide/TestFragmentActivity.java @@ -3,9 +3,9 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.appcompat.app.AppCompatActivity; import android.view.View; import android.widget.Button; diff --git a/app/src/main/res/layout/activity_first.xml b/app/src/main/res/layout/activity_first.xml index a821a6e..4a50187 100644 --- a/app/src/main/res/layout/activity_first.xml +++ b/app/src/main/res/layout/activity_first.xml @@ -56,6 +56,12 @@ android:layout_height="wrap_content" android:text="列表" /> +