张波

更新接口

rootProject.name = "wdinterface"
include ':app'
include ':wdinterface'
\ No newline at end of file
include ':wdinterface'
include ':wdinterfaceimpl'
\ No newline at end of file
... ...
... ... @@ -42,7 +42,7 @@ android {
}
dependencies {
api 'com.alibaba:arouter-api:1.5.2'
}
uploadArchives {
... ... @@ -53,7 +53,7 @@ uploadArchives {
}
pom.project {
artifactId 'wdinterface'
version '1.0.0'
version '1.0.3'
groupId 'com.wd'
packaging 'aar'
}
... ...
package com.wd.foundation.wdinterface
import com.alibaba.android.arouter.facade.template.IProvider
/**
* 作者 : hl
* 时间 : 2023/3/10
* 描述 :登录总线服务接口
**/
interface ILoginService : IProvider {
/**
* 获取缓存用户id
*/
fun getUserId(): String?
/**
* 获取缓存用户类型
*/
fun getUserType(): String?
/**
* 获取缓存用户token
*/
fun getUserToken(): String?
}
\ No newline at end of file
... ...
package com.wd.foundation.wdinterface
import com.alibaba.android.arouter.facade.template.IProvider
/**
* 作者 : hl
* 时间 : 2023/3/7
* 描述 : 获取省份信息
**/
interface IProvinceService : IProvider {
fun getProvinceCode(): String?
fun getCityId(): String?
fun getCityName(): String?
fun getCarriageCode(): String?
}
\ No newline at end of file
... ...
package com.wd.foundation.wdinterface;
public interface ITest {
}
package com.wd.foundation.wdinterface.app
import com.alibaba.android.arouter.facade.template.IProvider
/**
* 作者 : 张波
* 时间 : 2024/10/14
* 描述 : 应用信息获取服务接口
**/
interface IAppInfoService : IProvider {
/**
* 获取平台标识
*/
fun getPlat(): String
/**
* 获取端标识,如Android、ios
*/
fun getSystem(): String
/**
* 获取设备id,用于IMEI、DEVICE_ID字段等
*/
fun getDeviceId(): String
/**
* 获取应用版本码,如 100
*/
fun getVersionCode(): String
/**
* 获取应用版本号,如 1.0.0
*/
fun getVersionName(): String
/**
* 获取应用打包版本,如 "202410141452"
*/
fun getBuildVersion(): String
/**
* 获取手机系统版本,取值 VERSION.RELEASE
*/
fun getOsVersion(): String
/**
* 获取渠道号
*/
fun getChannelCode(): String
}
\ No newline at end of file
... ...
package com.wd.foundation.wdinterface.toast;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* toast使用接口
*/
public interface IToast extends IProvider {
void showShort(String message);
void showTopShort(String message, int y);
void showLong(String message);
/**
* 展示吐司
*
* @param stringId 字符串资源id
*/
void showShort(int stringId);
void showShortBottom(int stringId);
void showLong(int stringId);
void show(String content, int duration);
IToast getInst();
}
... ...
/build
\ No newline at end of file
... ...
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'maven'
}
android {
compileSdkVersion var.compileSdkVersion
defaultConfig {
minSdkVersion var.minSdkVersion
targetSdkVersion var.targetSdkVersion
versionCode var.versionCode
versionName var.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
buildConfigField "String", "API_VERSION", "\"${requestVersion}\""
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// 自定义AAR包名
android.libraryVariants.all { variant ->
variant.outputs.all {
if (outputFileName != null && outputFileName.endsWith(".aar")) {
def fileName = "${project.name}-${buildType.name}-v${var.aar_version}.aar"
outputFileName = fileName
}
}
}
}
dependencies {
api 'com.wd:wdinterface:1.0.1'
// 吐司 兼容 框架
api 'com.github.getActivity:Toaster:12.2'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "https://packages.aliyun.com/6708d221eef79c23d7b02189/maven/repo-higom/") {
authentication(userName: '6708d1cf6f4c940bd257c88d', password: 'Wm51gc4rARyr')
}
pom.project {
artifactId 'wdinterfaceimpl'
version '1.0.0'
groupId 'com.wd'
packaging 'aar'
}
}
}
}
\ No newline at end of file
... ...
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wd.foundation.wdinterfaceimpl">
</manifest>
\ No newline at end of file
... ...
package com.wd.foundation.wdinterfaceimpl.toast;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hjq.toast.config.IToastStyle;
@SuppressWarnings({"unused", "deprecation"})
public class CustomBlackToastStyle implements IToastStyle<View> {
private final int mGravity;
private final int mXOffset;
private final int mYOffset;
private final float mHorizontalMargin;
private final float mVerticalMargin;
public CustomBlackToastStyle(int gravity, int xOffset, int yOffset, float horizontalMargin, float verticalMargin) {
mGravity = gravity;
mXOffset = xOffset;
mYOffset = yOffset;
mHorizontalMargin = horizontalMargin;
mVerticalMargin = verticalMargin;
}
@Override
public View createView(Context context) {
TextView textView = new TextView(context);
textView.setId(android.R.id.message);
textView.setGravity(getTextGravity(context));
textView.setTextColor(getTextColor(context));
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize(context));
int horizontalPadding = getHorizontalPadding(context);
int verticalPadding = getVerticalPadding(context);
// 适配布局反方向特性
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
textView.setPaddingRelative(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
} else {
textView.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
}
textView.setLayoutParams(
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Drawable backgroundDrawable = getBackgroundDrawable(context);
// 设置背景
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
textView.setBackground(backgroundDrawable);
} else {
textView.setBackgroundDrawable(backgroundDrawable);
}
// 设置 Z 轴阴影
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
textView.setZ(getTranslationZ(context));
}
return textView;
}
protected int getTextGravity(Context context) {
return Gravity.CENTER;
}
protected int getTextColor(Context context) {
return 0XEEFFFFFF;
}
protected float getTextSize(Context context) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, context.getResources().getDisplayMetrics());
}
protected int getHorizontalPadding(Context context) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
context.getResources().getDisplayMetrics());
}
protected int getVerticalPadding(Context context) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
context.getResources().getDisplayMetrics());
}
protected Drawable getBackgroundDrawable(Context context) {
GradientDrawable drawable = new GradientDrawable();
// 设置颜色
drawable.setColor(0XB3000000);
// 设置圆角
drawable.setCornerRadius(
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()));
return drawable;
}
protected float getTranslationZ(Context context) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, context.getResources().getDisplayMetrics());
}
@Override
public int getYOffset() {
return mYOffset;
}
@Override
public int getGravity() {
return mGravity;
}
@Override
public int getXOffset() {
return mXOffset;
}
}
... ...
package com.wd.foundation.wdinterfaceimpl.toast;
import com.wd.foundation.wdinterface.toast.IToast;
/**
* toast使用接口
*/
public class ToastImpl implements IToast {
@Override
public void showShort(String msg) {
ToastNightUtil.showShort(msg);
}
@Override
public void showTopShort(String msg, int offsetY) {
ToastNightUtil.showTopShort(msg, offsetY);
}
@Override
public void showLong(String msg) {
ToastNightUtil.showLong(msg);
}
@Override
public void showShort(int resId) {
ToastNightUtil.showShort(resId);
}
@Override
public void showShortBottom(int resId) {
ToastNightUtil.showShortBottom(resId);
}
@Override
public void showLong(int resId) {
ToastNightUtil.showLong(resId);
}
@Override
public void show(String msg, int duration) {
ToastNightUtil.show(msg, duration);
}
IToast getInst() {
return this;
}
}
... ...
package com.wd.foundation.wdinterfaceimpl.toast;
import android.text.TextUtils;
import android.view.Gravity;
import android.widget.Toast;
import com.hjq.toast.Toaster;
/**
* 单例Toast工具类
* <p>
* 1.解决toast排队的问题
* 2.修复Toast在android 7.1手机上的BadTokenException
* 3.兼容位置、时长、stringId
* ToastUtils更名为com.people.matisse.util.ToastNightUtil,
* 第三方库也有这个类名,避免导错包。
* 统一使用:com.people.matisse.util.ToastNightUtil
*/
public class ToastNightUtil {
public static void showShort(String message) {
// show(message, Toast.LENGTH_SHORT);
if (!TextUtils.isEmpty(message)) {
Toaster.showShort(message);
}
}
public static void showTopShort(String message, int y) {
if (!TextUtils.isEmpty(message)) {
Toaster.setStyle(new CustomBlackToastStyle(Gravity.TOP, 0, y - 50, 0, 0));
Toaster.showShort(message);
}
}
public static void showLong(String message) {
// 显示长 Toast
Toaster.showLong(message);
}
public static void showShort(int stringId) {
Toaster.showShort(stringId);
}
public static void showShortBottom(int stringId) {
Toaster.setStyle(new CustomBlackToastStyle(Gravity.BOTTOM, 0, 200, 0, 0));
Toaster.showShort(stringId);
}
public static void showLong(int stringId) {
Toaster.showLong(stringId);
}
/**
* show Toast 可选时长
*
* @param content 内容
* @param duration {@link Toast#LENGTH_SHORT},{@link Toast#LENGTH_LONG}
*/
public static void show(String content, int duration) {
if (TextUtils.isEmpty(content)) {
return;
}
if (Toast.LENGTH_LONG == duration) {
Toaster.showLong(content);
} else {
Toaster.showShort(content);
}
}
}
... ...
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
\ No newline at end of file
... ...