- * 描述:标题栏组合控件 - *
- * sample: - *
- * .xml: - *
- *
- *
- * .java: - *
- * TitleBar titleBar ....findViewById(R.id...); - * titleBar.setTitle("...") - * ...... - */ - -public class TitleBar extends RelativeLayout implements View.OnClickListener { - - private ImageView mIvLeftBtn; - private ImageView mIvRightBtn; - private TextView mTvtitle; - private OnTitleBarClickListener mListener; - private OnTitleBarAllClickListener mAllClickListener; - private TextView mTvRightText; - private RelativeLayout mRlMain; - private View mVBottomLine; - private View mRootView; - private Button mBtnRed; - - public TitleBar(Context context) { - this(context, null); - } - - public TitleBar(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public TitleBar(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - initView(context); - } - /** - * @description 隐藏横线 - * @param - * @return - */ - public void hideline(){ - mVBottomLine.setVisibility(GONE); - } - private void initView(Context context) { - mRootView = inflate(context, R.layout.widget_title_bar, this); - - //左边按钮 - mIvLeftBtn = (ImageView) mRootView.findViewById(R.id.iv_left_btn); - //右边按扭 - mIvRightBtn = (ImageView) mRootView.findViewById(R.id.iv_right_btn); - //标题 - mTvtitle = (TextView) mRootView.findViewById(R.id.tv_title); - //右边文字按钮 - mTvRightText = (TextView) mRootView.findViewById(R.id.tv_right_text); - - //右边红点 - mBtnRed = (Button) mRootView.findViewById(R.id.btn_red); - - mRlMain = (RelativeLayout) mRootView.findViewById(R.id.rl_main); - // 底部线 - mVBottomLine = mRootView.findViewById(R.id.v_bottom_line); - - mIvLeftBtn.setOnClickListener(this); - mIvRightBtn.setOnClickListener(this); - mTvRightText.setOnClickListener(this); - - } - - /** - * 设置暗黑模式 - */ - public void setDarkTheme() { - mRootView.findViewById(R.id.rl_main).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.colorLightBlack)); - mTvtitle.setTextColor(ContextCompat.getColor(getContext(), R.color.colorWhile)); - mIvLeftBtn.setImageResource(R.mipmap.nav_white_back); - } - - @Override - public void onClick(View view) { - switch (view.getId()) { - //左边按钮 - case R.id.iv_left_btn: - if (null != mListener) { - mListener.onLeftButtonClick(view); - } - if (null != mAllClickListener) { - mAllClickListener.onLeftButtonClick(view); - } - break; - //右边按钮 - case R.id.iv_right_btn: - if (null != mListener) { - mListener.onRightButtonClick(view); - } - if (null != mAllClickListener) { - mAllClickListener.onRightButtonClick(view); - } - break; - //右边文本按钮 - case R.id.tv_right_text: - if (null != mAllClickListener) { - mAllClickListener.onRightTextButtonClick(view); - } - break; - } - } - - /** - * 底部线是否显示,默认是显示 - * - * @param show - */ - public void showBottomLine(boolean show) { - mVBottomLine.setVisibility(show ? View.VISIBLE : View.GONE); - } - - /** - * 显示或隐藏左边按钮 - * - * @param visible - */ - public void visibleIvLeftBtn(boolean visible) { - mIvLeftBtn.setVisibility(visible ? View.VISIBLE : View.GONE); - } - - /** - * 显示或隐藏右边按钮 - * - * @param visible - */ - public void visibleIvRightBtn(boolean visible) { - mIvRightBtn.setVisibility(visible ? View.VISIBLE : View.GONE); - } - - /** - * 显示或隐藏右边文本按钮 - * - * @param visible - */ - public void visibleTvRightTextBtn(boolean visible) { - mTvRightText.setVisibility(visible ? View.VISIBLE : View.GONE); - } - - /** - * 显示或隐藏右边红点 - * - * @param visible - */ - public void visibleRightRedDot(boolean visible) { - mBtnRed.setVisibility(visible ? View.VISIBLE : View.GONE); - } - - /** - * 设置左边按钮图标 - * - * @param ids - */ - public void setIvLeftBtnDrawable(@DrawableRes int ids) { - mIvLeftBtn.setImageResource(ids); - } - - /** - * 设置右边按钮图标 - * - * @param ids - */ - public void setIvRightBtnDrawable(@DrawableRes int ids) { - mIvRightBtn.setImageResource(ids); - } - - /** - * 设置标题 - * - * @param ids - */ - public void setTitle(@StringRes int ids) { - setTitle(getContext().getResources().getString(ids)); - } - - /** - * 设置标题 - * - * @param titleText - */ - public void setTitle(String titleText) { - mTvtitle.setText(titleText); - } - - /** - * 设置标题颜色 - * - * @param colorIds - */ - public void setTitleColor(@ColorRes int colorIds) { - mTvtitle.setTextColor(getResources().getColor(colorIds)); - } - - /** - * 设置标题背景色 - * - * @param colorIds - */ - public void setTitleBg(@ColorRes int colorIds) { - mRlMain.setBackgroundResource(colorIds); - } - - /** - * 设置右边文本按钮的文本 - * - * @param rightButtonText - */ - public void setTvRightText(String rightButtonText) { - mTvRightText.setText(rightButtonText); - } - - /** - * 设置右边文本按钮的颜色 - * - * @param color - */ - public void setTvRightTextColor(@ColorRes int color) { - mTvRightText.setTextColor(getResources().getColor(color)); - } - - /** - * 设置右边文本使能 - * @param enable - */ - public void setTvRightTextEnable(boolean enable){ - mTvRightText.setEnabled(enable); - } - - /** - * 设置标题栏点击事件监听器这个监听器只响应左边按钮与右边按钮。若还想响应右边 - * 文本按的按钮请使用{@link #setOnTitleBarAllClickListener(OnTitleBarAllClickListener)} - * - * @param clickListener {@link OnTitleBarClickListener} - */ - public void setOnTitleBarClickListener(OnTitleBarClickListener clickListener) { - this.mListener = clickListener; - } - - /** - * 设置标题栏的上的按钮全部点击事件监听器能响应左边按钮,右边按钮,右边文本按钮 - * - * @param clickListener - */ - public void setOnTitleBarAllClickListener(OnTitleBarAllClickListener clickListener) { - this.mAllClickListener = clickListener; - } - - - /** - * 标题栏的点击事件回调接口,响应两个按钮的 - */ - public interface OnTitleBarClickListener { - /** - * 左边按钮被点击 - * - * @param view - */ - void onLeftButtonClick(View view); - - /** - * 右边按钮被点击 - * - * @param view - */ - void onRightButtonClick(View view); - } - - /** - * 标题栏的点击事件回调接口,响应三个按钮的 - */ - public interface OnTitleBarAllClickListener extends OnTitleBarClickListener { - /** - * 右边文本按钮点击事件 - * - * @param view - */ - void onRightTextButtonClick(View view); - - } - - -} +package com.fenghoo.seven.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.fenghoo.seven.R; + +import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; +import androidx.annotation.StringRes; +import androidx.core.content.ContextCompat; + + +/** + * Created by Administrator on 2016/12/23. + * 作者:xudiwei + *
+ * 描述:标题栏组合控件 + *
+ * sample: + *
+ * .xml: + *
+ *
+ *
+ * .java: + *
+ * TitleBar titleBar ....findViewById(R.id...);
+ * titleBar.setTitle("...")
+ * ......
+ */
+
+public class TitleBar extends RelativeLayout implements View.OnClickListener {
+
+ private ImageView mIvLeftBtn;
+ private ImageView mIvRightBtn;
+ private TextView mTvtitle;
+ private OnTitleBarClickListener mListener;
+ private OnTitleBarAllClickListener mAllClickListener;
+ private TextView mTvRightText;
+ private RelativeLayout mRlMain;
+ private View mVBottomLine;
+ private View mRootView;
+ private Button mBtnRed;
+
+ public TitleBar(Context context) {
+ this(context, null);
+ }
+
+ public TitleBar(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public TitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ initView(context);
+ }
+ /**
+ * @description 隐藏横线
+ * @param
+ * @return
+ */
+ public void hideline(){
+ mVBottomLine.setVisibility(GONE);
+ }
+ private void initView(Context context) {
+ mRootView = inflate(context, R.layout.widget_title_bar, this);
+
+ //左边按钮
+ mIvLeftBtn = (ImageView) mRootView.findViewById(R.id.iv_left_btn);
+ //右边按扭
+ mIvRightBtn = (ImageView) mRootView.findViewById(R.id.iv_right_btn);
+ //标题
+ mTvtitle = (TextView) mRootView.findViewById(R.id.tv_title);
+ //右边文字按钮
+ mTvRightText = (TextView) mRootView.findViewById(R.id.tv_right_text);
+
+ //右边红点
+ mBtnRed = (Button) mRootView.findViewById(R.id.btn_red);
+
+ mRlMain = (RelativeLayout) mRootView.findViewById(R.id.rl_main);
+ // 底部线
+ mVBottomLine = mRootView.findViewById(R.id.v_bottom_line);
+
+ mIvLeftBtn.setOnClickListener(this);
+ mIvRightBtn.setOnClickListener(this);
+ mTvRightText.setOnClickListener(this);
+
+ }
+
+ /**
+ * 设置暗黑模式
+ */
+ public void setDarkTheme() {
+ mRootView.findViewById(R.id.rl_main).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.colorLightBlack));
+ mTvtitle.setTextColor(ContextCompat.getColor(getContext(), R.color.colorWhile));
+ mIvLeftBtn.setImageResource(R.mipmap.nav_white_back);
+ }
+
+ @Override
+ public void onClick(View view) {
+ int id = view.getId();
+ //左边按钮
+ if (id == R.id.iv_left_btn) {
+ if (null != mListener) {
+ mListener.onLeftButtonClick(view);
+ }
+ if (null != mAllClickListener) {
+ mAllClickListener.onLeftButtonClick(view);
+ }
+ } else if (id == R.id.iv_right_btn) {
+ //右边按钮
+ if (null != mListener) {
+ mListener.onRightButtonClick(view);
+ }
+ if (null != mAllClickListener) {
+ mAllClickListener.onRightButtonClick(view);
+ }
+ } else if (id == R.id.tv_right_text) {
+ //右边文本按钮
+ if (null != mAllClickListener) {
+ mAllClickListener.onRightTextButtonClick(view);
+ }
+ }
+ }
+
+ /**
+ * 底部线是否显示,默认是显示
+ *
+ * @param show
+ */
+ public void showBottomLine(boolean show) {
+ mVBottomLine.setVisibility(show ? View.VISIBLE : View.GONE);
+ }
+
+ /**
+ * 显示或隐藏左边按钮
+ *
+ * @param visible
+ */
+ public void visibleIvLeftBtn(boolean visible) {
+ mIvLeftBtn.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
+ /**
+ * 显示或隐藏右边按钮
+ *
+ * @param visible
+ */
+ public void visibleIvRightBtn(boolean visible) {
+ mIvRightBtn.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
+ /**
+ * 显示或隐藏右边文本按钮
+ *
+ * @param visible
+ */
+ public void visibleTvRightTextBtn(boolean visible) {
+ mTvRightText.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
+ /**
+ * 显示或隐藏右边红点
+ *
+ * @param visible
+ */
+ public void visibleRightRedDot(boolean visible) {
+ mBtnRed.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
+ /**
+ * 设置左边按钮图标
+ *
+ * @param ids
+ */
+ public void setIvLeftBtnDrawable(@DrawableRes int ids) {
+ mIvLeftBtn.setImageResource(ids);
+ }
+
+ /**
+ * 设置右边按钮图标
+ *
+ * @param ids
+ */
+ public void setIvRightBtnDrawable(@DrawableRes int ids) {
+ mIvRightBtn.setImageResource(ids);
+ }
+
+ /**
+ * 设置标题
+ *
+ * @param ids
+ */
+ public void setTitle(@StringRes int ids) {
+ setTitle(getContext().getResources().getString(ids));
+ }
+
+ /**
+ * 设置标题
+ *
+ * @param titleText
+ */
+ public void setTitle(String titleText) {
+ mTvtitle.setText(titleText);
+ }
+
+ /**
+ * 设置标题颜色
+ *
+ * @param colorIds
+ */
+ public void setTitleColor(@ColorRes int colorIds) {
+ mTvtitle.setTextColor(getResources().getColor(colorIds));
+ }
+
+ /**
+ * 设置标题背景色
+ *
+ * @param colorIds
+ */
+ public void setTitleBg(@ColorRes int colorIds) {
+ mRlMain.setBackgroundResource(colorIds);
+ }
+
+ /**
+ * 设置右边文本按钮的文本
+ *
+ * @param rightButtonText
+ */
+ public void setTvRightText(String rightButtonText) {
+ mTvRightText.setText(rightButtonText);
+ }
+
+ /**
+ * 设置右边文本按钮的颜色
+ *
+ * @param color
+ */
+ public void setTvRightTextColor(@ColorRes int color) {
+ mTvRightText.setTextColor(getResources().getColor(color));
+ }
+
+ /**
+ * 设置右边文本使能
+ * @param enable
+ */
+ public void setTvRightTextEnable(boolean enable){
+ mTvRightText.setEnabled(enable);
+ }
+
+ /**
+ * 设置标题栏点击事件监听器这个监听器只响应左边按钮与右边按钮。若还想响应右边
+ * 文本按的按钮请使用{@link #setOnTitleBarAllClickListener(OnTitleBarAllClickListener)}
+ *
+ * @param clickListener {@link OnTitleBarClickListener}
+ */
+ public void setOnTitleBarClickListener(OnTitleBarClickListener clickListener) {
+ this.mListener = clickListener;
+ }
+
+ /**
+ * 设置标题栏的上的按钮全部点击事件监听器能响应左边按钮,右边按钮,右边文本按钮
+ *
+ * @param clickListener
+ */
+ public void setOnTitleBarAllClickListener(OnTitleBarAllClickListener clickListener) {
+ this.mAllClickListener = clickListener;
+ }
+
+
+ /**
+ * 标题栏的点击事件回调接口,响应两个按钮的
+ */
+ public interface OnTitleBarClickListener {
+ /**
+ * 左边按钮被点击
+ *
+ * @param view
+ */
+ void onLeftButtonClick(View view);
+
+ /**
+ * 右边按钮被点击
+ *
+ * @param view
+ */
+ void onRightButtonClick(View view);
+ }
+
+ /**
+ * 标题栏的点击事件回调接口,响应三个按钮的
+ */
+ public interface OnTitleBarAllClickListener extends OnTitleBarClickListener {
+ /**
+ * 右边文本按钮点击事件
+ *
+ * @param view
+ */
+ void onRightTextButtonClick(View view);
+
+ }
+
+
+}
diff --git a/build.gradle b/build.gradle
index c3e1a31..c5ad805 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,37 +1,59 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
-
- repositories {
- google()
- jcenter()
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
- dependencies {
-
- classpath 'com.android.tools.build:gradle:3.5.0'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
- classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
-
- }
-}
-
-allprojects {
- repositories {
- google()
- jcenter()
- maven { url "https://jitpack.io"}
- maven { url "https://www.jitpack.io" }
-// maven { url 'https://dl.bintray.com/aweme-open-sdk-team/public' }
-
-
-
- }
-}
-
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+
+ ext {
+ agp_version = '8.7.3'
+ }
+ repositories {
+ maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+ maven { url 'https://maven.aliyun.com/repository/public' }//jcenter
+ maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }//gradle-plugin
+ maven { url 'https://maven.aliyun.com/repository/central' }//central
+ maven { url 'https://maven.aliyun.com/repository/google' }//google
+ google()
+ jcenter()
+ mavenCentral()
+
+ maven { url "https://jitpack.io" }
+
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
+ }
+ dependencies {
+
+ classpath "com.android.tools.build:gradle:$agp_version"
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+ classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
+
+ }
+}
+
+allprojects {
+ repositories {
+ maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+ maven { url 'https://maven.aliyun.com/repository/public' }//jcenter
+ maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }//gradle-plugin
+ maven { url 'https://maven.aliyun.com/repository/central' }//central
+ maven { url 'https://maven.aliyun.com/repository/google' }//google
+ flatDir {
+ dirs 'libs'
+ }
+
+
+ google()
+ jcenter()
+ maven { url "https://jitpack.io"}
+ maven { url "https://www.jitpack.io" }
+// maven { url 'https://dl.bintray.com/aweme-open-sdk-team/public' }
+
+
+
+ }
+}
+
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/citypicker/build.gradle b/citypicker/build.gradle
index 876d89f..222e77b 100644
--- a/citypicker/build.gradle
+++ b/citypicker/build.gradle
@@ -1,34 +1,41 @@
-apply plugin: 'com.android.library'
-apply plugin: 'com.github.dcendents.android-maven'
-group='com.github.zaaach'
-
-android {
- compileSdkVersion 28
- buildToolsVersion "28.0.3"
- defaultConfig {
- minSdkVersion 14
- targetSdkVersion 27
- versionCode 7
- versionName "2.0.3"
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- testImplementation 'junit:junit:4.12'
- compileOnly 'androidx.appcompat:appcompat:1.0.0'
- compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
- api 'com.google.android.material:material:1.0.0'
+apply plugin: 'com.android.library'
+// apply plugin: 'com.github.dcendents.android-maven' // 与 Gradle 8.9 不兼容,暂时注释
+group='com.github.zaaach'
+
+android {
+ namespace 'com.zaaach.citypicker'
+ compileSdk 34
+ compileSdkVersion 34
+ buildToolsVersion "30.0.2"
+ defaultConfig {
+ minSdkVersion 14
+ targetSdkVersion 27
+ versionCode 7
+ versionName "2.0.3"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ testImplementation 'junit:junit:4.12'
+ compileOnly 'androidx.appcompat:appcompat:1.0.0'
+ compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
+ api 'com.google.android.material:material:1.0.0'
}
\ No newline at end of file
diff --git a/citypicker/src/main/AndroidManifest.xml b/citypicker/src/main/AndroidManifest.xml
index ae05bf7..36e5782 100644
--- a/citypicker/src/main/AndroidManifest.xml
+++ b/citypicker/src/main/AndroidManifest.xml
@@ -1,11 +1,10 @@
-