diff --git a/README.md b/README.md index 52f9f75e..8cba5381 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hunheappkuangjia -混合移动应用框架APP-Android20 +混合移动应用框架APP-Android21 ### 1.ANROOMCrashActivity:验证APP压力测试 ### @@ -337,7 +337,7 @@
api 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.3.0' 监听键盘弹出过程
// https://github.com/getActivity/ToastUtils
api 'com.hjq:toast:5.8' -
// https://github.com/everhad/AndroidRatingStar 评论星星 +
// https://github.com/everhad/AndroidRatingStar 评论星星 PingfenMainActivity
api 'com.github.everhad:AndroidRatingStar:v1.0.4'
// https://github.com/li-xiaojun/XPopup 弹出框
api 'com.lxj:xpopup:1.8.4' @@ -380,7 +380,7 @@
api project(':commonlibs:hunheku:libapppay')
// Glide 4.0以上
api librarys.glide47 -
api project(':commonlibs:hunheku:libglide47') +
api project(':commonlibs:common:libglide47')
//TODO other libs
// https://github.com/crazyandcoder/citypicker 城市选择器
// pi 'liji.library.dev:citypickerview:4.3.2' @@ -395,7 +395,7 @@
api project(':commonlibs:yewulibs:slbota')
// https://github.com/ikew0ng/SwipeBackLayout
// api 'me.imid.swipebacklayout.lib:library:1.1.0' 关闭页面IOS效果 -
api project(':commonlibs:yewulibs:slbswipebacklayout') +
api project(':commonlibs:common:libswipebacklayout')
// slbwifi WIFI选择器
api project(':commonlibs:yewulibs:slbwifi')
// https://github.com/scwang90/SmartRefreshLayout 下拉刷新上拉加载 @@ -437,6 +437,8 @@ ### 99.commonlibs:dkplayer:DK播放器支持推流 ### ### 100.slbyanzheng:指纹登录组件 +### +### 101.HuxiAct:布局加载组件 diff --git a/build.gradle b/build.gradle index ce4e377a..2231d9a3 100644 --- a/build.gradle +++ b/build.gradle @@ -6,10 +6,11 @@ buildscript { google() mavenLocal() mavenCentral() - maven { url "https://jitpack.io" } + maven { url "https://www.jitpack.io" } maven { url 'https://maven.aliyun.com/repository/public/' } maven { url "http://mvn.mob.com/android" } - maven {url "http://maven.rongcloud.cn/repository/maven-releases/"} + maven { url "http://maven.rongcloud.cn/repository/maven-releases/" } + maven { url 'https://gitee.com/pgyer2020/analytics/raw/master' } // 备用仓库 maven { url 'http://developer.huawei.com/repo/' } } dependencies { @@ -31,10 +32,11 @@ allprojects { google() mavenLocal() mavenCentral() - maven { url "https://jitpack.io" } + maven { url "https://www.jitpack.io" } maven { url 'https://maven.aliyun.com/repository/public/' } maven { url "http://mvn.mob.com/android" } - maven {url "http://maven.rongcloud.cn/repository/maven-releases/"} + maven { url "http://maven.rongcloud.cn/repository/maven-releases/" } + maven { url 'https://gitee.com/pgyer2020/analytics/raw/master' } // 备用仓库 maven { url 'http://developer.huawei.com/repo/' } // flatDir { diff --git a/buildconfig.gradle b/buildconfig.gradle index 0a853961..b8043577 100644 --- a/buildconfig.gradle +++ b/buildconfig.gradle @@ -7,16 +7,16 @@ ext { supportLibVersion = '30.0.0' // 灯塔版本号 - dengtaversionCode = 10000 - dengtaversionName = "1.0.0.0" + dengtaversionCode = 20000 + dengtaversionName = "2.0.0.0" // 大屏版本号 - dapingversionCode = 10000 - dapingversionName = "1.0.0.0" + dapingversionCode = 20000 + dapingversionName = "2.0.0.0" // applicationId = "com.fosung.lighthouse" - appversionCode = 1000 - appversionName = "1.0.0.0" + appversionCode = 2000 + appversionName = "2.0.0.0" versionNamePrefixT = "_T_V" versionNamePrefixY = "_Y_V" @@ -74,7 +74,7 @@ retrofitgconverterscalars : "com.squareup.retrofit2:converter-scalars:2. // ------------- 图片加载 ------------- fresco : "com.facebook.fresco:fresco:0.11.0", animatedGif : "com.facebook.fresco:animated-gif:0.12.0", -picasso : "com.squareup.picasso:picasso:2.5.2", +picasso : "com.squareup.picasso:picasso:2.71828", photoView : "com.github.chrisbanes:PhotoView:2.1.3", nineoldandroids : "com.nineoldandroids:library:2.4.0", zxing : "com.google.zxing:core:3.2.1", diff --git a/commonlibs/baselibrary/build.gradle b/commonlibs/baselibrary/build.gradle index 9744ce29..7429cd72 100644 --- a/commonlibs/baselibrary/build.gradle +++ b/commonlibs/baselibrary/build.gradle @@ -5,20 +5,11 @@ apply from: './../../commonlibs1.gradle' def librarys = rootProject.ext.dependencies //依赖 dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - api project(':commonlibs:hunheku:libutils') + api project(':commonlibs:common:libutils') + api project(':commonlibs:common:libbase') // 网络请求 - api project(':commonlibs:hunheku:libmvp') - api project(':commonlibs:hunheku:libretrofit') - // webView - api project(':commonlibs:hunheku:libagentweb-core') - api project(':commonlibs:hunheku:libagentweb-filechooser') -// api 'com.just.agentweb:agentweb-androidx:4.1.4' // (必选) -// api 'com.just.agentweb:filechooser-androidx:4.1.4'// (可选) -// api 'com.download.library:downloader-androidx:4.1.4'// (可选) - // webView - api project(':commonlibs:hunheku:libwebview') - // 权限 - api project(':commonlibs:hunheku:librararyforfileprovdider') + api project(':commonlibs:common:libmvp') + api project(':commonlibs:common:libretrofit') // app升级 api project(':commonlibs:hunheku:libupdateapputilsold') // https://github.com/teprinciple/UpdateAppUtils @@ -29,28 +20,11 @@ dependencies { api 'com.mikepenz:community-material-typeface:1.8.36.1@aar' // https://github.com/drakeet/MultiType api 'me.drakeet.multitype:multitype:3.4.4' - // https://github.com/CymChad/BaseRecyclerViewAdapterHelper - api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.40' // https://github.com/jaredrummler/MaterialSpinner api 'com.jaredrummler:material-spinner:1.2.5' - // https://github.com/kyleduo/SwitchButton -// api 'com.kyleduo.switchbutton:library:2.0.3' // https://github.com/drawthink/ExpandableRecyclerView // api 'com.drawthink:expandable-recyclerview:0.0.3' api project(':commonlibs:hunheku:libexpandablerecyclerview') - // https://github.com/BolexLiu/AutoEx -// api 'com.github.BolexLiu.AutoEx:AutoEx-Lib-No-Op:v1.0.8' - // https://github.com/Jzvd/JZVideo -// api 'cn.jzvd:jiaozivideoplayer:7.6.0' - // https://github.com/HuanHaiLiuXin/CoolViewPager - api 'com.github.HuanHaiLiuXin:CoolViewPager:v1.0.0' - // https://github.com/airbnb/lottie-android - api 'com.airbnb.android:lottie:3.4.2' - // https://github.com/greenrobot/EventBus - api 'org.greenrobot:eventbus:3.1.1' - // https://github.com/Meituan-Dianping/walle -// api 'com.meituan.android.walle:library:1.1.7' -// api 'com.github.GeekCodesTeam:walle:1.1.7' // https://github.com/BolexLiu/PressScanCode api 'com.github.BolexLiu:PressScanCode:v1.0.0' // https://github.com/ethanhua/Skeleton @@ -61,13 +35,11 @@ dependencies { // api 'com.larswerkman:lobsterpicker:1.0.1' // https://github.com/square/leakcanary api librarys.leakcanaryAndroid - // https://github.com/gongwen/MarqueeViewLibrary -// api 'com.gongwen:marqueelibrary:1.1.3' // https://github.com/KunMinX/Linkage-RecyclerView // api 'com.kunminx.linkage:linkage-recyclerview:2.3.5' api project(':commonlibs:hunheku:liblinkagerecyclerview') // https://github.com/LuckSiege/PictureSelector - api 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.1' + api project(':commonlibs:yewulibs:slbpictureselector') // https://github.com/dongjunkun/DropDownMenu api 'com.github.dongjunkun:DropDownMenu:1.0.4' // https://github.com/jgilfelt/SystemBarTint @@ -99,25 +71,24 @@ dependencies { api 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.3.0' // https://github.com/getActivity/ToastUtils api 'com.github.getActivity:ToastUtils:9.2' - // https://github.com/everhad/AndroidRatingStar - api 'com.github.everhad:AndroidRatingStar:v1.0.4' // https://github.com/li-xiaojun/XPopup api 'com.github.li-xiaojun:XPopup:2.3.4' // https://github.com/meetsl/SCardView-master - api 'io.github.meetsl:SCardView:1.1' + api 'io.github.meetsl:SCardView:1.2' // https://github.com/nanchen2251/BankCardUtils api 'com.github.nanchen2251:BankCardUtils:1.0.2' // https://github.com/SherlockGougou/BigImageViewPager - api 'com.github.SherlockGougou:BigImageViewPager:v4_2.1.0' + api 'com.github.SherlockGougou:BigImageViewPager:androidx-6.1.5' + // matisse + api("com.zhihu.android:matisse:0.5.3-beta3") { + exclude group: 'com.github.bumptech.glide' + } // https://github.com/zzhoujay/RichText/ api 'com.zzhoujay.richtext:richtext:3.0.7' // https://github.com/maning0303/MNProgressHUD // api 'com.github.maning0303:MNProgressHUD:V1.1.8X' // https://github.com/MZCretin/ExpandableTextView api 'com.github.MZCretin:ExpandableTextView:v1.6.1-x' - // https://github.com/Manabu-GT/ExpandableTextView - api 'com.ms-square:expandableTextView:0.1.4' // https://github.com/yanzhenjie/NoFragment -// api 'com.yanzhenjie:fragment:1.0.1' api project(':commonlibs:hunheku:libyanzhenjiebase') } diff --git a/commonlibs/baselibrary/src/main/AndroidManifest.xml b/commonlibs/baselibrary/src/main/AndroidManifest.xml index 95ddce78..2c911b75 100644 --- a/commonlibs/baselibrary/src/main/AndroidManifest.xml +++ b/commonlibs/baselibrary/src/main/AndroidManifest.xml @@ -2,6 +2,9 @@ xmlns:tools="http://schemas.android.com/tools" package="com.haier.cellarette.baselibrary"> + @@ -20,11 +23,14 @@ - + - @@ -545,6 +551,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/Act.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/Act.java new file mode 100644 index 00000000..ea548629 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/Act.java @@ -0,0 +1,14 @@ +package com.haier.cellarette.baselibrary; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +public class Act extends AppCompatActivity { + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_marqueeviewlibrary); + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/TestCode.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/TestCode.java deleted file mode 100644 index 371d8b7b..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/TestCode.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.haier.cellarette.baselibrary; - -public class TestCode { - public static void main(String[] args) { - new MyThread().start(); - } - - static class MyThread extends Thread { - @Override - public void run() { - super.run(); - while (true) { - try { - System.out.println("aaaaa"); - sleep(80); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bannerviewquan/LXBannerViewbeifen.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bannerviewquan/LXBannerViewbeifen.java index 1d97a281..d12fa74d 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bannerviewquan/LXBannerViewbeifen.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bannerviewquan/LXBannerViewbeifen.java @@ -41,8 +41,8 @@ //import android.support.annotation.AttrRes; //import android.support.annotation.DrawableRes; -//import android.support.annotation.NonNull; -//import android.support.annotation.Nullable; +// +// //import android.support.annotation.RequiresApi; //import android.support.annotation.StyleRes; //import androidx.core.view.PagerAdapter; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseActivity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseActivity.java deleted file mode 100644 index ec538cae..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseActivity.java +++ /dev/null @@ -1,315 +0,0 @@ -/** - * Copyright 2016,Smart Haier.All rights reserved - */ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.util.AttributeSet; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; - -import androidx.annotation.IdRes; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.app.AppCompatDelegate; -import androidx.core.view.LayoutInflaterCompat; -import androidx.core.view.LayoutInflaterFactory; - -import com.geek.libutils.app.BaseAppManager; -import com.geek.libutils.app.BaseViewHelper; -import com.haier.cellarette.baselibrary.smartbar.IBaseAction; - - -public abstract class BaseActivity extends AppCompatActivity implements IBaseAction { - - public static final String REQUEST_CODE = "request_code"; - - private long mCurrentMs = System.currentTimeMillis(); - private Handler handler; - - @Override - protected void onCreate(Bundle savedInstanceState) { - interceptCreateView(); -// hideBottomUIMenu(); - super.onCreate(savedInstanceState); -// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - BaseAppManager.getInstance().add(this); -// AnnotateUtils.injectViews(this); - handler = new Handler(); - setContentView(getLayoutId()); - setup(savedInstanceState); -// StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.color_568EC0)); -// StatusBarUtilV7.immersive(this, ContextCompat.getColor(this, R.color.color_343533), 1.0f);// color_E5F7FF - } - - private void interceptCreateView() { - LayoutInflaterCompat.setFactory(LayoutInflater.from(this), new LayoutInflaterFactory() { - @Override - public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { - AppCompatDelegate delegate = getDelegate(); - View view = delegate.createView(parent, name, context, attrs); - if (view != null && view instanceof EditText) { - Log.d("***", "IME_FLAG_NO_EXTRACT_UI"); - EditText et = (EditText) view; - et.setImeOptions(et.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); - return et; - } - return view; - } - }); - } - - private long lastTime; - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); -// if (hasFocus) { HookUtil.hookClick(this);} - - } - - public abstract class OnMultiClickListener implements View.OnClickListener { - // 两次点击按钮之间的点击间隔不能少于1000毫秒 - private final int MIN_CLICK_DELAY_TIME = 1000; - private long lastClickTime; - - public abstract void onMultiClick(View v); - - @Override - public void onClick(View v) { - long curClickTime = System.currentTimeMillis(); - if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) { - // 超过点击间隔后再将lastClickTime重置为当前点击时间 - lastClickTime = curClickTime; - onMultiClick(v); - } - } - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_UP) { -// MobEventHelper.onEvent(this, "effective_click"); - } - - return super.dispatchTouchEvent(ev); - } - - @Override - protected void onResume() { - super.onResume(); -// MobEvent.onResume(this); - } - - @Override - protected void onPause() { - super.onPause(); -// MobEvent.onPause(this); - } - - protected abstract int getLayoutId(); - - protected void setup(Bundle savedInstanceState) { - - } - - protected final T f(@IdRes int resId) { - return BaseViewHelper.f(this, resId); - } - - public void startActivity(Class activity) { - startActivity(new Intent(this, activity)); - } - - public void startActivity(String action) { - startActivity(new Intent(action)); - } - - public void startActivityForResult(Class activity, int requestCode) { - startActivityForResult(new Intent(this, activity), requestCode); - } - - public void startActivityForResult(String action, int requestCode) { - startActivityForResult(new Intent(action), requestCode); - } - - @Override - public void startActivityForResult(Intent intent, int requestCode) { - if (intent.resolveActivity(getPackageManager()) == null) { - Log.e("Activity", "No Activity found to handle intent " + intent); - return; - } - - if (requestCode != -1 && intent.getIntExtra(REQUEST_CODE, -1) == -1) { - intent.putExtra(REQUEST_CODE, requestCode); - } - - super.startActivityForResult(intent, requestCode); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param activity - */ - public void targetToIfLogin(final Class activity) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivity(activity); -// } -// }); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param intent - */ - public void targetToIfLogin(final Intent intent) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivity(intent); -// } -// }); - } - - public void targetToIfLogin(final String action) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivity(action); -// } -// }); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param intent - */ - public void targetToForResultIfLogin(final Intent intent, final int requestCode) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivityForResult(intent, requestCode); -// } -// }); - } - - public void targetToForResultIfLogin(final String action, final int requestCode) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivityForResult(action, requestCode); -// } -// }); - } - - @Override - protected final void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); -// if (UserUtils.get().onActivityResult(requestCode, resultCode, data)) { -// if (UserUtils.get().isUserLogin()) { -// onUserLogined(UserUtils.get().userId()); -// } -// return; -// } -// if (LoginUtil.get().login_activity_result(requestCode, resultCode, data)) { -//// if (LoginUtil.get().isUserLogin()) { -//// onUserLogined(LoginUtil.get().userId()); -//// } else { -//// onUserLoginCanceled(); -//// } -// return; -// } -// if (SlbLoginUtil2.get().login_activity_result(requestCode, resultCode, data)) { -//// if (LoginUtil.get().isUserLogin()) { -//// onUserLogined(LoginUtil.get().userId()); -//// } else { -//// onUserLoginCanceled(); -//// } -// return; -// } - onActResult(requestCode, resultCode, data); - } - - protected void onUserLogined(String userId) { - } - - protected void onActResult(int requestCode, int resultCode, Intent data) { - } - - @Override - public void finish() { - hideSoftKeyboard(); -// ShowLoadingUtil.onDestory(); - super.finish(); - BaseAppManager.getInstance().remove(this); -// overridePendingTransition(R.anim.open_main, R.anim.close_next); - } - - @Override - protected void onDestroy() { - BaseAppManager.getInstance().remove(this); -// ShowLoadingUtil.onDestory(); - super.onDestroy(); - } - - @Override - public void onBackPressed() { - super.onBackPressed(); - } - - @Override - public void onHomePressed() { -// finish(); -// while (!BaseAppManager.getInstance().getAll().isEmpty()) { -// BaseAppManager.getInstance().top().finish(); -// } - -// Stack all = BaseAppManager.getInstance().getAll(); -// for (Iterator iterator = all.iterator(); iterator.hasNext();) { -// iterator.next().finish(); -// } - - BaseAppManager.getInstance().clear(); - Intent intent = new Intent("hs.act.phone.index"); - startActivity(intent); - finish(); - -// Application app = BaseApp.get(); -// if (app instanceof AndroidApplication) { -// ((AndroidApplication) app).onHomePressed(); -// } - } - - /** - * 隐藏软键盘 - */ - protected void hideSoftKeyboard() { - if (getCurrentFocus() != null) { - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), - InputMethodManager.HIDE_NOT_ALWAYS); - } - } - - @Override - public Activity who() { - return this; - } - - public String getIdentifier() { - return getClass().getName() + mCurrentMs; - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseActivityNoDoubleClick.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseActivityNoDoubleClick.java deleted file mode 100644 index 6ed6aeb2..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseActivityNoDoubleClick.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * Copyright 2016,Smart Haier.All rights reserved - */ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.util.AttributeSet; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; - -import androidx.annotation.IdRes; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.app.AppCompatDelegate; -import androidx.core.view.LayoutInflaterCompat; -import androidx.core.view.LayoutInflaterFactory; - -import com.geek.libutils.app.BaseAppManager; -import com.geek.libutils.app.BaseViewHelper; -import com.haier.cellarette.baselibrary.smartbar.IBaseAction; - -public abstract class BaseActivityNoDoubleClick extends AppCompatActivity implements IBaseAction { - - public static final String REQUEST_CODE = "request_code"; - - private long mCurrentMs = System.currentTimeMillis(); - private Handler handler; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - interceptCreateView(); -// hideBottomUIMenu(); - super.onCreate(savedInstanceState); -// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - BaseAppManager.getInstance().add(this); -// AnnotateUtils.injectViews(this); - handler = new Handler(); - setContentView(getLayoutId()); - setup(savedInstanceState); -// StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.color_568EC0)); -// StatusBarUtilV7.immersive(this, ContextCompat.getColor(this, R.color.color_343533), 1.0f);// color_E5F7FF - } - - private void interceptCreateView() { - LayoutInflaterCompat.setFactory(LayoutInflater.from(this), new LayoutInflaterFactory() { - @Override - public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { - AppCompatDelegate delegate = getDelegate(); - View view = delegate.createView(parent, name, context, attrs); - if (view != null && view instanceof EditText) { - Log.d("***", "IME_FLAG_NO_EXTRACT_UI"); - EditText et = (EditText) view; - et.setImeOptions(et.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); - return et; - } - return view; - } - }); - } - - private long lastTime; - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - - } - - public abstract class OnMultiClickListener implements View.OnClickListener { - // 两次点击按钮之间的点击间隔不能少于1000毫秒 - private final int MIN_CLICK_DELAY_TIME = 1000; - private long lastClickTime; - - public abstract void onMultiClick(View v); - - @Override - public void onClick(View v) { - long curClickTime = System.currentTimeMillis(); - if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) { - // 超过点击间隔后再将lastClickTime重置为当前点击时间 - lastClickTime = curClickTime; - onMultiClick(v); - } - } - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_UP) { -// MobEventHelper.onEvent(this, "effective_click"); - } - - return super.dispatchTouchEvent(ev); - } - - @Override - protected void onResume() { - super.onResume(); -// MobEvent.onResume(this); - } - - @Override - protected void onPause() { - super.onPause(); -// MobEvent.onPause(this); - } - - protected abstract int getLayoutId(); - - protected void setup(@Nullable Bundle savedInstanceState) { - - } - - protected final T f(@IdRes int resId) { - return BaseViewHelper.f(this, resId); - } - - public void startActivity(Class activity) { - startActivity(new Intent(this, activity)); - } - - public void startActivity(String action) { - startActivity(new Intent(action)); - } - - public void startActivityForResult(Class activity, int requestCode) { - startActivityForResult(new Intent(this, activity), requestCode); - } - - public void startActivityForResult(String action, int requestCode) { - startActivityForResult(new Intent(action), requestCode); - } - - @Override - public void startActivityForResult(Intent intent, int requestCode) { - if (intent.resolveActivity(getPackageManager()) == null) { - Log.e("Activity", "No Activity found to handle intent " + intent); - return; - } - - if (requestCode != -1 && intent.getIntExtra(REQUEST_CODE, -1) == -1) { - intent.putExtra(REQUEST_CODE, requestCode); - } - - super.startActivityForResult(intent, requestCode); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param activity - */ - public void targetToIfLogin(final Class activity) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivity(activity); -// } -// }); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param intent - */ - public void targetToIfLogin(final Intent intent) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivity(intent); -// } -// }); - } - - public void targetToIfLogin(final String action) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivity(action); -// } -// }); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param intent - */ - public void targetToForResultIfLogin(final Intent intent, final int requestCode) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivityForResult(intent, requestCode); -// } -// }); - } - - public void targetToForResultIfLogin(final String action, final int requestCode) { -// UserUtils.get().loginToDo(this, new Runnable() { -// @Override -// public void run() { -// startActivityForResult(action, requestCode); -// } -// }); - } - - @Override - protected final void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); -// if (UserUtils.get().onActivityResult(requestCode, resultCode, data)) { -// if (UserUtils.get().isUserLogin()) { -// onUserLogined(UserUtils.get().userId()); -// } -// return; -// } -// if (LoginUtil.get().login_activity_result(requestCode, resultCode, data)) { -//// if (LoginUtil.get().isUserLogin()) { -//// onUserLogined(LoginUtil.get().userId()); -//// } else { -//// onUserLoginCanceled(); -//// } -// return; -// } -// if (SlbLoginUtil2.get().login_activity_result(requestCode, resultCode, data)) { -//// if (LoginUtil.get().isUserLogin()) { -//// onUserLogined(LoginUtil.get().userId()); -//// } else { -//// onUserLoginCanceled(); -//// } -// return; -// } - onActResult(requestCode, resultCode, data); - } - - protected void onUserLogined(String userId) { - } - - protected void onActResult(int requestCode, int resultCode, Intent data) { - } - - @Override - public void finish() { - hideSoftKeyboard(); -// ShowLoadingUtil.onDestory(); - super.finish(); - BaseAppManager.getInstance().remove(this); -// overridePendingTransition(R.anim.open_main, R.anim.close_next); - } - - @Override - protected void onDestroy() { - BaseAppManager.getInstance().remove(this); -// ShowLoadingUtil.onDestory(); - super.onDestroy(); - } - - @Override - public void onBackPressed() { - super.onBackPressed(); - } - - @Override - public void onHomePressed() { -// finish(); -// while (!BaseAppManager.getInstance().getAll().isEmpty()) { -// BaseAppManager.getInstance().top().finish(); -// } - -// Stack all = BaseAppManager.getInstance().getAll(); -// for (Iterator iterator = all.iterator(); iterator.hasNext();) { -// iterator.next().finish(); -// } - - BaseAppManager.getInstance().clear(); - Intent intent = new Intent("hs.act.phone.index"); - startActivity(intent); - finish(); - -// Application app = BaseApp.get(); -// if (app instanceof AndroidApplication) { -// ((AndroidApplication) app).onHomePressed(); -// } - } - - /** - * 隐藏软键盘 - */ - protected void hideSoftKeyboard() { - if (getCurrentFocus() != null) { - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), - InputMethodManager.HIDE_NOT_ALWAYS); - } - } - - /** - * 隐藏虚拟按键,并且全屏 - */ - protected void hideBottomUIMenu() { - //隐藏虚拟按键,并且全屏 - if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api - View v = this.getWindow().getDecorView(); - v.setSystemUiVisibility(View.GONE); - } else if (Build.VERSION.SDK_INT >= 19) { - //for new api versions. - View decorView = getWindow().getDecorView(); - int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - /*| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN*/; - decorView.setSystemUiVisibility(uiOptions); - } - } - - @Override - public Activity who() { - return this; - } - - public String getIdentifier() { - return getClass().getName() + mCurrentMs; - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseFragment.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseFragment.java deleted file mode 100644 index 69bdea92..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseFragment.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.IdRes; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import com.geek.libutils.app.BaseApp; -import com.geek.libutils.app.BaseViewHelper; - - -public abstract class BaseFragment extends Fragment { - - private long mCurrentMs = System.currentTimeMillis(); - - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(getLayoutId(), container, false); - setup(rootView, savedInstanceState); -// StatusBarUtil.setColor(getActivity(), ContextCompat.getColor(getActivity(), R.color.color_568EC0)); - return rootView; - } - - protected abstract int getLayoutId(); - - @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); -// HookUtil.hookClick(this); - -// AnnotateUtils.injectViews(getActivity()); -// StatusBarUtil.setColor(getActivity(), ContextCompat.getColor(BaseApp.get(), R.color.color_BEDFFF)); -// StatusBarUtilV7.immersive(getActivity(), ContextCompat.getColor(getActivity(), R.color.color_343533), 1.0f);// color_E5F7FF - } - - @Override - public void onMultiWindowModeChanged(boolean isInMultiWindowMode) { - super.onMultiWindowModeChanged(isInMultiWindowMode); - - } - - @Override - public void onResume() { - super.onResume(); -// MobEvent.onEventStart(getActivity(), EventIdConst.PAGE_LOAD_DURATION, TAG); - } - - @Override - public void onPause() { - super.onPause(); -// MobEvent.onEventEnd(getActivity(), EventIdConst.PAGE_LOAD_DURATION, TAG); - } - - - protected void setup(View rootView, @Nullable Bundle savedInstanceState) { - - } - - protected T f(View rootView, @IdRes int resId) { - return BaseViewHelper.f(rootView, resId); - } - - @Override - public void startActivity(Intent intent) { - super.startActivity(intent); - } - - @Override - public void startActivityForResult(Intent intent, int requestCode) { - super.startActivityForResult(intent, requestCode); - } - - public void startActivity(Class activity) { - startActivity(new Intent(getActivity(), activity)); - } - - public void startActivity(String action) { - Intent intent = new Intent(action); - if (intent.resolveActivity(BaseApp.get().getPackageManager()) != null) { - startActivity(intent); - } - } - - public void startActivityForResult(Class activity, int requestCode) { - startActivityForResult(new Intent(getActivity(), activity), requestCode); - } - - public void startActivityForResult(String action, int requestCode) { - Intent intent = new Intent(action); - if (intent.resolveActivity(BaseApp.get().getPackageManager()) != null) { - startActivityForResult(intent, requestCode); - } - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param activity - */ - public void targetToIfLogin(final Class activity) { -// UserUtils.get().loginToDo(getActivity(), new Runnable() { -// @Override -// public void run() { -// startActivity(activity); -// } -// }); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param intent - */ - public void targetToIfLogin(final Intent intent) { -// UserUtils.get().loginToDo(getActivity(), new Runnable() { -// @Override -// public void run() { -// startActivity(intent); -// } -// }); - } - - public void targetToIfLogin(final String action) { -// UserUtils.get().loginToDo(getActivity(), new Runnable() { -// @Override -// public void run() { -// startActivity(action); -// } -// }); - } - - /** - * 跳转到指定activity,如果未登录,则弹出登录窗口 - * - * @param intent - */ - public void targetToForResultIfLogin(final Intent intent, final int requestCode) { -// UserUtils.get().loginToDo(getActivity(), new Runnable() { -// @Override -// public void run() { -// startActivityForResult(intent, requestCode); -// } -// }); - } - - public void targetToForResultIfLogin(final String action, final int requestCode) { -// UserUtils.get().loginToDo(getActivity(), new Runnable() { -// @Override -// public void run() { -// startActivityForResult(action, requestCode); -// } -// }); - } - - @Override - public final void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); -// if (UserUtils.get().onActivityResult(requestCode, resultCode, data)) { -// onUserLogined(UserUtils.get().userId()); -// return; -// } - - onActResult(requestCode, resultCode, data); - } - - public void onUserLogined(String userId) { - } - - public void onActResult(int requestCode, int resultCode, Intent data) { - } - - @Override - public void onDestroy() { -// ShowLoadingUtil.onDestory(); - super.onDestroy(); - } - - public String getIdentifier() { - return getClass().getName() + mCurrentMs; - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseIndexFragment.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseIndexFragment.java deleted file mode 100644 index b8910a68..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/BaseIndexFragment.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.haier.cellarette.baselibrary.baseactivitys; - -public abstract class BaseIndexFragment extends BaseFragment { - - /** - * 获取MainActivity的ViewPager - * @return - */ -// public IndexViewPager findIndexViewPager() { -// if (BaseAppManager.getInstance().top() instanceof RecDemo3Activity){ -// -// } -// if (getActivity() == null || !(getActivity() instanceof RecDemo3Activity)) { return null;} -// return null; -//// return ((RecDemo3Activity) getActivity()).getViewPager(); -// } - - /** - * 给Viewpager设置事件分发对象 - * - * @params view - */ -// public void setPagerTouchBindView(View view) { -// IndexViewPager pager = findIndexViewPager(); -// if (pager != null) { pager.bind(view);} -// } -// -// public void removePagerTouchBindView(View view) { -// IndexViewPager pager = findIndexViewPager(); -// if (pager != null) { pager.remove(view);} -// } - public void call(Object value) { - - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivity.java deleted file mode 100644 index a8a1e623..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivity.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.Manifest; -import android.annotation.TargetApi; -import android.app.Dialog; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Build; -import android.provider.Settings; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -import com.blankj.utilcode.util.AppUtils; -import com.blankj.utilcode.util.ScreenUtils; -import com.haier.cellarette.baselibrary.R; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public abstract class CheckPermissionsActivity extends BaseActivity { - - private List needRequestPermissonList; - private boolean isInstalls = true; - private Dialog dialog; - - protected abstract String[] YouNeedPermissions(); - - /** - * 需要进行检测的权限数组 - */ - protected String[] needPermissions = { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.REQUEST_INSTALL_PACKAGES - - }; - - private static final int PERMISSON_REQUESTCODE = 0; - - /** - * 判断是否需要检测,防止不停的弹框 - */ - private boolean isNeedCheck = true; - - @Override - protected void onResume() { - super.onResume(); - - if (null != YouNeedPermissions() || YouNeedPermissions().length != 0) { - needPermissions = YouNeedPermissions(); - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - isInstalls = getPackageManager().canRequestPackageInstalls(); - if (isInstalls) { - deletedPermission(); - } - } else { - deletedPermission(); - } - if (Build.VERSION.SDK_INT >= 23 && getApplicationInfo().targetSdkVersion >= 23) { - if (isNeedCheck) { - checkPermissions(needPermissions); - } - } - - } - - private void deletedPermission() { - for (int x = 0; x < needPermissions.length; x++) { - if (needPermissions[x].equals(Manifest.permission.REQUEST_INSTALL_PACKAGES)) { - needPermissions[x] = needPermissions[needPermissions.length - 1]; - needPermissions = Arrays.copyOf(needPermissions, needPermissions.length - 1); - } - } - } - - /** - * @param permissions - * @since 2.5.0 - */ - private void checkPermissions(String... permissions) { - try { - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - List needRequestPermissonList = findDeniedPermissions(permissions); - if (null != needRequestPermissonList - && needRequestPermissonList.size() > 0) { - String[] array = needRequestPermissonList.toArray(new String[needRequestPermissonList.size()]); - Method method = getClass().getMethod("requestPermissions", String[].class, - int.class); - - method.invoke(this, array, PERMISSON_REQUESTCODE); - } - } - } catch (Throwable e) { - } - } - - /** - * 获取权限集中需要申请权限的列表 - * - * @param permissions - * @return - * @since 2.5.0 - */ - private List findDeniedPermissions(String[] permissions) { - needRequestPermissonList = new ArrayList(); - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - try { - for (String perm : permissions) { - Method checkSelfMethod = getClass().getMethod("checkSelfPermission", String.class); - Method shouldShowRequestPermissionRationaleMethod = getClass().getMethod("shouldShowRequestPermissionRationale", - String.class); - if ((Integer) checkSelfMethod.invoke(this, perm) != PackageManager.PERMISSION_GRANTED - || (Boolean) shouldShowRequestPermissionRationaleMethod.invoke(this, perm)) { - needRequestPermissonList.add(perm); - } - } - } catch (Throwable e) { - - } - } - return needRequestPermissonList; - } - - /** - * 检测是否所有的权限都已经授权 - * - * @param grantResults - * @return - * @since 2.5.0 - */ - private boolean verifyPermissions(int[] grantResults) { - for (int result : grantResults) { - if (result != PackageManager.PERMISSION_GRANTED) { - return false; - } - } - return true; - } - - @TargetApi(26) - public void onRequestPermissionsResult(int requestCode, - String[] permissions, int[] paramArrayOfInt) { - if (requestCode == PERMISSON_REQUESTCODE) { - if (!verifyPermissions(paramArrayOfInt)) { -// showMissingPermissionDialog(); - isNeedCheck = false; - } - } - } - - @Override - protected void onActResult(int requestCode, int resultCode, Intent data) { - super.onActResult(requestCode, resultCode, data); - if (requestCode == 10086) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { - isInstalls = getPackageManager().canRequestPackageInstalls(); - if (!isInstalls) { -// showMissingPermissionDialog(); - } else { - if (dialog.isShowing()) { - dialog.dismiss(); - } - } - } - } - } - - /** - * 显示提示信息 - * - * @since 2.5.0 - */ - private void showMissingPermissionDialog() { - if (ScreenUtils.isLandscape()) { - return; - } -// AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("提示"); -// if (!isInstalls) { -// builder.setMessage("安装应用需要打开未知来源权限。"/* + "\n\n" + "请点击|" + "设置|" + "更多设置|" + "系统安全|" + "安装未知应用|" + "-允许酒知道安装。"*/); -// } else { -// builder.setMessage("当前应用缺少必要权限。" + "\n\n" + "请点击|" + "设置|" + "权限" + "-打开所需权限。"); -// -// } -// -// // 拒绝, 退出应用 -// builder.setNegativeButton("取消", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// finish(); -// } -// }); -// -// builder.setPositiveButton("设置", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// startAppSettings(); -// } -// }); -// -// -// builder.setCancelable(false); -// -// builder.show(); - - dialog = new Dialog(this, R.style.notice_dialog); - if (dialog.isShowing()) { - return; - } - dialog.setContentView(R.layout.notice_dialog); - dialog.setCancelable(false); - dialog.show(); - TextView tv_notice = dialog.findViewById(R.id.tv_notice); - Button btn_concle = dialog.findViewById(R.id.btn_concle); - Button btn_settings = dialog.findViewById(R.id.btn_settings); - if (!isInstalls) { - tv_notice.setText("安装应用需要打开未知来源权限" + "\n\n" + "请点击|" + "设置|" + "更多设置|" + "系统安全|" + "安装未知应用|" + "-允许应用安装"); - } else { - tv_notice.setText("当前应用缺少必要权限" + "\n\n" + "请点击|" + "设置|" + "权限" + "-打开所需权限"); - } - btn_concle.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - finish(); - } - }); - btn_settings.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startAppSettings(); - } - }); - - - } - - /** - * 启动应用的设置 - * - * @since 2.5.0 - */ - private void startAppSettings() { - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - // 跳到列表 -// Intent intent = new Intent(); -// intent.setAction(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); -// startActivityForResult(intent, 10086); - // 跳到单一bufen - Uri packageURI = Uri.parse("package:" + AppUtils.getAppPackageName()); - //注意这个是8.0新API - Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI); - startActivityForResult(intent, 10086); - } else { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.parse("package:" + getPackageName())); - startActivity(intent); - } - } - -// @Override -// public boolean onKeyDown(int keyCode, KeyEvent event) { -// if (keyCode == KeyEvent.KEYCODE_BACK) { -// this.finish(); -// return true; -// } -// return super.onKeyDown(keyCode, event); -// } - -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivity80.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivity80.java deleted file mode 100644 index 17d9e3f3..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivity80.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.Manifest; -import android.annotation.TargetApi; -import android.app.Dialog; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Build; -import android.provider.Settings; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -import com.blankj.utilcode.util.AppUtils; -import com.blankj.utilcode.util.ScreenUtils; -import com.haier.cellarette.baselibrary.R; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public abstract class CheckPermissionsActivity80 extends BaseActivity { - - private List needRequestPermissonList; - private boolean isInstalls = true; - private Dialog dialog; - - protected abstract String[] YouNeedPermissions(); - - /** - * 需要进行检测的权限数组 - */ - protected String[] needPermissions = { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.REQUEST_INSTALL_PACKAGES - - }; - - private static final int PERMISSON_REQUESTCODE = 0; - - /** - * 判断是否需要检测,防止不停的弹框 - */ - private boolean isNeedCheck = true; - - @Override - protected void onResume() { - super.onResume(); - - if (null != YouNeedPermissions() || YouNeedPermissions().length != 0) { - needPermissions = YouNeedPermissions(); - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - isInstalls = getPackageManager().canRequestPackageInstalls(); - if (isInstalls) { - deletedPermission(); - } - } else { - deletedPermission(); - } - if (Build.VERSION.SDK_INT >= 23 && getApplicationInfo().targetSdkVersion >= 23) { - if (isNeedCheck) { - checkPermissions(needPermissions); - } - } - - } - - private void deletedPermission() { - for (int x = 0; x < needPermissions.length; x++) { - if (needPermissions[x].equals(Manifest.permission.REQUEST_INSTALL_PACKAGES)) { - needPermissions[x] = needPermissions[needPermissions.length - 1]; - needPermissions = Arrays.copyOf(needPermissions, needPermissions.length - 1); - } - } - } - - /** - * @param permissions - * @since 2.5.0 - */ - private void checkPermissions(String... permissions) { - try { - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - List needRequestPermissonList = findDeniedPermissions(permissions); - if (null != needRequestPermissonList - && needRequestPermissonList.size() > 0) { - String[] array = needRequestPermissonList.toArray(new String[needRequestPermissonList.size()]); - Method method = getClass().getMethod("requestPermissions", String[].class, - int.class); - - method.invoke(this, array, PERMISSON_REQUESTCODE); - } - } - } catch (Throwable e) { - } - } - - /** - * 获取权限集中需要申请权限的列表 - * - * @param permissions - * @return - * @since 2.5.0 - */ - private List findDeniedPermissions(String[] permissions) { - needRequestPermissonList = new ArrayList(); - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - try { - for (String perm : permissions) { - Method checkSelfMethod = getClass().getMethod("checkSelfPermission", String.class); - Method shouldShowRequestPermissionRationaleMethod = getClass().getMethod("shouldShowRequestPermissionRationale", - String.class); - if ((Integer) checkSelfMethod.invoke(this, perm) != PackageManager.PERMISSION_GRANTED - || (Boolean) shouldShowRequestPermissionRationaleMethod.invoke(this, perm)) { - needRequestPermissonList.add(perm); - } - } - } catch (Throwable e) { - - } - } - return needRequestPermissonList; - } - - /** - * 检测是否所有的权限都已经授权 - * - * @param grantResults - * @return - * @since 2.5.0 - */ - private boolean verifyPermissions(int[] grantResults) { - for (int result : grantResults) { - if (result != PackageManager.PERMISSION_GRANTED) { - return false; - } - } - return true; - } - - @TargetApi(26) - public void onRequestPermissionsResult(int requestCode, - String[] permissions, int[] paramArrayOfInt) { - if (requestCode == PERMISSON_REQUESTCODE) { - if (!verifyPermissions(paramArrayOfInt)) { - showMissingPermissionDialog(); - isNeedCheck = false; - } - } - } - - @Override - protected void onActResult(int requestCode, int resultCode, Intent data) { - super.onActResult(requestCode, resultCode, data); - if (requestCode == 10086) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - isInstalls = getPackageManager().canRequestPackageInstalls(); - if (!isInstalls) { - showMissingPermissionDialog(); - } else { - if (dialog.isShowing()) { - dialog.dismiss(); - } - } - } - } - } - - /** - * 显示提示信息 - * - * @since 2.5.0 - */ - private void showMissingPermissionDialog() { - if (ScreenUtils.isLandscape()) { - return; - } -// AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("提示"); -// if (!isInstalls) { -// builder.setMessage("安装应用需要打开未知来源权限。"/* + "\n\n" + "请点击|" + "设置|" + "更多设置|" + "系统安全|" + "安装未知应用|" + "-允许酒知道安装。"*/); -// } else { -// builder.setMessage("当前应用缺少必要权限。" + "\n\n" + "请点击|" + "设置|" + "权限" + "-打开所需权限。"); -// -// } -// -// // 拒绝, 退出应用 -// builder.setNegativeButton("取消", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// finish(); -// } -// }); -// -// builder.setPositiveButton("设置", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// startAppSettings(); -// } -// }); -// -// -// builder.setCancelable(false); -// -// builder.show(); - - dialog = new Dialog(this, R.style.notice_dialog); - if (dialog.isShowing()) { - return; - } - dialog.setContentView(R.layout.notice_dialog); - dialog.setCancelable(false); - dialog.show(); - TextView tv_notice = dialog.findViewById(R.id.tv_notice); - Button btn_concle = dialog.findViewById(R.id.btn_concle); - Button btn_settings = dialog.findViewById(R.id.btn_settings); - if (!isInstalls) { - tv_notice.setText("安装应用需要打开未知来源权限" + "\n\n" + "请点击|" + "设置|" + "更多设置|" + "系统安全|" + "安装未知应用|" + "-允许应用安装"); - } else { - tv_notice.setText("当前应用缺少必要权限" + "\n\n" + "请点击|" + "设置|" + "权限" + "-打开所需权限"); - } - btn_concle.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - finish(); - } - }); - btn_settings.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startAppSettings(); - } - }); - - - } - - /** - * 启动应用的设置 - * - * @since 2.5.0 - */ - private void startAppSettings() { - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - // 跳到列表 -// Intent intent = new Intent(); -// intent.setAction(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); -// startActivityForResult(intent, 10086); - // 跳到单一bufen - Uri packageURI = Uri.parse("package:" + AppUtils.getAppPackageName()); - //注意这个是8.0新API - Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI); - startActivityForResult(intent, 10086); - } else { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.parse("package:" + getPackageName())); - startActivity(intent); - } - } - -// @Override -// public boolean onKeyDown(int keyCode, KeyEvent event) { -// if (keyCode == KeyEvent.KEYCODE_BACK) { -// this.finish(); -// return true; -// } -// return super.onKeyDown(keyCode, event); -// } - -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivityNoDoubleClick.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivityNoDoubleClick.java deleted file mode 100644 index b54b8166..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/CheckPermissionsActivityNoDoubleClick.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.Manifest; -import android.annotation.TargetApi; -import android.app.Dialog; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Build; -import android.provider.Settings; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -import com.blankj.utilcode.util.AppUtils; -import com.blankj.utilcode.util.ScreenUtils; -import com.haier.cellarette.baselibrary.R; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public abstract class CheckPermissionsActivityNoDoubleClick extends BaseActivityNoDoubleClick { - - private List needRequestPermissonList; - private boolean isInstalls = true; - private Dialog dialog; - - protected abstract String[] YouNeedPermissions(); - - /** - * 需要进行检测的权限数组 - */ - protected String[] needPermissions = { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.REQUEST_INSTALL_PACKAGES - - }; - - private static final int PERMISSON_REQUESTCODE = 0; - - /** - * 判断是否需要检测,防止不停的弹框 - */ - private boolean isNeedCheck = true; - - @Override - protected void onResume() { - super.onResume(); - - if (null != YouNeedPermissions() || YouNeedPermissions().length != 0) { - needPermissions = YouNeedPermissions(); - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - isInstalls = getPackageManager().canRequestPackageInstalls(); - if (isInstalls) { - deletedPermission(); - } - } else { - deletedPermission(); - } - if (Build.VERSION.SDK_INT >= 23 && getApplicationInfo().targetSdkVersion >= 23) { - if (isNeedCheck) { - checkPermissions(needPermissions); - } - } - - } - - private void deletedPermission() { - for (int x = 0; x < needPermissions.length; x++) { - if (needPermissions[x].equals(Manifest.permission.REQUEST_INSTALL_PACKAGES)) { - needPermissions[x] = needPermissions[needPermissions.length - 1]; - needPermissions = Arrays.copyOf(needPermissions, needPermissions.length - 1); - } - } - } - - /** - * @param permissions - * @since 2.5.0 - */ - private void checkPermissions(String... permissions) { - try { - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - List needRequestPermissonList = findDeniedPermissions(permissions); - if (null != needRequestPermissonList - && needRequestPermissonList.size() > 0) { - String[] array = needRequestPermissonList.toArray(new String[needRequestPermissonList.size()]); - Method method = getClass().getMethod("requestPermissions", String[].class, - int.class); - - method.invoke(this, array, PERMISSON_REQUESTCODE); - } - } - } catch (Throwable e) { - } - } - - /** - * 获取权限集中需要申请权限的列表 - * - * @param permissions - * @return - * @since 2.5.0 - */ - private List findDeniedPermissions(String[] permissions) { - needRequestPermissonList = new ArrayList(); - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - try { - for (String perm : permissions) { - Method checkSelfMethod = getClass().getMethod("checkSelfPermission", String.class); - Method shouldShowRequestPermissionRationaleMethod = getClass().getMethod("shouldShowRequestPermissionRationale", - String.class); - if ((Integer) checkSelfMethod.invoke(this, perm) != PackageManager.PERMISSION_GRANTED - || (Boolean) shouldShowRequestPermissionRationaleMethod.invoke(this, perm)) { - needRequestPermissonList.add(perm); - } - } - } catch (Throwable e) { - - } - } - return needRequestPermissonList; - } - - /** - * 检测是否所有的权限都已经授权 - * - * @param grantResults - * @return - * @since 2.5.0 - */ - private boolean verifyPermissions(int[] grantResults) { - for (int result : grantResults) { - if (result != PackageManager.PERMISSION_GRANTED) { - return false; - } - } - return true; - } - - @TargetApi(26) - public void onRequestPermissionsResult(int requestCode, - String[] permissions, int[] paramArrayOfInt) { - if (requestCode == PERMISSON_REQUESTCODE) { - if (!verifyPermissions(paramArrayOfInt)) { -// showMissingPermissionDialog(); - isNeedCheck = false; - } - } - } - - @Override - protected void onActResult(int requestCode, int resultCode, Intent data) { - super.onActResult(requestCode, resultCode, data); - if (requestCode == 10086) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - isInstalls = getPackageManager().canRequestPackageInstalls(); - if (!isInstalls) { -// showMissingPermissionDialog(); - } else { - if (dialog.isShowing()) { - dialog.dismiss(); - } - } - } - } - } - - /** - * 显示提示信息 - * - * @since 2.5.0 - */ - private void showMissingPermissionDialog() { - if (ScreenUtils.isLandscape()) { - return; - } -// AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("提示"); -// if (!isInstalls) { -// builder.setMessage("安装应用需要打开未知来源权限。"/* + "\n\n" + "请点击|" + "设置|" + "更多设置|" + "系统安全|" + "安装未知应用|" + "-允许酒知道安装。"*/); -// } else { -// builder.setMessage("当前应用缺少必要权限。" + "\n\n" + "请点击|" + "设置|" + "权限" + "-打开所需权限。"); -// -// } -// -// // 拒绝, 退出应用 -// builder.setNegativeButton("取消", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// finish(); -// } -// }); -// -// builder.setPositiveButton("设置", -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// startAppSettings(); -// } -// }); -// -// -// builder.setCancelable(false); -// -// builder.show(); - - dialog = new Dialog(this, R.style.notice_dialog); - if (dialog.isShowing()) { - return; - } - dialog.setContentView(R.layout.notice_dialog); - dialog.setCancelable(false); - dialog.show(); - TextView tv_notice = dialog.findViewById(R.id.tv_notice); - Button btn_concle = dialog.findViewById(R.id.btn_concle); - Button btn_settings = dialog.findViewById(R.id.btn_settings); - if (!isInstalls) { - tv_notice.setText("安装应用需要打开未知来源权限" + "\n\n" + "请点击|" + "设置|" + "更多设置|" + "系统安全|" + "安装未知应用|" + "-允许应用安装"); - } else { - tv_notice.setText("当前应用缺少必要权限" + "\n\n" + "请点击|" + "设置|" + "权限" + "-打开所需权限"); - } - btn_concle.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - finish(); - } - }); - btn_settings.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startAppSettings(); - } - }); - - - } - - /** - * 启动应用的设置 - * - * @since 2.5.0 - */ - private void startAppSettings() { - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - // 跳到列表 -// Intent intent = new Intent(); -// intent.setAction(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); -// startActivityForResult(intent, 10086); - // 跳到单一bufen - Uri packageURI = Uri.parse("package:" + AppUtils.getAppPackageName()); - //注意这个是8.0新API - Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI); - startActivityForResult(intent, 10086); - } else { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.parse("package:" + getPackageName())); - startActivity(intent); - } - } - -// @Override -// public boolean onKeyDown(int keyCode, KeyEvent event) { -// if (keyCode == KeyEvent.KEYCODE_BACK) { -// this.finish(); -// return true; -// } -// return super.onKeyDown(keyCode, event); -// } - -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/MyBaseActivity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/MyBaseActivity.java deleted file mode 100644 index 75e6663d..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/baseactivitys/MyBaseActivity.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.haier.cellarette.baselibrary.baseactivitys; - -import android.Manifest; - -public class MyBaseActivity extends CheckPermissionsActivity { - /** - * 需要进行检测的权限数组 - */ - protected String[] needPermissions = { - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.REQUEST_INSTALL_PACKAGES, - Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO - }; - - @Override - protected int getLayoutId() { - return 0; - } - - @Override - protected String[] YouNeedPermissions() { - return needPermissions; - } - -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bigImageviewpager/BigImageViewPagerAct.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bigImageviewpager/BigImageViewPagerAct.java new file mode 100644 index 00000000..b8f979fe --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/bigImageviewpager/BigImageViewPagerAct.java @@ -0,0 +1,521 @@ +package com.haier.cellarette.baselibrary.bigImageviewpager; + +import android.Manifest; +import android.app.Activity; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.Window; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RadioGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.SwitchCompat; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.bumptech.glide.Glide; +import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback; +import com.haier.cellarette.baselibrary.R; +import com.zhihu.matisse.Matisse; +import com.zhihu.matisse.MimeType; +import com.zhihu.matisse.engine.impl.GlideEngine; +import com.zhihu.matisse.internal.entity.CaptureStrategy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import cc.shinichi.library.ImagePreview; +import cc.shinichi.library.bean.ImageInfo; +import cc.shinichi.library.glide.ImageLoader; +import cc.shinichi.library.tool.ui.ToastUtil; +import cc.shinichi.library.view.listener.OnBigImageClickListener; +import cc.shinichi.library.view.listener.OnBigImageLongClickListener; +import cc.shinichi.library.view.listener.OnBigImagePageChangeListener; +import cc.shinichi.library.view.listener.OnDownloadClickListener; +import cc.shinichi.library.view.listener.OnOriginProgressListener; + +import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED; + +public class BigImageViewPagerAct extends AppCompatActivity { + + private static final String TAG = "MainActivity"; + + private String[] images = { + // 六种格式的图片 + "https://aloss.11oi.com/app/img/temp/launch_top.bmp", + "https://aloss.11oi.com/app/img/temp/launch_top.gif", + "https://aloss.11oi.com/app/img/temp/launch_top.jpeg", + "https://aloss.11oi.com/app/img/temp/launch_top.jpg", + "https://aloss.11oi.com/app/img/temp/launch_top.png", + "https://aloss.11oi.com/app/img/temp/launch_top.webp", + // 小尺寸图片 + "https://s1.ax1x.com/2020/10/16/0HXKv4.jpg", + // 普通jpg图片 + "http://img6.16fan.com/201510/11/005258wdngg6rv0tpn8z9z.jpg", + "http://img6.16fan.com/201510/11/013553aj3kp9u6iuz6k9uj.jpg", + "http://img6.16fan.com/201510/11/011753fnanichdca0wbhxc.jpg", + "http://img6.16fan.com/201510/11/011819zbzbciir9ctn295o.jpg", + "http://img6.16fan.com/201510/11/004847l7w568jc5n5wn385.jpg", + "http://img6.16fan.com/201510/11/004906z0a0a0e0hs56ce0t.jpg", + "http://img6.16fan.com/201510/11/004937pwttwjt0bgtoton7.jpg", + "http://img6.16fan.com/201510/11/004946t38ybzt8bq8c838y.jpg", + "http://img6.16fan.com/201510/11/004955d8ftz3t1sttt7ft7.jpg", + "http://img6.16fan.com/201510/11/005027qy2g55yyglb59zdu.jpg", + "http://img6.16fan.com/201510/11/005229bbtxkczcl0btmw8e.jpg", + // 大图:5760 * 3840 + "http://img6.16fan.com/attachments/wenzhang/201805/18/152660818127263ge.jpeg", + // 长图:2280 * 22116 + "http://img6.16fan.com/attachments/wenzhang/201805/18/152660818716180ge.jpeg" + }; + + boolean enableClickClose = false; + boolean enableDragClose = false; + boolean enableUpDragClose = false; + boolean enableDragIgnoreScale = false; + boolean showIndicator = false; + boolean showCloseButton = false; + boolean showDownButton = false; + boolean showErrorToast = false; + + private ImagePreview.LoadStrategy loadStrategy = ImagePreview.LoadStrategy.Default; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); + setExitSharedElementCallback(new MaterialContainerTransformSharedElementCallback()); + getWindow().setSharedElementsUseOverlay(false); + } + + setContentView(R.layout.activity_bigimageviewpager); + + SwitchCompat switchClickClose = findViewById(R.id.switchClickClose); + SwitchCompat switchDragClose = findViewById(R.id.switchDragClose); + SwitchCompat switchUpDragClose = findViewById(R.id.switchUpDragClose); + SwitchCompat switchDragCloseIgnore = findViewById(R.id.switchDragCloseIgnore); + SwitchCompat switchShowIndicator = findViewById(R.id.switchShowIndicator); + SwitchCompat switchShowCloseButton = findViewById(R.id.switchShowCloseButton); + SwitchCompat switchShowDownButton = findViewById(R.id.switchShowDownButton); + SwitchCompat switchShowErrorToast = findViewById(R.id.switchShowErrorToast); + + RadioGroup radioGroupStrategy = findViewById(R.id.radioGroupStrategy); + + switchClickClose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + enableClickClose = isChecked; + } + }); + switchClickClose.setChecked(true); + + switchDragClose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + enableDragClose = isChecked; + } + }); + switchDragClose.setChecked(true); + + switchUpDragClose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + enableUpDragClose = isChecked; + } + }); + switchUpDragClose.setChecked(true); + + switchDragCloseIgnore.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + enableDragIgnoreScale = isChecked; + } + }); + switchDragCloseIgnore.setChecked(false); + + switchShowIndicator.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + showIndicator = isChecked; + } + }); + switchShowIndicator.setChecked(true); + + switchShowCloseButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + showCloseButton = isChecked; + } + }); + switchShowCloseButton.setChecked(false); + + switchShowDownButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + showDownButton = isChecked; + } + }); + switchShowDownButton.setChecked(true); + switchShowErrorToast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + showErrorToast = isChecked; + } + }); + switchShowErrorToast.setChecked(false); + + loadStrategy = ImagePreview.LoadStrategy.Default; + radioGroupStrategy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + if (checkedId == R.id.radioThumb) { + loadStrategy = ImagePreview.LoadStrategy.AlwaysThumb; + } else if (checkedId == R.id.radioOrigin) { + loadStrategy = ImagePreview.LoadStrategy.AlwaysOrigin; + } else if (checkedId == R.id.radioDefault) { + loadStrategy = ImagePreview.LoadStrategy.Default; + } else if (checkedId == R.id.radioNetAuto) { + loadStrategy = ImagePreview.LoadStrategy.NetworkAuto; + } else { + loadStrategy = ImagePreview.LoadStrategy.Default; + } + } + }); + + ImageInfo imageInfo; + final List imageInfoList = new ArrayList<>(); + + for (String image : images) { + imageInfo = new ImageInfo(); + // 原图地址 + imageInfo.setOriginUrl(image); + if (image.contains("16fan.com")) { + // 缩略图;实际使用中,根据需求传入缩略图路径。如果没有缩略图url,可以将两项设置为一样。 + imageInfo.setThumbnailUrl(image.concat("-400")); + } else { + // 缩略图;实际使用中,根据需求传入缩略图路径。如果没有缩略图url,可以将两项设置为一样。 + imageInfo.setThumbnailUrl(image); + } + imageInfoList.add(imageInfo); + } + + + // 最简单的调用: + findViewById(R.id.buttonEasyUse).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // 仅需一行代码,默认配置为: + // 显示顶部进度指示器、 + // 显示右侧下载按钮、 + // 隐藏左侧关闭按钮、 + // 开启点击图片关闭、 + // 关闭下拉图片关闭、 + // 加载方式为手动模式 + // 加载原图的百分比在底部 + + // 一行代码即可实现大部分需求,如需定制,可参考下面自定义的代码: + ImagePreview.getInstance().setContext(BigImageViewPagerAct.this).setImageList(Arrays.asList(images)).start(); + } + }); + + ImageView image1 = findViewById(R.id.image1); + ImageView image2 = findViewById(R.id.image2); + ImageView image3 = findViewById(R.id.image3); + + List list2 = new ArrayList<>(); + list2.add("http://img6.16fan.com/201510/11/005258wdngg6rv0tpn8z9z.jpg"); + list2.add("http://img6.16fan.com/201510/11/013553aj3kp9u6iuz6k9uj.jpg"); + list2.add("http://img6.16fan.com/201510/11/011753fnanichdca0wbhxc.jpg"); + + Glide.with(this).load("http://img6.16fan.com/201510/11/005258wdngg6rv0tpn8z9z.jpg").into(image1); + Glide.with(this).load("http://img6.16fan.com/201510/11/013553aj3kp9u6iuz6k9uj.jpg").into(image2); + Glide.with(this).load("http://img6.16fan.com/201510/11/011753fnanichdca0wbhxc.jpg").into(image3); + + image1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ImagePreview.getInstance() + .setContext(BigImageViewPagerAct.this) + .setImageList(list2) + .setIndex(0) + .setTransitionView(view) + .setTransitionShareElementName("shared_element_container") + .start(); + } + }); + image2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ImagePreview.getInstance() + .setContext(BigImageViewPagerAct.this) + .setImageList(list2) + .setIndex(1) + .setTransitionView(view) + .setTransitionShareElementName("shared_element_container") + .start(); + } + }); + image3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ImagePreview.getInstance() + .setContext(BigImageViewPagerAct.this) + .setImageList(list2) + .setIndex(2) +// .setTransitionView(view) +// .setTransitionShareElementName("shared_element_container") + .start(); + } + }); + + // 完全自定义调用: + findViewById(R.id.buttonPreview).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // 完全自定义配置 + ImagePreview.getInstance() + // 上下文,必须是activity,不需要担心内存泄漏,本框架已经处理好 + .setContext(BigImageViewPagerAct.this) + // 从第几张图片开始,索引从0开始哦~ + .setIndex(0) + + //================================================================================================= + // 有三种设置数据集合的方式,根据自己的需求进行三选一: + // 1:第一步生成的imageInfo List + .setImageInfoList(imageInfoList) + + // 2:直接传url List + //.setImageList(List imageList) + + // 3:只有一张图片的情况,可以直接传入这张图片的url + //.setImage(String image) + //================================================================================================= + + // 加载策略,默认为手动模式 + .setLoadStrategy(loadStrategy) + + // 保存的文件夹名称,会在Picture目录进行文件夹的新建。比如:"BigImageView",会在Picture目录新建BigImageView文件夹) + .setFolderName("BigImageView") + + // 缩放动画时长,单位ms + .setZoomTransitionDuration(300) + + // 是否显示加载失败的Toast + .setShowErrorToast(showErrorToast) + + // 是否启用点击图片关闭。默认启用 + .setEnableClickClose(enableClickClose) + // 是否启用下拉关闭。默认不启用 + .setEnableDragClose(enableDragClose) + // 是否启用上拉关闭。默认不启用 + .setEnableUpDragClose(enableUpDragClose) + // 是否忽略缩放启用拉动关闭。默认不忽略 + .setEnableDragCloseIgnoreScale(enableDragIgnoreScale) + + // 是否显示关闭页面按钮,在页面左下角。默认不显示 + .setShowCloseButton(showCloseButton) + // 设置关闭按钮图片资源,可不填,默认为库中自带:R.drawable.ic_action_close + .setCloseIconResId(R.drawable.ic_action_close) + + // 是否显示下载按钮,在页面右下角。默认显示 + .setShowDownButton(showDownButton) + // 设置下载按钮图片资源,可不填,默认为库中自带:R.drawable.icon_download_new + .setDownIconResId(R.drawable.icon_download_new) + + // 设置是否显示顶部的指示器(1/9)默认显示 + .setShowIndicator(showIndicator) + // 设置顶部指示器背景shape,默认自带灰色圆角shape + .setIndicatorShapeResId(R.drawable.shape_indicator_bg) + + // 设置失败时的占位图,默认为库中自带R.drawable.load_failed,设置为 0 时不显示 + .setErrorPlaceHolder(R.drawable.load_failed) + + // 点击回调 + .setBigImageClickListener(new OnBigImageClickListener() { + @Override + public void onClick(Activity activity, View view, int position) { + // ... + Log.d(TAG, "onClick: "); + } + }) + // 长按回调 + .setBigImageLongClickListener(new OnBigImageLongClickListener() { + @Override + public boolean onLongClick(Activity activity, View view, int position) { + // ... + Log.d(TAG, "onLongClick: "); + return false; + } + }) + // 页面切换回调 + .setBigImagePageChangeListener(new OnBigImagePageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + Log.d(TAG, "onPageScrolled: "); + } + + @Override + public void onPageSelected(int position) { + Log.d(TAG, "onPageSelected: "); + } + + @Override + public void onPageScrollStateChanged(int state) { + Log.d(TAG, "onPageScrollStateChanged: "); + } + }) + // 下载按钮点击回调,可以拦截下载逻辑,从而实现自己下载或埋点统计 + .setDownloadClickListener(new OnDownloadClickListener() { + @Override + public void onClick(Activity activity, View view, int position) { + // 可以在此处执行您自己的下载逻辑、埋点统计等信息 + Log.d(TAG, "onClick: position = " + position); + } + + @Override + public boolean isInterceptDownload() { + // return true 时, 需要自己实现下载 + // return false 时, 使用内置下载 + return false; + } + }) + + //================================================================================================= + // 设置查看原图时的百分比样式:库中带有一个样式:ImagePreview.PROGRESS_THEME_CIRCLE_TEXT,使用如下: + .setProgressLayoutId(ImagePreview.PROGRESS_THEME_CIRCLE_TEXT, new OnOriginProgressListener() { + @Override + public void progress(View parentView, int progress) { + Log.d(TAG, "progress: " + progress); + + // 需要找到进度控件并设置百分比,回调中的parentView即传入的布局的根View,可通过parentView找到控件: + ProgressBar progressBar = parentView.findViewById(R.id.sh_progress_view); + TextView textView = parentView.findViewById(R.id.sh_progress_text); + progressBar.setProgress(progress); + String progressText = progress + "%"; + textView.setText(progressText); + } + + @Override + public void finish(View parentView) { + Log.d(TAG, "finish: "); + } + }) + + // 使用自定义百分比样式,传入自己的布局,并设置回调,再根据parentView找到进度控件进行百分比的设置: + //.setProgressLayoutId(R.layout.image_progress_layout_theme_1, new OnOriginProgressListener() { + // @Override public void progress(View parentView, int progress) { + // Log.d(TAG, "progress: " + progress); + // + // ProgressBar progressBar = parentView.findViewById(R.id.progress_horizontal); + // progressBar.setProgress(progress); + // } + // + // @Override public void finish(View parentView) { + // Log.d(TAG, "finish: "); + // } + //}) + //================================================================================================= + + // 开启预览 + .start(); + } + }); + + // 通过相册选择图片,进行预览 + findViewById(R.id.buttonChoose).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (ContextCompat.checkSelfPermission(BigImageViewPagerAct.this.getApplicationContext(), + Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(BigImageViewPagerAct.this, + Manifest.permission.WRITE_EXTERNAL_STORAGE)) { + // 拒绝权限 + ToastUtil.getInstance()._short(BigImageViewPagerAct.this.getApplicationContext(), "您拒绝了存储权限,无法读取图片!"); + } else { + // 申请权限 + ActivityCompat.requestPermissions(BigImageViewPagerAct.this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,}, 1); + } + } else { + // 选择图片 + chooseImage(); + } + } + }); + + // 清除磁盘缓存 + findViewById(R.id.buttonClean).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ImageLoader.cleanDiskCache(BigImageViewPagerAct.this); + ToastUtil.getInstance()._short(BigImageViewPagerAct.this, "磁盘缓存已成功清除"); + } + }); + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { + if (requestCode == 1) { + for (int i = 0; i < permissions.length; i++) { + if (grantResults[i] == PERMISSION_GRANTED) { + chooseImage(); + } else { + ToastUtil.getInstance()._short(BigImageViewPagerAct.this.getApplicationContext(), "您拒绝了存储权限,无法读取图片!"); + } + } + } + } + + // 去选择图片 + private void chooseImage() { + Matisse.from(BigImageViewPagerAct.this) + .choose(MimeType.ofImage()) + .capture(true) + .captureStrategy(new CaptureStrategy(true, "cc.shinichi.bigimageviewpager.fileprovider", "BigImage")) + .countable(true) + .maxSelectable(30) + .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) + .thumbnailScale(0.85f) + .imageEngine(new GlideEngine()) + .theme(com.zhihu.matisse.R.style.Matisse_Zhihu) + .showSingleMediaType(true) + .originalEnable(true) + .forResult(1); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 1) { + if (resultCode == RESULT_OK && data != null) { + List uriList = Matisse.obtainResult(data); + List urlList = new ArrayList<>(); + for (Uri uri : uriList) { + urlList.add(uri.toString()); + } + ImagePreview.getInstance() + .setContext(BigImageViewPagerAct.this) + .setImageList(urlList) + .setShowDownButton(false) + .setShowCloseButton(false) + .setEnableDragClose(true) + .setEnableClickClose(false) + .start(); + } + } + } +} \ No newline at end of file diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/emptyview/NiubiEmptyView.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/emptyview/NiubiEmptyView.java index 1f4041d3..29dbb2a2 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/emptyview/NiubiEmptyView.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/emptyview/NiubiEmptyView.java @@ -30,7 +30,7 @@ public NiubiEmptyView bind(Context context, View mRecyclerView, BaseQuickAdapter this.context = context; this.mAdapter = mAdapter; // loadingView = ((Activity) context).getLayoutInflater().inflate(R.layout.activity_recycleviewallsuses_demo8_viewloading, (ViewGroup) mRecyclerView.getParent(), false); - loadingView = ((Activity) context).getLayoutInflater().inflate(R.layout.activity_network_loading, (ViewGroup) mRecyclerView.getParent(), false); + loadingView = ((Activity) context).getLayoutInflater().inflate(R.layout.activity_network_loading1, (ViewGroup) mRecyclerView.getParent(), false); loadingView_content = loadingView.findViewById(R.id.loading_notice); imageView = loadingView.findViewById(R.id.loading_iv); noDataView = ((Activity) context).getLayoutInflater().inflate(R.layout.activity_recycleviewallsuses_demo8_viewnodata, (ViewGroup) mRecyclerView.getParent(), false); diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ExpandableTextViewAct.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ExpandableTextViewAct.java new file mode 100644 index 00000000..8f68050d --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ExpandableTextViewAct.java @@ -0,0 +1,281 @@ +package com.haier.cellarette.baselibrary.expandabletextview; + +import android.app.AlertDialog; +import android.content.Intent; +import android.graphics.Color; +import android.net.Uri; +import android.os.Bundle; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.SpannableStringBuilder; +import android.text.TextUtils; +import android.text.method.LinkMovementMethod; +import android.text.style.ForegroundColorSpan; +import android.text.util.Linkify; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.text.util.LinkifyCompat; + +import com.ctetin.expandabletextviewlibrary.ExpandableTextView; +import com.ctetin.expandabletextviewlibrary.app.LinkType; +import com.ctetin.expandabletextviewlibrary.app.StatusType; +import com.haier.cellarette.baselibrary.R; + + +/** + * 联系我: + * 792075058@qq.com + *

+ * 博客地址: + * https://www.jianshu.com/p/b7a8ddc639db + *

+ * Github地址(您的star是对我最大的鼓励): + * https://github.com/MZCretin/ExpandableTextView + */ +public class ExpandableTextViewAct extends AppCompatActivity { + private ExpandableTextView[] views; + private TextView[] tips; + private String[] indexs = new String[]{ + "3,5;6,9;10,12", + "3,5;6,11;12,13;21,22;27,28", + "2,6;7,12;13,14;22,23", + "3,5;6,9;10,11;19,20", + "3,5;6,9;10,11;19,21", + "3,5;6,9;10,11;14,16", + "3,5;6,9;10,11;14,15;20,21", + "3,5;6,9;10,11;14,16;21,22", + "3,5;6,9;10,11;14,15;20,21", + "4,6;7,10;11,12;15,16;21,22", + "4,6;7,10;11,12;15,16;24,29;40,45" + }; + + private TextView tvTips00; + + private ExpandableTextView.OnLinkClickListener linkClickListener = (type, content, selfContent) -> { + if (type.equals(LinkType.LINK_TYPE)) { + Toast.makeText(ExpandableTextViewAct.this, "你点击了链接 内容是:" + content, Toast.LENGTH_SHORT).show(); + } else if (type.equals(LinkType.MENTION_TYPE)) { + Toast.makeText(ExpandableTextViewAct.this, "你点击了@用户 内容是:" + content, Toast.LENGTH_SHORT).show(); + } else if (type.equals(LinkType.SELF)) { + Toast.makeText(ExpandableTextViewAct.this, "你点击了自定义规则 内容是:" + content + " " + selfContent, Toast.LENGTH_SHORT).show(); + } + }; + + private void initView() { + views = new ExpandableTextView[12]; + tips = new TextView[11]; + views[0] = findViewById(R.id.ep_01); + views[1] = findViewById(R.id.ep_02); + views[2] = findViewById(R.id.ep_03); + views[3] = findViewById(R.id.ep_04); + views[4] = findViewById(R.id.ep_05); + views[5] = findViewById(R.id.ep_06); + views[6] = findViewById(R.id.ep_07); + views[7] = findViewById(R.id.ep_08); + views[8] = findViewById(R.id.ep_09); + views[9] = findViewById(R.id.ep_10); + views[10] = findViewById(R.id.ep_11); + views[11] = findViewById(R.id.ep_12); + tips[0] = findViewById(R.id.tv_tips01); + tips[1] = findViewById(R.id.tv_tips02); + tips[2] = findViewById(R.id.tv_tips03); + tips[3] = findViewById(R.id.tv_tips04); + tips[4] = findViewById(R.id.tv_tips05); + tips[5] = findViewById(R.id.tv_tips06); + tips[6] = findViewById(R.id.tv_tips07); + tips[7] = findViewById(R.id.tv_tips08); + tips[8] = findViewById(R.id.tv_tips09); + tips[9] = findViewById(R.id.tv_tips10); + tips[10] = findViewById(R.id.tv_tips11); + tvTips00 = findViewById(R.id.tv_tips00); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_expandabletextview); + + initView(); + + setTips(); + String yourText = " 我所认识的中国,http://www.baidu.com 强大、友好 --习大大。@奥特曼 “一带一路”经济带带动了沿线国家的经济发展,促进我国与他国的友好往来和贸易发展,可谓“双赢”,Github地址。 自古以来,中国以和平、友好的面孔示人。汉武帝派张骞出使西域,开辟丝绸之路,增进与西域各国的友好往来。http://www.baidu.com 胡麻、胡豆、香料等食材也随之传入中国,汇集于中华美食。@RNG 漠漠古道,驼铃阵阵,这条路奠定了“一带一路”的基础,让世界认识了中国。"; +// String yourText = "1、哈哈\n2、哈哈\n3、哈哈\n4、哈哈\n5、哈哈\n6、哈哈\n7、哈哈\n8、哈哈\n9、哈哈\n1、哈哈"; +// String yourText = "1\n2考虑\n3考虑\n4考虑\n5考虑\n6考虑"; + + setContent(yourText, true); + + //在RecyclerView中查看效果 + findViewById(R.id.ll_recyclerview).setOnClickListener(v -> { + startActivity(new Intent(this, ShowInRecyclerViewActivity.class)); + }); + + //广告 从后台到app都是我自己一个人开发的 希望得到你的支持 + findViewById(R.id.ll_ad).setOnClickListener(v -> { + Uri uri = Uri.parse("http://a.app.qq.com/o/simple.jsp?pkgname=com.cretin"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + }); + } + + /** + * 设置内容 + * + * @param yourText + * @param d + */ + private void setContent(String yourText, boolean d) { + //1、正常带链接和@用户,没有展开和收回功能 + views[0].setContent(yourText); + views[0].setLinkClickListener(linkClickListener); + + //2、正常带链接,不带@用户,有展开和收回功能,有切换动画 + views[1].setContent(yourText); + views[1].setLinkClickListener(linkClickListener); + views[11].setContent(yourText); + views[11].setLinkClickListener(linkClickListener); + //添加展开和收回操作 + views[1].setExpandOrContractClickListener(type -> { + if (type.equals(StatusType.STATUS_CONTRACT)) { + Toast.makeText(ExpandableTextViewAct.this, "收回操作", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(ExpandableTextViewAct.this, "展开操作", Toast.LENGTH_SHORT).show(); + } + }); + //添加展开和收回操作 只触发点击 不真正触发展开和收回操作 + views[11].setExpandOrContractClickListener(type -> { + if (type.equals(StatusType.STATUS_CONTRACT)) { + Toast.makeText(ExpandableTextViewAct.this, "收回操作,不真正触发收回操作", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(ExpandableTextViewAct.this, "展开操作,不真正触发展开操作", Toast.LENGTH_SHORT).show(); + } + }, false); + + //3、正常不带链接,不带@用户,有展开和收回功能,有切换动画 + views[2].setContent(yourText); + views[2].setLinkClickListener(linkClickListener); + + //4、正常带链接和@用户,有展开和收回功能,有切换动画 + views[3].setContent(yourText); + views[3].setLinkClickListener(linkClickListener); + views[3].setNeedSelf(true); + + //5、正常带链接和@用户,有展开和收回功能,没有切换动画 + views[4].setContent(yourText); + views[4].setLinkClickListener(linkClickListener); + + //6、正常带链接和@用户,有展开,没有收回功能 + views[5].setContent(yourText); + views[5].setLinkClickListener(linkClickListener); + + //7、正常带链接和@用户,有展开,有收回功能,带附加内容(比如时间) + views[6].setContent(yourText); + views[6].setEndExpendContent(" 1小时前"); + views[6].setLinkClickListener(linkClickListener); + + //8、正常带链接和@用户,有展开,没有收回功能,带附加内容(比如时间) + views[7].setContent(yourText); + views[7].setEndExpendContent(" 1小时前"); + views[7].setLinkClickListener(linkClickListener); + + //9、正常带链接和@用户,有展开,有收回功能,有'展开'和'收起'始终靠右显示的功能 + views[8].setContent(yourText); + views[8].setLinkClickListener(linkClickListener); + //需要先开启始终靠右显示的功能 + views[8].setNeedAlwaysShowRight(true); + + //10、正常带链接和@用户,有展开,有收回功能,带自定义规则(解析[标题](规则)并处理,例如对一些字段进行自定义处理,比如文字中的"--习大大" 和 "Gitbub地址") + //如果你需要对一些字段进行自定义处理,比如文字中的"--习大大" 和 "Gitbub地址",你需要按照下面的形式去组装数据,这样控件就可以自动去解析并展示。 + /** + * 如需使用此功能,需要先开启 + * app:ep_need_self="true" + * views[8].setNeedSelf(true); + */ + String yourText1 = ""; + if (d) { + yourText1 = " 我所认识的中国,强大、友好,[--习大大](schema_jump_userinfo)。[http://www.baidu.com](http://www.baidu.com),@奥特曼 “一带一路”经济带带动了沿线国家的经济发展,促进我国与他国的友好往来和贸易发展,可谓“双赢”,[Github地址](https://github.com/MZCretin/ExpandableTextView)。http://www.baidu.com 自古以来,中国以和平、友好的面孔示人。汉武帝派张骞出使西域,开辟丝绸之路,增进与西域各国的友好往来。http://www.baidu.com 胡麻、胡豆、香料等食材也随之传入中国,汇集于中华美食。@RNG 漠漠古道,驼铃阵阵,这条路奠定了“一带一路”的基础,让世界认识了中国。"; + } else { + tips[9].setText("10、正常带链接和@用户,有展开,有收回功能,带自定义规则"); + yourText1 = yourText; + setTips(); + } + views[9].setContent(yourText1); + views[9].setLinkClickListener(linkClickListener); + //需要先开启 + views[9].setNeedSelf(true); + + //11、正常带链接和@用户,有展开,有收回功能,文本中链接不转换成网页链接的文本提示 + views[10].setContent(yourText); + views[10].setLinkClickListener(linkClickListener); + //监听是否初始化完成 在这里可以获取是否支持展开/收回 + views[10].setOnGetLineCountListener(new ExpandableTextView.OnGetLineCountListener() { + @Override + public void onGetLineCount(int lineCount, boolean canExpand) { + Toast.makeText(ExpandableTextViewAct.this, "行数:" + lineCount + " 是否满足展开条件:" + canExpand, Toast.LENGTH_SHORT).show(); + } + }); + } + + /** + * 设置tips + */ + private void setTips() { + //处理最上边的Tips + final SpannableString value = SpannableString.valueOf(tvTips00.getText()); + LinkifyCompat.addLinks(value, Linkify.ALL); + tvTips00.setMovementMethod(LinkMovementMethod.getInstance()); + tvTips00.setText(value); + + //处理剩下的 + for (int i = 0; i < indexs.length; i++) { + String index = indexs[i]; + TextView view = tips[i]; + String[] split = index.split(";"); + SpannableStringBuilder spannableStringBuilder = + new SpannableStringBuilder(view.getText()); + for (String s : + split) { + int x = Integer.parseInt(s.split(",")[0]) + 2; + int y = Integer.parseInt(s.split(",")[1]) + 2; + spannableStringBuilder.setSpan( + new ForegroundColorSpan(Color.parseColor("#FF6200")), + x, y, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + } + view.setText(spannableStringBuilder); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_layout, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + View view = LayoutInflater.from(this).inflate(R.layout.dialog_input, null); + new AlertDialog.Builder(this) + .setMessage("请输入将要替换的内容:") + .setTitle("提示") + .setView(view) + .setNegativeButton("取消", (dialog, which) -> dialog.dismiss()) + .setPositiveButton("确定", (dialog, which) -> { + EditText editText = view.findViewById(R.id.ed_content); + String string = editText.getText().toString(); + if (TextUtils.isEmpty(string)) { + Toast.makeText(this, "内容不能为空", Toast.LENGTH_SHORT).show(); + return; + } + setContent(string, false); + dialog.dismiss(); + }) + .show(); + return super.onOptionsItemSelected(item); + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ShowInRecyclerViewActivity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ShowInRecyclerViewActivity.java new file mode 100644 index 00000000..da1ebf7e --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ShowInRecyclerViewActivity.java @@ -0,0 +1,172 @@ +package com.haier.cellarette.baselibrary.expandabletextview; + +import android.app.AlertDialog; +import android.content.Context; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.ctetin.expandabletextviewlibrary.ExpandableTextView; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.haier.cellarette.baselibrary.R; + +import java.util.ArrayList; +import java.util.List; + +public class ShowInRecyclerViewActivity extends AppCompatActivity { + private RecyclerView recyclerView; + private MyRecyclerViewAdapter adapter; + private List list; + + private FloatingActionButton floatingActionButton; + + //是需要保存展开或收回状态 + private boolean flag = true; + private String content; + + private String yourText = "我所认识的中国,强大、友好我所认识的中国,强大、友好。@奥特曼 “一带一路”经济带带动了沿线国家的经济发展,促进我国与他国的友好往来和贸易发展,可谓“双赢”。http://www.baidu.com 自古以来,中国以和平、友好的面孔示人。汉武帝派张骞出使西域,开辟丝绸之路,增进与西域各国的友好往来。http://www.baidu.com 胡麻、胡豆、香料等食材也随之传入中国,汇集于中华美食。@RNG 漠漠古道,驼铃阵阵,这条路奠定了“一带一路”的基础,让世界认识了中国。"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_show_in_recycler_view); + + recyclerView = findViewById(R.id.recyclerview); + floatingActionButton = findViewById(R.id.float_btn); + + list = new ArrayList<>(); + changeStateAndSetData(null, false); + + floatingActionButton.setOnClickListener(v -> changeStateAndSetData(content, true)); + } + + /** + * 切换状态 + */ + private void changeStateAndSetData(String content, boolean change) { + if (change) + flag = !flag; + list.clear(); + if (flag) { + Toast.makeText(this, "保留之前的展开或收回状态", Toast.LENGTH_SHORT).show(); + floatingActionButton.setImageResource(R.mipmap.green); + for (int i = 0; i < 50; i++) { + if (TextUtils.isEmpty(content)) + list.add(new ViewModelWithFlag("第" + (i + 1) + "条数据:" + yourText)); + else + list.add(new ViewModelWithFlag("第" + (i + 1) + "条数据:" + content)); + } + } else { + Toast.makeText(this, "不保留之前的展开或收回状态", Toast.LENGTH_SHORT).show(); + floatingActionButton.setImageResource(R.mipmap.gray); + for (int i = 0; i < 50; i++) { + if (TextUtils.isEmpty(content)) + list.add(new ViewModel("第" + (i + 1) + "条数据:" + yourText)); + else + list.add(new ViewModel("第" + (i + 1) + "条数据:" + content)); + } + } + adapter = new MyRecyclerViewAdapter(this, list); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); + recyclerView.setAdapter(adapter); + adapter.notifyDataSetChanged(); + } + + + public class MyRecyclerViewAdapter extends RecyclerView.Adapter { + private Context mContext; + private List dataList; + + public MyRecyclerViewAdapter(Context context, List list) { + this.mContext = context; + this.dataList = list; + } + + @Override + public RecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(mContext).inflate(R.layout.item_text, parent, false); + return new RecyclerHolder(view); + } + + @Override + public void onBindViewHolder(RecyclerHolder holder, int position) { + if (flag) { + //注意:保留状态需要在设置内容之前调用bind方法 + holder.textView.bind((ViewModelWithFlag) list.get(position)); + holder.textView.setContent(((ViewModelWithFlag) list.get(position)).getTitle()); + } else { + holder.textView.setContent(((ViewModel) list.get(position)).getTitle()); + } + holder.textView.setLinkClickListener((type, content, selfContent) -> { + switch (type) { + case LINK_TYPE: + Toast.makeText(mContext, "点击链接:" + content, Toast.LENGTH_SHORT).show(); + break; + case MENTION_TYPE: + Toast.makeText(mContext, "点击用户:" + content, Toast.LENGTH_SHORT).show(); + break; + case SELF: + Toast.makeText(mContext, "你点击了自定义规则 内容是:" + content + " " + selfContent, Toast.LENGTH_SHORT).show(); + break; + } + }); + } + + @Override + public int getItemCount() { + return dataList.size(); + } + + class RecyclerHolder extends RecyclerView.ViewHolder { + private ExpandableTextView textView; + + private RecyclerHolder(View itemView) { + super(itemView); + textView = itemView.findViewById(R.id.tv_item); + itemView.setOnClickListener(v -> Toast.makeText( + ShowInRecyclerViewActivity.this, "您点击了第" + getLayoutPosition() + "个Item", Toast.LENGTH_SHORT).show()); + } + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_layout, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + View view = LayoutInflater.from(this).inflate(R.layout.dialog_input, null); + new AlertDialog.Builder(this) + .setMessage("请输入将要替换的内容:") + .setTitle("提示") + .setView(view) + .setNegativeButton("取消", (dialog, which) -> dialog.dismiss()) + .setPositiveButton("确定", (dialog, which) -> { + EditText editText = view.findViewById(R.id.ed_content); + String string = editText.getText().toString(); + if (TextUtils.isEmpty(string)) { + Toast.makeText(this, "内容不能为空", Toast.LENGTH_SHORT).show(); + return; + } + content = string; + changeStateAndSetData(string, false); + dialog.dismiss(); + }) + .show(); + return super.onOptionsItemSelected(item); + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ViewModel.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ViewModel.java new file mode 100644 index 00000000..e2e13d96 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ViewModel.java @@ -0,0 +1,23 @@ +package com.haier.cellarette.baselibrary.expandabletextview; + +/** + * @date: on 2018/9/20 + * @author: cretin + * @email: mxnzp_life@163.com + * @desc: ViewModel 不需要记住之前的状态 + */ +public class ViewModel { + private String title; + + public ViewModel(String title) { + this.title = title; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ViewModelWithFlag.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ViewModelWithFlag.java new file mode 100644 index 00000000..b6875bdf --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/expandabletextview/ViewModelWithFlag.java @@ -0,0 +1,44 @@ +package com.haier.cellarette.baselibrary.expandabletextview; + +import com.ctetin.expandabletextviewlibrary.app.StatusType; +import com.ctetin.expandabletextviewlibrary.model.ExpandableStatusFix; + +/** + * @date: on 2018/9/20 + * @author: cretin + * @email: mxnzp_life@163.com + * @desc: 如果你需要在滑动的时候保持之前的展开或者收起的状态 + * 则 + * 一、实现 ExpandableStatusFix + * 二、在你的model中定义一个 + * private StatusType status; + * 三、实现对应的方法,将你刚刚定义的status返回, + * 四、并在给ExpandableTextView设置内容之前,调用bind方法 + */ +public class ViewModelWithFlag implements ExpandableStatusFix { + private StatusType status; + + public ViewModelWithFlag(String title) { + this.title = title; + } + + private String title; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Override + public void setStatus(StatusType status) { + this.status = status; + } + + @Override + public StatusType getStatus() { + return status; + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/MarqueeView.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/MarqueeView.java index df61f7e6..5b31c241 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/MarqueeView.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/MarqueeView.java @@ -7,7 +7,6 @@ import android.view.animation.Animation; import android.widget.ViewFlipper; - import androidx.annotation.AnimRes; import androidx.annotation.Nullable; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/ComplexItemEntity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/ComplexItemEntity.java new file mode 100644 index 00000000..f568f9e4 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/ComplexItemEntity.java @@ -0,0 +1,51 @@ +package com.haier.cellarette.baselibrary.marqueelibrary.ui; + +/** + * Created by GongWen on 16/12/27. + */ + +public class ComplexItemEntity { + + private String title; + private String secondTitle; + private String time; + + public ComplexItemEntity(String title, String secondTitle, String time) { + this.title = title; + this.secondTitle = secondTitle; + this.time = time; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSecondTitle() { + return secondTitle; + } + + public void setSecondTitle(String secondTitle) { + this.secondTitle = secondTitle; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + @Override + public String toString() { + return "{" + + "title='" + title + '\'' + + ", secondTitle='" + secondTitle + '\'' + + ", time='" + time + '\'' + + '}'; + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/ComplexViewMF.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/ComplexViewMF.java new file mode 100644 index 00000000..b2a64246 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/ComplexViewMF.java @@ -0,0 +1,28 @@ +package com.haier.cellarette.baselibrary.marqueelibrary.ui; + +import android.content.Context; +import android.view.LayoutInflater; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.haier.cellarette.baselibrary.R; +import com.haier.cellarette.baselibrary.marqueelibrary.MarqueeFactory; + + +public class ComplexViewMF extends MarqueeFactory { + private LayoutInflater inflater; + + public ComplexViewMF(Context mContext) { + super(mContext); + inflater = LayoutInflater.from(mContext); + } + + @Override + public RelativeLayout generateMarqueeItemView(ComplexItemEntity data) { + RelativeLayout mView = (RelativeLayout) inflater.inflate(R.layout.complex_view, null); + ((TextView) mView.findViewById(R.id.title)).setText(data.getTitle()); + ((TextView) mView.findViewById(R.id.secondTitle)).setText(data.getSecondTitle()); + ((TextView) mView.findViewById(R.id.time)).setText(data.getTime()); + return mView; + } +} \ No newline at end of file diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/MarqueeViewLibraryAct.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/MarqueeViewLibraryAct.java new file mode 100644 index 00000000..0025a8ca --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/MarqueeViewLibraryAct.java @@ -0,0 +1,160 @@ +package com.haier.cellarette.baselibrary.marqueelibrary.ui; + +import android.os.Bundle; +import android.text.Html; +import android.text.Spanned; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.drawable.DrawableCompat; + +import com.haier.cellarette.baselibrary.R; +import com.haier.cellarette.baselibrary.marqueelibrary.MarqueeFactory; +import com.haier.cellarette.baselibrary.marqueelibrary.MarqueeView; +import com.haier.cellarette.baselibrary.marqueelibrary.SimpleMF; +import com.haier.cellarette.baselibrary.marqueelibrary.SimpleMarqueeView; +import com.haier.cellarette.baselibrary.marqueelibrary.util.OnItemClickListener; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +public class MarqueeViewLibraryAct extends AppCompatActivity { + private final List datas = Arrays.asList("《赋得古原草送别》", "离离原上草,一岁一枯荣。", "野火烧不尽,春风吹又生。", "远芳侵古道,晴翠接荒城。", "又送王孙去,萋萋满别情。", "测试测试测试测试测试测试测试测试测试测试测试"); + private SimpleMarqueeView marqueeView1, marqueeView2, marqueeView5, marqueeView6; + private SimpleMarqueeView marqueeView3; + private ImageView yellowSpeaker; + private MarqueeView marqueeView4; + + private WeakHandler mHandler = new WeakHandler(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_marqueeviewlibrary); + marqueeView1 = findViewById(R.id.marqueeView1); + marqueeView2 = findViewById(R.id.marqueeView2); + marqueeView3 = findViewById(R.id.marqueeView3); + yellowSpeaker = findViewById(R.id.yellowSpeaker); + marqueeView4 = findViewById(R.id.marqueeView4); + marqueeView5 = findViewById(R.id.marqueeView5); + marqueeView6 = findViewById(R.id.marqueeView6); + DrawableCompat.setTint(DrawableCompat.wrap(yellowSpeaker.getDrawable().mutate()), getResources().getColor(R.color.yellow)); + + initMarqueeView1(); + initMarqueeView2(); + initMarqueeView3(); + initMarqueeView4(); + initMarqueeView5(); + initMarqueeView6(); + } + + private void initMarqueeView1() { + SimpleMF marqueeFactory = new SimpleMF(MarqueeViewLibraryAct.this); + marqueeFactory.setData(datas); + marqueeView1.setMarqueeFactory(marqueeFactory); + marqueeView1.startFlipping(); + marqueeView1.setOnItemClickListener(onSimpleItemClickListener); + } + + private void initMarqueeView2() { + SimpleMF marqueeFactory2 = new SimpleMF(MarqueeViewLibraryAct.this); + marqueeFactory2.setData(datas); + marqueeView2.setMarqueeFactory(marqueeFactory2); + marqueeView2.startFlipping(); + marqueeView2.setOnItemClickListener(onSimpleItemClickListener); + } + + private void initMarqueeView3() { + SimpleMF marqueeFactory3 = new SimpleMF<>(MarqueeViewLibraryAct.this); + List datas3 = new ArrayList<>(); + datas3.add(Html.fromHtml("《赋得古原草送别》")); + datas3.add(Html.fromHtml("离离原上草,一岁一枯荣。")); + datas3.add(Html.fromHtml("野火烧不尽,春风吹又生。")); + datas3.add(Html.fromHtml("远芳侵古道,晴翠接荒城。")); + datas3.add(Html.fromHtml("又送王孙去,萋萋满别情。")); + marqueeFactory3.setData(datas3); + marqueeView3.setMarqueeFactory(marqueeFactory3); + marqueeView3.startFlipping(); + marqueeView3.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClickListener(TextView mView, Spanned mData, int mPosition) { + Toast.makeText(MarqueeViewLibraryAct.this, String.format("mPosition:%s,mData:%s,mView:%s,.", mPosition, mData, mView), Toast.LENGTH_SHORT).show(); + } + }); + } + + private void initMarqueeView4() { + List complexDatas = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + complexDatas.add(new ComplexItemEntity("标题 " + i, "副标题 " + i, "时间 " + i)); + } + MarqueeFactory marqueeFactory = new ComplexViewMF(MarqueeViewLibraryAct.this); + + marqueeFactory.setData(complexDatas); + marqueeView4.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClickListener(RelativeLayout mView, ComplexItemEntity mData, int mPosition) { + Toast.makeText(MarqueeViewLibraryAct.this, String.format("mPosition:%s,mData:%s,mView:%s,.", mPosition, mData, mView), Toast.LENGTH_SHORT).show(); + } + }); + marqueeView4.setInAndOutAnim(R.anim.in_top, R.anim.out_bottom); + marqueeView4.setMarqueeFactory(marqueeFactory); + marqueeView4.startFlipping(); + } + + private void initMarqueeView5() { + SimpleMF marqueeFactory = new SimpleMF(this); + marqueeFactory.setData(datas); + marqueeView5.setOnItemClickListener(onSimpleItemClickListener); + marqueeView5.setMarqueeFactory(marqueeFactory); + marqueeView5.startFlipping(); + } + + private void initMarqueeView6() { + final SimpleMF marqueeFactory = new SimpleMF<>(this); + marqueeFactory.setData(datas); + marqueeView6.setOnItemClickListener(onSimpleItemClickListener); + marqueeView6.setMarqueeFactory(marqueeFactory); + marqueeView6.startFlipping(); + + //测试重置数据效果 + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + Random random = new Random(); + int delayMillis = (random.nextInt(5) + 4) * 1000; + marqueeFactory.setData(datas); + mHandler.postDelayed(this, delayMillis); + } + }, 8000); + } + + @Override + public void onStart() { + super.onStart(); + marqueeView1.startFlipping(); + marqueeView2.startFlipping(); + marqueeView3.startFlipping(); + } + + @Override + public void onStop() { + super.onStop(); + marqueeView1.stopFlipping(); + marqueeView2.stopFlipping(); + marqueeView3.stopFlipping(); + } + + private OnItemClickListener onSimpleItemClickListener = new OnItemClickListener() { + @Override + public void onItemClickListener(TextView mView, String mData, int mPosition) { + Toast.makeText(MarqueeViewLibraryAct.this, String.format("mPosition:%s,mData:%s,mView:%s,.", mPosition, mData, mView), Toast.LENGTH_SHORT).show(); + } + }; +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/WeakHandler.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/WeakHandler.java new file mode 100644 index 00000000..9fcf8e72 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/marqueelibrary/ui/WeakHandler.java @@ -0,0 +1,518 @@ +/* + * Copyright (c) 2014 Badoo Trading Limited + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Portions of documentation in this code are modifications based on work created and + * shared by Android Open Source Project and used according to terms described in the + * Apache License, Version 2.0 + */ +package com.haier.cellarette.baselibrary.marqueelibrary.ui; + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; + + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; + +import java.lang.ref.WeakReference; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * Memory safer implementation of android.os.Handler + *

+ * Original implementation of Handlers always keeps hard reference to handler in queue of execution. + * If you create anonymous handler and post delayed message into it, it will keep all parent class + * for that time in memory even if it could be cleaned. + *

+ * This implementation is trickier, it will keep WeakReferences to runnables and messages, + * and GC could collect them once WeakHandler instance is not referenced any more + *

+ * + * @see Handler + * + * Created by Dmytro Voronkevych on 17/06/2014. + */ +@SuppressWarnings("unused") +public class WeakHandler { + private final Handler.Callback mCallback; // hard reference to Callback. We need to keep callback in memory + private final ExecHandler mExec; + private Lock mLock = new ReentrantLock(); + @SuppressWarnings("ConstantConditions") + @VisibleForTesting + final ChainedRef mRunnables = new ChainedRef(mLock, null); + + /** + * Default constructor associates this handler with the {@link Looper} for the + * current thread. + * + * If this thread does not have a looper, this handler won't be able to receive messages + * so an exception is thrown. + */ + public WeakHandler() { + mCallback = null; + mExec = new ExecHandler(); + } + + /** + * Constructor associates this handler with the {@link Looper} for the + * current thread and takes a callback interface in which you can handle + * messages. + * + * If this thread does not have a looper, this handler won't be able to receive messages + * so an exception is thrown. + * + * @param callback The callback interface in which to handle messages, or null. + */ + public WeakHandler(@Nullable Handler.Callback callback) { + mCallback = callback; // Hard referencing body + mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler + } + + /** + * Use the provided {@link Looper} instead of the default one. + * + * @param looper The looper, must not be null. + */ + public WeakHandler(@NonNull Looper looper) { + mCallback = null; + mExec = new ExecHandler(looper); + } + + /** + * Use the provided {@link Looper} instead of the default one and take a callback + * interface in which to handle messages. + * + * @param looper The looper, must not be null. + * @param callback The callback interface in which to handle messages, or null. + */ + public WeakHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) { + mCallback = callback; + mExec = new ExecHandler(looper, new WeakReference<>(callback)); + } + + /** + * Causes the Runnable r to be added to the message queue. + * The runnable will be run on the thread to which this handler is + * attached. + * + * @param r The Runnable that will be executed. + * + * @return Returns true if the Runnable was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean post(@NonNull Runnable r) { + return mExec.post(wrapRunnable(r)); + } + + /** + * Causes the Runnable r to be added to the message queue, to be run + * at a specific time given by uptimeMillis. + * The time-base is {@link android.os.SystemClock#uptimeMillis}. + * The runnable will be run on the thread to which this handler is attached. + * + * @param r The Runnable that will be executed. + * @param uptimeMillis The absolute time at which the callback should run, + * using the {@link android.os.SystemClock#uptimeMillis} time-base. + * + * @return Returns true if the Runnable was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. Note that a + * result of true does not mean the Runnable will be processed -- if + * the looper is quit before the delivery time of the message + * occurs then the message will be dropped. + */ + public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) { + return mExec.postAtTime(wrapRunnable(r), uptimeMillis); + } + + /** + * Causes the Runnable r to be added to the message queue, to be run + * at a specific time given by uptimeMillis. + * The time-base is {@link android.os.SystemClock#uptimeMillis}. + * The runnable will be run on the thread to which this handler is attached. + * + * @param r The Runnable that will be executed. + * @param uptimeMillis The absolute time at which the callback should run, + * using the {@link android.os.SystemClock#uptimeMillis} time-base. + * + * @return Returns true if the Runnable was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. Note that a + * result of true does not mean the Runnable will be processed -- if + * the looper is quit before the delivery time of the message + * occurs then the message will be dropped. + * + * @see android.os.SystemClock#uptimeMillis + */ + public final boolean postAtTime(Runnable r, Object token, long uptimeMillis) { + return mExec.postAtTime(wrapRunnable(r), token, uptimeMillis); + } + + /** + * Causes the Runnable r to be added to the message queue, to be run + * after the specified amount of time elapses. + * The runnable will be run on the thread to which this handler + * is attached. + * + * @param r The Runnable that will be executed. + * @param delayMillis The delay (in milliseconds) until the Runnable + * will be executed. + * + * @return Returns true if the Runnable was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. Note that a + * result of true does not mean the Runnable will be processed -- + * if the looper is quit before the delivery time of the message + * occurs then the message will be dropped. + */ + public final boolean postDelayed(Runnable r, long delayMillis) { + return mExec.postDelayed(wrapRunnable(r), delayMillis); + } + + /** + * Posts a message to an object that implements Runnable. + * Causes the Runnable r to executed on the next iteration through the + * message queue. The runnable will be run on the thread to which this + * handler is attached. + * This method is only for use in very special circumstances -- it + * can easily starve the message queue, cause ordering problems, or have + * other unexpected side-effects. + * + * @param r The Runnable that will be executed. + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean postAtFrontOfQueue(Runnable r) { + return mExec.postAtFrontOfQueue(wrapRunnable(r)); + } + + /** + * Remove any pending posts of Runnable r that are in the message queue. + */ + public final void removeCallbacks(Runnable r) { + final WeakRunnable runnable = mRunnables.remove(r); + if (runnable != null) { + mExec.removeCallbacks(runnable); + } + } + + /** + * Remove any pending posts of Runnable r with Object + * token that are in the message queue. If token is null, + * all callbacks will be removed. + */ + public final void removeCallbacks(Runnable r, Object token) { + final WeakRunnable runnable = mRunnables.remove(r); + if (runnable != null) { + mExec.removeCallbacks(runnable, token); + } + } + + /** + * Pushes a message onto the end of the message queue after all pending messages + * before the current time. It will be received in callback, + * in the thread attached to this handler. + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean sendMessage(Message msg) { + return mExec.sendMessage(msg); + } + + /** + * Sends a Message containing only the what value. + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean sendEmptyMessage(int what) { + return mExec.sendEmptyMessage(what); + } + + /** + * Sends a Message containing only the what value, to be delivered + * after the specified amount of time elapses. + * @see #sendMessageDelayed(Message, long) + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean sendEmptyMessageDelayed(int what, long delayMillis) { + return mExec.sendEmptyMessageDelayed(what, delayMillis); + } + + /** + * Sends a Message containing only the what value, to be delivered + * at a specific time. + * @see #sendMessageAtTime(Message, long) + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean sendEmptyMessageAtTime(int what, long uptimeMillis) { + return mExec.sendEmptyMessageAtTime(what, uptimeMillis); + } + + /** + * Enqueue a message into the message queue after all pending messages + * before (current time + delayMillis). You will receive it in + * callback, in the thread attached to this handler. + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. Note that a + * result of true does not mean the message will be processed -- if + * the looper is quit before the delivery time of the message + * occurs then the message will be dropped. + */ + public final boolean sendMessageDelayed(Message msg, long delayMillis) { + return mExec.sendMessageDelayed(msg, delayMillis); + } + + /** + * Enqueue a message into the message queue after all pending messages + * before the absolute time (in milliseconds) uptimeMillis. + * The time-base is {@link android.os.SystemClock#uptimeMillis}. + * You will receive it in callback, in the thread attached + * to this handler. + * + * @param uptimeMillis The absolute time at which the message should be + * delivered, using the + * {@link android.os.SystemClock#uptimeMillis} time-base. + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. Note that a + * result of true does not mean the message will be processed -- if + * the looper is quit before the delivery time of the message + * occurs then the message will be dropped. + */ + public boolean sendMessageAtTime(Message msg, long uptimeMillis) { + return mExec.sendMessageAtTime(msg, uptimeMillis); + } + + /** + * Enqueue a message at the front of the message queue, to be processed on + * the next iteration of the message loop. You will receive it in + * callback, in the thread attached to this handler. + * This method is only for use in very special circumstances -- it + * can easily starve the message queue, cause ordering problems, or have + * other unexpected side-effects. + * + * @return Returns true if the message was successfully placed in to the + * message queue. Returns false on failure, usually because the + * looper processing the message queue is exiting. + */ + public final boolean sendMessageAtFrontOfQueue(Message msg) { + return mExec.sendMessageAtFrontOfQueue(msg); + } + + /** + * Remove any pending posts of messages with code 'what' that are in the + * message queue. + */ + public final void removeMessages(int what) { + mExec.removeMessages(what); + } + + /** + * Remove any pending posts of messages with code 'what' and whose obj is + * 'object' that are in the message queue. If object is null, + * all messages will be removed. + */ + public final void removeMessages(int what, Object object) { + mExec.removeMessages(what, object); + } + + /** + * Remove any pending posts of callbacks and sent messages whose + * obj is token. If token is null, + * all callbacks and messages will be removed. + */ + public final void removeCallbacksAndMessages(Object token) { + mExec.removeCallbacksAndMessages(token); + } + + /** + * Check if there are any pending posts of messages with code 'what' in + * the message queue. + */ + public final boolean hasMessages(int what) { + return mExec.hasMessages(what); + } + + /** + * Check if there are any pending posts of messages with code 'what' and + * whose obj is 'object' in the message queue. + */ + public final boolean hasMessages(int what, Object object) { + return mExec.hasMessages(what, object); + } + + public final Looper getLooper() { + return mExec.getLooper(); + } + + private WeakRunnable wrapRunnable(@NonNull Runnable r) { + //noinspection ConstantConditions + if (r == null) { + throw new NullPointerException("Runnable can't be null"); + } + final ChainedRef hardRef = new ChainedRef(mLock, r); + mRunnables.insertAfter(hardRef); + return hardRef.wrapper; + } + + private static class ExecHandler extends Handler { + private final WeakReference mCallback; + + ExecHandler() { + mCallback = null; + } + + ExecHandler(WeakReference callback) { + mCallback = callback; + } + + ExecHandler(Looper looper) { + super(looper); + mCallback = null; + } + + ExecHandler(Looper looper, WeakReference callback) { + super(looper); + mCallback = callback; + } + + @Override + public void handleMessage(@NonNull Message msg) { + if (mCallback == null) { + return; + } + final Callback callback = mCallback.get(); + if (callback == null) { // Already disposed + return; + } + callback.handleMessage(msg); + } + } + + static class WeakRunnable implements Runnable { + private final WeakReference mDelegate; + private final WeakReference mReference; + + WeakRunnable(WeakReference delegate, WeakReference reference) { + mDelegate = delegate; + mReference = reference; + } + + @Override + public void run() { + final Runnable delegate = mDelegate.get(); + final ChainedRef reference = mReference.get(); + if (reference != null) { + reference.remove(); + } + if (delegate != null) { + delegate.run(); + } + } + } + + static class ChainedRef { + @Nullable + ChainedRef next; + @Nullable + ChainedRef prev; + @NonNull + final Runnable runnable; + @NonNull + final WeakRunnable wrapper; + + @NonNull + Lock lock; + + public ChainedRef(@NonNull Lock lock, @NonNull Runnable r) { + this.runnable = r; + this.lock = lock; + this.wrapper = new WeakRunnable(new WeakReference<>(r), new WeakReference<>(this)); + } + + public WeakRunnable remove() { + lock.lock(); + try { + if (prev != null) { + prev.next = next; + } + if (next != null) { + next.prev = prev; + } + prev = null; + next = null; + } finally { + lock.unlock(); + } + return wrapper; + } + + public void insertAfter(@NonNull ChainedRef candidate) { + lock.lock(); + try { + if (this.next != null) { + this.next.prev = candidate; + } + + candidate.next = this.next; + this.next = candidate; + candidate.prev = this; + } finally { + lock.unlock(); + } + } + + @Nullable + public WeakRunnable remove(Runnable obj) { + lock.lock(); + try { + ChainedRef curr = this.next; // Skipping head + while (curr != null) { + if (curr.runnable == obj) { // We do comparison exactly how Handler does inside + return curr.remove(); + } + curr = curr.next; + } + } finally { + lock.unlock(); + } + return null; + } + } +} \ No newline at end of file diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetModel.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetModel.java index 99ffde3c..473f62e8 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetModel.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetModel.java @@ -97,7 +97,7 @@ public void initReceiver(Context context) { public static void showWifiDlg(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context.getApplicationContext()); if (mWifiDialog == null) { - mWifiDialog = builder.setIcon(R.drawable.smartbar_home_icon) // + mWifiDialog = builder.setIcon(R.drawable.icon_download_new) // .setTitle("wifi设置") // .setMessage("当前无网络").setPositiveButton("设置", new DialogInterface .OnClickListener() { @@ -138,7 +138,7 @@ public void onClick(DialogInterface dialog, int which) { public static void showNoNetWorkDlg(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context.getApplicationContext()); if (mAlertDialog == null) { - mAlertDialog = builder.setIcon(R.drawable.smartbar_home_icon) // + mAlertDialog = builder.setIcon(R.drawable.icon_download_new) // .setTitle("网络设置") // .setMessage("当前无网络").setPositiveButton("设置", new DialogInterface .OnClickListener() { diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetStateUtils.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetStateUtils.java index 269875e1..ae1c3997 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetStateUtils.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/networkview/NetStateUtils.java @@ -1,6 +1,7 @@ package com.haier.cellarette.baselibrary.networkview; import android.Manifest; +import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; import android.location.LocationManager; @@ -68,6 +69,7 @@ public static boolean is2G(Context context) { /** * wifi是否打开 */ + @SuppressLint("MissingPermission") public static boolean isWifiEnabled(Context context) { ConnectivityManager mgrConn = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); diff --git a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/ConvertUtil.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/ConvertUtil.java similarity index 94% rename from yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/ConvertUtil.java rename to commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/ConvertUtil.java index 37d43798..00752e27 100644 --- a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/ConvertUtil.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/ConvertUtil.java @@ -1,4 +1,4 @@ -package com.example.slbappcomm.ratingstarview; +package com.haier.cellarette.baselibrary.ratingstarview; import android.text.TextUtils; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/PingfenMainActivity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/PingfenMainActivity.java new file mode 100644 index 00000000..655e5049 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/PingfenMainActivity.java @@ -0,0 +1,22 @@ +package com.haier.cellarette.baselibrary.ratingstarview; + +import android.os.Bundle; + +import androidx.appcompat.app.AppCompatActivity; + +import com.haier.cellarette.baselibrary.R; + +// https://github.com/everhad/AndroidRatingStar +// api 'com.github.everhad:AndroidRatingStar:v1.0.4' + +public class PingfenMainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_pingfen); + + RatingStarView rsv_rating = (RatingStarView) findViewById(R.id.rsv_rating); + rsv_rating.setRating(1.5f); + } +} \ No newline at end of file diff --git a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/RatingStarView.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/RatingStarView.java similarity index 99% rename from yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/RatingStarView.java rename to commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/RatingStarView.java index 3a3a5fab..fc260e00 100644 --- a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/RatingStarView.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/RatingStarView.java @@ -1,4 +1,4 @@ -package com.example.slbappcomm.ratingstarview; +package com.haier.cellarette.baselibrary.ratingstarview; import android.content.Context; import android.content.res.TypedArray; @@ -13,7 +13,7 @@ import android.view.MotionEvent; import android.view.View; -import com.example.slbappcomm.R; +import com.haier.cellarette.baselibrary.R; import java.util.ArrayList; diff --git a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/StarModel.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/StarModel.java similarity index 99% rename from yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/StarModel.java rename to commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/StarModel.java index 5fe00112..cf01adf8 100644 --- a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/StarModel.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/StarModel.java @@ -1,4 +1,4 @@ -package com.example.slbappcomm.ratingstarview; +package com.haier.cellarette.baselibrary.ratingstarview; import android.graphics.RectF; diff --git a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/VertexF.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/VertexF.java similarity index 80% rename from yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/VertexF.java rename to commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/VertexF.java index 934ad7a2..72ecb766 100644 --- a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/ratingstarview/VertexF.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/ratingstarview/VertexF.java @@ -1,4 +1,4 @@ -package com.example.slbappcomm.ratingstarview; +package com.haier.cellarette.baselibrary.ratingstarview; /** * Created by hxw on 2017-04-23. diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewalluses/demo4baseadpterhelp/hunhe/adapter/BaseRecActDemo41Adapter.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewalluses/demo4baseadpterhelp/hunhe/adapter/BaseRecActDemo41Adapter.java index 69ed0bc1..0269c7f5 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewalluses/demo4baseadpterhelp/hunhe/adapter/BaseRecActDemo41Adapter.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewalluses/demo4baseadpterhelp/hunhe/adapter/BaseRecActDemo41Adapter.java @@ -74,7 +74,7 @@ protected void convert(BaseViewHolder helper, BaseRecActDemo41Bean item) { break; case BaseRecActDemo41Bean.style4: final RecyclerView mRecyclerView = helper.getView(R.id.rvlist); - mRecyclerView.setLayoutManager(new GridLayoutManager(helper.itemView.getContext(), 1, OrientationHelper.HORIZONTAL, false)); + mRecyclerView.setLayoutManager(new GridLayoutManager(helper.itemView.getContext(), 1, RecyclerView.HORIZONTAL, false)); mRecyclerView.setHasFixedSize(true); mRecyclerView.setOnFlingListener(null); mLinearSnapHelper = new LinearSnapHelper(); diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6ItemDecoration.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6ItemDecoration.java index ca0a49e9..0168ce49 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6ItemDecoration.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6ItemDecoration.java @@ -1,7 +1,7 @@ package com.haier.cellarette.baselibrary.recycleviewmultitype.viewholders.demo6; import android.graphics.Rect; -//import android.support.annotation.NonNull; +// //import androidx.appcompat.widget.GridLayoutManager.SpanSizeLookup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.GridLayoutManager; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6footerHorizontalBinder.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6footerHorizontalBinder.java index 4ae6ce1b..fd77b0e3 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6footerHorizontalBinder.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewmultitype/viewholders/demo6/ItemDemo6footerHorizontalBinder.java @@ -1,6 +1,6 @@ package com.haier.cellarette.baselibrary.recycleviewmultitype.viewholders.demo6; -//import android.support.annotation.NonNull; +// //import androidx.appcompat.widget.LinearLayoutManager; //import androidx.appcompat.widget.LinearSnapHelper; //import androidx.appcompat.widget.OrientationHelper; @@ -56,7 +56,7 @@ public ViewHolder(View itemView) { super(itemView); recyclerView = itemView.findViewById(R.id.list1); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(itemView.getContext()); - linearLayoutManager.setOrientation(OrientationHelper.HORIZONTAL); + linearLayoutManager.setOrientation(RecyclerView.HORIZONTAL); recyclerView.setLayoutManager(linearLayoutManager); new LinearSnapHelper().attachToRecyclerView(recyclerView); adapter = new ItemDemo6footerAdapter(); diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewutils/JackSnapHelper.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewutils/JackSnapHelper.java index b991b863..9d6ccdfb 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewutils/JackSnapHelper.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/recycleviewutils/JackSnapHelper.java @@ -1,7 +1,7 @@ package com.haier.cellarette.baselibrary.recycleviewutils; -//import android.support.annotation.NonNull; -//import android.support.annotation.Nullable; +// +// //import androidx.appcompat.widget.LinearLayoutManager; //import androidx.appcompat.widget.LinearSnapHelper; //import androidx.appcompat.widget.OrientationHelper; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct.java new file mode 100644 index 00000000..00180571 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct.java @@ -0,0 +1,36 @@ +package com.haier.cellarette.baselibrary.scardview; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.haier.cellarette.baselibrary.R; + +public class SCardViewAct extends AppCompatActivity { + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scardview); + findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(SCardViewAct.this, SCardViewAct1.class)); + } + }); + findViewById(R.id.btn2).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(SCardViewAct.this, SCardViewAct2.class)); + } + }); + findViewById(R.id.btn3).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(SCardViewAct.this, SCardViewAct3.class)); + } + }); + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct1.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct1.java new file mode 100644 index 00000000..d38f8d05 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct1.java @@ -0,0 +1,19 @@ +package com.haier.cellarette.baselibrary.scardview; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.haier.cellarette.baselibrary.R; + +public class SCardViewAct1 extends AppCompatActivity { + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scardview1); + + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct2.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct2.java new file mode 100644 index 00000000..23fd2322 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct2.java @@ -0,0 +1,19 @@ +package com.haier.cellarette.baselibrary.scardview; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.haier.cellarette.baselibrary.R; + +public class SCardViewAct2 extends AppCompatActivity { + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scardview2); + + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct3.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct3.java new file mode 100644 index 00000000..f8a75da7 --- /dev/null +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scardview/SCardViewAct3.java @@ -0,0 +1,18 @@ +package com.haier.cellarette.baselibrary.scardview; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.haier.cellarette.baselibrary.R; + +public class SCardViewAct3 extends AppCompatActivity { + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scardview3); + } +} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scrollview/ScrollViewAct.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scrollview/ScrollViewAct.java index 8f17c8b1..92df893c 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scrollview/ScrollViewAct.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/scrollview/ScrollViewAct.java @@ -1,7 +1,7 @@ package com.haier.cellarette.baselibrary.scrollview; import android.os.Bundle; -//import android.support.annotation.Nullable; +// import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shoppingcar/ShoppingCarActivity.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shoppingcar/ShoppingCarActivity.java index cae063e6..29a5c854 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shoppingcar/ShoppingCarActivity.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shoppingcar/ShoppingCarActivity.java @@ -1,7 +1,7 @@ package com.haier.cellarette.baselibrary.shoppingcar; import android.os.Bundle; -//import android.support.annotation.Nullable; +// import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import android.view.View; diff --git a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/huxiview/BreathingViewHelper.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shuaxinviewanimation/BreathingViewHelper.java similarity index 99% rename from yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/huxiview/BreathingViewHelper.java rename to commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shuaxinviewanimation/BreathingViewHelper.java index c5844b7d..43412524 100644 --- a/yewulibs1/yewulibs1-appcomm/src/main/java/com/example/slbappcomm/huxiview/BreathingViewHelper.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/shuaxinviewanimation/BreathingViewHelper.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.example.slbappcomm.huxiview; +package com.haier.cellarette.baselibrary.shuaxinviewanimation; import android.graphics.Color; import android.os.AsyncTask; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/size/SizeUtils.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/size/SizeUtils.java deleted file mode 100644 index e02d0a04..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/size/SizeUtils.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.haier.cellarette.baselibrary.size; - -import android.content.Context; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.View; -import android.view.ViewGroup; - -/** - *

- *     author: Jeffery.L
- *     time  : 2016/8/2
- *     desc  : 尺寸相关工具类
- * 
- */ -public final class SizeUtils { - - private SizeUtils() { - throw new UnsupportedOperationException("u can't fuck me..."); - } - - /** - * dp转px - * - * @param dpValue dp值 - * @return px值 - */ - public static int dp2px(Context context, float dpValue) { - final float scale = context.getResources().getDisplayMetrics().density; - return (int) (dpValue * scale + 0.5f); - } - - /** - * px转dp - * - * @param pxValue px值 - * @return dp值 - */ - public static int px2dp(Context context,float pxValue) { - final float scale = context.getResources().getDisplayMetrics().density; - return (int) (pxValue / scale + 0.5f); - } - - /** - * sp转px - * - * @param spValue sp值 - * @return px值 - */ - public static int sp2px(Context context,float spValue) { - final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; - return (int) (spValue * fontScale + 0.5f); - } - - /** - * px转sp - * - * @param pxValue px值 - * @return sp值 - */ - public static int px2sp(Context context,float pxValue) { - final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; - return (int) (pxValue / fontScale + 0.5f); - } - - /** - * 各种单位转换 - *

该方法存在于TypedValue

- * - * @param unit 单位 - * @param value 值 - * @param metrics DisplayMetrics - * @return 转换结果 - */ - public static float applyDimension(int unit, float value, DisplayMetrics metrics) { - switch (unit) { - case TypedValue.COMPLEX_UNIT_PX: - return value; - case TypedValue.COMPLEX_UNIT_DIP: - return value * metrics.density; - case TypedValue.COMPLEX_UNIT_SP: - return value * metrics.scaledDensity; - case TypedValue.COMPLEX_UNIT_PT: - return value * metrics.xdpi * (1.0f / 72); - case TypedValue.COMPLEX_UNIT_IN: - return value * metrics.xdpi; - case TypedValue.COMPLEX_UNIT_MM: - return value * metrics.xdpi * (1.0f / 25.4f); - } - return 0; - } - - /** - * 在onCreate中获取视图的尺寸 - *

需回调onGetSizeListener接口,在onGetSize中获取view宽高

- *

用法示例如下所示

- *
-     * SizeUtils.forceGetViewSize(view, new SizeUtils.onGetSizeListener() {
-     *     Override
-     *     public void onGetSize(View view) {
-     *         view.getWidth();
-     *     }
-     * });
-     * 
- * - * @param view 视图 - * @param listener 监听器 - */ - public static void forceGetViewSize(final View view, final onGetSizeListener listener) { - view.post(new Runnable() { - @Override - public void run() { - if (listener != null) { - listener.onGetSize(view); - } - } - }); - } - - /** - * 获取到View尺寸的监听 - */ - public interface onGetSizeListener { - void onGetSize(View view); - } - - /** - * 测量视图尺寸 - * - * @param view 视图 - * @return arr[0]: 视图宽度, arr[1]: 视图高度 - */ - public static int[] measureView(View view) { - ViewGroup.LayoutParams lp = view.getLayoutParams(); - if (lp == null) { - lp = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ); - } - int widthSpec = ViewGroup.getChildMeasureSpec(0, 0, lp.width); - int lpHeight = lp.height; - int heightSpec; - if (lpHeight > 0) { - heightSpec = View.MeasureSpec.makeMeasureSpec(lpHeight, View.MeasureSpec.EXACTLY); - } else { - heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); - } - view.measure(widthSpec, heightSpec); - return new int[]{view.getMeasuredWidth(), view.getMeasuredHeight()}; - } - - /** - * 获取测量视图宽度 - * - * @param view 视图 - * @return 视图宽度 - */ - public static int getMeasuredWidth(View view) { - return measureView(view)[0]; - } - - /** - * 获取测量视图高度 - * - * @param view 视图 - * @return 视图高度 - */ - public static int getMeasuredHeight(View view) { - return measureView(view)[1]; - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/splash/AlphaView.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/splash/AlphaView.java index 7f267ce7..f3284071 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/splash/AlphaView.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/splash/AlphaView.java @@ -2,7 +2,7 @@ import android.content.Context; import android.content.res.TypedArray; -//import android.support.annotation.Nullable; +// //import androidx.core.view.PagerAdapter; import androidx.annotation.Nullable; //import androidx.core.view.ViewPager; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/statusbar/StatusBarUtil.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/statusbar/StatusBarUtil.java deleted file mode 100644 index defffe8d..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/statusbar/StatusBarUtil.java +++ /dev/null @@ -1,738 +0,0 @@ -package com.haier.cellarette.baselibrary.statusbar; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Context; -import android.graphics.Color; -import android.os.Build; -//import android.support.annotation.ColorInt; -//import android.support.annotation.IntRange; -//import android.support.annotation.NonNull; -//import androidx.coordinatorlayout.widget.CoordinatorLayout; -//import androidx.core.widget.DrawerLayout; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.LinearLayout; - -import androidx.annotation.ColorInt; -import androidx.annotation.IntRange; -import androidx.annotation.NonNull; -import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.drawerlayout.widget.DrawerLayout; - -import com.haier.cellarette.baselibrary.R; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -/** - * Created by Jaeger on 16/2/14. - *

- * Email: chjie.jaeger@gmail.com - * GitHub: https://github.com/laobie - */ -public class StatusBarUtil { - - public static final int DEFAULT_STATUS_BAR_ALPHA = 112; - private static final int FAKE_STATUS_BAR_VIEW_ID = R.id.statusbarutil_fake_status_bar_view; - private static final int FAKE_TRANSLUCENT_VIEW_ID = R.id.statusbarutil_translucent_view; - private static final int TAG_KEY_HAVE_SET_OFFSET = -123; - - /** - * 设置状态栏颜色 - * - * @param activity 需要设置的 activity - * @param color 状态栏颜色值 - */ - public static void setColor(Activity activity, @ColorInt int color) { - setColor(activity, color, DEFAULT_STATUS_BAR_ALPHA); - } - - /** - * 设置状态栏颜色 - * - * @param activity 需要设置的activity - * @param color 状态栏颜色值 - * @param statusBarAlpha 状态栏透明度 - */ - - public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha)); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); - View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID); - if (fakeStatusBarView != null) { - if (fakeStatusBarView.getVisibility() == View.GONE) { - fakeStatusBarView.setVisibility(View.VISIBLE); - } - fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); - } else { - decorView.addView(createStatusBarView(activity, color, statusBarAlpha)); - } - setRootView(activity); - } - } - - /** - * 为滑动返回界面设置状态栏颜色 - * - * @param activity 需要设置的activity - * @param color 状态栏颜色值 - */ - public static void setColorForSwipeBack(Activity activity, int color) { - setColorForSwipeBack(activity, color, DEFAULT_STATUS_BAR_ALPHA); - } - - /** - * 为滑动返回界面设置状态栏颜色 - * - * @param activity 需要设置的activity - * @param color 状态栏颜色值 - * @param statusBarAlpha 状态栏透明度 - */ - public static void setColorForSwipeBack(Activity activity, @ColorInt int color, - @IntRange(from = 0, to = 255) int statusBarAlpha) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - - ViewGroup contentView = activity.findViewById(android.R.id.content); - View rootView = contentView.getChildAt(0); - int statusBarHeight = getStatusBarHeight(activity); - if (rootView != null && rootView instanceof CoordinatorLayout) { - final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - coordinatorLayout.setFitsSystemWindows(false); - contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); - boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight; - if (isNeedRequestLayout) { - contentView.setPadding(0, statusBarHeight, 0, 0); - coordinatorLayout.post(new Runnable() { - @Override - public void run() { - coordinatorLayout.requestLayout(); - } - }); - } - } else { - coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha)); - } - } else { - contentView.setPadding(0, statusBarHeight, 0, 0); - contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); - } - setTransparentForWindow(activity); - } - } - - /** - * 设置状态栏纯色 不加半透明效果 - * - * @param activity 需要设置的 activity - * @param color 状态栏颜色值 - */ - public static void setColorNoTranslucent(Activity activity, @ColorInt int color) { - setColor(activity, color, 0); - } - - /** - * 设置状态栏颜色(5.0以下无半透明效果,不建议使用) - * - * @param activity 需要设置的 activity - * @param color 状态栏颜色值 - */ - @Deprecated - public static void setColorDiff(Activity activity, @ColorInt int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - transparentStatusBar(activity); - ViewGroup contentView = activity.findViewById(android.R.id.content); - // 移除半透明矩形,以免叠加 - View fakeStatusBarView = contentView.findViewById(FAKE_STATUS_BAR_VIEW_ID); - if (fakeStatusBarView != null) { - if (fakeStatusBarView.getVisibility() == View.GONE) { - fakeStatusBarView.setVisibility(View.VISIBLE); - } - fakeStatusBarView.setBackgroundColor(color); - } else { - contentView.addView(createStatusBarView(activity, color)); - } - setRootView(activity); - } - - /** - * 使状态栏半透明 - *

- * 适用于图片作为背景的界面,此时需要图片填充到状态栏 - * - * @param activity 需要设置的activity - */ - public static void setTranslucent(Activity activity) { - setTranslucent(activity, DEFAULT_STATUS_BAR_ALPHA); - } - - /** - * 使状态栏半透明 - *

- * 适用于图片作为背景的界面,此时需要图片填充到状态栏 - * - * @param activity 需要设置的activity - * @param statusBarAlpha 状态栏透明度 - */ - public static void setTranslucent(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - setTransparent(activity); - addTranslucentView(activity, statusBarAlpha); - } - - /** - * 针对根布局是 CoordinatorLayout, 使状态栏半透明 - *

- * 适用于图片作为背景的界面,此时需要图片填充到状态栏 - * - * @param activity 需要设置的activity - * @param statusBarAlpha 状态栏透明度 - */ - public static void setTranslucentForCoordinatorLayout(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - transparentStatusBar(activity); - addTranslucentView(activity, statusBarAlpha); - } - - /** - * 设置状态栏全透明 - * - * @param activity 需要设置的activity - */ - public static void setTransparent(Activity activity) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - transparentStatusBar(activity); - setRootView(activity); - } - - /** - * 使状态栏透明(5.0以上半透明效果,不建议使用) - *

- * 适用于图片作为背景的界面,此时需要图片填充到状态栏 - * - * @param activity 需要设置的activity - */ - @Deprecated - public static void setTranslucentDiff(Activity activity) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - // 设置状态栏透明 - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - setRootView(activity); - } - } - - /** - * 为DrawerLayout 布局设置状态栏变色 - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - * @param color 状态栏颜色值 - */ - public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) { - setColorForDrawerLayout(activity, drawerLayout, color, DEFAULT_STATUS_BAR_ALPHA); - } - - /** - * 为DrawerLayout 布局设置状态栏颜色,纯色 - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - * @param color 状态栏颜色值 - */ - public static void setColorNoTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) { - setColorForDrawerLayout(activity, drawerLayout, color, 0); - } - - /** - * 为DrawerLayout 布局设置状态栏变色 - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - * @param color 状态栏颜色值 - * @param statusBarAlpha 状态栏透明度 - */ - public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color, - @IntRange(from = 0, to = 255) int statusBarAlpha) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - activity.getWindow().setStatusBarColor(Color.TRANSPARENT); - } else { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - } - // 生成一个状态栏大小的矩形 - // 添加 statusBarView 到布局中 - ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); - View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID); - if (fakeStatusBarView != null) { - if (fakeStatusBarView.getVisibility() == View.GONE) { - fakeStatusBarView.setVisibility(View.VISIBLE); - } - fakeStatusBarView.setBackgroundColor(color); - } else { - contentLayout.addView(createStatusBarView(activity, color), 0); - } - // 内容布局不是 LinearLayout 时,设置padding top - if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { - contentLayout.getChildAt(1) - .setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(), - contentLayout.getPaddingRight(), contentLayout.getPaddingBottom()); - } - // 设置属性 - setDrawerLayoutProperty(drawerLayout, contentLayout); - addTranslucentView(activity, statusBarAlpha); - } - - /** - * 设置 DrawerLayout 属性 - * - * @param drawerLayout DrawerLayout - * @param drawerLayoutContentLayout DrawerLayout 的内容布局 - */ - private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) { - ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); - drawerLayout.setFitsSystemWindows(false); - drawerLayoutContentLayout.setFitsSystemWindows(false); - drawerLayoutContentLayout.setClipToPadding(true); - drawer.setFitsSystemWindows(false); - } - - /** - * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用) - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - * @param color 状态栏颜色值 - */ - @Deprecated - public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - // 生成一个状态栏大小的矩形 - ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); - View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID); - if (fakeStatusBarView != null) { - if (fakeStatusBarView.getVisibility() == View.GONE) { - fakeStatusBarView.setVisibility(View.VISIBLE); - } - fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA)); - } else { - // 添加 statusBarView 到布局中 - contentLayout.addView(createStatusBarView(activity, color), 0); - } - // 内容布局不是 LinearLayout 时,设置padding top - if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { - contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); - } - // 设置属性 - setDrawerLayoutProperty(drawerLayout, contentLayout); - } - } - - /** - * 为 DrawerLayout 布局设置状态栏透明 - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - */ - public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { - setTranslucentForDrawerLayout(activity, drawerLayout, DEFAULT_STATUS_BAR_ALPHA); - } - - /** - * 为 DrawerLayout 布局设置状态栏透明 - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - */ - public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout, - @IntRange(from = 0, to = 255) int statusBarAlpha) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - setTransparentForDrawerLayout(activity, drawerLayout); - addTranslucentView(activity, statusBarAlpha); - } - - /** - * 为 DrawerLayout 布局设置状态栏透明 - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - */ - public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - activity.getWindow().setStatusBarColor(Color.TRANSPARENT); - } else { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - } - - ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); - // 内容布局不是 LinearLayout 时,设置padding top - if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { - contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); - } - - // 设置属性 - setDrawerLayoutProperty(drawerLayout, contentLayout); - } - - /** - * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用) - * - * @param activity 需要设置的activity - * @param drawerLayout DrawerLayout - */ - @Deprecated - public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - // 设置状态栏透明 - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - // 设置内容布局属性 - ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); - contentLayout.setFitsSystemWindows(true); - contentLayout.setClipToPadding(true); - // 设置抽屉布局属性 - ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1); - vg.setFitsSystemWindows(false); - // 设置 DrawerLayout 属性 - drawerLayout.setFitsSystemWindows(false); - } - } - - /** - * 为头部是 ImageView 的界面设置状态栏全透明 - * - * @param activity 需要设置的activity - * @param needOffsetView 需要向下偏移的 View - */ - public static void setTransparentForImageView(Activity activity, View needOffsetView) { - setTranslucentForImageView(activity, 0, needOffsetView); - } - - /** - * 为头部是 ImageView 的界面设置状态栏透明(使用默认透明度) - * - * @param activity 需要设置的activity - * @param needOffsetView 需要向下偏移的 View - */ - public static void setTranslucentForImageView(Activity activity, View needOffsetView) { - setTranslucentForImageView(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView); - } - - /** - * 为头部是 ImageView 的界面设置状态栏透明 - * - * @param activity 需要设置的activity - * @param statusBarAlpha 状态栏透明度 - * @param needOffsetView 需要向下偏移的 View - */ - public static void setTranslucentForImageView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha, - View needOffsetView) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return; - } - setTransparentForWindow(activity); - addTranslucentView(activity, statusBarAlpha); - if (needOffsetView != null) { - Object haveSetOffset = needOffsetView.getTag(TAG_KEY_HAVE_SET_OFFSET); - if (haveSetOffset != null && (Boolean) haveSetOffset) { - return; - } - ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams(); - layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + getStatusBarHeight(activity), - layoutParams.rightMargin, layoutParams.bottomMargin); - needOffsetView.setTag(TAG_KEY_HAVE_SET_OFFSET, true); - } - } - - /** - * 为 fragment 头部是 ImageView 的设置状态栏透明 - * - * @param activity fragment 对应的 activity - * @param needOffsetView 需要向下偏移的 View - */ - public static void setTranslucentForImageViewInFragment(Activity activity, View needOffsetView) { - setTranslucentForImageViewInFragment(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView); - } - - /** - * 为 fragment 头部是 ImageView 的设置状态栏透明 - * - * @param activity fragment 对应的 activity - * @param needOffsetView 需要向下偏移的 View - */ - public static void setTransparentForImageViewInFragment(Activity activity, View needOffsetView) { - setTranslucentForImageViewInFragment(activity, 0, needOffsetView); - } - - /** - * 为 fragment 头部是 ImageView 的设置状态栏透明 - * - * @param activity fragment 对应的 activity - * @param statusBarAlpha 状态栏透明度 - * @param needOffsetView 需要向下偏移的 View - */ - public static void setTranslucentForImageViewInFragment(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha, - View needOffsetView) { - setTranslucentForImageView(activity, statusBarAlpha, needOffsetView); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - clearPreviousSetting(activity); - } - } - - /** - * 隐藏伪状态栏 View - * - * @param activity 调用的 Activity - */ - public static void hideFakeStatusBarView(Activity activity) { - ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); - View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID); - if (fakeStatusBarView != null) { - fakeStatusBarView.setVisibility(View.GONE); - } - View fakeTranslucentView = decorView.findViewById(FAKE_TRANSLUCENT_VIEW_ID); - if (fakeTranslucentView != null) { - fakeTranslucentView.setVisibility(View.GONE); - } - } - - @TargetApi(Build.VERSION_CODES.M) - public static void setLightMode(Activity activity) { - setMIUIStatusBarDarkIcon(activity, true); - setMeizuStatusBarDarkIcon(activity, true); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } - } - - @TargetApi(Build.VERSION_CODES.M) - public static void setDarkMode(Activity activity) { - setMIUIStatusBarDarkIcon(activity, false); - setMeizuStatusBarDarkIcon(activity, false); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } - } - - /** - * 修改 MIUI V6 以上状态栏颜色 - */ - private static void setMIUIStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) { - Class clazz = activity.getWindow().getClass(); - try { - Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); - Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); - int darkModeFlag = field.getInt(layoutParams); - Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); - extraFlagField.invoke(activity.getWindow(), darkIcon ? darkModeFlag : 0, darkModeFlag); - } catch (Exception e) { - //e.printStackTrace(); - } - } - - /** - * 修改魅族状态栏字体颜色 Flyme 4.0 - */ - private static void setMeizuStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) { - try { - WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); - Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); - Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); - darkFlag.setAccessible(true); - meizuFlags.setAccessible(true); - int bit = darkFlag.getInt(null); - int value = meizuFlags.getInt(lp); - if (darkIcon) { - value |= bit; - } else { - value &= ~bit; - } - meizuFlags.setInt(lp, value); - activity.getWindow().setAttributes(lp); - } catch (Exception e) { - //e.printStackTrace(); - } - } - - /////////////////////////////////////////////////////////////////////////////////// - - @TargetApi(Build.VERSION_CODES.KITKAT) - private static void clearPreviousSetting(Activity activity) { - ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); - View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID); - if (fakeStatusBarView != null) { - decorView.removeView(fakeStatusBarView); - ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0); - rootView.setPadding(0, 0, 0, 0); - } - } - - /** - * 添加半透明矩形条 - * - * @param activity 需要设置的 activity - * @param statusBarAlpha 透明值 - */ - private static void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) { - ViewGroup contentView = activity.findViewById(android.R.id.content); - View fakeTranslucentView = contentView.findViewById(FAKE_TRANSLUCENT_VIEW_ID); - if (fakeTranslucentView != null) { - if (fakeTranslucentView.getVisibility() == View.GONE) { - fakeTranslucentView.setVisibility(View.VISIBLE); - } - fakeTranslucentView.setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0)); - } else { - contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha)); - } - } - - /** - * 生成一个和状态栏大小相同的彩色矩形条 - * - * @param activity 需要设置的 activity - * @param color 状态栏颜色值 - * @return 状态栏矩形条 - */ - private static View createStatusBarView(Activity activity, @ColorInt int color) { - return createStatusBarView(activity, color, 0); - } - - /** - * 生成一个和状态栏大小相同的半透明矩形条 - * - * @param activity 需要设置的activity - * @param color 状态栏颜色值 - * @param alpha 透明值 - * @return 状态栏矩形条 - */ - private static View createStatusBarView(Activity activity, @ColorInt int color, int alpha) { - // 绘制一个和状态栏一样高的矩形 - View statusBarView = new View(activity); - LinearLayout.LayoutParams params = - new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity)); - statusBarView.setLayoutParams(params); - statusBarView.setBackgroundColor(calculateStatusColor(color, alpha)); - statusBarView.setId(FAKE_STATUS_BAR_VIEW_ID); - return statusBarView; - } - - /** - * 设置根布局参数 - */ - private static void setRootView(Activity activity) { - ViewGroup parent = activity.findViewById(android.R.id.content); - for (int i = 0, count = parent.getChildCount(); i < count; i++) { - View childView = parent.getChildAt(i); - if (childView instanceof ViewGroup) { - childView.setFitsSystemWindows(true); - ((ViewGroup) childView).setClipToPadding(true); - } - } - } - - /** - * 设置透明 - */ - private static void setTransparentForWindow(Activity activity) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().setStatusBarColor(Color.TRANSPARENT); - activity.getWindow() - .getDecorView() - .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - activity.getWindow() - .setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - } - } - - /** - * 使状态栏透明 - */ - @TargetApi(Build.VERSION_CODES.KITKAT) - private static void transparentStatusBar(Activity activity) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); - activity.getWindow().setStatusBarColor(Color.TRANSPARENT); - } else { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - } - } - - /** - * 创建半透明矩形 View - * - * @param alpha 透明值 - * @return 半透明 View - */ - private static View createTranslucentStatusBarView(Activity activity, int alpha) { - // 绘制一个和状态栏一样高的矩形 - View statusBarView = new View(activity); - LinearLayout.LayoutParams params = - new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity)); - statusBarView.setLayoutParams(params); - statusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0)); - statusBarView.setId(FAKE_TRANSLUCENT_VIEW_ID); - return statusBarView; - } - - /** - * 获取状态栏高度 - * - * @param context context - * @return 状态栏高度 - */ - private static int getStatusBarHeight(Context context) { - // 获得状态栏高度 - int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); - return context.getResources().getDimensionPixelSize(resourceId); - } - - /** - * 计算状态栏颜色 - * - * @param color color值 - * @param alpha alpha值 - * @return 最终的状态栏颜色 - */ - private static int calculateStatusColor(@ColorInt int color, int alpha) { - if (alpha == 0) { - return color; - } - float a = 1 - alpha / 255f; - int red = color >> 16 & 0xff; - int green = color >> 8 & 0xff; - int blue = color & 0xff; - red = (int) (red * a + 0.5); - green = (int) (green * a + 0.5); - blue = (int) (blue * a + 0.5); - return 0xff << 24 | red << 16 | green << 8 | blue; - } -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/statusbar/StatusBarUtilV7.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/statusbar/StatusBarUtilV7.java deleted file mode 100644 index f29cadec..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/statusbar/StatusBarUtilV7.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.haier.cellarette.baselibrary.statusbar; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Resources; -import android.os.Build; -//import android.support.annotation.FloatRange; -//import android.support.annotation.RequiresApi; -import android.util.Log; -import android.util.TypedValue; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; - -import androidx.annotation.FloatRange; -import androidx.annotation.RequiresApi; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.regex.Pattern; - -/** - * 状态栏透明 - * Created by SCWANG on 2016/10/26. - */ - -@SuppressWarnings("unused") -public class StatusBarUtilV7 { - - public static int DEFAULT_COLOR = 0; - public static float DEFAULT_ALPHA = 0;//Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? 0.2f : 0.3f; - public static final int MIN_API = 19; - - // - public static void immersive(Activity activity) { - immersive(activity, DEFAULT_COLOR, DEFAULT_ALPHA); - } - - public static void immersive(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { - immersive(activity.getWindow(), color, alpha); - } - - public static void immersive(Activity activity, int color) { - immersive(activity.getWindow(), color, 1f); - } - - public static void immersive(Window window) { - immersive(window, DEFAULT_COLOR, DEFAULT_ALPHA); - } - - public static void immersive(Window window, int color) { - immersive(window, color, 1f); - } - - public static void immersive(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { - if (Build.VERSION.SDK_INT >= 21) { - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(mixtureColor(color, alpha)); - - int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); - systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; - systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; - window.getDecorView().setSystemUiVisibility(systemUiVisibility); - } else if (Build.VERSION.SDK_INT >= 19) { - window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - setTranslucentView((ViewGroup) window.getDecorView(), color, alpha); - } else if (Build.VERSION.SDK_INT >= MIN_API && Build.VERSION.SDK_INT > 16) { - int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); - systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; - systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; - window.getDecorView().setSystemUiVisibility(systemUiVisibility); - } - } - // - - // - public static void darkMode(Activity activity, boolean dark) { - if (isFlyme4Later()) { - darkModeForFlyme4(activity.getWindow(), dark); - } else if (isMIUI6Later()) { - darkModeForMIUI6(activity.getWindow(), dark); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - darkModeForM(activity.getWindow(), dark); - } - } - - /** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */ - public static void darkMode(Activity activity) { - darkMode(activity.getWindow(), DEFAULT_COLOR, DEFAULT_ALPHA); - } - - public static void darkMode(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { - darkMode(activity.getWindow(), color, alpha); - } - - /** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */ - public static void darkMode(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { - if (isFlyme4Later()) { - darkModeForFlyme4(window, true); - immersive(window,color,alpha); - } else if (isMIUI6Later()) { - darkModeForMIUI6(window, true); - immersive(window,color,alpha); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - darkModeForM(window, true); - immersive(window, color, alpha); - } else if (Build.VERSION.SDK_INT >= 19) { - window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - setTranslucentView((ViewGroup) window.getDecorView(), color, alpha); - } else { - immersive(window, color, alpha); - } -// if (Build.VERSION.SDK_INT >= 21) { -// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); -// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); -// window.setStatusBarColor(Color.TRANSPARENT); -// } else if (Build.VERSION.SDK_INT >= 19) { -// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); -// } - -// setTranslucentView((ViewGroup) window.getDecorView(), color, alpha); - } - - //-------------------------> - - /** android 6.0设置字体颜色 */ - @RequiresApi(Build.VERSION_CODES.M) - private static void darkModeForM(Window window, boolean dark) { -// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); -// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); -// window.setStatusBarColor(Color.TRANSPARENT); - - int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); - if (dark) { - systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } else { - systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } - window.getDecorView().setSystemUiVisibility(systemUiVisibility); - } - - /** - * 设置Flyme4+的darkMode,darkMode时候字体颜色及icon变黑 - * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI - */ - public static boolean darkModeForFlyme4(Window window, boolean dark) { - boolean result = false; - if (window != null) { - try { - WindowManager.LayoutParams e = window.getAttributes(); - Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); - Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); - darkFlag.setAccessible(true); - meizuFlags.setAccessible(true); - int bit = darkFlag.getInt(null); - int value = meizuFlags.getInt(e); - if (dark) { - value |= bit; - } else { - value &= ~bit; - } - - meizuFlags.setInt(e, value); - window.setAttributes(e); - result = true; - } catch (Exception var8) { - Log.e("StatusBar", "darkIcon: failed"); - } - } - - return result; - } - - /** - * 设置MIUI6+的状态栏是否为darkMode,darkMode时候字体颜色及icon变黑 - * http://dev.xiaomi.com/doc/p=4769/ - */ - public static boolean darkModeForMIUI6(Window window, boolean darkmode) { - Class clazz = window.getClass(); - try { - int darkModeFlag = 0; - Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); - Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); - darkModeFlag = field.getInt(layoutParams); - Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); - extraFlagField.invoke(window, darkmode ? darkModeFlag : 0, darkModeFlag); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** 判断是否Flyme4以上 */ - public static boolean isFlyme4Later() { - return Build.FINGERPRINT.contains("Flyme_OS_4") - || Build.VERSION.INCREMENTAL.contains("Flyme_OS_4") - || Pattern.compile("Flyme OS [4|5]", Pattern.CASE_INSENSITIVE).matcher(Build.DISPLAY).find(); - } - - /** 判断是否为MIUI6以上 */ - public static boolean isMIUI6Later() { - try { - Class clz = Class.forName("android.os.SystemProperties"); - Method mtd = clz.getMethod("get", String.class); - String val = (String) mtd.invoke(null, "ro.miui.ui.version.name"); - val = val.replaceAll("[vV]", ""); - int version = Integer.parseInt(val); - return version >= 6; - } catch (Exception e) { - return false; - } - } - // - - - /** 增加View的paddingTop,增加的值为状态栏高度 */ - public static void setPadding(Context context, View view) { - if (Build.VERSION.SDK_INT >= MIN_API) { - view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context), - view.getPaddingRight(), view.getPaddingBottom()); - } - } - /** 增加View的paddingTop,增加的值为状态栏高度 (智能判断,并设置高度)*/ - public static void setPaddingSmart(Context context, View view) { - if (Build.VERSION.SDK_INT >= MIN_API) { - ViewGroup.LayoutParams lp = view.getLayoutParams(); - if (lp != null && lp.height > 0) { - lp.height += getStatusBarHeight(context);//增高 - } - view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context), - view.getPaddingRight(), view.getPaddingBottom()); - } - } - - /** 增加View的高度以及paddingTop,增加的值为状态栏高度.一般是在沉浸式全屏给ToolBar用的 */ - public static void setHeightAndPadding(Context context, View view) { - if (Build.VERSION.SDK_INT >= MIN_API) { - ViewGroup.LayoutParams lp = view.getLayoutParams(); - lp.height += getStatusBarHeight(context);//增高 - view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context), - view.getPaddingRight(), view.getPaddingBottom()); - } - } - /** 增加View上边距(MarginTop)一般是给高度为 WARP_CONTENT 的小控件用的*/ - public static void setMargin(Context context, View view) { - if (Build.VERSION.SDK_INT >= MIN_API) { - ViewGroup.LayoutParams lp = view.getLayoutParams(); - if (lp instanceof ViewGroup.MarginLayoutParams) { - ((ViewGroup.MarginLayoutParams) lp).topMargin += getStatusBarHeight(context);//增高 - } - view.setLayoutParams(lp); - } - } - /** - * 创建假的透明栏 - */ - public static void setTranslucentView(ViewGroup container, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { - if (Build.VERSION.SDK_INT >= 19) { - int mixtureColor = mixtureColor(color, alpha); - View translucentView = container.findViewById(android.R.id.custom); - if (translucentView == null && mixtureColor != 0) { - translucentView = new View(container.getContext()); - translucentView.setId(android.R.id.custom); - ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(container.getContext())); - container.addView(translucentView, lp); - } - if (translucentView != null) { - translucentView.setBackgroundColor(mixtureColor); - } - } - } - - public static int mixtureColor(int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { - int a = (color & 0xff000000) == 0 ? 0xff : color >>> 24; - return (color & 0x00ffffff) | (((int) (a * alpha)) << 24); - } - - /** 获取状态栏高度 */ - public static int getStatusBarHeight(Context context) { - int result = 24; - int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); - if (resId > 0) { - result = context.getResources().getDimensionPixelSize(resId); - } else { - result = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, - result, Resources.getSystem().getDisplayMetrics()); - } - return result; - } -} \ No newline at end of file diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/tablayout/UnAnimTabLayout.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/tablayout/UnAnimTabLayout.java index d93f372c..fd9c6bf7 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/tablayout/UnAnimTabLayout.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/tablayout/UnAnimTabLayout.java @@ -1,7 +1,7 @@ package com.haier.cellarette.baselibrary.tablayout; import android.content.Context; -//import android.support.annotation.NonNull; +// //import android.support.design.widget.TabLayout; import android.util.AttributeSet; diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/usersdk/LoginUtil.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/usersdk/LoginUtil.java deleted file mode 100644 index e0b3dd9f..00000000 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/usersdk/LoginUtil.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.haier.cellarette.baselibrary.usersdk; - -import android.app.Activity; -import android.content.Intent; - -/** - * Created by shining on 2017/11/8. - */ - -public class LoginUtil { - - public static final int LOGIN_REQUEST_CODE = 301; - public static final int LOGINOUT_REQUEST_CODE = 302; - public static final int LOGIN_RESULT_OK = 101; - public static final int LOGIN_RESULT_CANCELED = 102; - public static final int LOGINOUT_RESULT_OK = 201; - public static final int LOGINOUT_RESULT_CANCELED = 202; - - private static LoginUtil sInstance; - private static final Object lock = new Object(); - private Runnable mLastRunnnable; - - - public LoginUtil() { - } - - public static LoginUtil get() { - if (sInstance == null) { - synchronized (lock) { - sInstance = new LoginUtil(); - } - } - return sInstance; - } - - /** - * 用户是否登录 - * - * @return - */ - public static boolean isUserLogin() { - // step 1 判断内存中是否有user_id -// if (!TextUtils.isEmpty(DataProvider.getUser_id())) { -// return true; -// } -// // step 2 如果内存中没有, 则去文件中找 -// String uid = (String) SpUtils.get(get()).get(ConstantUtil.USER_ID, null); -// // step 3 如果文件中有, 则提到内存中 -// if (!TextUtils.isEmpty(uid)) { -// DataProvider.setUser_id(uid); -// return true; -// } - // 未登录 - return false; - } - - - - public void loginTowhere(Activity activity, Runnable runnable) { - if (isUserLogin()) { - if (runnable != null) { - runnable.run(); - } - } - mLastRunnnable = runnable; - login(activity); - } - - public void login(Activity activity) { - Intent intent = new Intent("hs.act.loginactivity"); - if (intent.resolveActivity(activity.getPackageManager()) != null) { - activity.startActivityForResult(intent, LOGIN_REQUEST_CODE); - } - } - - public void loginOutTowhere(Activity activity, Runnable runnable) { - if (isUserLogin()) { - if (runnable == null) { - runnable.run(); - } - } - mLastRunnnable = runnable; - loginOut(activity); - } - - public void loginOut(Activity activity) { - Intent intent = new Intent("hs.act.loginoutactivity"); - if (intent.resolveActivity(activity.getPackageManager()) != null) { - activity.startActivityForResult(intent, LOGINOUT_REQUEST_CODE); - } - } - - public boolean login_activity_result(int requestCode, int resultCode, Intent data) { - Runnable runnable = mLastRunnnable; - mLastRunnnable = null; - //已登录 - if (requestCode == LOGIN_REQUEST_CODE) { - if (resultCode == LOGIN_RESULT_OK && runnable != null) { - runnable.run(); - } - return true; - } - //未登录 - if (requestCode == LOGINOUT_REQUEST_CODE) { - if (resultCode == LOGINOUT_RESULT_OK && runnable != null) { - runnable.run(); - } - return true; - } - - return false; - } - -} diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/widget/SwitchButton.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/widget/SwitchButton.java index 96dba82c..0a433d95 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/widget/SwitchButton.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/widget/SwitchButton.java @@ -22,6 +22,7 @@ /** * 自义定开关按钮 + * https://github.com/kyleduo/SwitchButton */ public class SwitchButton extends View implements Checkable { private static final int DEFAULT_WIDTH = dp2pxInt(58); diff --git a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/zothers/SpannableStringUtils.java b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/zothers/SpannableStringUtils.java index de6cd0b6..1616c3fd 100644 --- a/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/zothers/SpannableStringUtils.java +++ b/commonlibs/baselibrary/src/main/java/com/haier/cellarette/baselibrary/zothers/SpannableStringUtils.java @@ -39,8 +39,8 @@ //import android.support.annotation.ColorInt; //import android.support.annotation.DrawableRes; -//import android.support.annotation.NonNull; -//import android.support.annotation.Nullable; +// +// /** *

diff --git a/commonlibs/baselibrary/src/main/res/drawable/bg_large_oval_radius.xml b/commonlibs/baselibrary/src/main/res/drawable/bg_large_oval_radius.xml
new file mode 100644
index 00000000..817dafad
--- /dev/null
+++ b/commonlibs/baselibrary/src/main/res/drawable/bg_large_oval_radius.xml
@@ -0,0 +1,5 @@
+
+
+    
+    
+
\ No newline at end of file
diff --git a/commonlibs/baselibrary/src/main/res/drawable/bg_oval_radius.xml b/commonlibs/baselibrary/src/main/res/drawable/bg_oval_radius.xml
new file mode 100644
index 00000000..549e684a
--- /dev/null
+++ b/commonlibs/baselibrary/src/main/res/drawable/bg_oval_radius.xml
@@ -0,0 +1,5 @@
+
+
+    
+    
+
\ No newline at end of file
diff --git a/commonlibs/baselibrary/src/main/res/drawable/ed_bg.xml b/commonlibs/baselibrary/src/main/res/drawable/ed_bg.xml
new file mode 100644
index 00000000..e26708fd
--- /dev/null
+++ b/commonlibs/baselibrary/src/main/res/drawable/ed_bg.xml
@@ -0,0 +1,8 @@
+
+
+    
+    
+
\ No newline at end of file
diff --git a/commonlibs/baselibrary/src/main/res/layout/activity_bigimageviewpager.xml b/commonlibs/baselibrary/src/main/res/layout/activity_bigimageviewpager.xml
new file mode 100644
index 00000000..8360455f
--- /dev/null
+++ b/commonlibs/baselibrary/src/main/res/layout/activity_bigimageviewpager.xml
@@ -0,0 +1,296 @@
+
+
+
+    
+
+        
+
+