baselib做成依赖

This commit is contained in:
姜珂 2025-07-09 16:02:54 +08:00
parent d8aebf8453
commit dc9cd44256
498 changed files with 1474 additions and 10835 deletions

View File

@ -1,12 +1,15 @@
apply plugin: 'com.android.library'
plugins {
id 'com.android.library' // application
id 'maven-publish' //
}
android {
namespace "com.tfq.library"
compileSdkVersion 34
compileSdkVersion 36
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
minSdkVersion 24
targetSdkVersion 36
}
buildTypes {
@ -18,11 +21,8 @@ android {
}
dependencies {
// api 'androidx.constraintlayout:constraintlayout:1.1.3'
api 'androidx.appcompat:appcompat:1.7.0'
api 'com.google.android.material:material:1.11.0'
// api 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
// api 'androidx.core:core-ktx:1.10.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
@ -31,30 +31,46 @@ dependencies {
api 'com.gyf.immersionbar:immersionbar:3.0.0-beta05'
//
api 'com.github.getActivity:XXPermissions:18.63'
api 'com.github.getActivity:XXPermissions:23.0'
api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.28'
api 'androidx.activity:activity:1.8.0'
api 'androidx.activity:activity:1.10.1'
api 'com.google.code.gson:gson:2.10.1'
api 'com.alibaba:fastjson:1.2.55'
api 'com.google.code.gson:gson:2.13.1'
//
api 'com.squareup.okhttp3:okhttp:3.4.2'
api 'com.squareup.okhttp3:logging-interceptor:3.5.0'
// api 'com.squareup.okhttp3:okhttp:3.4.2'
// api 'com.squareup.okhttp3:logging-interceptor:3.5.0'
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.16'
api 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.16'
//
api 'com.github.bumptech.glide:glide:3.7.0'
api 'com.google.android:flexbox:0.3.1'
api 'com.github.bumptech.glide:glide:4.14.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.1'
api 'com.github.bumptech.glide:glide:4.16.0'
// Glide图形转换工具
api 'jp.wasabeef:glide-transformations:2.0.1'
api 'jp.wasabeef:glide-transformations:4.3.0'
// https://github.com/getActivity/Toaster
api 'com.github.getActivity:Toaster:12.8'
//
api 'com.github.centerzx:ShapeBlurView:1.0.5'
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId = 'com.chuangketie.jk' //
artifactId = 'base-lib' //
version = '1.0.0'
artifact("$buildDir/outputs/aar/${project.name}-release.aar")// AAR
}
}
repositories {
maven {
url = "file://${projectDir.parent}/maven" //
}
}
}
}

View File

@ -1,26 +0,0 @@
package com.tfq.library;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.tfq.library.test", appContext.getPackageName());
}
}

View File

@ -2,7 +2,6 @@ package com.tfq.library.app;
public class BaseConstants {
public static boolean BASE_APP_DEBUG_PRINT;
/**
* 底部导航栏颜色 默认白色
@ -13,4 +12,28 @@ public class BaseConstants {
* 自定义dialog使用的layout类型
*/
public static int dialog_layout = 2;
/**
* 自定义字符串 打印
*/
public final static String LOG_PRINT = "LOG_PRINT";
/**
* 自定义字符串 隐私权限管理
*/
public final static String PRIVACY = "privacy";
/**
* 自定义字符串 撤回隐私授权
*/
public final static String AUTHORIZATIO = "authorizatio";
/**
* 自定义字符串 打开URL
*/
public final static String PLAYURL = "playUrl";
/**
* 自定义字符串 权限请求
*/
public final static String REQUEST_PER = "request_per";
/**
* 自定义字符串 跳转动画
*/
public final static String ANIMATION_SKIP = "animation_skip";
}

View File

@ -1,116 +1,88 @@
package com.tfq.library.app;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.hjq.toast.Toaster;
import com.tfq.library.utils.LogK;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/**
* Created by Administrator on 2016/10/28.
*/
public class LibraryApp implements IConstituteApp {
public static Activity activityTop;
private static Context mContext;
private static LibraryApp instance;
public Application application;
public class LibraryApp {
private static volatile LibraryApp instance;
private final Context context;
private final Map<String, String> adSlots;
private LibraryApp(LibraryApp.Builder builder) {
this.context = builder.context;
this.adSlots = Collections.unmodifiableMap(new HashMap<>(builder.adSlots));
}
private static String validateNonEmpty(String value) {
if (value == null || value.trim().isEmpty()) {
return "";
// throw new IllegalArgumentException("Parameter cannot be empty");
}
return value;
}
public static LibraryApp getInstance() {
if (instance == null) {
// throw new IllegalStateException("Call Builder.initialize() first");
}
return instance;
}
public static Context getContext() {
return mContext;
// 参数暴露接口
public Context getContext() {
return context;
}
public static Activity getActivityTop() {
return activityTop;
public String getSlotConfig(String slotType) {
return adSlots.getOrDefault(slotType, "0"); // 未配置返回默认值
}
public static String getChannel() {
try {
PackageManager pm = mContext.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
return appInfo.metaData.getString("UMENG_CHANNEL");
} catch (PackageManager.NameNotFoundException ignored) {
public boolean isSlotConfig(String slotType) {
return Boolean.parseBoolean(adSlots.getOrDefault(slotType, String.valueOf(false))); // 未配置返回默认值
}
public static class Builder {
private final Context context;
private final Map<String, String> adSlots = new LinkedHashMap<>();
/**
* 必传的几个选项
*
* @param ctx
*/
public Builder(Context ctx) {
this.context = Objects.requireNonNull(ctx);
}
return "other";
}
public static String getJson(String fileName, Context context) {
StringBuilder stringBuilder = new StringBuilder();
try {
InputStream is = context.getAssets().open(fileName);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
public LibraryApp.Builder addSlot(String slotType, String config) {
if (slotType != null) {
adSlots.put(slotType, config != null ? config : "0"); // 默认值处理
}
} catch (IOException e) {
e.printStackTrace();
return this;
}
return stringBuilder.toString();
public synchronized void initialize() {
if (instance == null) {
instance = new LibraryApp(this);
}
boolean print = getInstance().isSlotConfig(BaseConstants.LOG_PRINT);
LogK.setDebug(print);
// 初始化 Toast 框架
Toaster.init((Application) context);
}
}
@Override
public void onCreate(Application application) {
mContext = application.getApplicationContext();
instance = this;
this.application = application;
register();
// 初始化 Toast 框架
Toaster.init(application);
}
private void register() {
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
}
@Override
public void onActivityStarted(@NonNull Activity activity) {
activityTop = activity;
}
@Override
public void onActivityResumed(@NonNull Activity activity) {
}
@Override
public void onActivityPaused(@NonNull Activity activity) {
}
@Override
public void onActivityStopped(@NonNull Activity activity) {
}
@Override
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
}
@Override
public void onActivityDestroyed(@NonNull Activity activity) {
}
});
}
}

View File

@ -1,12 +1,12 @@
package com.tfq.library.base;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.gyf.immersionbar.ImmersionBar;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.utils.AppUtil;
import com.tfq.library.view.Animation;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
@ -17,6 +17,8 @@ import androidx.appcompat.app.AppCompatActivity;
*/
public abstract class BaseActivity extends AppCompatActivity {
private boolean statusBarDarkFont;
/****************************abstract area*************************************/
@LayoutRes
@ -47,10 +49,10 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void processLogic() {
}
private boolean statusBarDarkFont;
public void setStatusBarDarkFont(boolean statusBarDarkFont){
public void setStatusBarDarkFont(boolean statusBarDarkFont) {
this.statusBarDarkFont = statusBarDarkFont;
}
/*************************lifecycle area*****************************************************/
@Override
@ -61,7 +63,7 @@ public abstract class BaseActivity extends AppCompatActivity {
initData(savedInstanceState);
initClick();
processLogic();
ImmersionBar.with((Activity) this)
ImmersionBar.with(this)
.transparentStatusBar() //不写也可以默认就是透明色
.statusBarDarkFont(statusBarDarkFont)
.navigationBarColor(BaseConstants.navigationBarColor)
@ -75,6 +77,19 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void startActivity(Class<? extends AppCompatActivity> activity) {
Intent intent = new Intent(this, activity);
startActivity(intent);
Animation.startAnimation(this);
}
@Override
public void finish() {
super.finish();
Animation.startAnimation(this);
}
@Override
public void startActivityForResult(Intent intent, int requestCode) {
super.startActivityForResult(intent, requestCode);
Animation.startAnimation(this);
}
@Override

View File

@ -1,14 +1,21 @@
package com.tfq.library.base;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.tfq.library.utils.PermissionDialog;
import com.tfq.library.R;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.app.LibraryApp;
import com.tfq.library.view.Animation;
import com.tfq.library.view.AuthDialog;
import java.util.List;
@ -17,6 +24,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import static com.tfq.library.app.BaseConstants.REQUEST_PER;
/**
* Created by JiangKe on 2025/02/20.
*/
@ -48,6 +57,13 @@ public abstract class BaseFragment extends Fragment {
protected void processLogic() {
}
/**
* 进入动画区
*/
protected void animationStart() {
Animation.startAnimation(requireActivity());
}
/**
* 权限请求
*/
@ -88,20 +104,13 @@ public abstract class BaseFragment extends Fragment {
if (!req_permission) {//不弹窗直接申请权限
requestPermission(permission, show_doNotAskAgain, listener);
} else {//先弹窗,再去申请
PermissionDialog permissionDialog = new PermissionDialog(getActivity(), "request_per", "权限申请"
, content, new PermissionDialog.Listener_Result() {
new AuthDialog(getActivity(), REQUEST_PER, new AuthDialog.Listener() {
@Override
public void success(boolean b) {
if (b) {//同意申请权限,去申请
requestPermission(permission, show_doNotAskAgain, listener);
} else {//不同意申请权限
}
public void callBack() {
//同意申请权限,去申请
requestPermission(permission, show_doNotAskAgain, listener);
}
});
permissionDialog.setCanceledOnTouchOutside(false);
permissionDialog.setCancelable(false);
permissionDialog.show();
}).show();
}
}

View File

@ -1,5 +1,6 @@
package com.tfq.library.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
@ -20,11 +21,8 @@ import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import androidx.core.content.FileProvider;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.tfq.library.app.LibraryApp;
@ -39,6 +37,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import androidx.core.content.FileProvider;
public class AppUtil {
/**
* 获取屏幕分辨率?
@ -119,8 +119,8 @@ public class AppUtil {
public static String getPackageName() {
String name = "";
try {
PackageManager packageManager = LibraryApp.getContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(LibraryApp.getContext().getPackageName(), 0);
PackageManager packageManager = LibraryApp.getInstance().getContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(LibraryApp.getInstance().getContext().getPackageName(), 0);
name = packageInfo.applicationInfo.packageName;
} catch (Throwable e) {
e.printStackTrace();
@ -289,7 +289,7 @@ public class AppUtil {
public static boolean connectStatus() {
boolean isConnect = true;
try {
ConnectivityManager manager = (ConnectivityManager) LibraryApp.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
ConnectivityManager manager = (ConnectivityManager) LibraryApp.getInstance().getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
NetworkCapabilities networkCapabilities = manager.getNetworkCapabilities(manager.getActiveNetwork());
if (networkCapabilities != null) {
@ -406,8 +406,8 @@ public class AppUtil {
public static String getAppVersionName() {
String appVersionName = "1";
try {
PackageManager packageManager = LibraryApp.getContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(LibraryApp.getContext().getPackageName(), 0);
PackageManager packageManager = LibraryApp.getInstance().getContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(LibraryApp.getInstance().getContext().getPackageName(), 0);
appVersionName = packageInfo.versionName;
} catch (Throwable e) {
e.printStackTrace();
@ -445,8 +445,8 @@ public class AppUtil {
public static String getAppVersionCode() {
String appVersionCode = "1";
try {
PackageManager packageManager = LibraryApp.getContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(LibraryApp.getContext().getPackageName(), 0);
PackageManager packageManager = LibraryApp.getInstance().getContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(LibraryApp.getInstance().getContext().getPackageName(), 0);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
appVersionCode = packageInfo.versionCode + "";
} else {
@ -481,6 +481,7 @@ public class AppUtil {
/**
* 判断字符串是否为整数或小数含正负数
*
* @param input 待检测字符串
* @return true-是数字false-不是数字
*/
@ -545,12 +546,8 @@ public class AppUtil {
try {
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(signature));
LogK.i("监听2" + " 22");
String publickey = cert.getPublicKey().toString();
LogK.d("-------密码TRACK " + publickey);
// publickey = publickey.substring(publickey.indexOf("modulus:") + 9,publickey.indexOf("\n", publickey.indexOf("modulus:")));
LogK.d("-------密码TRACK " + publickey);
return publickey;
} catch (Exception e) {
e.printStackTrace();
@ -562,14 +559,12 @@ public class AppUtil {
PackageManager pm = context.getPackageManager();
List<PackageInfo> apps = pm.getInstalledPackages(PackageManager.GET_SIGNATURES);
Iterator<PackageInfo> iter = apps.iterator();
LogK.i("签名1 " + iter + "");
LogK.i("监听1 " + "----------");
while (iter.hasNext()) {
PackageInfo info = iter.next();
String packageName = info.packageName;
//按包名 取签名
if (packageName.equals(AppUtil.getPackageName(context))) {
LogK.i("监听1 " + info.signatures[0].toByteArray() + "----------");
assert info.signatures != null;
return info.signatures[0].toByteArray();
}
@ -601,6 +596,7 @@ public class AppUtil {
* @param sizeInBytes 字节数
* @return 格式化后的字符串
*/
@SuppressLint("DefaultLocale")
public static String getSizeInUnit(long sizeInBytes) {
if (sizeInBytes < 1024) {
return sizeInBytes + " B";
@ -694,10 +690,8 @@ public class AppUtil {
*/
public static void closeKeyBoard(View currentFocus) {
try {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
InputMethodManager imm = (InputMethodManager) LibraryApp.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
InputMethodManager imm = (InputMethodManager) LibraryApp.getInstance().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -17,7 +17,7 @@ public class BigPhotoDialog extends Dialog {
private View contentView;
public BigPhotoDialog(Context context, String url) {
super(context, R.style.CustomDialog);
super(context, R.style.Dialog);
this.mContext = context;
this.url = url;
inflater = LayoutInflater.from(context);
@ -30,7 +30,7 @@ public class BigPhotoDialog extends Dialog {
}
private void setViews() {
contentView = inflater.inflate(R.layout.layout_dialog_bigphoto, null);
contentView = inflater.inflate(R.layout.library_layout_dialog_bigphoto, null);
setContentView(contentView);
ImageView imageView = contentView.findViewById(R.id.image_view);
try {

View File

@ -6,7 +6,7 @@ import com.tfq.library.R;
public class CustomLoadMoreView extends LoadMoreView {
@Override
public int getLayoutId() {
return R.layout.quick_view_load_more;
return R.layout.library_quick_view_load_more;
}
/**

View File

@ -1,79 +0,0 @@
package com.tfq.library.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtils {
/**
* @param l_str 精确到秒的字符串
* @param format 时间戳转换成日期格式字符串
* @return
*/
public static String timeStamp2Date(String l_str, String format) {
if (l_str == null || l_str.isEmpty() || l_str.equals("null")) {
return "";
}
if (format == null || format.isEmpty()) {
format = "yyyy-MM-dd HH:mm:ss";
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new Date(Long.valueOf(l_str + "000")));
}
/**
* 日期格式字符串转换成时间戳
*
* @param date_str 字符串日期
* @param format yyyy-MM-dd HH:mm:ss
* @return
*/
public static String date2TimeStamp(String date_str, String format) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return String.valueOf(sdf.parse(date_str).getTime() / 1000);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* 取得当前时间戳精确到秒
*
* @return
*/
public static String timeStamp() {
long time = System.currentTimeMillis();
String t = String.valueOf(time / 1000);
return t;
}
public static void main(String[] args) {
String timeStamp = timeStamp();
System.out.println("timeStamp=" + timeStamp); //运行输出:timeStamp=1470278082
System.out.println(System.currentTimeMillis());//运行输出:1470278082980
//该方法的作用是返回当前的计算机时间时间的表达格式为当前计算机时间和GMT时间(格林威治时间)1970年1月1号0时0分0秒所差的毫秒数
String date = timeStamp2Date(timeStamp, "yyyy-MM-dd HH:mm:ss");
System.out.println("date=" + date);//运行输出:date=2016-08-04 10:34:42
String timeStamp2 = date2TimeStamp(date, "yyyy-MM-dd HH:mm:ss");
System.out.println(timeStamp2); //运行输出:1470278082
}
public static String gapMin(Date start_date, Date end_date) {
if (end_date.getTime() > start_date.getTime()) {
long nd = 1000 * 24 * 60 * 60;//每天毫秒数
long nh = 1000 * 60 * 60;//每小时毫秒数
long nm = 1000 * 60;//每分钟毫秒数
long diff = end_date.getTime() - start_date.getTime(); // 获得两个时间的毫秒时间差异
long day = diff / nd; // 计算差多少天
long hour = diff % nd / nh; // 计算差多少小时
long min = diff % nd % nh / nm; // 计算差多少分钟
// return day + "" + hour + "小时" + min + "分钟";
return diff / nm + "";
} else {
return "-1";
}
}
}

View File

@ -1,27 +0,0 @@
package com.tfq.library.utils;
import android.text.InputFilter;
import android.text.Spanned;
import java.util.regex.Pattern;
public class DecimalInputFilter implements InputFilter {
private final Pattern decimalPattern = Pattern.compile("^-?\\d*\\.?\\d{0,2}$");
@Override
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
String newText = dest.toString().substring(0, dstart)
+ source.toString()
+ dest.toString().substring(dend);
// 允许空输入或单个负号
if (newText.isEmpty() || newText.equals("-")) return null;
// 验证格式并限制小数点后两位
if (!decimalPattern.matcher(newText).matches()) {
return "";
}
return null;
}
}

View File

@ -10,7 +10,6 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import com.tfq.library.R;
@ -34,7 +33,7 @@ public class DialogUtils {
// 加载模糊背景
View blurContainer = LayoutInflater.from(dialog.getContext())
.inflate(R.layout.blur_background, rootView, false);
.inflate(R.layout.library_blur_background, rootView, false);
rootView.addView(blurContainer);
// 创建圆角背景

View File

@ -655,8 +655,8 @@ public class FileUtil {
File oldFile = new File(filePath);
String name = oldFile.getName();
//压缩文件路径 照片路径/
LibraryApp.getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File externalCacheDir = LibraryApp.getContext().getExternalCacheDir();
LibraryApp.getInstance().getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File externalCacheDir = LibraryApp.getInstance().getContext().getExternalCacheDir();
// String targetPath = oldFile.getPath()+name+"2.jpg";
String targetPath = externalCacheDir + name;
int quality = 100;//压缩比例0-100

View File

@ -18,7 +18,7 @@ public class GlideLoadUtils {
if (context != null) {
Glide.with(context)
.load(url)
.placeholder(R.mipmap.ic_loading)
.placeholder(R.drawable.library_ic_loading)
// .error(R.mipmap.image_load_error)
.into(imageView);
}

View File

@ -5,29 +5,50 @@ import android.util.Log;
import com.tfq.library.app.BaseConstants;
public class LogK {
private static final String TAG_PREFIX = "LibraryLog_http";
private static boolean DEBUG = false;
public static boolean isDebug() {
return DEBUG;
}
public static void setDebug(boolean debug) {
DEBUG = debug;
}
public static void d(String msg) {
if (BaseConstants.BASE_APP_DEBUG_PRINT)
Log.d("LogK", "LogK.d http data: " + msg);
if (DEBUG) Log.d(TAG_PREFIX, buildMessage(msg));
}
public static void e(String msg) {
if (BaseConstants.BASE_APP_DEBUG_PRINT)
Log.e("LogK", "LogK.e http data: " + msg);
if (DEBUG) Log.e(TAG_PREFIX, buildMessage(msg));
}
public static void i(String msg) {
if (BaseConstants.BASE_APP_DEBUG_PRINT)
Log.i("LogK", "LogK.i http data: " + msg);
if (DEBUG) Log.i(TAG_PREFIX, buildMessage(msg));
}
public static void w(String msg) {
if (BaseConstants.BASE_APP_DEBUG_PRINT)
Log.w("LogK", "LogK.w http data: " + msg);
if (DEBUG) Log.w(TAG_PREFIX, buildMessage(msg));
}
public static void v(String msg) {
if (BaseConstants.BASE_APP_DEBUG_PRINT)
Log.v("LogK", "LogK.v http data: " + msg);
if (DEBUG) Log.v(TAG_PREFIX, buildMessage(msg));
}
private static String buildMessage(String msg) {
StackTraceElement[] trace = new Throwable().getStackTrace();
String caller = "<unknown>";
for (int i = 3; i < trace.length; i++) {
if (!trace[i].getClassName().equals(LogK.class.getName())) {
String className = trace[i].getClassName();
caller = className.substring(className.lastIndexOf('.') + 1) +
"." + trace[i].getMethodName() +
":" + trace[i].getLineNumber();
break;
}
}
return "[" + Thread.currentThread().getId() + "] " + caller + "" + msg;
}
}

View File

@ -1,228 +0,0 @@
package com.tfq.library.utils;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.tfq.library.R;
public class PermissionDialog extends Dialog {
private final Context mContext;
private final LayoutInflater inflater;
private Listener listener;
private Listener_Location listener_location;
private View contentView;
private String type;
private String content;
private String title;
private Listener_Intent listener_intent;
private Listener_Result listener_result;
public PermissionDialog(Context context, Listener listener) {
super(context, R.style.CustomDialog);
this.listener = listener;
this.mContext = context;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String type, String title, String content, Listener_Location listener_location) {
super(context, R.style.CustomDialog);
this.listener_location = listener_location;
this.mContext = context;
this.type = type;
this.title = title;
this.content = content;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String type) {
super(context, R.style.CustomDialog);
this.mContext = context;
this.type = type;
this.title = title;
this.content = content;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String title, String content, Listener listener) {
super(context, R.style.CustomDialog);
this.mContext = context;
this.title = title;
this.content = content;
this.listener = listener;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String type, String title, String content) {
super(context, R.style.CustomDialog);
this.mContext = context;
this.type = type;
this.title = title;
this.content = content;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String type, String title, String content, Listener_Result listener_result) {
super(context, R.style.CustomDialog);
this.listener_result = listener_result;
this.mContext = context;
this.type = type;
this.title = title;
this.content = content;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String type, String title, String content, Listener listener) {
super(context, R.style.CustomDialog);
this.listener = listener;
this.mContext = context;
this.type = type;
this.title = title;
this.content = content;
inflater = LayoutInflater.from(context);
}
public PermissionDialog(Context context, String type, String title, String content, Listener listener, Listener_Intent listener_intent) {
super(context, R.style.CustomDialog);
this.listener = listener;
this.listener_intent = listener_intent;
this.mContext = context;
this.type = type;
this.title = title;
this.content = content;
inflater = LayoutInflater.from(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setViews();
}
private void setViews() {
contentView = inflater.inflate(R.layout.layout_dialog_permission, null);
setContentView(contentView);
TextView tv_title = contentView.findViewById(R.id.tv_title);
TextView tv_content = contentView.findViewById(R.id.tv_content);
TextView tv_left = contentView.findViewById(R.id.tv_left);
TextView tv_right = contentView.findViewById(R.id.tv_right);
if ("cancel_authorization".equals(type)) {
tv_left.setVisibility(View.GONE);
tv_content.setText(content);
tv_title.setText(title);
tv_content.setGravity(Gravity.CENTER);
} else if ("reject_authorization".equals(type)) {
tv_content.setText(content);
tv_title.setText(title);
// tv_right.setImageDrawable(App.getContext().getDrawable(R.mipmap.ic_confirm));
} else if ("isLocServiceEnable".equals(type)) {
tv_content.setText(content);
tv_title.setText(title);
// tv_right.setImageDrawable(App.getContext().getDrawable(R.mipmap.ic_confirm));
} else if ("request_per".equals(type)) {
tv_content.setText(content);
tv_title.setText(title);
// tv_right.setImageDrawable(App.getContext().getDrawable(R.mipmap.ic_confirm));
// this.setCanceledOnTouchOutside(false);
// this.setCancelable(false);
}else if ("del_project".equals(type)) {
tv_content.setText(content);
tv_title.setText(title);
tv_right.setTextColor(mContext.getResources().getColor(R.color.gold));
}else if ("export_data".equals(type)) {
tv_content.setText(content);
tv_title.setText(title);
tv_right.setTextColor(mContext.getResources().getColor(R.color.gold));
} else {
tv_content.setText(content);
tv_title.setText(title);
}
tv_left.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if ("isLocServiceEnable".equals(type)) {
listener_location.success(false);
} else if ("reject_authorization".equals(type)) {
if (listener != null) {
listener.success();
}
if (listener_result != null) {
listener_result.success(false);
}
} else if ("request_per".equals(type)) {
if (listener_result != null) {
listener_result.success(false);
}
}
dismiss();
}
});
tv_right.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if ("reject_authorization".equals(type)) {
if (listener_intent != null) {
listener_intent.success();
} else {
Intent intent = new Intent();
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", mContext.getPackageName(), null));
mContext.startActivity(intent);
}
} else if ("cancel_authorization".equals(type)) {
dismiss();
} else if ("isLocServiceEnable".equals(type)) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
mContext.startActivity(intent);
} catch (ActivityNotFoundException ex) {
intent.setAction(Settings.ACTION_SETTINGS);
try {
mContext.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
listener_location.success(true);
dismiss();
} else if (listener != null) {
listener.success();
dismiss();
} else if (listener_result != null) {
listener_result.success(true);
dismiss();
}
}
});
}
public interface Listener {
void success();
}
public interface Listener_Result {
void success(boolean b);
}
public interface Listener_Location {
void success(boolean b);
}
public interface Listener_Intent {
void success();
}
}

View File

@ -1,6 +1,5 @@
package com.tfq.library.utils;
import android.icu.math.BigDecimal;
import android.view.Gravity;
import com.hjq.toast.ToastParams;
@ -9,8 +8,6 @@ import com.hjq.toast.style.CustomToastStyle;
import com.hjq.toast.style.WhiteToastStyle;
import com.tfq.library.R;
import java.math.BigInteger;
public class ToasterUtil {
public static void show(String text) {
@ -50,25 +47,25 @@ public class ToasterUtil {
case 1:
params = new ToastParams();
params.text = text;
params.style = new CustomToastStyle(R.layout.toast_success);
params.style = new CustomToastStyle(R.layout.library_toast_success);
Toaster.show(params);
break;
case 2:
params = new ToastParams();
params.text = text;
params.style = new CustomToastStyle(R.layout.toast_info);
params.style = new CustomToastStyle(R.layout.library_toast_info);
Toaster.show(params);
break;
case 3:
params = new ToastParams();
params.text = text;
params.style = new CustomToastStyle(R.layout.toast_warn);
params.style = new CustomToastStyle(R.layout.library_toast_warn);
Toaster.show(params);
break;
case 4:
params = new ToastParams();
params.text = text;
params.style = new CustomToastStyle(R.layout.toast_error);
params.style = new CustomToastStyle(R.layout.library_toast_error);
Toaster.show(params);
break;
case 10:
@ -78,7 +75,7 @@ public class ToasterUtil {
Toaster.show(params);
break;
case 20:
Toaster.setView(R.layout.toast_custom_view);
Toaster.setView(R.layout.library_toast_custom_view);
Toaster.setGravity(Gravity.CENTER);
Toaster.show(text);
break;

View File

@ -1,9 +1,8 @@
package com.tfq.library.utils.style;
package com.tfq.library.utils.toaster_style;
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;
@ -33,26 +32,16 @@ public class BlackToastStyle implements IToastStyle<View> {
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.setPaddingRelative(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);
}
textView.setBackground(backgroundDrawable);
// 设置 Z 轴阴影
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
textView.setZ(getTranslationZ(context));
}
textView.setZ(getTranslationZ(context));
return textView;
}

View File

@ -1,4 +1,4 @@
package com.tfq.library.utils.style;
package com.tfq.library.utils.toaster_style;
import android.content.Context;
import android.graphics.drawable.Drawable;

View File

@ -0,0 +1,31 @@
package com.tfq.library.view;
import android.app.Activity;
import com.tfq.library.R;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.app.LibraryApp;
/**
* Description: 动画效果
* Created by JiangKe .
*/
public class Animation {
public static void startAnimation(Activity mActivity) {
String slotConfig = LibraryApp.getInstance().getSlotConfig(BaseConstants.ANIMATION_SKIP);//默认 0
if (slotConfig.equals("1")) {//默认动画
return;
}
//Scale缩放;Rotate旋转;Alpha透明度
if (slotConfig.equals("0")) {//淡入动画Fade
mActivity.overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);
} else if (slotConfig.equals("2")) {//缩放动画+透明度Scale + Fade
mActivity.overridePendingTransition(R.anim.zoom_in_1, R.anim.zoom_out_1);
} else if (slotConfig.equals("3")) {//缩放+旋转+透明度三效合一
mActivity.overridePendingTransition(R.anim.zoom_in_2, R.anim.zoom_out_2);
} else if (slotConfig.equals("4")) {//translate
mActivity.overridePendingTransition(R.anim.zoom_in_3, R.anim.zoom_out_3);
}
}
}

View File

@ -5,14 +5,22 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.tfq.library.R;
import com.tfq.library.app.BaseConstants;
import static com.tfq.library.app.BaseConstants.AUTHORIZATIO;
import static com.tfq.library.app.BaseConstants.PLAYURL;
import static com.tfq.library.app.BaseConstants.PRIVACY;
import static com.tfq.library.app.BaseConstants.REQUEST_PER;
public class AuthDialog extends Dialog {
private final Context mContext;
@ -22,21 +30,21 @@ public class AuthDialog extends Dialog {
private String type;
public AuthDialog(Context context, Listener listener) {
super(context, R.style.CustomDialog);
super(context, R.style.Dialog);
this.listener = listener;
this.mContext = context;
inflater = LayoutInflater.from(context);
}
public AuthDialog(Context context, String type) {
super(context, R.style.CustomDialog);
super(context, R.style.Dialog);
this.mContext = context;
this.type = type;
inflater = LayoutInflater.from(context);
}
public AuthDialog(Context context, String type, Listener listener) {
super(context, R.style.CustomDialog);
super(context, R.style.Dialog);
this.listener = listener;
this.mContext = context;
this.type = type;
@ -50,7 +58,18 @@ public class AuthDialog extends Dialog {
}
private void setViews() {
int layout = BaseConstants.dialog_layout == 0 ? R.layout.layout_dialog_auth : BaseConstants.dialog_layout == 1 ? R.layout.layout_dialog_auth2 : R.layout.layout_dialog_auth3;
// 确保Dialog显示在底部
Window window = getWindow();
assert window != null;
// 设置窗口动画
window.setWindowAnimations(R.style.ZoomDialogAnimation);
WindowManager.LayoutParams params = window.getAttributes();
DisplayMetrics d = mContext.getResources().getDisplayMetrics(); // 获取屏幕宽高用
params.width = (int) (d.widthPixels * 1.0); // 宽度设置为屏幕的0..8 0.9
params.gravity = Gravity.CENTER;
window.setAttributes(params);
int layout = BaseConstants.dialog_layout == 0 ? R.layout.library_layout_dialog_auth : BaseConstants.dialog_layout == 1 ? R.layout.library_layout_dialog_auth2 : R.layout.library_layout_dialog_auth3;
contentView = inflater.inflate(layout, null);
setContentView(contentView);
TextView tv_left = contentView.findViewById(R.id.tv_left);
@ -58,7 +77,7 @@ public class AuthDialog extends Dialog {
TextView tv_content = contentView.findViewById(R.id.tv_content);
TextView tv_title = contentView.findViewById(R.id.tv_title);
if ("privacy".equals(type)) {
if (PRIVACY.equals(type)) {
tv_title.setText("隐私权限管理");
tv_content.setText("请在本应用的详情页面的权限列表找到'权限'并打开进行设置。");
tv_right.setOnClickListener(new View.OnClickListener() {
@ -82,7 +101,7 @@ public class AuthDialog extends Dialog {
dismiss();
}
});
} else if ("authorizatio".equals(type)) {
} else if (AUTHORIZATIO.equals(type)) {
tv_title.setText("撤回隐私授权");
tv_content.setText("若您撤回本App的隐私授权我们将会停止收集您的个人信息,并且不再为您提供相应服务,谨慎进行此步操作。");
tv_left.setOnClickListener(new View.OnClickListener() {
@ -101,7 +120,7 @@ public class AuthDialog extends Dialog {
dismiss();
}
});
} else if ("playUrl".equals(type)) {
} else if (PLAYURL.equals(type)) {
tv_title.setText("此链接无效");
tv_content.setText("请输入正确地址");
tv_content.setGravity(Gravity.CENTER);
@ -118,6 +137,27 @@ public class AuthDialog extends Dialog {
});
this.setCanceledOnTouchOutside(false);
this.setCancelable(false);
}else if (REQUEST_PER.equals(type)) {
tv_title.setText("权限申请");
tv_content.setText("当前操作需要您授权相应权限,否则可能无法正常使用此功能");
tv_content.setGravity(Gravity.CENTER);
tv_right.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
if (listener != null) {
listener.callBack();
}
}
});
tv_left.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
this.setCanceledOnTouchOutside(false);
this.setCancelable(false);
} else {
tv_right.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -33,7 +33,7 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
/**
* Description:
* Description: 从上往下的弹出提示view
* Created by JiangKe .
*/
public class SlideDownView extends LinearLayout {
@ -138,7 +138,7 @@ public class SlideDownView extends LinearLayout {
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, getResources().getDisplayMetrics()));
imageView.setLayoutParams(imageParams);
imageView.setPadding((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics()));
imageView.setImageResource(R.drawable.ic_place);
imageView.setImageResource(R.drawable.library_ic_place);
imageView.setId(R.id.image_view); // 确保在ids.xml中定义了此ID
if (mImageView != 0) {
imageView.setVisibility(VISIBLE);

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromYDelta="100%"
android:toYDelta="0" />

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromYDelta="0"
android:toYDelta="100%" />

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="150"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="150"
android:fromXDelta="0"
android:toXDelta="100%p" />
</set>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:fillAfter="true">
<translate
android:fromXDelta="100%p"
android:fromYDelta="0"
android:toXDelta="0"
android:toYDelta="0" />
<alpha
android:fromAlpha="0"
android:toAlpha="1" />
</set>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:fillAfter="true">
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="100%p"
android:toYDelta="0" />
<alpha
android:fromAlpha="1"
android:toAlpha="0" />
</set>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="100%"
android:toYDelta="0" />

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="0"
android:toYDelta="100%" />

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="600"
android:toYDelta="100%p" />
</set>
android:duration="300"
android:fromYDelta="100%"
android:toYDelta="0%" />
</set>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="600"
android:fromYDelta="100%p" />
</set>
android:duration="300"
android:fromYDelta="0%"
android:toYDelta="100%" />
</set>

View File

@ -0,0 +1,6 @@
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent">
<scale
android:duration="300"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:interpolator="@android:interpolator/decelerate_cubic"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
<alpha
android:duration="300"
android:fromAlpha="0.0"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toAlpha="1.0" />
</set>

View File

@ -0,0 +1,18 @@
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="200"
android:fromXScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1.0"
/>
<alpha
android:duration="700"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>

View File

@ -0,0 +1,17 @@
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="300"
android:fromXScale="0.5"
android:fromYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0"
/>
<alpha
android:duration="200"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>

View File

@ -0,0 +1,6 @@
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent">
<scale
android:duration="300"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:interpolator/decelerate_quad"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.8"
android:toYScale="0.8" />
<alpha
android:duration="300"
android:fromAlpha="1.0"
android:interpolator="@android:interpolator/decelerate_quad"
android:toAlpha="0.0" />
</set>

View File

@ -0,0 +1,17 @@
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <scale-->
<!-- android:duration="100"-->
<!-- android:fromXScale="1"-->
<!-- android:pivotX="50%"-->
<!-- android:pivotY="50%"-->
<!-- android:toXScale="0.0"-->
<!-- android:toYScale="0.0"-->
<!-- />-->
<alpha
android:duration="300"
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>
</set>

View File

@ -0,0 +1,17 @@
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="300"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5"
/>
<alpha
android:duration="200"
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>
</set>

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportHeight="24"
>
<path
android:fillColor="#FF000000"
android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"
/>
</vector>

View File

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#51D54D"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp"
>
<ImageView
android:id="@+id/image_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="5dp"
android:src="@drawable/ic_place"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:gravity="center_vertical"
android:orientation="vertical"
>
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:text="title"
android:textColor="@color/white"
android:textSize="17dp"
android:textStyle="bold"
/>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="5dp"
/>
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:text="content"
android:textColor="@color/white"
android:textSize="13dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -8,7 +8,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/ll_radio_white">
android:background="@drawable/library_ll_radius_white">
<TextView
android:id="@+id/tv_title"

View File

@ -12,7 +12,7 @@
android:paddingLeft="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ll_radio_white"
android:background="@drawable/library_ll_radius_white"
>
<TextView
@ -50,7 +50,7 @@
android:id="@+id/tv_left"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:background="@drawable/round_button_blue"
android:background="@drawable/library_button_radius_02"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
@ -66,7 +66,7 @@
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginLeft="8dp"
android:background="@drawable/round_button_blue"
android:background="@drawable/library_button_radius_02"
android:ellipsize="end"
android:gravity="center"
android:lines="1"

View File

@ -8,7 +8,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ll_radio_white"
android:background="@drawable/library_ll_radius_white"
android:paddingLeft="15dp"
android:paddingTop="18dp"
android:paddingRight="15dp"
@ -54,14 +54,14 @@
android:id="@+id/tv_left"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:background="@drawable/round_button_green"
android:background="@drawable/library_button_radius_01"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:paddingLeft="33dp"
android:paddingRight="33dp"
android:text="取消"
android:textColor="@color/black"
android:textColor="@color/themeColorText"
android:textSize="13dp"
/>
@ -70,14 +70,14 @@
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginLeft="35dp"
android:background="@drawable/round_button_green"
android:background="@drawable/library_button_radius_01"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:paddingLeft="33dp"
android:paddingRight="33dp"
android:text="确定"
android:textColor="@color/black"
android:textColor="@color/themeColorText"
android:textSize="13dp"
/>

View File

@ -10,7 +10,7 @@
android:layout_marginLeft="15dp"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="15dp"
android:background="@drawable/ll_radio_white">
android:background="@drawable/library_ll_radius_white">
<TextView
android:id="@+id/tv_title"

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_gradient"
android:background="@drawable/library_shape_gradient"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="15dp"
@ -14,7 +14,7 @@
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/ic_toast" />
android:src="@drawable/library_ic_toast" />
<TextView
android:id="@android:id/message"

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toast_error_bg"
android:background="@drawable/library_toast_error_bg"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="20dp"
@ -16,7 +16,7 @@
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/toast_error_ic" />
android:src="@drawable/library_toast_error_ic" />
<TextView
android:id="@android:id/message"

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toast_warn_bg"
android:background="@drawable/library_toast_hint_bg"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="20dp"
@ -16,7 +16,7 @@
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/toast_warn_ic" />
android:src="@drawable/library_toast_info_ic" />
<TextView
android:id="@android:id/message"

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_button_green"
android:background="@drawable/library_button_radius_01"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="20dp"
@ -16,7 +16,7 @@
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/toast_success_ic" />
android:src="@drawable/library_toast_success_ic" />
<TextView
android:id="@android:id/message"

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toast_hint_bg"
android:background="@drawable/library_toast_warn_bg"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="20dp"
@ -16,7 +16,7 @@
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/toast_info_ic" />
android:src="@drawable/library_toast_warn_ic" />
<TextView
android:id="@android:id/message"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -2,19 +2,19 @@
<!--ShapeButton-->
<declare-styleable name="ShapeTextView">
<!--Button圆角-->
<attr name="shapeRadius" format="dimension"></attr>
<attr name="shapeRadius" format="dimension" />
<!--边框宽度-->
<attr name="shapeStrokeWidth" format="dimension"></attr>
<attr name="shapeStrokeWidth" format="dimension" />
<!--边框颜色-->
<attr name="shapeStrokeColor" format="color"></attr>
<attr name="shapeStrokeColor" format="color" />
<!--背景颜色-->
<attr name="shapeBackgroundColor" format="color"></attr>
<attr name="shapeBackgroundColor" format="color" />
<!--背景按下的颜色-->
<attr name="shapeBackgroundSelectorColor" format="color"></attr>
<attr name="shapeBackgroundSelectorColor" format="color" />
<!--字体粗细-->
<attr name="shapeStorkeWidth" format="float"></attr>
<attr name="shapeStorkeWidth" format="float" />
<!--是否自动轮播-->
<attr name="shapeMarquee" format="boolean"></attr>
<attr name="shapeMarquee" format="boolean" />
</declare-styleable>
<!--自定义从顶部下滑View-->
@ -22,17 +22,17 @@
<!--左侧图片-->
<attr name="custom_image" format="reference"/>
<!--标题名称-->
<attr name="text_title" format="string"></attr>
<attr name="text_title" format="string" />
<!--标题名称大小-->
<attr name="text_title_size" format="float"></attr>
<attr name="text_title_size" format="float" />
<!--内容名称-->
<attr name="text_content" format="string"></attr>
<attr name="text_content" format="string" />
<!--内容名称大小-->
<attr name="text_content_size" format="float"></attr>
<attr name="text_content_size" format="float" />
<!--关闭view所需时间 毫秒-->
<attr name="hide_milliseconds" format="integer"></attr>
<attr name="hide_milliseconds" format="integer" />
<!--view是否居中-->
<attr name="view_center" format="boolean"></attr>
<attr name="view_center" format="boolean" />
</declare-styleable>

View File

@ -1,263 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
<color name="themr_color_white">#FAFAFA</color><!--淡灰白色 App基本背景颜色-->
<color name="theme_color">#9C78FF</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#4285F6</color>
<color name="themeColor">#ffcf06</color>
<color name="blue">#0000FF</color>
<color name="beizhuColor">#55999999</color>
<color name="bg_shense">#A1000000</color>
<color name="transparent">#00000000</color>
<color name="translucent">#22050505</color>
<color name="backGroundColor">#B0EEEEEE</color>
<color name="main_bottom_un_select">#999999</color>
<color name="button_shense">#AD1A1818</color>
<color name="lineColor">#e9e9e9</color>
<color name="indexOptionTextColor">#363636</color>
<color name="login_layout_line">#e5e5e5</color>
<color name="red">#FF0000</color>
<color name="text_color">#333333</color>
<color name="text_color_99">#99333333</color>
<color name="deepskyblue">#00bfff</color><!--深天蓝色 -->
<color name="bg_blue">#1541AE</color><!--蓝色 -->
<color name="wathet">#1B97F7</color><!--蓝色 -->
<!--背景框线条颜色-->
<color name="background_line_color">#cccccc</color>
<!---->
<color name="background_content_color">#ECE1E1</color>
<color name="light_green">#7ecf89</color><!--浅绿-->
<!--按钮字体颜色-->
<color name="register_button_text_color">#eb9224</color>
<!--按钮颜色-->
<color name="confirm_background_color">#777777</color>
<!--暗橘黄色-->
<color name="dark_orange_yellow">#f5f7fc</color>
<!--接单-->
<color name="color_order_receipt">#035496</color>
<!--删除-->
<color name="color_order_delete">#C91204</color>
<!--背景灰色-->
<color name="color_my_transport_order_bg">#D9D9D9</color>
<color name="color_my_transport_order_car_number">#686667</color>
<!--按钮-->
<color name="color_send_out">#AE9301</color>
<!--颜色-->
<color name="color_xyz">#E65425</color>
<color name="DarkOrange">#FF8C00</color>
<color name="blue_zfb">#0C7CD8</color><!-- 支付宝蓝色 -->
<color name="whitesmoke">#f5f5f5</color><!--烟白色 -->
<color name="black333">#333333</color><!-- 微浅黑色 -->
<color name="skyblue">#87ceeb</color><!--天蓝色 -->
<color name="colorYang">#FFE2C59B</color><!--羊皮纸色-->
<color name="ivory">#FFFFFFF0</color><!--象牙色-->
<color name="lightYellow">#FFFFFFE0</color><!--亮黄色-->
<color name="yellow">#FFFFFF00</color><!--黄色-->
<color name="snow">#FFFFFAFA</color><!--雪白色-->
<color name="floralWhite">#FFFFFAF0</color><!--花白色-->
<color name="lemonChiffon">#FFFFFACD</color><!--柠檬绸色-->
<color name="cornSilk">#FFFFF8DC</color><!--米绸色-->
<color name="seashell">#FFFFF5EE</color><!--海贝色-->
<color name="lavenderBlush">#FFFFF0F5</color><!--淡紫红色-->
<color name="papayaWhip">#FFFFEFD5</color><!--番木色-->
<color name="blanchedAlmond">#FFFFEBCD</color><!--白杏色-->
<color name="mistyRose">#FFFFE4E1</color><!--浅玫瑰色-->
<color name="bisque">#FFFFE4C4</color><!--桔黄色-->
<color name="moccasin">#FFFFE4B5</color><!--鹿皮色-->
<color name="navajoWhite">#FFFFDEAD</color><!--纳瓦白-->
<color name="peachPuff">#FFFFDAB9</color><!--桃色-->
<color name="themeColorText">#ffffff</color>
<color name="gold">#FFFFD700</color><!--金色-->
<color name="pink">#FFFFC0CB</color><!--粉红色-->
<color name="lightPink">#FFFFB6C1</color><!--亮粉红色-->
<color name="orange">#FFFFA500</color><!--橙色-->
<color name="lightSalmon">#FFFFA07A</color><!--亮肉色-->
<color name="darkOrange">#FFFF8C00</color><!--暗桔黄色-->
<color name="coral">#FFFF7F50</color><!--珊瑚色-->
<color name="hotPink">#FFFF69B4</color><!--热粉红色-->
<color name="tomato">#FFFF6347</color><!--西红柿色-->
<color name="orangeRed">#FFFF4500</color><!--红橙色-->
<color name="deepPink">#FFFF1493</color><!--深粉红色-->
<color name="fuchsia">#FFFF00FF</color><!--紫红色-->
<color name="oldLace">#FFFDF5E6</color><!--老花色-->
<color name="lightGoldenrodYellow">#FFFAFAD2</color><!--亮金黄色-->
<color name="linen">#FFFAF0E6</color><!--亚麻色-->
<color name="antiqueWhite">#FFFAEBD7</color><!--古董白色-->
<color name="salmon">#FFFA8072</color><!--鲜肉色-->
<color name="ghostWhite">#FFF8F8FF</color><!--幽灵白-->
<color name="mintCream">#FFF5FFFA</color><!--薄荷色-->
<color name="whiteSmoke">#FFF5F5F5</color><!--烟白色-->
<color name="beige">#FFF5F5DC</color><!--米色-->
<color name="wheat">#FFF5DEB3</color><!--浅黄色-->
<color name="sandyBrown">#FFF4A460</color><!--沙褐色-->
<color name="azure">#FFF0FFFF</color><!--天蓝色-->
<color name="aliceBlue">#FFF0F8FF</color><!--艾利斯兰色-->
<color name="khaki">#FFF0E68C</color><!--黄褐色-->
<color name="lightCoral">#FFF08080</color><!--亮珊瑚色-->
<color name="paleGoldenrod">#FFEEE8AA</color><!--苍麒麟色-->
<color name="violet">#FFEE82EE</color><!--紫罗兰色-->
<color name="darkSalmon">#FFE9967A</color><!--暗肉色-->
<color name="lavender">#FFE6E6FA</color><!--淡紫色-->
<color name="lightCyan">#FFE0FFFF</color><!--亮青色-->
<color name="burlyWood">#FFDEB887</color><!--实木色-->
<color name="plum">#FFDDA0DD</color><!--洋李色-->
<color name="lightGrey">#FFDCDCDC</color><!--淡灰色-->
<color name="crimson">#FFDC143C</color><!--暗深红色-->
<color name="paleVioletRed">#FFDB7093</color><!--苍紫罗兰色-->
<color name="goldenrod">#FFDAA520</color><!--金麒麟色-->
<color name="orchid">#FFDA70D6</color><!--淡紫色-->
<color name="thistle">#FFD8BFD8</color><!--蓟色-->
<color name="lightGray">#FFD3D3D3</color><!--亮灰色-->
<color name="tan">#FFD2B48C</color><!--茶色-->
<color name="chocolate">#FFD2691E</color><!--巧可力色-->
<color name="peru">#FFCD853F</color><!--秘鲁色-->
<color name="indianRed">#FFCD5C5C</color><!--印第安红色-->
<color name="mediumVioletRed">#FFC71585</color><!--中紫罗兰色-->
<color name="silver">#FFC0C0C0</color><!--银色-->
<color name="darkKhaki">#FFBDB76B</color><!--暗黄褐色-->
<color name="rosyBrown">#FFBC8F8F</color><!--褐玫瑰红色-->
<color name="mediumOrchid">#FFBA55D3</color><!--中粉紫色-->
<color name="darkGoldenrod">#FFB8860B</color><!--暗金黄色-->
<color name="firebrick">#FFB22222</color><!--火砖色-->
<color name="powderBlue">#FFB0E0E6</color><!--粉蓝色-->
<color name="lightSteelBlue">#FFB0C4DE</color><!--亮钢兰色-->
<color name="paleTurquoise">#FFAFEEEE</color><!--苍宝石绿色-->
<color name="greenYellow">#FFADFF2F</color><!--黄绿色-->
<color name="lightBlue">#FFADD8E6</color><!--亮蓝色-->
<color name="darkGray">#FFA9A9A9</color><!--暗灰色-->
<color name="brown">#FFA52A2A</color><!--褐色-->
<color name="sienna">#FFA0522D</color><!--赭色-->
<color name="darkOrchid">#FF9932CC</color><!--暗紫色-->
<color name="paleGreen">#FF98FB98</color><!--苍绿色-->
<color name="darkViolet">#FF9400D3</color><!--暗紫罗兰色-->
<color name="mediumPurple">#FF9370DB</color><!--中紫色-->
<color name="lightGreen">#FF90EE90</color><!--亮绿色-->
<color name="darkSeaGreen">#FF8FBC8F</color><!--暗海兰色-->
<color name="saddleBrown">#FF8B4513</color><!--重褐色-->
<color name="darkMagenta">#FF8B008B</color><!--暗洋红色-->
<color name="darkRed">#FF8B0000</color><!--暗红色-->
<color name="blueViolet">#FF8A2BE2</color><!--紫罗兰蓝色-->
<color name="lightSkyBlue">#FF87CEFA</color><!--亮天蓝色-->
<color name="skyBlue">#FF87CEEB</color><!--天蓝色-->
<color name="gray">#FF808080</color><!--灰色-->
<color name="olive">#FF808000</color><!--橄榄色-->
<color name="purple">#FF800080</color><!--紫色-->
<color name="maroon">#FF800000</color><!--粟色-->
<color name="aquamarine">#FF7FFFD4</color><!--碧绿色-->
<color name="chartreuse">#FF7FFF00</color><!--黄绿色-->
<color name="lawnGreen">#FF7CFC00</color><!--草绿色-->
<color name="mediumSlateBlue">#FF7B68EE</color><!--中暗蓝色-->
<color name="lightSlateGray">#FF778899</color><!--亮蓝灰色-->
<color name="slateGray">#FF708090</color><!--灰石色-->
<color name="oliveDrab">#FF6B8E23</color><!--深绿褐色-->
<color name="slateBlue">#FF6A5ACD</color><!--石蓝色-->
<color name="dimGray">#FF696969</color><!--暗灰色-->
<color name="mediumAquamarine">#FF66CDAA</color><!--中绿色-->
<color name="cornFlowerBlue">#FF6495ED</color><!--菊兰色-->
<color name="cadetBlue">#FF5F9EA0</color><!--军兰色-->
<color name="darkOliveGreen">#FF556B2F</color><!--暗橄榄绿色-->
<color name="indigo">#FF4B0082</color><!--靛青色-->
<color name="mediumTurquoise">#FF48D1CC</color><!--中绿宝石色-->
<color name="darkSlateBlue">#FF483D8B</color><!--暗灰蓝色-->
<color name="steelBlue">#FF4682B4</color><!--钢兰色-->
<color name="royalBlue">#FF4169E1</color><!--皇家蓝色-->
<color name="turquoise">#FF40E0D0</color><!--青绿色-->
<color name="mediumSeaGreen">#FF3CB371</color><!--中海蓝色-->
<color name="limeGreen">#FF32CD32</color><!--橙绿色-->
<color name="darkSlateGray">#FF2F4F4F</color><!--暗瓦灰色-->
<color name="seaGreen">#FF2E8B57</color><!--海绿色-->
<color name="forestGreen">#FF228B22</color><!--森林绿色-->
<color name="lightSeaGreen">#FF20B2AA</color><!--亮海蓝色-->
<color name="dodgerBlue">#FF1E90FF</color><!--闪兰色-->
<color name="midnightBlue">#FF191970</color><!--中灰兰色-->
<color name="aqua">#FF00FFFF</color><!--浅绿色-->
<color name="springGreen">#FF00FF7F</color><!--春绿色-->
<color name="lime">#FF00FF00</color><!--酸橙色-->
<color name="mediumSpringGreen">#FF00FA9A</color><!--中春绿色-->
<color name="darkTurquoise">#FF00CED1</color><!--暗宝石绿色-->
<color name="deepSkyBlue">#FF00BFFF</color><!--深天蓝色-->
<color name="darkCyan">#FF008B8B</color><!--暗青色-->
<color name="teal">#FF008080</color><!--水鸭色-->
<color name="green">#FF008000</color><!--绿色-->
<color name="darkGreen">#FF006400</color><!--暗绿色-->
<color name="mediumBlue">#FF0000CD</color><!--中兰色-->
<color name="darkBlue">#FF00008B</color><!--暗蓝色-->
<color name="navy">#FF000080</color><!--海军色-->
<color name="unBlack">#FF2B2B2B</color><!--不知名黑色-->
<color name="textcolor_white_a">#ffffff</color>
<color name="textcolor_black_b1">#111111</color>
<color name="textcolor_black_b2">#666666</color>
<color name="textcolor_black_b3">#999999</color>
<color name="textcolor_black_b4">#bbbbbb</color>
<color name="textcolor_black_b5">#828282</color>
<color name="textcolor_blue_c">#0099ff</color>
<color name="textcolor_blue_c2">#a9dbfc</color>
<color name="textcolor_blue_text">#006ec1</color>
<color name="textcolor_blue_text_refresh">#4b83a9</color>
<color name="textcolor_red_d">#e5533b</color>
<color name="textcolor_red_text">#c2001e</color>
<color name="textcolor_green_e">#19aa49</color>
<color name="background_bg1">#ebebe9</color>
<color name="background_bg2">#d1d1d1</color>
<color name="background_bg3">#ff0000</color>
<color name="background_bg7">#f6f6f5</color>
<color name="background_bg5">#f5f5f5</color>
<color name="background_bg9">#e0e0e0</color>
<color name="dark">#FF222222</color><!-- 暗色 -->
<color name="light">#FFEEEEEE</color><!-- 亮色 -->
<color name="gestureline_green">#00cd56</color>
<color name="gestureline_red">#99E0260C</color>
<color name="highlight">#45C01A</color>
<color name="refresh_blue">#A80375c2</color>
<drawable name="more_popu_pressed">#d9d9d9</drawable>
<drawable name="more_popu_normal">#ffffff</drawable>
<drawable name="background_bg5">#ebebeb</drawable>
<drawable name="contact_bottom_popu_normal">#ebebe9</drawable>
<color name="color_ll_normal">#fff</color>
<color name="color_ll_press">#e5e5e5</color>
<color name="color_head_press">#666</color>
<color name="color_main">#f2f2f2</color>
<color name="color_gray">#999</color>
<color name="color_black">#000</color>
<color name="color_black_light">#222</color>
<color name="color_red">#f22121</color>
<color name="color_blue">#0099cc</color>
<color name="color_blue_trans">#7A0099cc</color>
<color name="color_gray_unable">#333</color>
<color name="textcolor_black_trans">#66000000</color>
<color name="textcolor_black_bb">#333333</color>
<color name="textcolor_black_forget">#666666</color>
<color name="menu_title_color">#333333</color>
<color name="menu_sub_title_color">#72747B</color>
<color name="menu_color">#666666</color>
<color name="menu_stroke">#888888</color>
<color name="menu_stroke_live">#4DFFFFFF</color>
<color name="menu_selected_live">#33E5E5E5</color>
<color name="menu_selected_color">#FFFFFF</color>
<color name="bg_color">#F2F6FA</color>
<color name="player_style_pre">#CC3DA6EC</color>
<color name="transparent">#00000000</color>
<!-- 吐司 -->
<color name="toast_hint_color">#3F51B5</color>

View File

@ -1,63 +1,13 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<!-- 标签栏菜单主样式-->
<style name="menu">
<item name="android:gravity">center</item>
<item name="android:button">@null</item>
<item name="android:textColor">#3d4038</item>
</style>
<style name="BaseAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- &lt;!&ndash; Customize your theme here. &ndash;&gt;
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">#FFFFFF</item>
<item name="colorAccent">@color/colorAccent</item>
&lt;!&ndash;<item name="android:windowBackground">@android:color/transparent</item>&ndash;&gt;
&lt;!&ndash;<item name="android:windowAnimationStyle">@style/ActivityInOutAnimation</item>&ndash;&gt;
<item name="android:windowIsTranslucent">true</item>-->
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="toolbarStyle">@color/colorAccent</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowLayoutInDisplayCutoutMode" tools:ignore="NewApi">shortEdges</item>
</style>
<style name="AppTheme.Main" parent="BaseAppTheme" />
<!--activity的启动和退出动画-->
<style name="ActivityInOutAnimation" parent="android:style/Animation.Translucent">
<item name="android:activityOpenEnterAnimation">@anim/activity_in_animation</item>
<item name="android:activityOpenExitAnimation">@anim/activity_out_animation</item>
<item name="android:activityCloseEnterAnimation">@anim/activity_in_animation</item>
<item name="android:activityCloseExitAnimation">@anim/activity_out_animation</item>
</style>
<!--项目中的dailog向上滑入的动画-->
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<style name="Dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
@ -65,158 +15,14 @@
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowEnterAnimation">@anim/dialog_show_enter</item>
<item name="android:windowExitAnimation">@anim/dialog_show_exis</item>
</style>
<!--打电话弹窗-->
<style name="CallTelPhoneDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowEnterAnimation">@anim/dialog_show_enter</item>
<item name="android:windowExitAnimation">@anim/dialog_show_exis</item>
</style>
<style name="choose_register" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">#737070</item>
<item name="colorControlActivated">@color/themeColor</item>
</style>
<style name="FloatWindowAnimation">
<item name="android:windowEnterAnimation">@anim/anim_float_window_enter</item>
<item name="android:windowExitAnimation">@anim/anim_float_window_exit</item>
</style>
<style name="Theme.PictureInPicture" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
<!--继承AppCompatActivity时设置全屏-->
<style name="NoTitleFullscreen" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<!--<style name="notitle">
<item name="android:windowNoTitle">true</item>
</style>-->
<declare-styleable name="DoubleHeadedDragonBar">
<!--进度条按钮宽高-->
<attr name="button_width" format="dimension" />
<attr name="button_height" format="dimension" />
<!--进图条按钮图片-->
<attr name="button_img" format="reference" />
<!--单位字体颜色-->
<attr name="text_color" format="color" />
<!--进图条背景颜色-->
<attr name="bg_color" format="color" />
<!--进度条颜色-->
<attr name="value_color" format="color" />
<!--进度条宽-->
<attr name="seek_height" format="dimension" />
</declare-styleable>
<!-- 自定义仿IOS的ActionSheet底部Dialog的样式 ,有模糊效果 -->
<style name="ActionGeneralDialog" parent="@android:style/Theme.Dialog">
<!-- 背景透明 -->
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<!-- 浮于Activity之上 -->
<item name="android:windowIsFloating">true</item>
<!-- 边框 -->
<item name="android:windowFrame">@null</item>
<!-- Dialog以外的区域模糊效果 -->
<item name="android:backgroundDimEnabled">true</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 半透明 -->
<item name="android:windowIsTranslucent">true</item>
<!-- Dialog进入及退出动画 -->
<item name="android:windowAnimationStyle">@style/ActionSheetDialogAnimation</item>
</style>
<!-- ActionSheet进出动画 -->
<style name="ActionSheetDialogAnimation" parent="@android:style/Animation.Dialog">
<item name="android:windowEnterAnimation">@anim/actionsheet_dialog_in</item>
<item name="android:windowExitAnimation">@anim/actionsheet_dialog_out</item>
</style>
<!--从下而上Dialog出场动画主题样式-->
<style name="MenuButtomAnimationStyle" parent="android:style/Theme.Dialog">
<!-- 是否有标题-->
<item name="android:windowNoTitle">true</item>
<!--背景颜色及透明程度-->
<item name="android:windowBackground">@android:color/transparent</item>
<!--是否浮现在activity之上-->
<item name="android:windowIsFloating">true</item>
<!--是否模糊-->
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowAnimationStyle">@style/MusicButtomAnimation</item>
</style>
<!--从下而上动画-->
<style name="MusicButtomAnimation">
<!-- 入场动画 -->
<item name="android:windowEnterAnimation">@anim/bottom_menu_enter</item>
<!-- 出厂动画 -->
<item name="android:windowExitAnimation">@anim/bottom_menu_exit</item>
<item name="android:windowExitAnimation">@anim/dialog_show_exit</item>
</style>
<!--中间弹窗式Activity-->
<style name="ActivityCenterDialogAnimation" parent="@style/Theme.AppCompat.Light.NoActionBar">
<!-- 是否有标题-->
<item name="android:windowNoTitle">true</item>
<!--背景颜色及透明程度-->
<item name="android:windowBackground">@android:color/transparent</item>
<!--是否浮现在activity之上-->
<item name="android:windowIsFloating">true</item>
<!--是否模糊-->
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<!--项目中的dailog从里向外的动画-->
<style name="ZoomDialogAnimation">
<item name="android:windowEnterAnimation">@anim/zoom_in</item>
<item name="android:windowExitAnimation">@anim/zoom_out</item>
</style>
<!--播放器标题-->
<style name="MusicTitleStyle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:gravity">center_vertical</item>
<item name="android:ellipsize">marquee</item>
<item name="android:singleLine">true</item>
<item name="android:textSize">16dp</item>
<item name="android:textColor">#FFFFFF</item>
</style>
<!--播放器时间字体样式-->
<style name="MusicTimeStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:textSize">12dp</item>
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:background">?attr/selectableItemBackground</item>
</style>
<!--从屏幕中间出场的动画样式-->
<style name="CenterDialogAnimationStyle" parent="Animation.AppCompat.Dialog">
<!-- 是否有标题-->
<item name="android:windowNoTitle">true</item>
<!--背景颜色及透明程度-->
<item name="android:windowBackground">@android:color/transparent</item>
<!--是否浮现在activity之上-->
<item name="android:windowIsFloating">true</item>
<!--是否模糊-->
<item name="android:backgroundDimEnabled">true</item>
</style>
<!--锁屏Theme-->
<style name="MusicLockScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>

View File

@ -1,17 +0,0 @@
package com.tfq.library;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -5,11 +5,11 @@ plugins {
android {
namespace 'com.tfq.libraryad'
compileSdkVersion 34
compileSdkVersion 36
defaultConfig {
minSdkVersion 24
targetSdkVersion 34
targetSdkVersion 36
}
buildTypes {
@ -21,7 +21,6 @@ android {
sourceSets {
main {
jniLibs.srcDirs = ['libs']
// assets.srcDirs += ['../android_data/csj_config']
}
}
@ -43,18 +42,14 @@ dependencies {
//
implementation 'com.gyf.immersionbar:immersionbar:3.0.0-beta05'
//gson
// implementation 'com.google.code.gson:gson:2.13.1'
// implementation 'com.alibaba:fastjson:2.0.57'
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId = 'com.jiangke.group' //
artifactId = 'JKBaseLib' //
groupId = 'com.chuangketie.jk' //
artifactId = 'ad-lib' //
version = '1.0.0'
artifact("$buildDir/outputs/aar/${project.name}-release.aar")// AAR
}

View File

@ -4,6 +4,8 @@ import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
@ -12,20 +14,21 @@ import android.widget.ImageView;
import com.tfq.libraryad.R;
import java.util.Objects;
public class LoadingDialog extends Dialog {
private final Context mContext;
private final LayoutInflater inflater;
private Listener listener;
private View contentView;
public LoadingDialog(Context context) {
super(context, R.style.CustomDialog);
super(context, R.style.AnimationDialog);
this.mContext = context;
inflater = LayoutInflater.from(context);
}
public LoadingDialog(Context context, Listener listener) {
super(context, R.style.CustomDialog);
super(context, R.style.AnimationDialog);
this.listener = listener;
this.mContext = context;
inflater = LayoutInflater.from(context);
@ -38,20 +41,23 @@ public class LoadingDialog extends Dialog {
}
private void setViews() {
contentView = inflater.inflate(R.layout.ad_dialog_loading, null);
View contentView = inflater.inflate(R.layout.ad_dialog_loading, null);
setContentView(contentView);
ImageView loadingImageView = contentView.findViewById(R.id.loading_imageview);
AnimationDrawable loadingAnimation = (AnimationDrawable) loadingImageView.getBackground();
loadingAnimation.start();
Window dialogWindow = getWindow();
// assert dialogWindow != null;
// 设置窗口动画
// dialogWindow.setWindowAnimations(R.style.CustomDialog);
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = UIUtils.dp2px(mContext, 70);
lp.height = UIUtils.dp2px(mContext, 70);
dialogWindow.setAttributes(lp);
setCanceledOnTouchOutside(false);
setCancelable(false);
ImageView loadingImageView = contentView.findViewById(R.id.loading_imageview);
AnimationDrawable loadingAnimation = (AnimationDrawable) loadingImageView.getBackground();
loadingAnimation.start();
}
public interface Listener {

View File

@ -0,0 +1,6 @@
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>

View File

@ -0,0 +1,6 @@
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp" />
<solid android:color="#E1E1E1" />
<solid android:color="#F0F0F0" />
<corners android:radius="10dp" />
</shape>

View File

@ -2,16 +2,24 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ad_ll_radio_loading"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/loading_imageview"
android:layout_width="30dp"
android:layout_height="30dp"
<RelativeLayout
android:layout_centerInParent="true"
android:background="@drawable/ad_anim_loading"
/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ad_ll_radio_loading"
>
<ImageView
android:id="@+id/loading_imageview"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:background="@drawable/ad_anim_loading"
/>
</RelativeLayout>
</RelativeLayout>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent">#00000000</color>
</resources>

View File

@ -1,21 +1,15 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- 项目中的Dialog向上滑入的动画样式定义 -->
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<!-- 去除窗口框架 -->
<!--dailog的动画-->
<style name="AnimationDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<!-- 设置窗口为浮动状态 -->
<item name="android:windowIsFloating">true</item>
<!-- 设置窗口不透明 -->
<item name="android:windowIsTranslucent">false</item>
<!-- 设置窗口背景为透明色 -->
<item name="android:windowBackground">#00000000</item>
<!-- 隐藏标题栏 -->
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
<!-- 启用背景变暗效果 -->
<item name="android:backgroundDimEnabled">true</item>
<!-- 设置窗口进入时的动画 -->
<item name="android:windowEnterAnimation">@anim/dialog_show_enter</item>
<!-- 设置窗口退出时的动画 -->
<item name="android:windowExitAnimation">@anim/dialog_show_exit</item> <!-- 假设更正为dialog_show_exit -->
<item name="android:windowEnterAnimation">@anim/ad_dialog_in</item>
<item name="android:windowExitAnimation">@anim/ad_dialog_out</item>
</style>
</resources>

View File

@ -32,6 +32,7 @@ new AdApp.Builder(this, Constants.APP_NAME, getChannel(), getAppSplash())
.addSlot(AD_CODE_FEED3, "feed3_id") // 信息流3广告位
.addSlot(AD_CODE_BANNER, "banner_id") // banner广告位
.addSlot(AD_CODE_Draw, "draw_id") // draw广告位
.addSlot(NO_AD,"true") //强制不开启广告
.initialize();
```

View File

@ -1,24 +1,24 @@
ext {
base = [
//
applicationId : "com.tfq.finances.jzrcj",
applicationId : "com.tfq.demo",
versionCode : 100,
versionName : "1.0.0",
company_name : "济宁同风起网络科技有限公司",
APP_DEBUG_PRINT : "false",//true: log
need_login : "true",//
need_login : "false",//
appinfoId : "48", // id
appId : "5666885",
csjId : "5666885",
csjIdSplash : "103509305",
csjIdCQP : "103508062",
csjIdFeed1 : "103507590",
csjIdFeed2 : "103507765",
csjIdFeed3 : "103507590",
csjIdReward : "103508260",
csjIdBanner : "103507868",
csjIdDraw : "103507868",
appId : "5440503",
csjId : "5440503",
csjIdSplash : "102493122",
csjIdCQP : "102492769",
csjIdFeed1 : "102493121",
csjIdFeed2 : "102492595",
csjIdFeed3 : "102493121",
csjIdReward : "102711070",
csjIdBanner : "103548860",
csjIdDraw : "103548860",
umId : "684282abbc47b67d837db577",
@ -39,7 +39,7 @@ ext {
]
channel = [
appName : "记账日常记",
appName : "Demo",
appLogo : "@drawable/app_logo",
appKaiPing: "@drawable/app_splash",
]

View File

@ -23,13 +23,13 @@ android {
}
}
compileSdkVersion 34
compileSdkVersion 36
namespace rootProject.ext.base.applicationId //
defaultConfig {
applicationId rootProject.ext.base.applicationId
minSdkVersion 24
targetSdkVersion 34
targetSdkVersion 36
multiDexEnabled true
versionCode rootProject.ext.base.versionCode
versionName rootProject.ext.base.versionName

View File

@ -109,7 +109,7 @@
/>
<activity
android:name="com.tfq.finances.finances.activity.Activity_Login"
android:name="com.tfq.finances.main.Activity_Login"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity"
/>
@ -125,7 +125,7 @@
/>
<activity
android:name="com.tfq.finances.finances.activity.Activity_Setting_More"
android:name="com.tfq.finances.main.Activity_Setting_More"
android:screenOrientation="portrait"
/>

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
package com.tfq.finances.core.constants;
import com.tfq.finances.app.App;
import com.tfq.finances.jzrcj.R;
import com.tfq.demo.R;
public class Constants {
/**

View File

@ -1,137 +0,0 @@
package com.tfq.finances.core.enums;
import com.tfq.finances.jzrcj.R;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum AvatarEnum {
// 枚举实例
AVATAR1(1, "头像1", R.mipmap.avatar_01, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR2(2, "头像2", R.mipmap.avatar_02, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR3(3, "头像3", R.mipmap.avatar_03, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR4(4, "头像4", R.mipmap.avatar_04, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR5(5, "头像5", R.mipmap.avatar_05, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR6(6, "头像6", R.mipmap.avatar_06, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR7(7, "头像7", R.mipmap.avatar_07, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR8(8, "头像8", R.mipmap.avatar_08, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR9(9, "头像9", R.mipmap.avatar_09, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR10(10, "头像10", R.mipmap.avatar_10, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR11(11, "头像11", R.mipmap.avatar_11, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR12(12, "头像12", R.mipmap.avatar_12, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR13(13, "头像13", R.mipmap.avatar_13, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR14(14, "头像14", R.mipmap.avatar_14, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR15(15, "头像15", R.mipmap.avatar_15, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR16(16, "头像16", R.mipmap.avatar_16, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR17(17, "头像17", R.mipmap.avatar_17, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR18(18, "头像18", R.mipmap.avatar_18, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR19(19, "头像19", R.mipmap.avatar_19, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null),
AVATAR20(20, "头像20", R.mipmap.avatar_20, R.drawable.ll_boder_head, R.drawable.ll_boder_head_null);
private final int id;
private final String name;
private final int avatar;
private final int icUnOnChecked;
private final int icOnChecked;
// 缓存映射
private static final Map<Integer, AvatarEnum> ID_MAP = new HashMap<>();
private static final Map<String, AvatarEnum> NAME_MAP = new HashMap<>();
static {
for (AvatarEnum category : values()) {
ID_MAP.put(category.id, category);
NAME_MAP.put(category.name, category);
}
}
AvatarEnum(int id, String name, int avatar, int icOnChecked, int icUnOnChecked) {
this.id = id;
this.name = name;
this.avatar = avatar;
this.icOnChecked = icOnChecked;
this.icUnOnChecked = icUnOnChecked;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getAvatar() {
return avatar;
}
public int getIcUnOnChecked() {
return icUnOnChecked;
}
public int getIcOnChecked() {
return icOnChecked;
}
/**
* 获取所有枚举的列表
* @return 包含所有枚举的列表
*/
public static List<AvatarEnum> getAll() {
List<AvatarEnum> list = new ArrayList<>();
for (AvatarEnum category : values()) {
list.add(category);
}
return list;
}
/**
* 根据ID获取枚举
* @param id 枚举ID
* @return 对应的枚举实例未找到返回null
*/
public static AvatarEnum getById(int id) {
return ID_MAP.get(id);
}
/**
* 根据名称获取枚举
* @param name 枚举名称
* @return 对应的枚举实例未找到返回null
*/
public static AvatarEnum getByName(String name) {
return NAME_MAP.get(name);
}
/**
* 根据ID获取名称
* @param id 枚举ID
* @return 对应的名称未找到返回null
*/
public static String getNameById(int id) {
AvatarEnum category = ID_MAP.get(id);
return category != null ? category.name : null;
}
/**
* 根据ID获取头像
* @param id 枚举ID
* @return 对应的名称未找到返回null
*/
public static int getAvatarById(int id) {
AvatarEnum category = ID_MAP.get(id);
return category != null ? category.avatar : 0;
}
/**
* 根据名称获取ID
* @param name 枚举名称
* @return 对应的ID未找到返回-1
*/
public static int getIdByName(String name) {
AvatarEnum category = NAME_MAP.get(name);
return category != null ? category.id : -1;
}
}

View File

@ -1,148 +0,0 @@
package com.tfq.finances.core.enums;
import com.tfq.finances.jzrcj.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum SystemExpensesCategoriesEnum {
// 枚举实例
RESTAURANT(31325, "餐饮", R.mipmap.ic_cy_check, R.mipmap.ic_cy_checked),
FRUIT(31326, "水果", R.mipmap.ic_sg_check, R.mipmap.ic_sg_checked),
SNACK(31327, "零食", R.mipmap.ic_ls_check, R.mipmap.ic_ls_checked),
GROCERY(31328, "买菜", R.mipmap.ic_mc_check, R.mipmap.ic_mc_checked),
CHILD(31329, "孩子", R.mipmap.ic_hz_check, R.mipmap.ic_hz_checked),
MEMBERSHIP(31330, "会员", R.mipmap.ic_hy_check, R.mipmap.ic_hy_checked),
COURIER(31331, "快递", R.mipmap.ic_kd_check, R.mipmap.ic_kd_checked),
BEAUTY(31332, "美容", R.mipmap.ic_mr_check, R.mipmap.ic_mr_checked),
STUDY(31333, "学习", R.mipmap.ic_xx_check, R.mipmap.ic_xx_checked),
DAILY_NECESSITIES(31334, "日用品", R.mipmap.ic_ryp_check, R.mipmap.ic_ryp_checked),
UTILITIES(31335, "水电煤", R.mipmap.ic_sdm_check, R.mipmap.ic_sdm_checked),
COMMUNICATION(31336, "通讯", R.mipmap.ic_tx_check, R.mipmap.ic_tx_checked),
MAINTENANCE(31337, "维修", R.mipmap.ic_wx_check, R.mipmap.ic_wx_checked),
TRANSPORTATION(31338, "交通", R.mipmap.ic_jt_check, R.mipmap.ic_jt_checked),
PET(31339, "宠物", R.mipmap.ic_cw_check, R.mipmap.ic_cw_checked),
LOTTERY(31340, "彩票", R.mipmap.ic_cp_check, R.mipmap.ic_cp_checked),
CLOTHING(31341, "服饰", R.mipmap.ic_fs_check, R.mipmap.ic_fs_checked),
GIFT(31342, "礼物", R.mipmap.ic_lw_check, R.mipmap.ic_lw_checked),
DIGITAL(31343, "数码", R.mipmap.ic_sm_check, R.mipmap.ic_sm_checked),
ENTERTAINMENT(31344, "娱乐", R.mipmap.ic_yl_check, R.mipmap.ic_yl_checked),
MEDICINE(31345, "医药", R.mipmap.ic_yy_check, R.mipmap.ic_yy_checked),
HOUSING(31346, "住房", R.mipmap.ic_zf_check, R.mipmap.ic_zf_checked),
CAR(31347, "汽车", R.mipmap.ic_qc_check, R.mipmap.ic_qc_checked),
ELECTRICAL_APPLIANCE(31348, "电器", R.mipmap.ic_dq_check, R.mipmap.ic_dq_checked),
OFFICE(31349, "办公", R.mipmap.ic_bg_check, R.mipmap.ic_bg_checked),
INSURANCE(31350, "保险", R.mipmap.ic_bx_check, R.mipmap.ic_bx_checked),
FURNITURE(31351, "家具", R.mipmap.ic_jj_check, R.mipmap.ic_jj_checked),
DONATION(31352, "捐赠", R.mipmap.ic_jzeng_check, R.mipmap.ic_jzeng_checked),
SPORTS(31353, "运动", R.mipmap.ic_yd_check, R.mipmap.ic_yd_checked),
TRAVEL(31354, "旅行", R.mipmap.ic_lx_check, R.mipmap.ic_lx_checked),
INVESTMENT(31355, "投资", R.mipmap.ic_tz_check, R.mipmap.ic_tz_checked),
GAME(31356, "游戏", R.mipmap.ic_yx_check, R.mipmap.ic_yx_checked),
CASH_GIFT(31357, "礼金", R.mipmap.ic_lj_check, R.mipmap.ic_lj_checked),
JEWELRY(31358, "珠宝", R.mipmap.ic_zb_check, R.mipmap.ic_zb_checked),
ELDERS(31359, "长辈", R.mipmap.ic_zbei_check, R.mipmap.ic_zbei_checked),
TOBACCO_ALCOHOL(31360, "烟酒", R.mipmap.ic_yj_check, R.mipmap.ic_yj_checked);
private final int id;
private final String name;
private final int iconUnchecked;
private final int iconChecked;
// 缓存映射
private static final Map<Integer, SystemExpensesCategoriesEnum> ID_MAP = new HashMap<>();
private static final Map<String, SystemExpensesCategoriesEnum> NAME_MAP = new HashMap<>();
static {
for (SystemExpensesCategoriesEnum category : values()) {
ID_MAP.put(category.id, category);
NAME_MAP.put(category.name, category);
}
}
SystemExpensesCategoriesEnum(int id, String name, int iconUnchecked, int iconChecked) {
this.id = id;
this.name = name;
this.iconUnchecked = iconUnchecked;
this.iconChecked = iconChecked;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getIconUnchecked() {
return iconUnchecked;
}
public int getIconChecked() {
return iconChecked;
}
/**
* 获取所有枚举的列表
* @return 包含所有枚举的列表
*/
public static List<SystemExpensesCategoriesEnum> getAll() {
List<SystemExpensesCategoriesEnum> list = new ArrayList<>();
for (SystemExpensesCategoriesEnum category : values()) {
list.add(category);
}
return list;
}
/**
* 根据ID获取枚举
* @param id 枚举ID
* @return 对应的枚举实例未找到返回null
*/
public static SystemExpensesCategoriesEnum getById(int id) {
return ID_MAP.get(id);
}
/**
* 根据名称获取枚举
* @param name 枚举名称
* @return 对应的枚举实例未找到返回null
*/
public static SystemExpensesCategoriesEnum getByName(String name) {
return NAME_MAP.get(name);
}
/**
* 根据ID获取名称
* @param id 枚举ID
* @return 对应的名称未找到返回null
*/
public static String getNameById(int id) {
SystemExpensesCategoriesEnum category = ID_MAP.get(id);
return category != null ? category.name : null;
}
/**
* 根据ID获取选中的图标
* @param id 枚举ID
* @return 对应的名称未找到返回null
*/
public static int getCheckedIconById(int id) {
SystemExpensesCategoriesEnum category = ID_MAP.get(id);
return category != null ? category.iconChecked : -1;
}
/**
* 根据名称获取ID
* @param name 枚举名称
* @return 对应的ID未找到返回-1
*/
public static int getIdByName(String name) {
SystemExpensesCategoriesEnum category = NAME_MAP.get(name);
return category != null ? category.id : -1;
}
}

View File

@ -1,118 +0,0 @@
package com.tfq.finances.core.enums;
import com.tfq.finances.jzrcj.R;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum SystemIncomeCategoriesEnum {
// 枚举实例
RED_PACKET(31361, "收红包", R.mipmap.ic_shb_check, R.mipmap.ic_shb_checked),
SALARY(31362, "工资", R.mipmap.ic_gz_check, R.mipmap.ic_gz_checked),
PART_TIME_JOB(31363, "兼职", R.mipmap.ic_jz_check, R.mipmap.ic_jz_checked),
FINANCIAL_MANAGEMENT(31364, "理财", R.mipmap.ic_lc_check, R.mipmap.ic_lc_checked),
INSURANCE(31365, "保险", R.mipmap.ic_bx_check, R.mipmap.ic_bx_checked),
BONUS(31366, "奖金", R.mipmap.ic_jjin_check, R.mipmap.ic_jjin_checked),
REIMBURSEMENT(31367, "报销", R.mipmap.ic_bxiao_check, R.mipmap.ic_bxiao_checked);
private final int id;
private final String name;
private final int mipmapCheck;
private final int mipmapChecked;
// 缓存映射
private static final Map<Integer, SystemIncomeCategoriesEnum> ID_MAP = new HashMap<>();
private static final Map<String, SystemIncomeCategoriesEnum> NAME_MAP = new HashMap<>();
static {
for (SystemIncomeCategoriesEnum category : values()) {
ID_MAP.put(category.id, category);
NAME_MAP.put(category.name, category);
}
}
SystemIncomeCategoriesEnum(int id, String name, int mipmapCheck, int mipmapChecked) {
this.id = id;
this.name = name;
this.mipmapCheck = mipmapCheck;
this.mipmapChecked = mipmapChecked;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getIconUnchecked() {
return mipmapCheck;
}
public int getIconChecked() {
return mipmapChecked;
}
/**
* 获取所有枚举的列表
* @return 包含所有枚举的列表
*/
public static List<SystemIncomeCategoriesEnum> getAll() {
List<SystemIncomeCategoriesEnum> list = new ArrayList<>();
for (SystemIncomeCategoriesEnum category : values()) {
list.add(category);
}
return list;
}
/**
* 根据ID获取枚举
* @param id 枚举ID
* @return 对应的枚举实例未找到返回null
*/
public static SystemIncomeCategoriesEnum getById(int id) {
return ID_MAP.get(id);
}
/**
* 根据名称获取枚举
* @param name 枚举名称
* @return 对应的枚举实例未找到返回null
*/
public static SystemIncomeCategoriesEnum getByName(String name) {
return NAME_MAP.get(name);
}
/**
* 根据ID获取名称
* @param id 枚举ID
* @return 对应的名称未找到返回null
*/
public static String getNameById(int id) {
SystemIncomeCategoriesEnum category = ID_MAP.get(id);
return category != null ? category.name : null;
}
/**
* 根据ID获取选中的图标
* @param id 枚举ID
* @return 对应的名称未找到返回null
*/
public static int getCheckedIconById(int id) {
SystemIncomeCategoriesEnum category = ID_MAP.get(id);
return category != null ? category.mipmapChecked : -1;
}
/**
* 根据名称获取ID
* @param name 枚举名称
* @return 对应的ID未找到返回-1
*/
public static int getIdByName(String name) {
SystemIncomeCategoriesEnum category = NAME_MAP.get(name);
return category != null ? category.id : -1;
}
}

View File

@ -1,165 +0,0 @@
package com.tfq.finances.finances.activity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.tfq.ad.ad.AdFeedUtils;
import com.tfq.ad.app.ADConstants;
import com.tfq.ad.app.AdApp;
import com.tfq.finances.finances.view.CircleProgressBarWithAnimation;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.network.api.finances.BudgetsService;
import com.tfq.finances.network.config.ApiCallback;
import com.tfq.finances.network.model.response.finances.budgets.BudgetsMonthResp;
import com.tfq.finances.network.model.response.finances.budgets.BudgetsResp;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.base.BaseActivity;
import com.tfq.library.utils.AddTextDialog;
import com.tfq.library.utils.AppUtil;
import com.tfq.library.utils.LogK;
import com.tfq.library.utils.ToasterUtil;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class Activity_Budgets extends BaseActivity {
private CircleProgressBarWithAnimation progressBar;
private TextView tv_month;
private TextView tv_residue;
private TextView tv_current;
private TextView tv_expenditure;
private FrameLayout fl_content;
@Override
protected int getLayoutId() {
return R.layout.activity_budgets_layout;
}
@Override
protected void initView() {
ImageView iv_back = findViewById(R.id.iv_back);
iv_back.setOnClickListener(this::onClick);
TextView tv_edit = findViewById(R.id.tv_edit);
tv_edit.setOnClickListener(this::onClick);
tv_residue = findViewById(R.id.tv_residue);
tv_current = findViewById(R.id.tv_current);
tv_expenditure = findViewById(R.id.tv_expenditure);
tv_month = findViewById(R.id.tv_month);
progressBar = findViewById(R.id.progressBar);
fl_content = findViewById(R.id.fl_content);
}
@SuppressLint("SetTextI18n")
@Override
protected void initData(Bundle savedInstanceState) {
setStatusBarDarkFont(true);
getMonthBudgetsInfo();
}
@Override
protected void onResume() {
super.onResume();
initAd();
}
private void initAd() {
AdFeedUtils.show_ad(this, AdApp.getInstance().getSlotConfig(ADConstants.AD_CODE_FEED1), fl_content, 20, "budgets", 3);
}
@Override
protected void onPause() {
super.onPause();
AdFeedUtils.cancelTag("budgets");
}
@SuppressLint("SetTextI18n")
private void getMonthBudgetsInfo( ) {
// 方式1使用SimpleDateFormat兼容所有API版本
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM", Locale.getDefault());
// 初始化
String currentDate = sdf.format(new Date());
tv_month.setText(currentDate.split("-")[1] + "月总预算");
new BudgetsService(this).getMonthBudgetsInfo(currentDate, new ApiCallback<BudgetsMonthResp>() {
@Override
public void onSuccess(BudgetsMonthResp response) {
if (response!=null) {
tv_residue.setText(String.valueOf(response.getRemainingAmount()));
tv_current.setText(String.valueOf(response.getAmount()));
tv_expenditure.setText(String.valueOf(response.getTotalExpenses()));
// 随机生成0-100的进度值
float randomProgress = 0;
if (response.getTotalExpenses().compareTo(response.getAmount()) > 0) {//支出大于预算
randomProgress = 100;
} else {
BigDecimal divide = response.getTotalExpenses().divide(response.getAmount(), 2, RoundingMode.HALF_UP);
randomProgress = divide.multiply(new BigDecimal(100)).floatValue();
}
// 随机生成0-100的进度值
// float randomProgress = (float) (Math.random() * 100);
// 带动画设置新进度
progressBar.setProgress(randomProgress, true);
}else {
// 带动画设置新进度
progressBar.setProgress(0, true);
}
}
@Override
public void onFailure(int errorCode, String errorMessage) {
}
});
}
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.iv_back) {
finish();
} else if (viewId == R.id.tv_edit) {
addBudgetsDialog();
}
}
private void addBudgetsDialog() {
new AddTextDialog(this, "", "设置预算", "budgets", new AddTextDialog.Listener() {
@Override
public void success(String name) {
LogK.e("name=" + name);
if (AppUtil.isNumeric(name)) {
// 方式1使用SimpleDateFormat兼容所有API版本
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM", Locale.getDefault());
// 初始化
String currentDate = sdf.format(new Date());
new BudgetsService(Activity_Budgets.this).setBudgetsInfo(new BigDecimal(name),currentDate, new ApiCallback<BudgetsResp>() {
@Override
public void onSuccess(BudgetsResp response) {
getMonthBudgetsInfo();
}
@Override
public void onFailure(int errorCode, String errorMessage) {
ToasterUtil.show(errorMessage);
}
});
}else {
ToasterUtil.show("输入不准确");
}
}
}).show();
}
}

View File

@ -1,129 +0,0 @@
package com.tfq.finances.finances.activity;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.finances.fragment.Fm_Page_Expenditure;
import com.tfq.finances.finances.fragment.Fm_Page_Income;
import com.tfq.library.adapter.MyFragmentStateAdapter;
import com.tfq.library.base.BaseActivity;
import com.tfq.library.utils.AppUtil;
import java.util.ArrayList;
import java.util.List;
public class Activity_Detail_Add extends BaseActivity {
private ViewPager2 viewPager;
private boolean isReqSuccessRefreshRv;
private View view1, view2;
@Override
protected int getLayoutId() {
return R.layout.activity_detail_add;
}
@Override
protected void initView() {
ImageView iv_back = findViewById(R.id.iv_back);
iv_back.setOnClickListener(this::onClick);
TextView tv_left = findViewById(R.id.tv_left);
tv_left.setOnClickListener(this::onClick);
TextView tv_right = findViewById(R.id.tv_right);
tv_right.setOnClickListener(this::onClick);
viewPager = findViewById(R.id.viewPager);
view1 = findViewById(R.id.view1);
view2 = findViewById(R.id.view2);
List<Fragment> fragmentList = new ArrayList<>();
fragmentList.add(new Fm_Page_Expenditure());
fragmentList.add(new Fm_Page_Income());
viewPager.setAdapter(new MyFragmentStateAdapter(getSupportFragmentManager(), getLifecycle(), fragmentList));
viewPager.registerOnPageChangeCallback(PagerChangeListener());
viewPager.setUserInputEnabled(false);
}
@Override
protected void initData(Bundle savedInstanceState) {
setStatusBarDarkFont(true);
}
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.iv_back) {
toFinish();
} else if (viewId == R.id.tv_left) {
viewPager.setCurrentItem(0);
view1.setVisibility(VISIBLE);
view2.setVisibility(GONE);
} else if (viewId == R.id.tv_right) {
viewPager.setCurrentItem(1);
view2.setVisibility(VISIBLE);
view1.setVisibility(GONE);
}
}
private void toFinish() {
if (isReqSuccessRefreshRv) {
isReqSuccessRefreshRv = false;
Intent intent = new Intent();
setResult(Activity.RESULT_OK, intent);
finish();
} else {
finish();
}
}
@Override
protected void onPause() {
super.onPause();
// AppUtil.closeKeyBoard(this);
}
public void setReqSuccessRefreshRv(boolean isReqSuccessRefreshRv) {
this.isReqSuccessRefreshRv = isReqSuccessRefreshRv;
}
@Override
public void onBackPressed() {
if (true) {
// 自定义拦截逻辑如显示确认对话框
toFinish();
} else {
super.onBackPressed(); // 默认返回行为
}
}
private ViewPager2.OnPageChangeCallback PagerChangeListener() {
return new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
switch (position) {
case 0:
break;
case 1:
break;
}
}
};
}
}

View File

@ -1,247 +0,0 @@
package com.tfq.finances.finances.activity;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tfq.ad.ad.AdFeedUtils;
import com.tfq.ad.app.ADConstants;
import com.tfq.ad.app.AdApp;
import com.tfq.finances.finances.adapter.TransactionsAdapter;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.network.api.finances.BillsService;
import com.tfq.finances.network.config.ApiCallback;
import com.tfq.finances.network.model.response.finances.transactions.BillsResp;
import com.tfq.finances.utils.BigDecimalUtils;
import com.tfq.finances.utils.androidpicker.CalculateUtils;
import com.tfq.finances.utils.androidpicker.DateMode;
import com.tfq.finances.utils.animation.AnimationClick;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.base.BaseActivity;
import com.tfq.library.utils.RecyclerViewHelper;
import com.tfq.library.utils.ToasterUtil;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import androidx.recyclerview.widget.RecyclerView;
public class Activity_Transactions extends BaseActivity {
private TextView tv_month;
private TextView tv_year;
private CalculateUtils calculateUtils;
private TextView tv_choose_year;
private RecyclerView recycler_view;
private TransactionsAdapter mAdapter;
private boolean isReqServer;
private LinearLayout ll_choose_year;
private TextView tv_balance, tv_income, tv_expenditure;
private TextView tv01, tv02, tv03, tv04, tv05, tv06, tv07;
private FrameLayout fl_content;
@Override
protected int getLayoutId() {
return R.layout.activity_transactions_layout;
}
@Override
protected void initView() {
ImageView iv_back = findViewById(R.id.iv_back);
iv_back.setOnClickListener(this::onClick);
tv_month = findViewById(R.id.tv_month);
tv_month.setOnClickListener(this::onClick);
tv_year = findViewById(R.id.tv_year);
tv_year.setOnClickListener(this::onClick);
ll_choose_year = findViewById(R.id.ll_choose_year);
ll_choose_year.setOnClickListener(this::onClick);
tv_choose_year = findViewById(R.id.tv_choose_year);
recycler_view = findViewById(R.id.recycler_view);
fl_content = findViewById(R.id.fl_content);
tv_balance = findViewById(R.id.tv_balance);
tv_income = findViewById(R.id.tv_income);
tv_expenditure = findViewById(R.id.tv_expenditure);
tv01 = findViewById(R.id.tv_01);
tv02 = findViewById(R.id.tv_02);
tv03 = findViewById(R.id.tv_03);
tv04 = findViewById(R.id.tv_04);
tv05 = findViewById(R.id.tv_05);
tv06 = findViewById(R.id.tv_06);
tv07 = findViewById(R.id.tv_07);
initRecyclerView();
}
@SuppressLint("SetTextI18n")
@Override
protected void initData(Bundle savedInstanceState) {
setStatusBarDarkFont(true);
checkLeft();
}
private void initAd() {
AdFeedUtils.show_ad(this, AdApp.getInstance().getSlotConfig(ADConstants.AD_CODE_FEED1), fl_content, 20, "budgets", 3);
}
@Override
protected void onPause() {
super.onPause();
AdFeedUtils.cancelTag("budgets");
}
private void getMonthBillsInfo(String currentDate) {
new BillsService(this).getMonthBillsInfo(currentDate, new ApiCallback<List<BillsResp>>() {
@Override
public void onSuccess(List<BillsResp> response) {
setAdapter(response);
}
@Override
public void onFailure(int errorCode, String errorMessage) {
ToasterUtil.show(errorMessage);
}
});
}
private void setAdapter(List<BillsResp> response) {
if (response != null && !response.isEmpty()) {
mAdapter.setNewData(response);
List<BigDecimal> balance = new ArrayList<>();
List<BigDecimal> expenditure = new ArrayList<>();
List<BigDecimal> income = new ArrayList<>();
for (int i = 0; i < response.size(); i++) {
balance.add(response.get(i).getBalance());
expenditure.add(response.get(i).getExpenditure());
income.add(response.get(i).getIncome());
}
BigDecimal sum = BigDecimalUtils.sum(expenditure);
tv_expenditure.setText(String.valueOf(sum));
BigDecimal sum2 = BigDecimalUtils.sum(income);
tv_income.setText(String.valueOf(sum2));
BigDecimal sum3 = BigDecimalUtils.sum(balance);
tv_balance.setText(String.valueOf(sum3));
AnimationClick.startScaleAnimation(recycler_view);
} else {
mAdapter.setNewData(new ArrayList<>());
tv_expenditure.setText("0");
tv_income.setText("0");
tv_balance.setText("0");
}
}
private void initRecyclerView() {
mAdapter = new TransactionsAdapter(R.layout.item_transactions_layout);
recycler_view.setAdapter(mAdapter);
RecyclerViewHelper.initRecyclerViewV(this, recycler_view, mAdapter);
}
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.iv_back) {
finish();
} else if (viewId == R.id.tv_month) {
checkLeft();
} else if (viewId == R.id.tv_year) {
checkRight();
} else if (viewId == R.id.ll_choose_year) {
if (!isReqServer) {
isReqServer = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
isReqServer = false;
}
}, 500);
calculateUtils.yearMonthDay(DateMode.YEAR);
calculateUtils.choose_date(tv_choose_year);
calculateUtils.setListener(new CalculateUtils.Listener() {
@Override
public void success(String year) {
getMonthBillsInfo(year);
}
});
}
}
}
private void checkLeft() {
tv_month.setTextColor(Color.parseColor("#FFFFFF"));
tv_year.setTextColor(Color.parseColor("#000000"));
tv_month.setSelected(true);
tv_year.setSelected(false);
ll_choose_year.setVisibility(View.VISIBLE);
// 方式1使用SimpleDateFormat兼容所有API版本
SimpleDateFormat sdf = new SimpleDateFormat("yyyy", Locale.getDefault());
// 初始化
calculateUtils = new CalculateUtils(this);
String currentDate = sdf.format(new Date());
tv_choose_year.setText(currentDate + "");
getMonthBillsInfo(currentDate);
tv01.setText("月份");
tv02.setText("月收入");
tv03.setText("月支出");
tv04.setText("月结余");
tv05.setText("月结余");
tv06.setText("月收入");
tv07.setText("月支出");
initAd();
}
private void checkRight() {
tv_month.setTextColor(Color.parseColor("#000000"));
tv_year.setTextColor(Color.parseColor("#FFFFFF"));
tv_month.setSelected(false);
tv_year.setSelected(true);
ll_choose_year.setVisibility(View.GONE);
getYearBillsInfo();
tv01.setText("年份");
tv02.setText("年收入");
tv03.setText("年支出");
tv04.setText("年结余");
tv05.setText("年结余");
tv06.setText("年收入");
tv07.setText("年支出");
initAd();
}
private void getYearBillsInfo() {
new BillsService(this).getYearBillsInfo(new ApiCallback<List<BillsResp>>() {
@Override
public void onSuccess(List<BillsResp> response) {
setAdapter(response);
}
@Override
public void onFailure(int errorCode, String errorMessage) {
ToasterUtil.show(errorMessage);
}
});
}
}

View File

@ -1,28 +0,0 @@
package com.tfq.finances.finances.adapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tfq.finances.app.App;
import com.tfq.finances.core.enums.CommonTypeOriginEnum;
import com.tfq.finances.finances.model.HeadConfig;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.main.model.TypeOriginConfig;
import com.tfq.finances.utils.animation.AnimationClick;
public class HeadAdapter extends BaseQuickAdapter<HeadConfig, BaseViewHolder> {
public HeadAdapter(int layoutID) {
super(layoutID);
}
@Override
protected void convert(BaseViewHolder helper, HeadConfig entity) {
helper.setImageResource(R.id.iv_head, entity.getHeadResource()!=-1?entity.getHeadResource(): R.mipmap.ic_head);
if (entity.getItemCheck()){
helper.setBackgroundRes(R.id.iv_head, entity.getHeadChecked());
AnimationClick.startScaleAnimation(helper.getView(R.id.iv_head));
}else {
helper.setBackgroundRes(R.id.iv_head, entity.getHeadCheck());
}
}
}

View File

@ -1,32 +0,0 @@
package com.tfq.finances.finances.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.network.model.response.finances.transactions.BillsResp;
public class TransactionsAdapter extends BaseQuickAdapter<BillsResp, BaseViewHolder> {
public TransactionsAdapter(int layoutID) {
super(layoutID);
}
@Override
protected void convert(BaseViewHolder helper, BillsResp entity) {
if (!TextUtils.isEmpty(entity.getTimeKey())) {
if (entity.getTimeKey().length() > 2) {
helper.setText(R.id.tv_timeKey, entity.getTimeKey() + "");
} else {
helper.setText(R.id.tv_timeKey, entity.getTimeKey() + "");
}
} else {
helper.setText(R.id.tv_timeKey, "未知");
}
helper.setText(R.id.tv_expenditure, String.valueOf(entity.getExpenditure()));
helper.setText(R.id.tv_income, String.valueOf(entity.getIncome()));
helper.setText(R.id.tv_balance, String.valueOf(entity.getBalance()));
}
}

View File

@ -1,396 +0,0 @@
package com.tfq.finances.finances.fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.github.gzuliyujiang.wheelpicker.annotation.DateMode;
import com.gyf.immersionbar.ImmersionBar;
import com.gyf.immersionbar.OnKeyboardListener;
import com.tfq.finances.core.enums.CommonTypeOriginEnum;
import com.tfq.finances.core.enums.SystemExpensesCategoriesEnum;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.main.adapter.TypeOriginAdapter;
import com.tfq.finances.main.model.TypeOriginConfig;
import com.tfq.finances.network.api.finances.CategoriesService;
import com.tfq.finances.network.config.ApiCallback;
import com.tfq.finances.network.config.token.TokenManager;
import com.tfq.finances.network.model.response.finances.categories.CategoriesAllResp;
import com.tfq.finances.network.model.response.finances.categories.CategoriesData;
import com.tfq.finances.utils.androidpicker.CalculateUtils;
import com.tfq.finances.utils.animation.AnimationClick;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.base.BaseFragment;
import com.tfq.library.utils.AddTextDialog;
import com.tfq.library.utils.AppUtil;
import com.tfq.library.utils.LogK;
import com.tfq.library.utils.RecyclerViewHelper;
import com.tfq.library.utils.ToasterUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static android.view.View.VISIBLE;
/**
* 支出
*/
public class Fm_Page_Expenditure extends BaseFragment {
private LinearLayout ll_keyboard;
private LinearLayout ll, ll_today;
private EditText et_remark;
private TextView tv_0, tv_1, tv_2, tv_3, tv_4, tv_5, tv_6, tv_7, tv_8, tv_9, tv_dot;
private TextView tv_num1, tv_num2, tv_symbol1, tv_result, tv_add, tv_subtract, tv_complete, tv_today;
private ImageView iv_delete, iv_today, iv_hide_keybord;
private long lastEventTime = 0;
private CalculateUtils calculateUtils;
private RecyclerView recycler_view;
private int old_checked_item = 0;
private TypeOriginAdapter mAdapter;
@Override
protected int getLayoutId() {
return R.layout.fm_page_expenditure;
}
@Override
protected void initView() {
ll_keyboard = findViewBy_Id(R.id.ll_keyboard);
ll = findViewBy_Id(R.id.ll);
tv_result = findViewBy_Id(R.id.tv_result);
et_remark = findViewBy_Id(R.id.et_remark);
tv_7 = findViewBy_Id(R.id.tv_7);
tv_8 = findViewBy_Id(R.id.tv_8);
tv_9 = findViewBy_Id(R.id.tv_9);
ll_today = findViewBy_Id(R.id.ll_today);
tv_today = findViewBy_Id(R.id.tv_today);
iv_today = findViewBy_Id(R.id.iv_today);
tv_4 = findViewBy_Id(R.id.tv_4);
tv_5 = findViewBy_Id(R.id.tv_5);
tv_6 = findViewBy_Id(R.id.tv_6);
tv_add = findViewBy_Id(R.id.tv_add);
tv_1 = findViewBy_Id(R.id.tv_1);
tv_2 = findViewBy_Id(R.id.tv_2);
tv_3 = findViewBy_Id(R.id.tv_3);
tv_subtract = findViewBy_Id(R.id.tv_subtract);
tv_dot = findViewBy_Id(R.id.tv_dot);
tv_0 = findViewBy_Id(R.id.tv_0);
iv_delete = findViewBy_Id(R.id.iv_delete);
tv_complete = findViewBy_Id(R.id.tv_complete);
tv_num1 = findViewBy_Id(R.id.tv_num1);
tv_num2 = findViewBy_Id(R.id.tv_num2);
tv_symbol1 = findViewBy_Id(R.id.tv_symbol1);
iv_hide_keybord = findViewBy_Id(R.id.iv_hide_keybord);
ll.setVisibility(View.GONE);
recycler_view = findViewBy_Id(R.id.recycler_view);
initListener();
}
private void initListener() {
tv_7.setOnClickListener(this::onClick);
tv_8.setOnClickListener(this::onClick);
tv_9.setOnClickListener(this::onClick);
ll_today.setOnClickListener(this::onClick);
tv_4.setOnClickListener(this::onClick);
tv_5.setOnClickListener(this::onClick);
tv_6.setOnClickListener(this::onClick);
tv_add.setOnClickListener(this::onClick);
tv_1.setOnClickListener(this::onClick);
tv_2.setOnClickListener(this::onClick);
tv_3.setOnClickListener(this::onClick);
tv_subtract.setOnClickListener(this::onClick);
tv_dot.setOnClickListener(this::onClick);
tv_0.setOnClickListener(this::onClick);
iv_delete.setOnClickListener(this::onClick);
tv_complete.setOnClickListener(this::onClick);
iv_hide_keybord.setOnClickListener(this::onClick);
}
@Override
protected void initData(Bundle savedInstanceState) {
ImmersionBar.with(this)
.statusBarDarkFont(true)
.navigationBarColor(BaseConstants.navigationBarColor)
.keyboardEnable(true)
.setOnKeyboardListener(new OnKeyboardListener() {
@Override
public void onKeyboardChange(boolean isPopup, int keyboardHeight) {
LogK.e("isPopup=" + isPopup); //isPopup为true软键盘弹出为false软键盘关闭
if (System.currentTimeMillis() - lastEventTime > 100) { // 100ms间隔阈值
lastEventTime = System.currentTimeMillis();
if (isPopup) {
ll_keyboard.setVisibility(View.GONE);
} else {
ll_keyboard.setVisibility(View.VISIBLE);
}
}
}
}).init();
// 初始化
calculateUtils = new CalculateUtils(getActivity());
calculateUtils.initialize(1, tv_complete, tv_num1, tv_num2, tv_symbol1, tv_result, tv_today, et_remark);
initRecyclerView();
reqCategoriesAll();
}
private void initRecyclerView() {
mAdapter = new TypeOriginAdapter(R.layout.item_type_origin_layout);
recycler_view.setAdapter(mAdapter);
GridLayoutManager manager = new GridLayoutManager(getActivity(), 4, RecyclerView.VERTICAL, false);
RecyclerViewHelper.initRecyclerViewV(getActivity(), recycler_view, mAdapter);
recycler_view.setLayoutManager(manager);
List<TypeOriginConfig> typeOriginConfigs = getTypeOriginConfigs();
mAdapter.setNewData(typeOriginConfigs);
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@SuppressLint("NotifyDataSetChanged")
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
if (getOldCheckedItem() != position) {
if (mAdapter.getData().get(position).getTypeOriginId() == -1) {//点击自定义应该弹窗并且选中,若取消弹窗,应该返回之前的老按钮
addTypeDialog();
} else {
setAndRefresh(position);
calculateUtils.setOriginBean(mAdapter.getData().get(position));
refreshRv(position);
ll.setVisibility(View.VISIBLE);
}
} else {
refreshRv(position);
ll.setVisibility(View.VISIBLE);
}
}
});
AnimationClick.startScaleAnimation(recycler_view);
calculateUtils.setOriginBean(mAdapter.getData().get(0));
}
private void refreshRv(int position) {
RecyclerView.LayoutManager layoutManager = recycler_view.getLayoutManager();
// 或者方法3使用scrollToPositionWithOffset
if (layoutManager instanceof LinearLayoutManager) {
View view = layoutManager.findViewByPosition(position);
if (view != null) {
LogK.e("recycler_view.getHeight()1=" + recycler_view.getHeight());
int offset = 200;
if (ll.getVisibility() == VISIBLE) {
offset = recycler_view.getHeight() / 2 - view.getHeight() / 2;
} /*else {
ll.setVisibility(VISIBLE);
// 或者方法3使用scrollToPositionWithOffset
offset = recycler_view.getHeight() / 2 - ll.getHeight() / 2 - view.getHeight() / 2;
}*/
((LinearLayoutManager) layoutManager).scrollToPositionWithOffset(position, offset);
}
}
}
private void reqCategoriesAll() {
TokenManager instance = TokenManager.getInstance(getActivity());
new CategoriesService(getActivity()).getCategoriesList(instance.getUserId(), 1, new ApiCallback<CategoriesAllResp>() {
@Override
public void onSuccess(CategoriesAllResp response) {
List<TypeOriginConfig> list = new ArrayList<>();
if (response.getUser() != null && !response.getUser().isEmpty()) {
for (CategoriesData categoriesData : Objects.requireNonNull(response.getUser())) {
String name = categoriesData.getName();
int id = categoriesData.getId();
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.USER.getName());
config.setTypeOriginId(id);
config.setTypeOriginName(name);
config.setTypeOriginIdCheck(R.mipmap.ic_zdy_check);
config.setTypeOriginIdChecked(R.mipmap.ic_zdy_checked);
list.add(config);
}
}
addZdyType(list);
if (getActivity() != null) {
getActivity().runOnUiThread(() -> {
mAdapter.addData(list);
});
}
}
@Override
public void onFailure(int errorCode, String errorMessage) {
ToasterUtil.show(errorMessage);
}
});
}
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.tv_7) {
calculateUtils.press("7", tv_7);
} else if (viewId == R.id.tv_8) {
calculateUtils.press("8", tv_8);
} else if (viewId == R.id.tv_9) {
calculateUtils.press("9", tv_9);
} else if (viewId == R.id.ll_today) {
calculateUtils.yearMonthDay(DateMode.YEAR_MONTH);
calculateUtils.choose_date(tv_today, iv_today);
} else if (viewId == R.id.tv_4) {
calculateUtils.press("4", tv_4);
} else if (viewId == R.id.tv_5) {
calculateUtils.press("5", tv_5);
} else if (viewId == R.id.tv_6) {
calculateUtils.press("6", tv_6);
} else if (viewId == R.id.tv_add) {
calculateUtils.symbol("+");
} else if (viewId == R.id.tv_1) {
calculateUtils.press("1", tv_1);
} else if (viewId == R.id.tv_2) {
calculateUtils.press("2", tv_2);
} else if (viewId == R.id.tv_3) {
calculateUtils.press("3", tv_3);
} else if (viewId == R.id.tv_subtract) {
calculateUtils.symbol("-");
} else if (viewId == R.id.tv_dot) {
calculateUtils.press(".", tv_dot);
} else if (viewId == R.id.tv_0) {
calculateUtils.press("0", tv_0);
} else if (viewId == R.id.iv_delete) {
calculateUtils.onClickDelete();
} else if (viewId == R.id.tv_complete) {
if (tv_complete.getText().toString().equals("完成")){
ll.setVisibility(View.GONE);
AppUtil.closeKeyBoard(ll);
}
calculateUtils.onClickFinish();
} else if (viewId == R.id.iv_hide_keybord) {
ll.setVisibility(View.GONE);
AppUtil.closeKeyBoard(ll);
}
}
private void addZdyType(List<TypeOriginConfig> list) {
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.USER.getName());
config.setTypeOriginId(-1);
config.setTypeOriginName("自定义");
config.setTypeOriginIdCheck(R.mipmap.ic_zdy_check);
config.setTypeOriginIdChecked(R.mipmap.ic_zdy_checked);
list.add(config);
}
private void addZdyResponse(String response, String name) {
List<TypeOriginConfig> data = mAdapter.getData();
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.USER.getName());
config.setTypeOriginId(Integer.parseInt(response));
config.setTypeOriginName(name);
config.setTypeOriginIdCheck(R.mipmap.ic_zdy_check);
config.setTypeOriginIdChecked(R.mipmap.ic_zdy_checked);
data.add(data.size() - 1, config);
setAndRefreshNoCheck(data.size() - 2);
// refreshRv(getOldCheckedItem());
}
@SuppressLint("NotifyDataSetChanged")
private void setAndRefresh(int position) {
mAdapter.getData().get(position).setItemCheck(true);
mAdapter.getData().get(getOldCheckedItem()).setItemCheck(false);
setOldCheckedItem(position);
mAdapter.notifyDataSetChanged();
calculateUtils.setOriginBean(mAdapter.getData().get(position));
}
@SuppressLint("NotifyDataSetChanged")
private void setAndRefreshNoCheck(int position) {
mAdapter.notifyDataSetChanged();
}
private void addTypeDialog() {
new AddTextDialog(getActivity(), new AddTextDialog.ListenerFail() {
@Override
public void success(String name) {
LogK.e("success");
new CategoriesService(getActivity()).addCategories(1, name, "", new ApiCallback<String>() {
@Override
public void onSuccess(String response) {//response 31370 是id
if (getActivity() != null) {
getActivity().runOnUiThread(() -> {
addZdyResponse(response, name);
});
}
}
@Override
public void onFailure(int errorCode, String errorMessage) {
ToasterUtil.show(errorMessage);
}
});
}
@SuppressLint("NotifyDataSetChanged")
@Override
public void callCancel() {
LogK.e("callCancel");
}
}).show();
}
@NonNull
private List<TypeOriginConfig> getTypeOriginConfigs() {
List<TypeOriginConfig> typeOriginConfigs = new ArrayList<>();
List<SystemExpensesCategoriesEnum> categoriesEnumList = SystemExpensesCategoriesEnum.getAll();
for (int i = 0; i < categoriesEnumList.size(); i++) {
SystemExpensesCategoriesEnum systemExpensesCategoriesEnum = categoriesEnumList.get(i);
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.SYSTEM.getName());
config.setTypeOriginId(systemExpensesCategoriesEnum.getId());
config.setTypeOriginName(systemExpensesCategoriesEnum.getName());
config.setTypeOriginIdCheck(systemExpensesCategoriesEnum.getIconUnchecked());
config.setTypeOriginIdChecked(systemExpensesCategoriesEnum.getIconChecked());
if (i == 0) {
config.setItemCheck(true);
}
typeOriginConfigs.add(config);
}
return typeOriginConfigs;
}
public int getOldCheckedItem() {
return old_checked_item;
}
public void setOldCheckedItem(int old_checked_item) {
this.old_checked_item = old_checked_item;
}
}

View File

@ -1,384 +0,0 @@
package com.tfq.finances.finances.fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.github.gzuliyujiang.wheelpicker.annotation.DateMode;
import com.gyf.immersionbar.ImmersionBar;
import com.gyf.immersionbar.OnKeyboardListener;
import com.tfq.finances.core.enums.CommonTypeOriginEnum;
import com.tfq.finances.core.enums.SystemIncomeCategoriesEnum;
import com.tfq.finances.jzrcj.R;
import com.tfq.finances.main.adapter.TypeOriginAdapter;
import com.tfq.finances.main.model.TypeOriginConfig;
import com.tfq.finances.network.api.finances.CategoriesService;
import com.tfq.finances.network.config.ApiCallback;
import com.tfq.finances.network.config.token.TokenManager;
import com.tfq.finances.network.model.response.finances.categories.CategoriesAllResp;
import com.tfq.finances.network.model.response.finances.categories.CategoriesData;
import com.tfq.finances.utils.androidpicker.CalculateUtils;
import com.tfq.finances.utils.animation.AnimationClick;
import com.tfq.library.app.BaseConstants;
import com.tfq.library.base.BaseFragment;
import com.tfq.library.utils.AddTextDialog;
import com.tfq.library.utils.AppUtil;
import com.tfq.library.utils.LogK;
import com.tfq.library.utils.RecyclerViewHelper;
import com.tfq.library.utils.ToasterUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static android.view.View.VISIBLE;
/**
* 支出
*/
public class Fm_Page_Income extends BaseFragment {
private LinearLayout ll, ll_today;
private EditText et_remark;
private TextView tv_0, tv_1, tv_2, tv_3, tv_4, tv_5, tv_6, tv_7, tv_8, tv_9, tv_dot;
private TextView tv_num1, tv_num2, tv_symbol1, tv_result, tv_add, tv_subtract, tv_complete, tv_today;
private ImageView iv_delete, iv_today, iv_hide_keybord;
private LinearLayout ll_keyboard;
private long lastEventTime = 0;
private CalculateUtils calculateUtils;
private TypeOriginAdapter mAdapter;
private RecyclerView recycler_view;
private int old_checked_item = 0;
@Override
protected int getLayoutId() {
return R.layout.fm_page_income;
}
@Override
protected void initView() {
ll_keyboard = findViewBy_Id(R.id.ll_keyboard);
ll = findViewBy_Id(R.id.ll);
tv_result = findViewBy_Id(R.id.tv_result);
et_remark = findViewBy_Id(R.id.et_remark);
tv_7 = findViewBy_Id(R.id.tv_7);
tv_8 = findViewBy_Id(R.id.tv_8);
tv_9 = findViewBy_Id(R.id.tv_9);
ll_today = findViewBy_Id(R.id.ll_today);
tv_today = findViewBy_Id(R.id.tv_today);
iv_today = findViewBy_Id(R.id.iv_today);
tv_4 = findViewBy_Id(R.id.tv_4);
tv_5 = findViewBy_Id(R.id.tv_5);
tv_6 = findViewBy_Id(R.id.tv_6);
tv_add = findViewBy_Id(R.id.tv_add);
tv_1 = findViewBy_Id(R.id.tv_1);
tv_2 = findViewBy_Id(R.id.tv_2);
tv_3 = findViewBy_Id(R.id.tv_3);
tv_subtract = findViewBy_Id(R.id.tv_subtract);
tv_dot = findViewBy_Id(R.id.tv_dot);
tv_0 = findViewBy_Id(R.id.tv_0);
iv_delete = findViewBy_Id(R.id.iv_delete);
tv_complete = findViewBy_Id(R.id.tv_complete);
tv_num1 = findViewBy_Id(R.id.tv_num1);
tv_num2 = findViewBy_Id(R.id.tv_num2);
tv_symbol1 = findViewBy_Id(R.id.tv_symbol1);
iv_hide_keybord = findViewBy_Id(R.id.iv_hide_keybord);
ll.setVisibility(View.GONE);
recycler_view = findViewBy_Id(R.id.recycler_view);
initListener();
}
private void initListener() {
tv_7.setOnClickListener(this::onClick);
tv_8.setOnClickListener(this::onClick);
tv_9.setOnClickListener(this::onClick);
ll_today.setOnClickListener(this::onClick);
tv_4.setOnClickListener(this::onClick);
tv_5.setOnClickListener(this::onClick);
tv_6.setOnClickListener(this::onClick);
tv_add.setOnClickListener(this::onClick);
tv_1.setOnClickListener(this::onClick);
tv_2.setOnClickListener(this::onClick);
tv_3.setOnClickListener(this::onClick);
tv_subtract.setOnClickListener(this::onClick);
tv_dot.setOnClickListener(this::onClick);
tv_0.setOnClickListener(this::onClick);
iv_delete.setOnClickListener(this::onClick);
tv_complete.setOnClickListener(this::onClick);
iv_hide_keybord.setOnClickListener(this::onClick);
}
@Override
protected void initData(Bundle savedInstanceState) {
ImmersionBar.with(this)
.statusBarDarkFont(true)
.navigationBarColor(BaseConstants.navigationBarColor)
.keyboardEnable(true)
.setOnKeyboardListener(new OnKeyboardListener() {
@Override
public void onKeyboardChange(boolean isPopup, int keyboardHeight) {
LogK.e("isPopup=" + isPopup); //isPopup为true软键盘弹出为false软键盘关闭
if (System.currentTimeMillis() - lastEventTime > 100) { // 100ms间隔阈值
lastEventTime = System.currentTimeMillis();
if (isPopup) {
ll_keyboard.setVisibility(View.GONE);
} else {
ll_keyboard.setVisibility(View.VISIBLE);
}
}
}
}).init();
// 初始化
calculateUtils = new CalculateUtils(getActivity());
calculateUtils.initialize(2, tv_complete, tv_num1, tv_num2, tv_symbol1, tv_result, tv_today, et_remark);
initRecyclerView();
reqCategoriesAll();
}
private void initRecyclerView() {
mAdapter = new TypeOriginAdapter(R.layout.item_type_origin_layout);
recycler_view.setAdapter(mAdapter);
GridLayoutManager manager = new GridLayoutManager(getActivity(), 4, RecyclerView.VERTICAL, false);
RecyclerViewHelper.initRecyclerViewV(getActivity(), recycler_view, mAdapter);
recycler_view.setLayoutManager(manager);
List<TypeOriginConfig> typeOriginConfigs = getTypeOriginConfigs();
mAdapter.setNewData(typeOriginConfigs);
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@SuppressLint("NotifyDataSetChanged")
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
if (getOldCheckedItem() != position) {
if (mAdapter.getData().get(position).getTypeOriginId() == -1) {//点击自定义应该弹窗并且选中,若取消弹窗,应该返回之前的老按钮
addTypeDialog();
} else {
setAndRefresh(position);
calculateUtils.setOriginBean(mAdapter.getData().get(position));
refreshRv(position);
ll.setVisibility(View.VISIBLE);
}
}
}
});
AnimationClick.startScaleAnimation(recycler_view);
calculateUtils.setOriginBean(mAdapter.getData().get(0));
}
private void refreshRv(int position) {
RecyclerView.LayoutManager layoutManager = recycler_view.getLayoutManager();
// 或者方法3使用scrollToPositionWithOffset
if (layoutManager instanceof LinearLayoutManager) {
View view = layoutManager.findViewByPosition(position);
if (view != null) {
LogK.e("recycler_view.getHeight()1=" + recycler_view.getHeight());
int offset = 800;
if (ll.getVisibility() == VISIBLE) {
offset = recycler_view.getHeight() / 2 - view.getHeight() / 2;
} else {
ll.setVisibility(VISIBLE);
// 或者方法3使用scrollToPositionWithOffset
offset = recycler_view.getHeight() / 2 - ll.getHeight() / 2 - view.getHeight() / 2;
}
((LinearLayoutManager) layoutManager).scrollToPositionWithOffset(position, offset);
}
}
}
private void reqCategoriesAll() {
TokenManager instance = TokenManager.getInstance(getActivity());
new CategoriesService(getActivity()).getCategoriesList(instance.getUserId(), 2, new ApiCallback<CategoriesAllResp>() {
@Override
public void onSuccess(CategoriesAllResp response) {
List<TypeOriginConfig> list = new ArrayList<>();
if (response.getUser() != null && !response.getUser().isEmpty()) {
for (CategoriesData categoriesData : Objects.requireNonNull(response.getUser())) {
String name = categoriesData.getName();
int id = categoriesData.getId();
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.USER.getName());
config.setTypeOriginId(id);
config.setTypeOriginName(name);
config.setTypeOriginIdCheck(R.mipmap.ic_zdy_check);
config.setTypeOriginIdChecked(R.mipmap.ic_zdy_checked);
list.add(config);
}
}
addZdyType(list);
if (getActivity() != null) {
getActivity().runOnUiThread(() -> {
mAdapter.addData(list);
});
}
}
@Override
public void onFailure(int errorCode, String errorMessage) {
}
});
}
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.tv_7) {
calculateUtils.press("7", tv_7);
} else if (viewId == R.id.tv_8) {
calculateUtils.press("8", tv_8);
} else if (viewId == R.id.tv_9) {
calculateUtils.press("9", tv_9);
} else if (viewId == R.id.ll_today) {
calculateUtils.yearMonthDay(DateMode.YEAR_MONTH);
calculateUtils.choose_date(tv_today, iv_today);
} else if (viewId == R.id.tv_4) {
calculateUtils.press("4", tv_4);
} else if (viewId == R.id.tv_5) {
calculateUtils.press("5", tv_5);
} else if (viewId == R.id.tv_6) {
calculateUtils.press("6", tv_6);
} else if (viewId == R.id.tv_add) {
calculateUtils.symbol("+");
} else if (viewId == R.id.tv_1) {
calculateUtils.press("1", tv_1);
} else if (viewId == R.id.tv_2) {
calculateUtils.press("2", tv_2);
} else if (viewId == R.id.tv_3) {
calculateUtils.press("3", tv_3);
} else if (viewId == R.id.tv_subtract) {
calculateUtils.symbol("-");
} else if (viewId == R.id.tv_dot) {
calculateUtils.press(".", tv_dot);
} else if (viewId == R.id.tv_0) {
calculateUtils.press("0", tv_0);
} else if (viewId == R.id.iv_delete) {
calculateUtils.onClickDelete();
} else if (viewId == R.id.tv_complete) {
if (tv_complete.getText().toString().equals("完成")){
ll.setVisibility(View.GONE);
AppUtil.closeKeyBoard(ll);
}
calculateUtils.onClickFinish();
} else if (viewId == R.id.iv_hide_keybord) {
ll.setVisibility(View.GONE);
AppUtil.closeKeyBoard(ll);
}
}
private void addZdyType(List<TypeOriginConfig> list) {
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.USER.getName());
config.setTypeOriginId(-1);
config.setTypeOriginName("自定义");
config.setTypeOriginIdCheck(R.mipmap.ic_zdy_check);
config.setTypeOriginIdChecked(R.mipmap.ic_zdy_checked);
list.add(config);
}
private void addZdyResponse(String response, String name) {
List<TypeOriginConfig> data = mAdapter.getData();
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.USER.getName());
config.setTypeOriginId(Integer.parseInt(response));
config.setTypeOriginName(name);
config.setTypeOriginIdCheck(R.mipmap.ic_zdy_check);
config.setTypeOriginIdChecked(R.mipmap.ic_zdy_checked);
data.add(data.size() - 1, config);
setAndRefresh(data.size() - 2);
refreshRv(getOldCheckedItem());
}
@SuppressLint("NotifyDataSetChanged")
private void setAndRefresh(int position) {
mAdapter.getData().get(position).setItemCheck(true);
mAdapter.getData().get(getOldCheckedItem()).setItemCheck(false);
setOldCheckedItem(position);
mAdapter.notifyDataSetChanged();
calculateUtils.setOriginBean(mAdapter.getData().get(position));
}
private void addTypeDialog() {
new AddTextDialog(getActivity(), new AddTextDialog.ListenerFail() {
@Override
public void success(String name) {
LogK.e("success");
new CategoriesService(getActivity()).addCategories(2, name, "", new ApiCallback<String>() {
@Override
public void onSuccess(String response) {//response 31370 是id
addZdyResponse(response, name);
}
@Override
public void onFailure(int errorCode, String errorMessage) {
ToasterUtil.show(errorMessage);
}
});
}
@SuppressLint("NotifyDataSetChanged")
@Override
public void callCancel() {
LogK.e("callCancel");
}
}).show();
}
@NonNull
private List<TypeOriginConfig> getTypeOriginConfigs() {
List<TypeOriginConfig> typeOriginConfigs = new ArrayList<>();
List<SystemIncomeCategoriesEnum> categoriesEnumList = SystemIncomeCategoriesEnum.getAll();
for (int i = 0; i < categoriesEnumList.size(); i++) {
SystemIncomeCategoriesEnum systemIncomeCategoriesEnum = categoriesEnumList.get(i);
TypeOriginConfig config = new TypeOriginConfig();
config.setType(CommonTypeOriginEnum.SYSTEM.getName());
config.setTypeOriginId(systemIncomeCategoriesEnum.getId());
config.setTypeOriginName(systemIncomeCategoriesEnum.getName());
config.setTypeOriginIdCheck(systemIncomeCategoriesEnum.getIconUnchecked());
config.setTypeOriginIdChecked(systemIncomeCategoriesEnum.getIconChecked());
if (i == 0) {
config.setItemCheck(true);
}
typeOriginConfigs.add(config);
}
return typeOriginConfigs;
}
public int getOldCheckedItem() {
return old_checked_item;
}
public void setOldCheckedItem(int old_checked_item) {
this.old_checked_item = old_checked_item;
}
}

Some files were not shown because too many files have changed in this diff Show More