Commit 43817993 by Wyh

5.21接單部分問題修復,首頁功能列表隱藏

parent 8b376a1f
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_8" />
<stroke
android:width="@dimen/dp_2"
android:color="@color/order_state0_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="@dimen/dp_19"
android:height="@dimen/dp_19" />
<stroke
android:width="3dp"
android:color="#00000000" />
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/color_aaa" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/theme_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_nodata"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/png_no_record" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:text="暫無數據"
android:textColor="@color/color_66"
android:textSize="@dimen/dp_16" />
</LinearLayout>
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class OrderGoupNumBean(
val `data`: Data,
val success: Boolean,
val sysTime: Long) {
data class Data(
val self: List<SelfTakeaway>,
val selfTakeaway: List<SelfTakeaway>,
val takeaway: List<SelfTakeaway>) {
data class SelfTakeaway(
val STATUS: Int,
val SumNum: Int
)
}
}
\ No newline at end of file
......@@ -8,7 +8,6 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Switch;
......@@ -20,13 +19,11 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.PrintTransitUtils;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
......@@ -36,11 +33,9 @@ import com.joe.print.R2;
import com.joe.print.di.component.DaggerPrinterAddComponent;
import com.joe.print.mvp.contract.PrinterAddContract;
import com.joe.print.mvp.presenter.PrinterAddPresenter;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.joe.print.mvp.print.PrinterRoot;
import com.joe.print.mvp.ui.adapter.SelectPrintAdapter;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.zhy.autolayout.utils.ScreenUtils;
import java.util.List;
......
.idea
.DS_Store
local.properties
/*.iml
/build
ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle")
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
multiDexEnabled true
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
debug {
buildConfigField "boolean", "LOG_DEBUG", "true"
buildConfigField "boolean", "USE_CANARY", "true"
minifyEnabled false
}
release {
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "USE_CANARY", "false"
minifyEnabled false
zipAlignEnabled false
}
}
}
dependencies {
def lintVersion = '26.4.2'
// compileOnly "com.android.tools.lint:lint-api:$lintVersion"
// compileOnly "com.android.tools.lint:lint-checks:$lintVersion"
}
//jar {
// manifest {
// attributes("Lint-Registry-v2": 'com.qmuiteam.qmui.lint.QMUIIssueRegistry')
// }
//}
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.qmuiteam.lint">
</manifest>
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.tools.lint.client.api.JavaEvaluator;
import com.android.tools.lint.client.api.UElementHandler;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.JavaContext;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import com.google.common.collect.Lists;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.uast.UCallExpression;
import org.jetbrains.uast.UElement;
import org.jetbrains.uast.UExpression;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
/**
* 检测 QMUILog 中是否使用了 F Word。
* Created by Kayo on 2017/9/19.
*/
public class QMUIFWordDetector extends Detector implements Detector.UastScanner {
public static final Issue ISSUE_F_WORD =
Issue.create("QMUIDontUseTheFWordInLog",
"Please, don't use the f word, type something more nicely.",
"Do I need to explain this? \uD83D\uDD95",
Category.CORRECTNESS, 5, Severity.WARNING,
new Implementation(QMUIFWordDetector.class, EnumSet.of(Scope.JAVA_FILE)));
@Nullable
@Override
public List<Class<? extends UElement>> getApplicableUastTypes() {
return Lists.<Class<? extends UElement>>newArrayList(
UCallExpression.class);
}
@Nullable
@Override
public UElementHandler createUastHandler(@NotNull JavaContext context) {
return new FWordHandler(context);
}
static class FWordHandler extends UElementHandler {
private static final List<String> checkMedthods = Arrays.asList("e", "w", "i", "d");
private static final List<String> fWords = Arrays.asList("fuck", "bitch", "bullshit");
private JavaContext mJavaContext;
FWordHandler(@NotNull JavaContext context) {
mJavaContext = context;
}
@Override
public void visitCallExpression(@NotNull UCallExpression node) {
JavaEvaluator evaluator = mJavaContext.getEvaluator();
PsiMethod method = node.resolve();
if (evaluator.isMemberInClass(method, "android.util.Log") ||
evaluator.isMemberInClass(method, "com.qmuiteam.qmui.QMUILog")) {
String methodName = node.getMethodName();
if (checkMedthods.contains(methodName)) {
List<UExpression> expressions = node.getValueArguments();
for (UExpression expression : expressions) {
String text = expression.asRenderString();
for(String fword: fWords){
int index = text.indexOf(fword);
if(index >= 0){
mJavaContext.report(
ISSUE_F_WORD, expression,
mJavaContext.getRangeLocation(expression, index, fword.length()), "\uD83D\uDD95");
}
}
}
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.resources.ResourceFolderType;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.ResourceContext;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
/**
* 检测图片的尺寸的正确性,例如2倍图的宽高应该为偶数,3倍图的宽高应该为3的倍数
* Created by Kayo on 2017/9/7.
*/
public class QMUIImageScaleDetector extends Detector implements Detector.BinaryResourceScanner {
public static final Issue ISSUE_IMAGE_SCALE =
Issue.create("QMUIImageSizeDisproportionate",
"The size of this image is disproportionate.",
"Please check the size of the image, for example, the height and width of the 3x plot should be 1.5 times 2x plot.",
Category.ICONS, 4, Severity.WARNING,
new Implementation(QMUIImageScaleDetector.class, Scope.BINARY_RESOURCE_FILE_SCOPE));
private static final String IGNORE_IMAGE_NIGHT_PNG = ".9.png";
private static final String CHECK_IMAGE_WEBP = ".webp";
private static final String CHECK_IMAGE_PNG = ".png";
private static final String CHECK_IMAGE_JPEG = ".jpeg";
private static final String CHECK_IMAGE_JPG = ".jpg";
@Override
public boolean appliesTo(ResourceFolderType var1) {
return var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.MIPMAP)) || var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.DRAWABLE));
}
@Override
public void checkBinaryResource(ResourceContext context) {
String filename = context.file.getName();
if (filename.contains(IGNORE_IMAGE_NIGHT_PNG)) {
return;
}
if (filename.contains(CHECK_IMAGE_WEBP) || filename.contains(CHECK_IMAGE_PNG) || filename.contains(CHECK_IMAGE_JPEG) || filename.contains(CHECK_IMAGE_JPG)) {
String filePath = context.file.getPath();
String pattern = ".*?[mipmap|drawable]\\-xhdpi.*?";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(filePath);
if (m.find()) {
String threePlotFilePath = filePath.replace("xhdpi", "xxhdpi");
File threePlotFile = new File(threePlotFilePath);
try {
BufferedImage targetImage = ImageIO.read(context.file);
int targetWidth = targetImage.getWidth();
int targetHeight = targetImage.getHeight();
BufferedImage threePlotImage = ImageIO.read(threePlotFile);
int threePlotWidth = threePlotImage.getWidth();
int threePlotHeight = threePlotImage.getHeight();
if ((double) threePlotWidth / targetWidth != 1.5 || (double) threePlotHeight / targetHeight != 1.5) {
Location fileLocation = Location.create(context.file);
context.report(ISSUE_IMAGE_SCALE, fileLocation, "2倍图 " + filePath +
" 与其3倍图宽高分别为 (" + targetWidth + ", " + targetHeight + ") 和 (" + threePlotWidth + ", " + threePlotHeight + "),不符合比例关系。");
}
} catch (Exception ignored) {
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.resources.ResourceFolderType;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.ResourceContext;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import java.awt.image.BufferedImage;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
/**
* 检测图片的尺寸的正确性,例如2倍图的宽高应该为偶数,3倍图的宽高应该为3的倍数
* Created by Kayo on 2017/8/30.
*/
public class QMUIImageSizeDetector extends Detector implements Detector.BinaryResourceScanner {
public static final Issue ISSUE_IMAGE_SIZE =
Issue.create("QMUIImageSizeInvalid",
"The size of this image is not correct.",
"Please check the size of the image, for example, the height and width of the 2x plot should be even.",
Category.ICONS, 2, Severity.WARNING,
new Implementation(QMUIImageSizeDetector.class, Scope.BINARY_RESOURCE_FILE_SCOPE));
private static final String IGNORE_IMAGE_NIGHT_PNG = ".9.png";
private static final String CHECK_IMAGE_WEBP = ".webp";
private static final String CHECK_IMAGE_PNG = ".png";
private static final String CHECK_IMAGE_JPEG = ".jpeg";
private static final String CHECK_IMAGE_JPG = ".jpg";
/**
* 去掉数值多余的0与小数点符号
*/
public static String trimZeroAndDot(double number) {
String value = String.valueOf(number);
if (value.indexOf(".") > 0) {
value = value.replaceAll("0+?$", ""); // 去掉多余的0
value = value.replaceAll("[.]$", ""); // 若此时最后一位是小数点符号,则去掉该符号
}
return value;
}
@Override
public boolean appliesTo(ResourceFolderType var1) {
return var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.MIPMAP)) || var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.DRAWABLE));
}
@Override
public void checkBinaryResource(ResourceContext context) {
String filename = context.file.getName();
if (filename.contains(IGNORE_IMAGE_NIGHT_PNG)) {
return;
}
if (filename.contains(CHECK_IMAGE_WEBP) || filename.contains(CHECK_IMAGE_PNG) || filename.contains(CHECK_IMAGE_JPEG) || filename.contains(CHECK_IMAGE_JPG)) {
String filePath = context.file.getPath();
String pattern = ".*?[mipmap|drawable]\\-(x*)hdpi.*?";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(filePath);
if (m.find()) {
double multiple = 1.5;
if (m.group(1).length() > 0) {
multiple = m.group(1).length() + 1;
}
try {
BufferedImage targetImage = ImageIO.read(context.file);
int width = targetImage.getWidth();
int height = targetImage.getHeight();
if (width % multiple != 0 || height % multiple != 0) {
Location fileLocation = Location.create(context.file);
context.report(ISSUE_IMAGE_SIZE, fileLocation, filePath + " 为" + trimZeroAndDot(multiple) + "倍图,其宽高应该是" + trimZeroAndDot(multiple) + "的倍数,目前宽高为 (" + width + ", " + height + ")。");
}
} catch (Exception ignored) {
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.tools.lint.client.api.IssueRegistry;
import com.android.tools.lint.detector.api.Issue;
import java.util.Arrays;
import java.util.List;
import static com.android.tools.lint.detector.api.ApiKt.CURRENT_API;
@SuppressWarnings("unused")
public final class QMUIIssueRegistry extends IssueRegistry {
@Override public List<Issue> getIssues() {
return Arrays.asList(
QMUIFWordDetector.ISSUE_F_WORD,
QMUIJavaVectorDrawableDetector.ISSUE_JAVA_VECTOR_DRAWABLE,
QMUIXmlVectorDrawableDetector.ISSUE_XML_VECTOR_DRAWABLE,
QMUIImageSizeDetector.ISSUE_IMAGE_SIZE,
QMUIImageScaleDetector.ISSUE_IMAGE_SCALE
);
}
@Override
public int getApi() {
return CURRENT_API;
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import android.icu.util.ULocale;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import javax.inject.Scope;
/**
* 检测是否在 getDrawable 方法中传入了 Vector Drawable,在 4.0 及以下版本的系统中会导致 Crash
* Created by Kayo on 2017/8/24.
*/
public class QMUIJavaVectorDrawableDetector extends Detector implements Detector.UastScanner {
public static final Issue ISSUE_JAVA_VECTOR_DRAWABLE =
Issue.create("QMUIGetVectorDrawableWithWrongFunction",
"Should use the corresponding method to get vector drawable.",
"Using the normal method to get the vector drawable will cause a crash on Android versions below 4.0",
ULocale.Category.CORRECTNESS, 8, Severity.ERROR,
new Implementation(QMUIJavaVectorDrawableDetector.class, Scope.JAVA_FILE_SCOPE));
@Override
public List<String> getApplicableMethodNames() {
return Collections.singletonList("getDrawable");
}
@Override
public void visitMethod(@NotNull JavaContext context,
@Nullable JavaElementVisitor visitor,
@NotNull PsiMethodCallExpression call,
@NotNull PsiMethod method) {
super.visitMethod(context, visitor, call, method);
PsiExpressionList args = call.getArgumentList();
if (args.getExpressions().length == 0) {
return;
}
Project project = context.getProject();
List<File> resourceFolder = project.getResourceFolders();
if (resourceFolder.isEmpty()) {
return;
}
String resourcePath = resourceFolder.get(0).getAbsolutePath();
for (PsiExpression expression : args.getExpressions()) {
String input = expression.toString();
if (input != null && input.contains("R.drawable")) {
// 找出 drawable 相关的参数
// 获取 drawable 名字
String drawableName = input.replace("R.drawable.", "");
try {
// 若 drawable 为 Vector Drawable,则文件后缀为 xml,根据 resource 路径,drawable 名字,文件后缀拼接出完整路径
FileInputStream fileInputStream = new FileInputStream(resourcePath + "/drawable/" + drawableName + ".xml");
BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
String line = reader.readLine();
if (line.contains("vector")) {
// 若文件存在,并且包含首行包含 vector,则为 Vector Drawable,抛出警告
context.report(ISSUE_JAVA_VECTOR_DRAWABLE, method, context.getLocation(method), expression.toString() + " 为 Vector Drawable,请使用 getVectorDrawable 方法获取,避免 4.0 及以下版本的系统产生 Crash");
}
reader.close();
fileInputStream.close();
} catch (Exception ignored) {
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import org.w3c.dom.Attr;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.List;
/**
* 检测是否在 drawableLeft / drawableRight / drawableTop / drawableBottom 中传入了 Vector Drawable,在 4.0 及以下版本的系统中会导致 Crash
* Created by Kayo on 2017/8/29.
*/
public class QMUIXmlVectorDrawableDetector extends ResourceXmlDetector {
public static final Issue ISSUE_XML_VECTOR_DRAWABLE =
Issue.create("QMUIGetVectorDrawableWithWrongProperty",
"Should use the corresponding property to get vector drawable.",
"Using the normal property to get the vector drawable will cause a crash on Android versions below 4.0.",
Category.CORRECTNESS, 8, Severity.ERROR,
new Implementation(QMUIXmlVectorDrawableDetector.class, Scope.RESOURCE_FILE_SCOPE));
private static final Collection<String> mAttrList = Lists.newArrayList(ATTR_DRAWABLE_LEFT, ATTR_DRAWABLE_RIGHT, ATTR_DRAWABLE_TOP, ATTR_DRAWABLE_BOTTOM);
@Override
public boolean appliesTo(ResourceFolderType folderType) {
return ResourceFolderType.LAYOUT == folderType;
}
@Override
public Collection<String> getApplicableElements() {
return ALL;
}
@Override
public Collection<String> getApplicableAttributes() {
return mAttrList;
}
@Override
public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) {
// 判断资源文件夹是否存在
Project project = context.getProject();
List<File> resourceFolder = project.getResourceFolders();
if (resourceFolder.isEmpty()) {
return;
}
// 获取项目资源文件夹路径
String resourcePath = resourceFolder.get(0).getAbsolutePath();
// 获取 drawable 名字
String drawableName = attribute.getValue().replace("@drawable/", "");
FileInputStream fileInputStream = null;
BufferedReader reader = null;
try {
// 若 drawable 为 Vector Drawable,则文件后缀为 xml,根据 resource 路径,drawable 名字,文件后缀拼接出完整路径
fileInputStream = new FileInputStream(resourcePath + "/drawable/" + drawableName + ".xml");
reader = new BufferedReader(new InputStreamReader(fileInputStream));
String line = reader.readLine();
if (line.contains("vector")) {
// 若文件存在,并且包含首行包含 vector,则为 Vector Drawable,抛出警告
context.report(ISSUE_XML_VECTOR_DRAWABLE, attribute, context.getLocation(attribute), attribute.getValue() + " 为 Vector Drawable,请使用 Vector 属性进行设置,避免 4.0 及以下版本的系统产生 Crash");
}
} catch (Exception ignored) {
}finally {
if(fileInputStream != null){
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(reader != null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
......@@ -2,12 +2,9 @@ include 'cc-register',
'cc',
'demo_interceptors',
'android_internal',
'public-base',
'arms',
'pools',
'qm-qmui',
// 'qm-lintrule',
// 'qm-lintrule',
'qm-arch',
'qm-arch-annotation',
'qm-skin-maker',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment