提交 7060007c 编写于 作者: B Blankj

see 06/18 log

上级 31bcebba
......@@ -8,8 +8,8 @@ gradle.ext {
compileSdkVersion = 27
minSdkVersion = 14
targetSdkVersion = 27
versionCode = 1_024_002
versionName = '1.24.2'// E.g. 1.9.72 => 1,009,072
versionCode = 1_024_003
versionName = '1.24.3'// E.g. 1.9.72 => 1,009,072
// lib version
kotlin_version = '1.3.10'
......@@ -33,10 +33,14 @@ gradle.ext {
launcher_pkg : new DepConfig(":launcher:pkg"),
lib_base : new DepConfig(":lib:base"),
lib_common : new DepConfig(":lib:common"),
subutil_app : new DepConfig(":subutil:app"),
subutil_export : new DepConfig(":subutil:export"),
subutil_lib : new DepConfig(":subutil:lib"),
subutil_pkg : new DepConfig(":subutil:pkg"),
utilcode_app : new DepConfig(":utilcode:app"),
utilcode_export : new DepConfig(":utilcode:export"),
utilcode_lib : new DepConfig(true/*是否本地调试*/, ":utilcode:lib", "com.blankj:utilcode:$versionName"),
utilcode_pkg : new DepConfig(":utilcode:pkg"),
......
......@@ -55,18 +55,20 @@ class MainActivity : CommonDrawerActivity() {
BarUtils.setStatusBarColor4Drawer(mBaseDrawerRootLayout, launcherMainFakeStatusBar, Color.TRANSPARENT, false)
BarUtils.addMarginTopEqualStatusBarHeight(launcherMainToolbar)
launcherMainCoreUtilBtn.setOnClickListener {
BusUtils.postStatic<Any>("CoreUtilActivity#start", this)
}
launcherMainSubUtilBtn.setOnClickListener {
BusUtils.postStatic<Any>("SubUtilActivity#start", this)
}
applyDebouncingClickListener(
launcherMainCoreUtilBtn,
launcherMainSubUtilBtn
)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.launcherMainCoreUtilBtn -> BusUtils.postStatic<Any>("CoreUtilActivity#start", this)
R.id.launcherMainSubUtilBtn -> BusUtils.postStatic<Any>("SubUtilActivity#start", this)
}
}
override fun onBackPressed() {
ActivityUtils.startHomeActivity()
......
......@@ -25,7 +25,7 @@ class SplashActivity : CommonBackActivity() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import com.blankj.utilcode.util.AntiShakeUtils;
import com.blankj.utilcode.util.ClickUtils;
/**
* <pre>
......@@ -21,6 +21,13 @@ import com.blankj.utilcode.util.AntiShakeUtils;
public abstract class BaseActivity extends AppCompatActivity
implements IBaseView {
private View.OnClickListener mClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
onDebouncingClick(v);
}
};
protected View mContentView;
protected Activity mActivity;
......@@ -41,11 +48,9 @@ public abstract class BaseActivity extends AppCompatActivity
setContentView(mContentView = LayoutInflater.from(this).inflate(layoutId, null));
}
@Override
public void onClick(View view) {
if (AntiShakeUtils.isValid(view)) {
onWidgetClick(view);
}
public void applyDebouncingClickListener(View... views) {
ClickUtils.applyGlobalDebouncing(views, mClickListener);
ClickUtils.applyScale(views);
}
}
......@@ -15,7 +15,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.blankj.utilcode.util.AntiShakeUtils;
import com.blankj.utilcode.util.ClickUtils;
/**
* <pre>
......@@ -31,12 +31,17 @@ public abstract class BaseFragment extends Fragment
private static final String TAG = "BaseFragment";
private static final String STATE_SAVE_IS_HIDDEN = "STATE_SAVE_IS_HIDDEN";
private ClickUtils.OnDebouncingClickListener mDebouncingClick = new ClickUtils.OnDebouncingClickListener() {
@Override
public void onDebouncingClick(View v) {
BaseFragment.this.onDebouncingClick(v);
}
};
protected Activity mActivity;
protected LayoutInflater mInflater;
protected View mContentView;
private long lastClick = 0;
@Override
public void onAttach(Context context) {
super.onAttach(context);
......@@ -113,9 +118,8 @@ public abstract class BaseFragment extends Fragment
super.onDestroy();
}
@Override
public void onClick(View view) {
if (AntiShakeUtils.isValid(view)) onWidgetClick(view);
public void applyDebouncingClickListener(View... views) {
ClickUtils.applyGlobalDebouncing(views, mDebouncingClick);
}
public <T extends View> T findViewById(@IdRes int id) {
......
......@@ -2,6 +2,7 @@ package com.blankj.lib.base;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
......@@ -14,8 +15,7 @@ import android.view.View;
* desc :
* </pre>
*/
public interface IBaseView extends View.OnClickListener {
public interface IBaseView {
void initData(@Nullable Bundle bundle);
......@@ -27,5 +27,5 @@ public interface IBaseView extends View.OnClickListener {
void doBusiness();
void onWidgetClick(View view);
void onDebouncingClick(@NonNull View view);
}
apply {
from "${rootDir.path}/gradle/config/configLib.gradle"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<manifest package="com.blankj.subutil.export" />
package com.blankj.subutil.export.api;
import android.content.Context;
/**
* <pre>
* author: blankj
* blog : http://blankj.com
* time : 2019/06/09
* desc :
* </pre>
*/
public interface SubUtilApi {
void startSubUtilActivity(Context context);
}
......@@ -15,6 +15,7 @@ readme {
dependencies {
compileOnly gradle.ext.dep.support_appcompat_v7
compileOnly gradle.ext.dep.support_design
compileOnly gradle.ext.dep.utilcode_lib
api(gradle.ext.dep.glide) {
exclude group: "com.android.support"
}
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blankj.subutil">
<application>
<provider
android:name=".util.Utils$ContentProvider4SubUtil"
android:authorities="${applicationId}.subutil.content.provider"
android:exported="false"
android:multiprocess="true" />
</application>
</manifest>
<manifest package="com.blankj.subutil" />
package com.blankj.subutil.util;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.blankj.utilcode.util.RomUtils;
import com.blankj.utilcode.util.Utils;
import java.util.List;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2019/05/20
* desc : utils about app store
* </pre>
*/
public class AppStoreUtils {
private static final String TAG = "AppStoreUtils";
private static final String GOOGLE_PLAY_APP_STORE_PACKAGE_NAME = "com.android.vending";
/**
* 获取跳转到应用商店的 Intent
*
* @return 跳转到应用商店的 Intent
*/
public static Intent getAppStoreIntent() {
return getAppStoreIntent(Utils.getApp().getPackageName(), false);
}
/**
* 获取跳转到应用商店的 Intent
*
* @param isIncludeGooglePlayStore 是否包括 Google Play 商店
* @return 跳转到应用商店的 Intent
*/
public static Intent getAppStoreIntent(boolean isIncludeGooglePlayStore) {
return getAppStoreIntent(Utils.getApp().getPackageName(), isIncludeGooglePlayStore);
}
/**
* 获取跳转到应用商店的 Intent
*
* @param packageName 包名
* @return 跳转到应用商店的 Intent
*/
public static Intent getAppStoreIntent(final String packageName) {
return getAppStoreIntent(packageName, false);
}
/**
* 获取跳转到应用商店的 Intent
* <p>优先跳转到手机自带的应用市场</p>
*
* @param packageName 包名
* @param isIncludeGooglePlayStore 是否包括 Google Play 商店
* @return 跳转到应用商店的 Intent
*/
public static Intent getAppStoreIntent(final String packageName, boolean isIncludeGooglePlayStore) {
if (RomUtils.isSamsung()) {// 三星单独处理跳转三星市场
Intent samsungAppStoreIntent = getSamsungAppStoreIntent(packageName);
if (samsungAppStoreIntent != null) return samsungAppStoreIntent;
}
if (RomUtils.isLeeco()) {// 乐视单独处理跳转乐视市场
Intent leecoAppStoreIntent = getLeecoAppStoreIntent(packageName);
if (leecoAppStoreIntent != null) return leecoAppStoreIntent;
}
Uri uri = Uri.parse("market://details?id=" + packageName);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
List<ResolveInfo> resolveInfos = Utils.getApp().getPackageManager()
.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfos == null || resolveInfos.size() == 0) {
Log.e(TAG, "No app store!");
return null;
}
Intent googleIntent = null;
for (ResolveInfo resolveInfo : resolveInfos) {
String pkgName = resolveInfo.activityInfo.packageName;
if (!GOOGLE_PLAY_APP_STORE_PACKAGE_NAME.equals(pkgName)) {
if (isAppSystem(pkgName)) {
intent.setPackage(pkgName);
return intent;
}
} else {
intent.setPackage(GOOGLE_PLAY_APP_STORE_PACKAGE_NAME);
googleIntent = intent;
}
}
if (isIncludeGooglePlayStore && googleIntent != null) {
return googleIntent;
}
intent.setPackage(resolveInfos.get(0).activityInfo.packageName);
return intent;
}
private static boolean go2NormalAppStore(String packageName) {
Intent intent = getNormalAppStoreIntent();
if (intent == null) return false;
intent.setData(Uri.parse("market://details?id=" + packageName));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Utils.getApp().startActivity(intent);
return true;
}
private static Intent getNormalAppStoreIntent() {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("market://details?id=" + Utils.getApp().getPackageName());
intent.setData(uri);
if (getAvailableIntentSize(intent) > 0) {
return intent;
}
return null;
}
private static Intent getSamsungAppStoreIntent(final String packageName) {
Intent intent = new Intent();
intent.setClassName("com.sec.android.app.samsungapps", "com.sec.android.app.samsungapps.Main");
intent.setData(Uri.parse("http://www.samsungapps.com/appquery/appDetail.as?appId=" + packageName));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (getAvailableIntentSize(intent) > 0) {
return intent;
}
return null;
}
private static Intent getLeecoAppStoreIntent(final String packageName) {
Intent intent = new Intent();
intent.setClassName("com.letv.app.appstore", "com.letv.app.appstore.appmodule.details.DetailsActivity");
intent.setAction("com.letv.app.appstore.appdetailactivity");
intent.putExtra("packageName", packageName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (getAvailableIntentSize(intent) > 0) {
return intent;
}
return null;
}
private static int getAvailableIntentSize(final Intent intent) {
return Utils.getApp().getPackageManager()
.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
.size();
}
private static boolean isAppSystem(final String packageName) {
if (TextUtils.isEmpty(packageName)) return false;
try {
PackageManager pm = Utils.getApp().getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
return ai != null && (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
}
}
......@@ -6,6 +6,8 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.blankj.utilcode.util.Utils;
/**
* <pre>
* author: Blankj
......
package com.blankj.subutil.util;
import android.content.Context;
import android.telephony.TelephonyManager;
import com.blankj.utilcode.util.Utils;
import java.util.HashMap;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2019/06/11
* desc : utils about country code
* </pre>
*/
public class CountryUtils {
private static HashMap<String, String> countryCodeMap;
public static String getCountryCodeBySim(String defaultValue) {
String code = getCountryCodeFromMap().get(getCountryBySim());
if (code == null) {
return defaultValue;
}
return code;
}
public static String getCountryCodeByLanguage(String defaultValue) {
String code = getCountryCodeFromMap().get(getCountryByLanguage());
if (code == null) {
return defaultValue;
}
return code;
}
public static String getCountryByLanguage() {
return Utils.getApp().getResources().getConfiguration().locale.getCountry();
}
public static String getCountryBySim() {
TelephonyManager manager = (TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
if (manager != null) {
return manager.getSimCountryIso().toUpperCase();
}
return "";
}
private static HashMap<String, String> getCountryCodeFromMap() {
if (countryCodeMap == null) {
countryCodeMap = new HashMap<>(256);
countryCodeMap.put("AL", "+355");
countryCodeMap.put("DZ", "+213");
countryCodeMap.put("AF", "+93");
countryCodeMap.put("AR", "+54");
countryCodeMap.put("AE", "+971");
countryCodeMap.put("AW", "+297");
countryCodeMap.put("OM", "+968");
countryCodeMap.put("AZ", "+994");
countryCodeMap.put("AC", "+247");
countryCodeMap.put("EG", "+20");
countryCodeMap.put("ET", "+251");
countryCodeMap.put("IE", "+353");
countryCodeMap.put("EE", "+372");
countryCodeMap.put("AD", "+376");
countryCodeMap.put("AO", "+244");
countryCodeMap.put("AI", "+1");
countryCodeMap.put("AG", "+1");
countryCodeMap.put("AT", "+43");
countryCodeMap.put("AX", "+358");
countryCodeMap.put("AU", "+61");
countryCodeMap.put("BB", "+1");
countryCodeMap.put("PG", "+675");
countryCodeMap.put("BS", "+1");
countryCodeMap.put("PK", "+92");
countryCodeMap.put("PY", "+595");
countryCodeMap.put("PS", "+970");
countryCodeMap.put("BH", "+973");
countryCodeMap.put("PA", "+507");
countryCodeMap.put("BR", "+55");
countryCodeMap.put("BY", "+375");
countryCodeMap.put("BM", "+1");
countryCodeMap.put("BG", "+359");
countryCodeMap.put("MP", "+1");
countryCodeMap.put("BJ", "+229");
countryCodeMap.put("BE", "+32");
countryCodeMap.put("IS", "+354");
countryCodeMap.put("PR", "+1");
countryCodeMap.put("PL", "+48");
countryCodeMap.put("BA", "+387");
countryCodeMap.put("BO", "+591");
countryCodeMap.put("BZ", "+501");
countryCodeMap.put("BW", "+267");
countryCodeMap.put("BT", "+975");
countryCodeMap.put("BF", "+226");
countryCodeMap.put("BI", "+257");
countryCodeMap.put("KP", "+850");
countryCodeMap.put("GQ", "+240");
countryCodeMap.put("DK", "+45");
countryCodeMap.put("DE", "+49");
countryCodeMap.put("TL", "+670");
countryCodeMap.put("TG", "+228");
countryCodeMap.put("DO", "+1");
countryCodeMap.put("DM", "+1");
countryCodeMap.put("RU", "+7");
countryCodeMap.put("EC", "+593");
countryCodeMap.put("ER", "+291");
countryCodeMap.put("FR", "+33");
countryCodeMap.put("FO", "+298");
countryCodeMap.put("PF", "+689");
countryCodeMap.put("GF", "+594");
countryCodeMap.put("VA", "+39");
countryCodeMap.put("PH", "+63");
countryCodeMap.put("FJ", "+679");
countryCodeMap.put("FI", "+358");
countryCodeMap.put("CV", "+238");
countryCodeMap.put("FK", "+500");
countryCodeMap.put("GM", "+220");
countryCodeMap.put("CG", "+242");
countryCodeMap.put("CD", "+243");
countryCodeMap.put("CO", "+57");
countryCodeMap.put("CR", "+506");
countryCodeMap.put("GG", "+44");
countryCodeMap.put("GD", "+1");
countryCodeMap.put("GL", "+299");
countryCodeMap.put("GE", "+995");
countryCodeMap.put("CU", "+53");
countryCodeMap.put("GP", "+590");
countryCodeMap.put("GU", "+1");
countryCodeMap.put("GY", "+592");
countryCodeMap.put("KZ", "+7");
countryCodeMap.put("HT", "+509");
countryCodeMap.put("KR", "+82");
countryCodeMap.put("NL", "+31");
countryCodeMap.put("BQ", "+599");
countryCodeMap.put("SX", "+1");
countryCodeMap.put("ME", "+382");
countryCodeMap.put("HN", "+504");
countryCodeMap.put("KI", "+686");
countryCodeMap.put("DJ", "+253");
countryCodeMap.put("KG", "+996");
countryCodeMap.put("GN", "+224");
countryCodeMap.put("GW", "+245");
countryCodeMap.put("CA", "+1");
countryCodeMap.put("GH", "+233");
countryCodeMap.put("GA", "+241");
countryCodeMap.put("KH", "+855");
countryCodeMap.put("CZ", "+420");
countryCodeMap.put("ZW", "+263");
countryCodeMap.put("CM", "+237");
countryCodeMap.put("QA", "+974");
countryCodeMap.put("KY", "+1");
countryCodeMap.put("CC", "+61");
countryCodeMap.put("KM", "+269");
countryCodeMap.put("XK", "+383");
countryCodeMap.put("CI", "+225");
countryCodeMap.put("KW", "+965");
countryCodeMap.put("HR", "+385");
countryCodeMap.put("KE", "+254");
countryCodeMap.put("CK", "+682");
countryCodeMap.put("CW", "+599");
countryCodeMap.put("LV", "+371");
countryCodeMap.put("LS", "+266");
countryCodeMap.put("LA", "+856");
countryCodeMap.put("LB", "+961");
countryCodeMap.put("LT", "+370");
countryCodeMap.put("LR", "+231");
countryCodeMap.put("LY", "+218");
countryCodeMap.put("LI", "+423");
countryCodeMap.put("RE", "+262");
countryCodeMap.put("LU", "+352");
countryCodeMap.put("RW", "+250");
countryCodeMap.put("RO", "+40");
countryCodeMap.put("MG", "+261");
countryCodeMap.put("IM", "+44");
countryCodeMap.put("MV", "+960");
countryCodeMap.put("MT", "+356");
countryCodeMap.put("MW", "+265");
countryCodeMap.put("MY", "+60");
countryCodeMap.put("ML", "+223");
countryCodeMap.put("MK", "+389");
countryCodeMap.put("MH", "+692");
countryCodeMap.put("MQ", "+596");
countryCodeMap.put("YT", "+262");
countryCodeMap.put("MU", "+230");
countryCodeMap.put("MR", "+222");
countryCodeMap.put("US", "+1");
countryCodeMap.put("AS", "+1");
countryCodeMap.put("VI", "+1");
countryCodeMap.put("MN", "+976");
countryCodeMap.put("MS", "+1");
countryCodeMap.put("BD", "+880");
countryCodeMap.put("PE", "+51");
countryCodeMap.put("FM", "+691");
countryCodeMap.put("MM", "+95");
countryCodeMap.put("MD", "+373");
countryCodeMap.put("MA", "+212");
countryCodeMap.put("MC", "+377");
countryCodeMap.put("MZ", "+258");
countryCodeMap.put("MX", "+52");
countryCodeMap.put("NA", "+264");
countryCodeMap.put("ZA", "+27");
countryCodeMap.put("SS", "+211");
countryCodeMap.put("NR", "+674");
countryCodeMap.put("NI", "+505");
countryCodeMap.put("NP", "+977");
countryCodeMap.put("NE", "+227");
countryCodeMap.put("NG", "+234");
countryCodeMap.put("NU", "+683");
countryCodeMap.put("NO", "+47");
countryCodeMap.put("NF", "+672");
countryCodeMap.put("PW", "+680");
countryCodeMap.put("PT", "+351");
countryCodeMap.put("JP", "+81");
countryCodeMap.put("SE", "+46");
countryCodeMap.put("CH", "+41");
countryCodeMap.put("SV", "+503");
countryCodeMap.put("WS", "+685");
countryCodeMap.put("RS", "+381");
countryCodeMap.put("SL", "+232");
countryCodeMap.put("SN", "+221");
countryCodeMap.put("CY", "+357");
countryCodeMap.put("SC", "+248");
countryCodeMap.put("SA", "+966");
countryCodeMap.put("BL", "+590");
countryCodeMap.put("CX", "+61");
countryCodeMap.put("ST", "+239");
countryCodeMap.put("SH", "+290");
countryCodeMap.put("PN", "+870");
countryCodeMap.put("KN", "+1");
countryCodeMap.put("LC", "+1");
countryCodeMap.put("MF", "+590");
countryCodeMap.put("SM", "+378");
countryCodeMap.put("PM", "+508");
countryCodeMap.put("VC", "+1");
countryCodeMap.put("LK", "+94");
countryCodeMap.put("SK", "+421");
countryCodeMap.put("SI", "+386");
countryCodeMap.put("SJ", "+47");
countryCodeMap.put("SZ", "+268");
countryCodeMap.put("SD", "+249");
countryCodeMap.put("SR", "+597");
countryCodeMap.put("SB", "+677");
countryCodeMap.put("SO", "+252");
countryCodeMap.put("TJ", "+992");
countryCodeMap.put("TH", "+66");
countryCodeMap.put("TZ", "+255");
countryCodeMap.put("TO", "+676");
countryCodeMap.put("TC", "+1");
countryCodeMap.put("TA", "+290");
countryCodeMap.put("TT", "+1");
countryCodeMap.put("TN", "+216");
countryCodeMap.put("TV", "+688");
countryCodeMap.put("TR", "+90");
countryCodeMap.put("TM", "+993");
countryCodeMap.put("TK", "+690");
countryCodeMap.put("WF", "+681");
countryCodeMap.put("VU", "+678");
countryCodeMap.put("GT", "+502");
countryCodeMap.put("VE", "+58");
countryCodeMap.put("BN", "+673");
countryCodeMap.put("UG", "+256");
countryCodeMap.put("UA", "+380");
countryCodeMap.put("UY", "+598");
countryCodeMap.put("UZ", "+998");
countryCodeMap.put("GR", "+30");
countryCodeMap.put("ES", "+34");
countryCodeMap.put("EH", "+212");
countryCodeMap.put("SG", "+65");
countryCodeMap.put("NC", "+687");
countryCodeMap.put("NZ", "+64");
countryCodeMap.put("HU", "+36");
countryCodeMap.put("SY", "+963");
countryCodeMap.put("JM", "+1");
countryCodeMap.put("AM", "+374");
countryCodeMap.put("YE", "+967");
countryCodeMap.put("IQ", "+964");
countryCodeMap.put("UM", "+1");
countryCodeMap.put("IR", "+98");
countryCodeMap.put("IL", "+972");
countryCodeMap.put("IT", "+39");
countryCodeMap.put("IN", "+91");
countryCodeMap.put("ID", "+62");
countryCodeMap.put("GB", "+44");
countryCodeMap.put("VG", "+1");
countryCodeMap.put("IO", "+246");
countryCodeMap.put("JO", "+962");
countryCodeMap.put("VN", "+84");
countryCodeMap.put("ZM", "+260");
countryCodeMap.put("JE", "+44");
countryCodeMap.put("TD", "+235");
countryCodeMap.put("GI", "+350");
countryCodeMap.put("CL", "+56");
countryCodeMap.put("CF", "+236");
countryCodeMap.put("CN", "+86");
countryCodeMap.put("MO", "+853");
countryCodeMap.put("TW", "+886");
countryCodeMap.put("HK", "+852");
}
return countryCodeMap;
}
}
......@@ -14,6 +14,8 @@ import android.provider.Settings;
import android.support.annotation.RequiresPermission;
import android.util.Log;
import com.blankj.utilcode.util.Utils;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
......
package com.blankj.subutil.util;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
/**
* <pre>
* author:
* ___ ___ ___ ___
* _____ / /\ /__/\ /__/| / /\
* / /::\ / /::\ \ \:\ | |:| / /:/
* / /:/\:\ ___ ___ / /:/\:\ \ \:\ | |:| /__/::\
* / /:/~/::\ /__/\ / /\ / /:/~/::\ _____\__\:\ __| |:| \__\/\:\
* /__/:/ /:/\:| \ \:\ / /:/ /__/:/ /:/\:\ /__/::::::::\ /__/\_|:|____ \ \:\
* \ \:\/:/~/:/ \ \:\ /:/ \ \:\/:/__\/ \ \:\~~\~~\/ \ \:\/:::::/ \__\:\
* \ \::/ /:/ \ \:\/:/ \ \::/ \ \:\ ~~~ \ \::/~~~~ / /:/
* \ \:\/:/ \ \::/ \ \:\ \ \:\ \ \:\ /__/:/
* \ \::/ \__\/ \ \:\ \ \:\ \ \:\ \__\/
* \__\/ \__\/ \__\/ \__\/
* blog : http://blankj.com
* time : 16/12/08
* desc : utils about initialization
* </pre>
*/
public final class Utils {
@SuppressLint("StaticFieldLeak")
private static Application sApplication;
private Utils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* Init utils.
* <p>Init it in the class of Application.</p>
*
* @param context context
*/
public static void init(final Context context) {
if (context == null) {
init(getApplicationByReflect());
return;
}
init((Application) context.getApplicationContext());
}
/**
* Init utils.
* <p>Init it in the class of Application.</p>
*
* @param app application
*/
public static void init(final Application app) {
if (sApplication == null) {
if (app == null) {
Utils.sApplication = getApplicationByReflect();
} else {
Utils.sApplication = app;
}
}
}
/**
* Return the context of Application object.
*
* @return the context of Application object
*/
public static Application getApp() {
if (sApplication != null) return sApplication;
return getApplicationByReflect();
}
private static Application getApplicationByReflect() {
try {
@SuppressLint("PrivateApi")
Class<?> activityThread = Class.forName("android.app.ActivityThread");
Object at = activityThread.getMethod("currentActivityThread").invoke(null);
Object app = activityThread.getMethod("getApplication").invoke(at);
if (app == null) {
throw new NullPointerException("u should init first");
}
init((Application) app);
return sApplication;
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
throw new NullPointerException("u should init first");
}
public static final class ContentProvider4SubUtil extends ContentProvider {
@Override
public boolean onCreate() {
Utils.init(getContext());
return true;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
return null;
}
@Nullable
@Override
public String getType(@NonNull Uri uri) {
return null;
}
@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
return null;
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
}
}
\ No newline at end of file
......@@ -66,11 +66,11 @@ public final class SSLConfig {
new X509ExtendedTrustManager() {
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) { /**/ }
public void checkClientTrusted(X509Certificate[] chain, String authType) {/**/}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) { /**/ }
public void checkServerTrusted(X509Certificate[] chain, String authType) {/**/}
@Override
public X509Certificate[] getAcceptedIssuers() {
......@@ -79,19 +79,19 @@ public final class SSLConfig {
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) { /**/ }
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) {/**/}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) { /**/ }
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) {/**/}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) { /**/ }
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) {/**/}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) { /**/ }
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) {/**/}
}
};
} else {
......@@ -99,11 +99,11 @@ public final class SSLConfig {
new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) { /**/ }
public void checkClientTrusted(X509Certificate[] chain, String authType) {/**/}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) { /**/ }
public void checkServerTrusted(X509Certificate[] chain, String authType) {/**/}
@Override
public X509Certificate[] getAcceptedIssuers() {
......
......@@ -28,7 +28,7 @@ var isPlainObject = function isPlainObject(obj) {
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for (key in obj) { /**/ }
for (key in obj) {/**/}
return typeof key === 'undefined' || hasOwn.call(obj, key);
};
......
......@@ -4,5 +4,6 @@ apply {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api gradle.ext.dep.subutil_export
api gradle.ext.dep.lib_common
}
\ No newline at end of file
......@@ -11,6 +11,14 @@
android:name=".feature.SubUtilActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop" />
<activity
android:name=".feature.appStore.AppStoreActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop" />
<activity
android:name=".feature.countryCode.CountryCodeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop" />
<activity
android:name=".feature.location.LocationActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
......
......@@ -6,9 +6,14 @@ import android.os.Bundle
import android.view.View
import com.blankj.lib.common.CommonTitleActivity
import com.blankj.subutil.pkg.R
import com.blankj.subutil.pkg.feature.appStore.AppStoreActivity
import com.blankj.subutil.pkg.feature.countryCode.CountryCodeActivity
import com.blankj.subutil.pkg.feature.location.LocationActivity
import com.blankj.subutil.pkg.feature.pinyin.PinyinActivity
import com.blankj.subutil.util.AppStoreUtils
import com.blankj.utilcode.util.BusUtils
import kotlinx.android.synthetic.main.activity_util_sub.*
import kotlinx.android.synthetic.main.activity_util_sub.view.*
/**
* ```
......@@ -38,17 +43,23 @@ class SubUtilActivity : CommonTitleActivity() {
return R.layout.activity_util_sub
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
applyDebouncingClickListener(
subUtilAppStoreBtn,
subUtilCountryCodeBtn,
subUtilLocationBtn,
subUtilPinyinBtn
)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
fun locationClick(view: View) {
LocationActivity.start(this)
}
fun pinyinClick(view: View) {
PinyinActivity.start(this)
override fun onDebouncingClick(view: View) {
when(view.id) {
R.id.subUtilAppStoreBtn -> AppStoreActivity.start(this)
R.id.subUtilCountryCodeBtn -> CountryCodeActivity.start(this)
R.id.subUtilLocationBtn -> LocationActivity.start(this)
R.id.subUtilPinyinBtn -> PinyinActivity.start(this)
}
}
}
package com.blankj.subutil.pkg.feature.appStore
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.blankj.lib.common.CommonTitleActivity
import com.blankj.subutil.pkg.R
import com.blankj.subutil.util.AppStoreUtils
import com.blankj.utilcode.util.ActivityUtils
import kotlinx.android.synthetic.main.activity_app_store.*
/**
* ```
* author: Blankj
* blog : http://blankj.com
* time : 17/02/01
* desc : demo about PinyinUtils
* ```
*/
class AppStoreActivity : CommonTitleActivity() {
companion object {
fun start(context: Context) {
val starter = Intent(context, AppStoreActivity::class.java)
context.startActivity(starter)
}
}
override fun bindTitle(): CharSequence {
return getString(R.string.demo_app_store)
}
override fun initData(bundle: Bundle?) {}
override fun bindLayout(): Int {
return R.layout.activity_app_store
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
applyDebouncingClickListener(appStoreSystem)
}
override fun doBusiness() {}
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.appStoreSystem -> {
AppStoreUtils.getAppStoreIntent("com.tencent.mm")?.apply {
ActivityUtils.startActivity(this)
}
}
}
}
}
package com.blankj.subutil.pkg.feature.countryCode
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.blankj.lib.common.CommonTitleActivity
import com.blankj.subutil.pkg.R
import com.blankj.subutil.util.CountryUtils
import com.blankj.utilcode.util.SpanUtils
import kotlinx.android.synthetic.main.activity_country_code.*
/**
* ```
* author: Blankj
* blog : http://blankj.com
* time : 17/02/01
* desc : demo about PinyinUtils
* ```
*/
class CountryCodeActivity : CommonTitleActivity() {
companion object {
fun start(context: Context) {
val starter = Intent(context, CountryCodeActivity::class.java)
context.startActivity(starter)
}
}
override fun bindTitle(): CharSequence {
return getString(R.string.demo_country_code)
}
override fun initData(bundle: Bundle?) {}
override fun bindLayout(): Int {
return R.layout.activity_country_code
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
SpanUtils.with(countryCodeAboutTv)
.appendLine("getCountryByLanguage: " + CountryUtils.getCountryByLanguage())
.appendLine("getCountryBySim: " + CountryUtils.getCountryBySim())
.appendLine("getCountryCodeByLanguage: " + CountryUtils.getCountryCodeByLanguage("Default"))
.appendLine("getCountryCodeBySim: " + CountryUtils.getCountryCodeBySim("Default"))
.create()
}
override fun doBusiness() {}
override fun onDebouncingClick(view: View) {}
}
......@@ -90,7 +90,7 @@ class LocationActivity : CommonTitleActivity() {
bindService(Intent(this, LocationService::class.java), conn, Context.BIND_AUTO_CREATE)
}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun onDestroy() {
unbindService(conn)
......
......@@ -60,5 +60,5 @@ class PinyinActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
package com.blankj.subutil.pkg.impl;
import android.content.Context;
import com.blankj.subutil.export.api.SubUtilApi;
import com.blankj.subutil.pkg.feature.SubUtilActivity;
/**
* <pre>
* author: blankj
* blog : http://blankj.com
* time : 2019/06/09
* desc :
* </pre>
*/
public class SubUtilApiImpl implements SubUtilApi {
@Override
public void startSubUtilActivity(Context context) {
SubUtilActivity.Companion.start(context);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/spacing_16">
<Button
android:id="@+id/appStoreSystem"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_store_system" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/spacing_16">
<TextView
android:id="@+id/countryCodeAboutTv"
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
......@@ -7,17 +7,31 @@
android:padding="@dimen/spacing_16">
<Button
android:id="@+id/subUtilAppStoreBtn"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/demo_app_store" />
<Button
android:id="@+id/subUtilCountryCodeBtn"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/demo_country_code" />
<Button
android:id="@+id/subUtilLocationBtn"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="locationClick"
android:text="@string/demo_location" />
<Button
android:id="@+id/subUtilPinyinBtn"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="pinyinClick"
android:text="@string/demo_pinyin" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="demo_app_store">App Store Demo</string>
<string name="demo_country_code">Country Code Demo</string>
<string name="demo_location">LocationUtils Demo</string>
<string name="demo_pinyin">PinyinUtils Demo</string>
</resources>
<!--App Store 相关-->
<string name="app_store_system">Go System App Store</string>
</resources>
\ No newline at end of file
apply {
from "${rootDir.path}/gradle/config/configLib.gradle"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<manifest package="com.blankj.utilcode.export" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blankj.utilcode">
<permission android:name="com.blankj.utilcode.util.bus" />
<application>
<activity
android:name="com.blankj.utilcode.util.PermissionUtils$PermissionActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
......@@ -12,6 +15,7 @@
<provider
android:name="com.blankj.utilcode.util.Utils$FileProvider4UtilCode"
android:authorities="${applicationId}.utilcode.provider"
android:exported="false"
android:grantUriPermissions="true"
android:multiprocess="true">
<meta-data
......@@ -21,7 +25,7 @@
<service
android:name="com.blankj.utilcode.util.BusUtils$ServerService"
android:exported="true">
android:permission="com.blankj.utilcode.util.bus">
<intent-filter>
<action android:name="${applicationId}.messenger" />
</intent-filter>
......
......@@ -51,6 +51,7 @@ public final class ActivityUtils {
* @return the activity by context.
*/
public static Activity getActivityByContext(@NonNull Context context) {
if (context instanceof Activity) return (Activity) context;
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity) context;
......@@ -1086,6 +1087,16 @@ public final class ActivityUtils {
return Utils.getActivityLifecycle().getTopActivity();
}
/**
* Return whether the activity is alive.
*
* @param context The context.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isActivityAlive(final Context context) {
return isActivityAlive(getActivityByContext(context));
}
/**
* Return whether the activity is alive.
*
......
......@@ -14,7 +14,7 @@ public final class AdaptScreenUtils {
private static List<Field> sMetricsFields;
/**
* Adapt for the horizontal screen, and call it in [android.app.Activity.getResources].
* Adapt for the horizontal screen, and call it in {@link android.app.Activity#getResources()}.
*/
public static Resources adaptWidth(final Resources resources, final int designWidth) {
float newXdpi = (resources.getDisplayMetrics().widthPixels * 72f) / designWidth;
......@@ -23,18 +23,18 @@ public final class AdaptScreenUtils {
}
/**
* Adapt for the vertical screen, and call it in [android.app.Activity.getResources].
* Adapt for the vertical screen, and call it in {@link android.app.Activity#getResources()}.
*/
public static Resources adaptHeight(final Resources resources, final int designHeight) {
return adaptHeight(resources, designHeight, false);
}
/**
* Adapt for the vertical screen, and call it in [android.app.Activity.getResources].
* Adapt for the vertical screen, and call it in {@link android.app.Activity#getResources()}.
*/
public static Resources adaptHeight(final Resources resources, final int designHeight, final boolean includeNavBar) {
float screenHeight = resources.getDisplayMetrics().heightPixels * 72f
+ (includeNavBar ? getNavBarHeight(resources) : 0);
float screenHeight = (resources.getDisplayMetrics().heightPixels
+ (includeNavBar ? getNavBarHeight(resources) : 0)) * 72f;
float newXdpi = screenHeight / designHeight;
applyDisplayMetrics(resources, newXdpi);
return resources;
......
package com.blankj.utilcode.util;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.view.View;
/**
* <pre>
* author: blankj
* blog : http://blankj.com
* time : 2018/12/29
* desc : utils about anti shake
* </pre>
*/
public final class AntiShakeUtils {
private static final long DEFAULT_DURATION = 200;
private static final int TAG_KEY = 0x7EFFFFFF;
private AntiShakeUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
public static boolean isValid(@NonNull View view) {
return isValid(view, DEFAULT_DURATION);
}
public static boolean isValid(@NonNull View view, @IntRange(from = 0) long duration) {
long curTime = System.currentTimeMillis();
Object tag = view.getTag(TAG_KEY);
if (!(tag instanceof Long)) {
view.setTag(TAG_KEY, curTime);
return true;
}
long preTime = (Long) tag;
if (curTime - preTime <= duration) return false;
view.setTag(TAG_KEY, curTime);
return true;
}
}
package com.blankj.utilcode.util;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.view.MotionEvent;
import android.view.View;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2019/06/12
* desc : utils about click
* </pre>
*/
public class ClickUtils {
private static final int SCALE = -1;
private static final float SCALE_DEFAULT_FACTOR = -0.08f;
private static final long DEBOUNCING_DEFAULT_DURATION = 200;
public static void applyScale(final View... views) {
applyScale(views, null);
}
public static void applyScale(final View[] views, final float[] scaleFactors) {
if (views == null || views.length == 0) return;
for (int i = 0; i < views.length; i++) {
if (views[i] == null) continue;
if (scaleFactors == null || i >= scaleFactors.length) {
views[i].setTag(SCALE, SCALE_DEFAULT_FACTOR);
} else {
views[i].setTag(SCALE, scaleFactors[i]);
}
views[i].setClickable(true);
views[i].setOnTouchListener(OnUtilsTouchListener.getInstance());
}
}
public static void applySingleDebouncing(final View view, final View.OnClickListener listener) {
applySingleDebouncing(new View[]{view}, listener);
}
public static void applySingleDebouncing(final View view, @IntRange(from = 0) long duration,
final View.OnClickListener listener) {
applySingleDebouncing(new View[]{view}, duration, listener);
}
public static void applySingleDebouncing(final View[] views, final View.OnClickListener listener) {
applySingleDebouncing(views, DEBOUNCING_DEFAULT_DURATION, listener);
}
public static void applySingleDebouncing(final View[] views,
@IntRange(from = 0) long duration,
final View.OnClickListener listener) {
applyDebouncing(views, false, duration, listener);
}
public static void applyGlobalDebouncing(final View view, final View.OnClickListener listener) {
applyGlobalDebouncing(new View[]{view}, listener);
}
public static void applyGlobalDebouncing(final View view, @IntRange(from = 0) long duration,
final View.OnClickListener listener) {
applyGlobalDebouncing(new View[]{view}, duration, listener);
}
public static void applyGlobalDebouncing(final View[] views, final View.OnClickListener listener) {
applyGlobalDebouncing(views, DEBOUNCING_DEFAULT_DURATION, listener);
}
public static void applyGlobalDebouncing(final View[] views,
@IntRange(from = 0) long duration,
final View.OnClickListener listener) {
applyDebouncing(views, true, duration, listener);
}
private static void applyDebouncing(final View[] views,
final boolean isGlobal,
@IntRange(from = 0) long duration,
final View.OnClickListener listener) {
if (views == null || views.length == 0 || listener == null) return;
for (View view : views) {
if (view == null) continue;
view.setOnClickListener(new OnDebouncingClickListener(isGlobal, duration) {
@Override
public void onDebouncingClick(View v) {
listener.onClick(v);
}
});
}
}
private static class OnUtilsTouchListener implements View.OnTouchListener {
public static OnUtilsTouchListener getInstance() {
return LazyHolder.INSTANCE;
}
private OnUtilsTouchListener() {/**/}
@Override
public boolean onTouch(final View v, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
processScale(v, true);
} else if (action == MotionEvent.ACTION_UP
|| action == MotionEvent.ACTION_CANCEL) {
processScale(v, false);
}
return false;
}
private void processScale(final View view, boolean isDown) {
Object tag = view.getTag(SCALE);
if (!(tag instanceof Float)) return;
float value = isDown ? 1 + (Float) tag : 1;
view.animate()
.scaleX(value)
.scaleY(value)
.setDuration(100)
.start();
}
}
public static abstract class OnDebouncingClickListener implements View.OnClickListener {
private static final int TAG_KEY = 0x7EFFFFFF;
private static boolean mEnabled = true;
private static final Runnable ENABLE_AGAIN = new Runnable() {
@Override
public void run() {
mEnabled = true;
}
};
private static boolean isValid(@NonNull final View view, final long duration) {
long curTime = System.currentTimeMillis();
Object tag = view.getTag(TAG_KEY);
if (!(tag instanceof Long)) {
view.setTag(TAG_KEY, curTime);
return true;
}
long preTime = (Long) tag;
if (curTime - preTime <= duration) return false;
view.setTag(TAG_KEY, curTime);
return true;
}
private long mDuration;
private boolean mIsGlobal;
public OnDebouncingClickListener() {
this(true, DEBOUNCING_DEFAULT_DURATION);
}
public OnDebouncingClickListener(final boolean isGlobal) {
this(isGlobal, DEBOUNCING_DEFAULT_DURATION);
}
public OnDebouncingClickListener(final long duration) {
this(true, duration);
}
public OnDebouncingClickListener(final boolean isGlobal, final long duration) {
mIsGlobal = isGlobal;
mDuration = duration;
}
@Override
public final void onClick(View v) {
if (mIsGlobal) {
if (mEnabled) {
mEnabled = false;
v.postDelayed(ENABLE_AGAIN, mDuration);
onDebouncingClick(v);
}
} else {
if (isValid(v, mDuration)) {
onDebouncingClick(v);
}
}
}
public abstract void onDebouncingClick(View v);
}
private static class LazyHolder {
private static final OnUtilsTouchListener INSTANCE = new OnUtilsTouchListener();
}
}
......@@ -34,26 +34,12 @@ public final class KeyboardUtils {
/**
* Show the soft input.
*
* @param activity The activity.
*/
public static void showSoftInput(final Activity activity) {
showSoftInput(activity, InputMethodManager.SHOW_FORCED);
}
/**
* Show the soft input.
*
* @param activity The activity.
* @param flags Provides additional operating flags. Currently may be
* 0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
*/
public static void showSoftInput(final Activity activity, final int flags) {
View view = activity.getCurrentFocus();
if (view == null) {
view = new View(activity);
}
showSoftInput(view, flags);
public static void showSoftInput() {
InputMethodManager imm =
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) return;
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
/**
......@@ -76,9 +62,6 @@ public final class KeyboardUtils {
InputMethodManager imm =
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) return;
// clear the focus of view
view.clearFocus();
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
......@@ -91,6 +74,7 @@ public final class KeyboardUtils {
}
}
});
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
/**
......@@ -132,7 +116,7 @@ public final class KeyboardUtils {
public static void toggleSoftInput() {
InputMethodManager imm =
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
//noinspection ConstantConditions
if (imm == null) return;
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
......@@ -290,7 +274,7 @@ public final class KeyboardUtils {
if (view.getRootView() == window.getDecorView().getRootView()) {
leakViewField.set(imm, null);
}
} catch (Throwable ignore) { /**/ }
} catch (Throwable ignore) {/**/}
}
}
......
......@@ -113,7 +113,7 @@ public class PathUtils {
* @return the path of /data/data/package/shared_prefs
*/
public static String getInternalAppSpPath() {
return Utils.getApp().getApplicationInfo().dataDir + "shared_prefs";
return Utils.getApp().getApplicationInfo().dataDir + "/shared_prefs";
}
/**
......@@ -123,7 +123,7 @@ public class PathUtils {
*/
public static String getInternalAppNoBackupFilesPath() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return Utils.getApp().getApplicationInfo().dataDir + "no_backup";
return Utils.getApp().getApplicationInfo().dataDir + "/no_backup";
}
return getAbsolutePath(Utils.getApp().getNoBackupFilesDir());
}
......
......@@ -348,7 +348,7 @@ public final class RomUtils {
if (!TextUtils.isEmpty(manufacturer)) {
return manufacturer.toLowerCase();
}
} catch (Throwable ignore) { /**/ }
} catch (Throwable ignore) {/**/}
return UNKNOWN;
}
......@@ -358,7 +358,7 @@ public final class RomUtils {
if (!TextUtils.isEmpty(brand)) {
return brand.toLowerCase();
}
} catch (Throwable ignore) { /**/ }
} catch (Throwable ignore) {/**/}
return UNKNOWN;
}
......@@ -373,7 +373,7 @@ public final class RomUtils {
if (!TextUtils.isEmpty(display)) {
ret = display.toLowerCase();
}
} catch (Throwable ignore) { /**/ }
} catch (Throwable ignore) {/**/}
}
if (TextUtils.isEmpty(ret)) {
return UNKNOWN;
......@@ -407,7 +407,7 @@ public final class RomUtils {
if (input != null) {
try {
input.close();
} catch (IOException ignore) { /**/ }
} catch (IOException ignore) {/**/}
}
}
return "";
......@@ -421,7 +421,7 @@ public final class RomUtils {
);
prop.load(is);
return prop.getProperty(key, "");
} catch (Exception ignore) { /**/ }
} catch (Exception ignore) {/**/}
return "";
}
......@@ -431,7 +431,7 @@ public final class RomUtils {
Class<?> clz = Class.forName("android.os.SystemProperties");
Method getMethod = clz.getMethod("get", String.class, String.class);
return (String) getMethod.invoke(clz, key, "");
} catch (Exception e) { /**/ }
} catch (Exception e) {/**/}
return "";
}
......
......@@ -778,6 +778,10 @@ public final class SpanUtils {
mType = type;
}
public SpannableStringBuilder get() {
return mBuilder;
}
/**
* Create the span string.
*
......
......@@ -387,7 +387,7 @@ public final class ToastUtils {
mTNmHandlerField.setAccessible(true);
Handler tnHandler = (Handler) mTNmHandlerField.get(mTN);
mTNmHandlerField.set(mTN, new SafeHandler(tnHandler));
} catch (Exception ignored) { /**/ }
} catch (Exception ignored) {/**/}
}
}
......@@ -496,7 +496,7 @@ public final class ToastUtils {
if (mWM != null) {
mWM.addView(mView, mParams);
}
} catch (Exception ignored) { /**/ }
} catch (Exception ignored) {/**/}
Utils.runOnUiThreadDelayed(new Runnable() {
@Override
......@@ -512,7 +512,7 @@ public final class ToastUtils {
if (mWM != null) {
mWM.removeViewImmediate(mView);
}
} catch (Exception ignored) { /**/ }
} catch (Exception ignored) {/**/}
mView = null;
mWM = null;
mToast = null;
......
......@@ -10,6 +10,7 @@ import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
......@@ -63,7 +64,8 @@ public final class UriUtils {
if (path != null) return new File(path);
Log.d("UriUtils", uri.toString() + " parse failed. -> 0");
return null;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
}// end 0
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& DocumentsContract.isDocumentUri(Utils.getApp(), uri)) {
if ("com.android.externalstorage.documents".equals(authority)) {
final String docId = DocumentsContract.getDocumentId(uri);
......@@ -72,16 +74,29 @@ public final class UriUtils {
if ("primary".equalsIgnoreCase(type)) {
return new File(Environment.getExternalStorageDirectory() + "/" + split[1]);
}
Log.d("UriUtils", uri.toString() + " parse failed. -> 1");
Log.d("UriUtils", uri.toString() + " parse failed. -> 1_0");
return null;
} else if ("com.android.providers.downloads.documents".equals(authority)) {
}// end 1_0
else if ("com.android.providers.downloads.documents".equals(authority)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id)
);
return getFileFromUri(contentUri, 2);
} else if ("com.android.providers.media.documents".equals(authority)) {
if (!TextUtils.isEmpty(id)) {
if (id.startsWith("raw:")) {
return new File(id.substring(4));
}
try {
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id)
);
return getFileFromUri(contentUri, "1_1");
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
Log.d("UriUtils", uri.toString() + " parse failed. -> 1_1");
return null;
}// end 1_1
else if ("com.android.providers.media.documents".equals(authority)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
......@@ -93,34 +108,38 @@ public final class UriUtils {
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
} else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 3");
Log.d("UriUtils", uri.toString() + " parse failed. -> 1_2");
return null;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[]{split[1]};
return getFileFromUri(contentUri, selection, selectionArgs, 4);
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, 5);
} else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 6");
return getFileFromUri(contentUri, selection, selectionArgs, "1_2");
}// end 1_2
else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, "1_3");
}// end 1_3
else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 1_4");
return null;
}
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, 7);
} else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 8");
}// end 1_4
}// end 1
else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, "2");
}// end 2
else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 3");
return null;
}
}// end 3
}
private static File getFileFromUri(final Uri uri, final int code) {
private static File getFileFromUri(final Uri uri, final String code) {
return getFileFromUri(uri, null, null, code);
}
private static File getFileFromUri(final Uri uri,
final String selection,
final String[] selectionArgs,
final int code) {
final String code) {
final Cursor cursor = Utils.getApp().getContentResolver().query(
uri, new String[]{"_data"}, selection, selectionArgs, null);
if (cursor == null) {
......
......@@ -496,7 +496,7 @@ public final class Utils {
if (view.getRootView() == activity.getWindow().getDecorView().getRootView()) {
leakViewField.set(imm, null);
}
} catch (Throwable ignore) { /**/ }
} catch (Throwable ignore) {/**/}
}
}
}
......
package com.blankj.utilcode.util;
import android.view.View;
import android.view.ViewGroup;
/**
* <pre>
* author: blankj
* blog : http://blankj.com
* time : 2019/06/18
* desc : utils about view
* </pre>
*/
public class ViewUtils {
public static void setViewEnabled(View view, boolean enabled) {
setViewEnabled(view, enabled, (View) null);
}
public static void setViewEnabled(View view, boolean enabled, View... excludes) {
if (view == null) return;
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
setViewEnabled(viewGroup.getChildAt(i), enabled, excludes);
}
}
if (excludes != null) {
for (View exclude : excludes) {
if (view == exclude) return;
}
}
view.setEnabled(enabled);
}
}
\ No newline at end of file
......@@ -4,5 +4,6 @@ apply {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api gradle.ext.dep.utilcode_export
api gradle.ext.dep.lib_common
}
\ No newline at end of file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blankj.utilcode.pkg">
<uses-permission android:name="com.blankj.utilcode.util.bus" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- app -->
......@@ -135,6 +137,10 @@
android:name=".feature.clean.CleanActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop" />
<activity
android:name=".feature.click.ClickActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop" />
<activity
android:name=".feature.device.DeviceActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
......
......@@ -12,6 +12,7 @@ import com.blankj.utilcode.pkg.feature.app.AppActivity
import com.blankj.utilcode.pkg.feature.bar.BarActivity
import com.blankj.utilcode.pkg.feature.brightness.BrightnessActivity
import com.blankj.utilcode.pkg.feature.clean.CleanActivity
import com.blankj.utilcode.pkg.feature.click.ClickActivity
import com.blankj.utilcode.pkg.feature.device.DeviceActivity
import com.blankj.utilcode.pkg.feature.flashlight.FlashlightActivity
import com.blankj.utilcode.pkg.feature.fragment.FragmentActivity
......@@ -35,6 +36,7 @@ import com.blankj.utilcode.pkg.feature.span.SpanActivity
import com.blankj.utilcode.pkg.feature.toast.ToastActivity
import com.blankj.utilcode.pkg.feature.vibrate.VibrateActivity
import com.blankj.utilcode.util.BusUtils
import kotlinx.android.synthetic.main.activity_util_core.*
/**
* ```
......@@ -64,129 +66,78 @@ class CoreUtilActivity : CommonTitleActivity() {
return R.layout.activity_util_core
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
fun activityClick(view: View) {
ActivityActivity.start(this)
}
fun adaptScreenClick(view: View) {
AdaptScreenActivity.start(this)
}
fun appClick(view: View) {
AppActivity.start(this)
}
fun barClick(view: View) {
BarActivity.start(this)
}
fun brightnessClick(view: View) {
BrightnessActivity.start(this)
}
fun cleanClick(view: View) {
CleanActivity.start(this)
}
fun busClick(view: View) {
BusUtils.postStatic<Any>("BusActivity#start", this)
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
applyDebouncingClickListener(
coreUtilActivityBtn,
coreUtilAdaptScreenBtn,
coreUtilAppBtn,
coreUtilBarBtn,
coreUtilBrightnessBtn,
coreUtilBusBtn,
coreUtilCleanBtn,
coreUtilClickBtn,
coreUtilCrashBtn,
coreUtilDeviceBtn,
coreUtilFlashlightBtn,
coreUtilFragmentBtn,
coreUtilImageBtn,
coreUtilKeyboardBtn,
coreUtilLogBtn,
coreUtilMetaDataBtn,
coreUtilNetworkBtn,
coreUtilPathBtn,
coreUtilPermissionBtn,
coreUtilPhoneBtn,
coreUtilProcessBtn,
coreUtilReflectBtn,
coreUtilResourceBtn,
coreUtilRomBtn,
coreUtilScreenBtn,
coreUtilSdcardBtn,
coreUtilSnackbarBtn,
coreUtilSpStaticBtn,
coreUtilSpanBtn,
coreUtilToastBtn,
coreUtilVibrateBtn
)
}
fun crashClick(view: View) {
throw NullPointerException("crash test")
}
fun deviceClick(view: View) {
DeviceActivity.start(this)
}
fun flashlightClick(view: View) {
FlashlightActivity.start(this)
}
fun fragmentClick(view: View) {
FragmentActivity.start(this)
}
fun imageClick(view: View) {
ImageActivity.start(this)
}
fun keyboardClick(view: View) {
KeyboardActivity.start(this)
}
fun logClick(view: View) {
LogActivity.start(this)
}
fun metaDataClick(view: View) {
MetaDataActivity.start(this)
}
fun networkClick(view: View) {
NetworkActivity.start(this)
}
fun pathClick(view: View) {
PathActivity.start(this)
}
fun permissionClick(view: View) {
PermissionActivity.start(this)
}
fun phoneClick(view: View) {
PhoneActivity.start(this)
}
fun processClick(view: View) {
ProcessActivity.start(this)
}
fun reflectClick(view: View) {
ReflectActivity.start(this)
}
fun resourceClick(view: View) {
ResourceActivity.start(this)
}
fun romClick(view: View) {
RomActivity.start(this)
}
fun screenClick(view: View) {
ScreenActivity.start(this)
}
fun sdcardClick(view: View) {
SDCardActivity.start(this)
}
fun snackbarClick(view: View) {
SnackbarActivity.start(this)
}
fun spStaticClick(view: View) {
SPStaticActivity.start(this)
}
fun spannableClick(view: View) {
SpanActivity.start(this)
}
fun toastClick(view: View) {
ToastActivity.start(this)
}
override fun doBusiness() {}
fun vibrateClick(view: View) {
VibrateActivity.start(this)
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.coreUtilActivityBtn -> ActivityActivity.start(this)
R.id.coreUtilAdaptScreenBtn -> AdaptScreenActivity.start(this)
R.id.coreUtilAppBtn -> AppActivity.start(this)
R.id.coreUtilBarBtn -> BarActivity.start(this)
R.id.coreUtilBrightnessBtn -> BrightnessActivity.start(this)
R.id.coreUtilBusBtn -> BusUtils.postStatic<Any>("BusActivity#start", this)
R.id.coreUtilCleanBtn -> CleanActivity.start(this)
R.id.coreUtilClickBtn -> ClickActivity.start(this)
R.id.coreUtilCrashBtn -> throw NullPointerException("crash test")
R.id.coreUtilDeviceBtn -> DeviceActivity.start(this)
R.id.coreUtilFlashlightBtn -> FlashlightActivity.start(this)
R.id.coreUtilFragmentBtn -> FragmentActivity.start(this)
R.id.coreUtilImageBtn -> ImageActivity.start(this)
R.id.coreUtilKeyboardBtn -> KeyboardActivity.start(this)
R.id.coreUtilLogBtn -> LogActivity.start(this)
R.id.coreUtilMetaDataBtn -> MetaDataActivity.start(this)
R.id.coreUtilNetworkBtn -> NetworkActivity.start(this)
R.id.coreUtilNetworkBtn -> NetworkActivity.start(this)
R.id.coreUtilPathBtn -> PathActivity.start(this)
R.id.coreUtilPermissionBtn -> PermissionActivity.start(this)
R.id.coreUtilPhoneBtn -> PhoneActivity.start(this)
R.id.coreUtilProcessBtn -> ProcessActivity.start(this)
R.id.coreUtilReflectBtn -> ReflectActivity.start(this)
R.id.coreUtilResourceBtn -> ResourceActivity.start(this)
R.id.coreUtilRomBtn -> RomActivity.start(this)
R.id.coreUtilScreenBtn -> ScreenActivity.start(this)
R.id.coreUtilSdcardBtn -> SDCardActivity.start(this)
R.id.coreUtilSnackbarBtn -> SnackbarActivity.start(this)
R.id.coreUtilSpStaticBtn -> SPStaticActivity.start(this)
R.id.coreUtilSpanBtn -> SpanActivity.start(this)
R.id.coreUtilToastBtn -> ToastActivity.start(this)
R.id.coreUtilVibrateBtn -> VibrateActivity.start(this)
}
}
}
......@@ -54,35 +54,37 @@ class ActivityActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
activityClzBtn.setOnClickListener(this)
activityClzOptBtn.setOnClickListener(this)
activityClzAnimBtn.setOnClickListener(this)
activityActClzBtn.setOnClickListener(this)
activityActClzOptBtn.setOnClickListener(this)
activityActClzSharedElementBtn.setOnClickListener(this)
activityActClzAnimBtn.setOnClickListener(this)
activityPkgClsBtn.setOnClickListener(this)
activityPkgClsOptBtn.setOnClickListener(this)
activityPkgClsAnimBtn.setOnClickListener(this)
activityActPkgClsBtn.setOnClickListener(this)
activityActPkgClsOptBtn.setOnClickListener(this)
activityActPkgClsSharedElementBtn.setOnClickListener(this)
activityActPkgClsAnimBtn.setOnClickListener(this)
activityIntentBtn.setOnClickListener(this)
activityIntentOptBtn.setOnClickListener(this)
activityIntentSharedElementBtn.setOnClickListener(this)
activityIntentAnimBtn.setOnClickListener(this)
activityIntentsBtn.setOnClickListener(this)
activityIntentsOptBtn.setOnClickListener(this)
activityIntentsAnimBtn.setOnClickListener(this)
activityActIntentsBtn.setOnClickListener(this)
activityActIntentsOptBtn.setOnClickListener(this)
activityActIntentsAnimBtn.setOnClickListener(this)
activityActClzSharedElementBtn.setOnClickListener(this)
activityStartHomeActivityBtn.setOnClickListener(this)
activityFinishActivityBtn.setOnClickListener(this)
activityFinishToActivityBtn.setOnClickListener(this)
activityFinishAllActivitiesBtn.setOnClickListener(this)
applyDebouncingClickListener(
activityClzBtn,
activityClzOptBtn,
activityClzAnimBtn,
activityActClzBtn,
activityActClzOptBtn,
activityActClzSharedElementBtn,
activityActClzAnimBtn,
activityPkgClsBtn,
activityPkgClsOptBtn,
activityPkgClsAnimBtn,
activityActPkgClsBtn,
activityActPkgClsOptBtn,
activityActPkgClsSharedElementBtn,
activityActPkgClsAnimBtn,
activityIntentBtn,
activityIntentOptBtn,
activityIntentSharedElementBtn,
activityIntentAnimBtn,
activityIntentsBtn,
activityIntentsOptBtn,
activityIntentsAnimBtn,
activityActIntentsBtn,
activityActIntentsOptBtn,
activityActIntentsAnimBtn,
activityActClzSharedElementBtn,
activityStartHomeActivityBtn,
activityFinishActivityBtn,
activityFinishToActivityBtn,
activityFinishAllActivitiesBtn
)
SpanUtils.with(activityAboutTv)
.appendLine("isActivityExists: " + ActivityUtils.isActivityExists(AppUtils.getAppPackageName(), SubActivityActivity::class.java.name))
.appendLine("getLauncherActivity: " + ActivityUtils.getLauncherActivity(AppUtils.getAppPackageName()))
......@@ -103,7 +105,7 @@ class ActivityActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.activityClzBtn -> ActivityUtils.startActivity(SubActivityActivity::class.java)
R.id.activityClzOptBtn -> ActivityUtils.startActivity(SubActivityActivity::class.java,
......
......@@ -38,7 +38,7 @@ class SubActivityActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun onBackPressed() {
super.onBackPressed()
......
......@@ -35,7 +35,7 @@ class AdaptCloseActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun getResources(): Resources {
return AdaptScreenUtils.closeAdapt(super.getResources())
......
......@@ -38,7 +38,7 @@ class AdaptHeightActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun getResources(): Resources {
return AdaptScreenUtils.adaptHeight(super.getResources(), 1920)
......
......@@ -28,14 +28,16 @@ class AdaptScreenActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
adaptScreenAdaptWidthBtn.setOnClickListener(this)
adaptScreenAdaptHeightBtn.setOnClickListener(this)
adaptScreenCloseAdaptBtn.setOnClickListener(this)
applyDebouncingClickListener(
adaptScreenAdaptWidthBtn,
adaptScreenAdaptHeightBtn,
adaptScreenCloseAdaptBtn
)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.adaptScreenAdaptWidthBtn -> AdaptWidthActivity.start(this)
R.id.adaptScreenAdaptHeightBtn -> AdaptHeightActivity.start(this)
......
......@@ -38,7 +38,7 @@ class AdaptWidthActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun getResources(): Resources {
return AdaptScreenUtils.adaptWidth(super.getResources(), 1080)
......
......@@ -53,14 +53,16 @@ class AppActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
appInstallAppBtn.setOnClickListener(this)
appInstallAppSilentBtn.setOnClickListener(this)
appUninstallAppBtn.setOnClickListener(this)
appUninstallAppSilentBtn.setOnClickListener(this)
appLaunchAppBtn.setOnClickListener(this)
appRelaunchAppBtn.setOnClickListener(this)
appExitAppBtn.setOnClickListener(this)
appLaunchAppDetailsSettingsBtn.setOnClickListener(this)
applyDebouncingClickListener(
appInstallAppBtn,
appInstallAppSilentBtn,
appUninstallAppBtn,
appUninstallAppSilentBtn,
appLaunchAppBtn,
appRelaunchAppBtn,
appExitAppBtn,
appLaunchAppDetailsSettingsBtn
)
SpanUtils.with(appAboutTv)
.appendLine("isAppRoot: " + AppUtils.isAppRoot())
.appendLine("isAppDebug: " + AppUtils.isAppDebug())
......@@ -84,7 +86,7 @@ class AppActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.appInstallAppBtn -> if (AppUtils.isAppInstalled(Config.TEST_PKG)) {
ToastUtils.showShort(R.string.app_install_tips)
......
......@@ -36,20 +36,22 @@ class BarActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusAboutBtn.setOnClickListener(this)
barStatusSetColorBtn.setOnClickListener(this)
barStatusSetAlphaBtn.setOnClickListener(this)
barStatusSetImageViewBtn.setOnClickListener(this)
barStatusSetCustomBtn.setOnClickListener(this)
barStatusSetFragmentBtn.setOnClickListener(this)
barStatusSetDrawerBtn.setOnClickListener(this)
barNotificationAboutBtn.setOnClickListener(this)
barNavAboutBtn.setOnClickListener(this)
applyDebouncingClickListener(
barStatusAboutBtn,
barStatusSetColorBtn,
barStatusSetAlphaBtn,
barStatusSetImageViewBtn,
barStatusSetCustomBtn,
barStatusSetFragmentBtn,
barStatusSetDrawerBtn,
barNotificationAboutBtn,
barNavAboutBtn
)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusAboutBtn -> BarStatusActivity.start(this)
R.id.barStatusSetColorBtn -> BarStatusColorActivity.start(this)
......
......@@ -47,13 +47,13 @@ class BarNavActivity : CommonTitleActivity() {
barNavVisibilityCb.setOnCheckedChangeListener { buttonView, isChecked ->
BarUtils.setNavBarVisibility(this, isChecked)
}
barNavSetColorBtn.setOnClickListener(this)
applyDebouncingClickListener(barNavSetColorBtn)
}
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barNavSetColorBtn -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
BarUtils.setNavBarColor(this, ColorUtils.getRandomColor())
......
......@@ -40,12 +40,12 @@ class BarNotificationActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barNotificationShowBtn.setOnClickListener(this)
applyDebouncingClickListener(barNotificationShowBtn)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barNotificationShowBtn -> {
BarUtils.setNotificationBarVisibility(true)
......
......@@ -56,7 +56,7 @@ class BarStatusActivity : CommonTitleActivity() {
updateAboutStatus()
}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
private fun updateAboutStatus() {
SpanUtils.with(barStatusAboutTv)
......
......@@ -55,7 +55,7 @@ class BarStatusAlphaActivity : CommonBackActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusAlphaSetTransparentBtn.setOnClickListener(this)
applyDebouncingClickListener(barStatusAlphaSetTransparentBtn)
barStatusAlphaChangeAlphaSb.setOnSeekBarChangeListener(translucentListener)
barStatusAlphaAboutTv.text = mAlpha.toString()
......@@ -65,7 +65,7 @@ class BarStatusAlphaActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusAlphaSetTransparentBtn -> barStatusAlphaChangeAlphaSb.progress = 0
}
......
......@@ -49,7 +49,7 @@ class BarStatusAlphaFragment : BaseLazyFragment() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusAlphaFragmentSetTransparentBtn.setOnClickListener(this)
applyDebouncingClickListener(barStatusAlphaFragmentSetTransparentBtn)
barStatusAlphaFragmentChangeAlphaSb.setOnSeekBarChangeListener(translucentListener)
barStatusAlphaFragmentAboutTv.text = mAlpha.toString()
......@@ -60,7 +60,7 @@ class BarStatusAlphaFragment : BaseLazyFragment() {
LogUtils.d("doLazyBusiness() called")
}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusAlphaSetTransparentBtn -> barStatusAlphaFragmentChangeAlphaSb.progress = 0
}
......
......@@ -42,7 +42,7 @@ class BarStatusColorActivity : CommonBackActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusColorRandomColorBtn.setOnClickListener(this)
applyDebouncingClickListener(barStatusColorRandomColorBtn)
updateStatusBar()
}
......@@ -50,7 +50,7 @@ class BarStatusColorActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusColorRandomColorBtn -> {
mColor = ColorUtils.getRandomColor()
......
......@@ -36,7 +36,7 @@ class BarStatusColorFragment : BaseLazyFragment() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusColorFragmentRandomColorBtn.setOnClickListener(this)
applyDebouncingClickListener(barStatusColorFragmentRandomColorBtn)
updateFakeStatusBar()
}
......@@ -44,7 +44,7 @@ class BarStatusColorFragment : BaseLazyFragment() {
LogUtils.d("doLazyBusiness() called")
}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusColorFragmentRandomColorBtn -> {
mColor = ColorUtils.getRandomColor()
......
......@@ -43,5 +43,5 @@ class BarStatusCustomActivity : CommonBackActivity() {
BarUtils.setStatusBarColor(this, Color.TRANSPARENT).setBackgroundResource(R.drawable.bar_status_custom)
}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -39,5 +39,5 @@ class BarStatusCustomFragment : BaseLazyFragment() {
LogUtils.d("doLazyBusiness() called")
}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -81,8 +81,10 @@ class BarStatusDrawerActivity : CommonDrawerActivity() {
barStatusDrawerAlphaCb.setOnCheckedChangeListener(mAlphaCheckedChangeListener)
barStatusDrawerFrontCb.setOnCheckedChangeListener(mFrontCheckedChangeListener)
barStatusDrawerChangeAlphaSb.setOnSeekBarChangeListener(mColorListener)
barStatusDrawerRandomColorBtn.setOnClickListener(this)
barStatusDrawerSetTransparentBtn.setOnClickListener(this)
applyDebouncingClickListener(
barStatusDrawerRandomColorBtn,
barStatusDrawerSetTransparentBtn
)
barStatusDrawerChangeAlphaSb.visibility = View.GONE
barStatusDrawerSetTransparentBtn.visibility = View.GONE
......@@ -92,7 +94,7 @@ class BarStatusDrawerActivity : CommonDrawerActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusDrawerRandomColorBtn -> {
mColor = ColorUtils.getRandomColor()
......
......@@ -103,5 +103,5 @@ class BarStatusFragmentActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -55,7 +55,7 @@ class BarStatusImageViewActivity : CommonBackActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusImageViewSetTransparentBtn.setOnClickListener(this)
applyDebouncingClickListener(barStatusImageViewSetTransparentBtn)
barStatusImageViewChangeAlphaSb.setOnSeekBarChangeListener(translucentListener)
barStatusImageViewAboutTv.text = mAlpha.toString()
......@@ -64,7 +64,7 @@ class BarStatusImageViewActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusImageViewSetTransparentBtn -> barStatusImageViewChangeAlphaSb.progress = 0
}
......
......@@ -49,7 +49,7 @@ class BarStatusImageViewFragment : BaseLazyFragment() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
barStatusImageViewFragmentSetTransparentBtn.setOnClickListener(this)
applyDebouncingClickListener(barStatusImageViewFragmentSetTransparentBtn)
barStatusImageViewFragmentChangeAlphaSb.setOnSeekBarChangeListener(translucentListener)
barStatusImageViewFragmentAboutTv.text = mAlpha.toString()
......@@ -60,7 +60,7 @@ class BarStatusImageViewFragment : BaseLazyFragment() {
LogUtils.d("doLazyBusiness() called")
}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.barStatusImageViewSetTransparentBtn -> barStatusImageViewFragmentChangeAlphaSb.progress = 0
}
......
......@@ -92,7 +92,7 @@ class BrightnessActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
private fun updateBrightness() {
SpanUtils.with(brightnessAboutTv)
......
......@@ -47,8 +47,10 @@ class BusActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
busStartRemoteBtn.setOnClickListener(this)
busPostBtn.setOnClickListener(this)
applyDebouncingClickListener(
busStartRemoteBtn,
busPostBtn
)
}
override fun doBusiness() {
......@@ -59,7 +61,7 @@ class BusActivity : CommonTitleActivity() {
})
}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.busStartRemoteBtn -> BusRemoteActivity.start(this)
R.id.busPostBtn -> {
......
......@@ -46,8 +46,10 @@ class BusRemoteActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
busRemotePostBtn.setOnClickListener(this)
busRemotePost2MainBtn.setOnClickListener(this)
applyDebouncingClickListener(
busRemotePostBtn,
busRemotePost2MainBtn
)
}
override fun doBusiness() {
......@@ -58,7 +60,7 @@ class BusRemoteActivity : CommonTitleActivity() {
})
}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.busRemotePostBtn -> BusUtils.post(BUS_KEY, BUNDLE)
R.id.busRemotePost2MainBtn -> BusUtils.post(BusActivity.BUS_KEY, BusActivity.BUNDLE)
......
......@@ -48,11 +48,13 @@ class CleanActivity : CommonTitleActivity() {
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
snackBarRootView = findViewById(android.R.id.content)
cleanInternalCacheBtn.setOnClickListener(this)
cleanInternalFilesBtn.setOnClickListener(this)
cleanInternalDatabasesBtn.setOnClickListener(this)
cleanInternalSpBtn.setOnClickListener(this)
cleanExternalCacheBtn.setOnClickListener(this)
applyDebouncingClickListener(
cleanInternalCacheBtn,
cleanInternalFilesBtn,
cleanInternalDatabasesBtn,
cleanInternalSpBtn,
cleanExternalCacheBtn
)
internalCachePath = cacheDir.path
internalFilesPath = filesDir.path
......@@ -66,7 +68,7 @@ class CleanActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.cleanInternalCacheBtn -> showSnackbar(CleanUtils.cleanInternalCache(), internalCachePath)
R.id.cleanInternalFilesBtn -> showSnackbar(CleanUtils.cleanInternalFiles(), internalFilesPath)
......
package com.blankj.utilcode.pkg.feature.click
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.blankj.lib.common.CommonTitleActivity
import com.blankj.utilcode.pkg.R
import com.blankj.utilcode.util.ClickUtils
import kotlinx.android.synthetic.main.activity_click.*
/**
* ```
* author: Blankj
* blog : http://blankj.com
* time : 2016/09/29
* desc : demo about CleanUtils
* ```
*/
class ClickActivity : CommonTitleActivity() {
companion object {
fun start(context: Context) {
val starter = Intent(context, ClickActivity::class.java)
context.startActivity(starter)
}
}
override fun bindTitle(): CharSequence {
return getString(R.string.demo_click)
}
override fun initData(bundle: Bundle?) {}
override fun bindLayout(): Int {
return R.layout.activity_click
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
ClickUtils.applyScale(clickScaleDefaultBtn)
ClickUtils.applyScale(arrayOf(clickScaleCustomBtn), floatArrayOf(-0.5f))
}
override fun doBusiness() {}
override fun onDebouncingClick(view: View) {}
}
......@@ -42,10 +42,11 @@ class DeviceActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
deviceShutdownBtn.setOnClickListener(this)
deviceRebootBtn.setOnClickListener(this)
deviceReboot2RecoveryBtn.setOnClickListener(this)
deviceReboot2BootloaderBtn.setOnClickListener(this)
applyDebouncingClickListener(deviceShutdownBtn,
deviceRebootBtn,
deviceReboot2RecoveryBtn,
deviceReboot2BootloaderBtn
)
SpanUtils.with(deviceAboutTv)
.appendLine("isRoot: " + DeviceUtils.isDeviceRooted())
......@@ -68,7 +69,7 @@ class DeviceActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.deviceShutdownBtn -> DeviceUtils.shutdown()
R.id.deviceRebootBtn -> DeviceUtils.reboot()
......
......@@ -62,7 +62,7 @@ class FlashlightActivity : CommonTitleActivity() {
updateAboutFlashlight()
}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
private fun updateAboutFlashlight() {
SpanUtils.with(flashlightAboutTv)
......
......@@ -37,14 +37,16 @@ class ChildFragment : BaseLazyFragment() {
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
FragmentUtils.setBackgroundColor(this, ColorUtils.getRandomColor(false))
fragmentChildShowStackBtn.setOnClickListener(this)
fragmentChildPopBtn.setOnClickListener(this)
fragmentChildRemoveBtn.setOnClickListener(this)
applyDebouncingClickListener(
fragmentChildShowStackBtn,
fragmentChildPopBtn,
fragmentChildRemoveBtn
)
}
override fun doLazyBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.fragmentChildShowStackBtn -> DialogHelper.showFragmentDialog(
SpanUtils().appendLine("top: " + FragmentUtils.getSimpleName(FragmentUtils.getTop(fragmentManager!!)))
......
......@@ -42,21 +42,22 @@ class ContainerFragment : BaseLazyFragment(), FragmentUtils.OnBackClickListener
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
FragmentUtils.setBackgroundColor(this, ColorUtils.getRandomColor(false))
fragmentRootShowStackBtn.setOnClickListener(this)
fragmentRootAddChildBtn.setOnClickListener(this)
fragmentRootAddChildStackBtn.setOnClickListener(this)
fragmentRootAddHideBtn.setOnClickListener(this)
fragmentRootAddHideStackBtn.setOnClickListener(this)
fragmentRootAddShowBtn.setOnClickListener(this)
fragmentRootPopToRootBtn.setOnClickListener(this)
fragmentRootHideShowBtn.setOnClickListener(this)
fragmentRootReplaceBtn.setOnClickListener(this)
applyDebouncingClickListener(
fragmentRootShowStackBtn,
fragmentRootAddChildBtn,
fragmentRootAddChildStackBtn,
fragmentRootAddHideBtn,
fragmentRootAddHideStackBtn,
fragmentRootAddShowBtn,
fragmentRootPopToRootBtn,
fragmentRootHideShowBtn,
fragmentRootReplaceBtn
)
}
override fun doLazyBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.fragmentRootShowStackBtn -> DialogHelper.showFragmentDialog(
SpanUtils().appendLine("top: " + FragmentUtils.getSimpleName(FragmentUtils.getTop(fragmentManager!!)))
......
......@@ -80,7 +80,7 @@ class FragmentActivity : CommonBackActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun onBackPressed() {
if (!FragmentUtils.dispatchBackPress(mFragments[curIndex])) {
......
......@@ -45,7 +45,7 @@ class RootFragment : BaseLazyFragment(), FragmentUtils.OnBackClickListener {
override fun doLazyBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun onBackClick(): Boolean {
if (FragmentUtils.dispatchBackPress(childFragmentManager)) return true
......
......@@ -102,7 +102,7 @@ class ImageActivity : CommonTaskActivity<List<BaseCell>>() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
class ImageCell(@StringRes val resId: Int, private val image: Bitmap) : BaseCell(R.layout.item_image) {
......
......@@ -40,10 +40,12 @@ class KeyboardActivity : CommonTitleActivity() {
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
KeyboardUtils.fixAndroidBug5497(this)
keyboardHideSoftInputBtn.setOnClickListener(this)
keyboardShowSoftInputBtn.setOnClickListener(this)
keyboardToggleSoftInputBtn.setOnClickListener(this)
keyboardShowDialogBtn.setOnClickListener(this)
applyDebouncingClickListener(
keyboardHideSoftInputBtn,
keyboardShowSoftInputBtn,
keyboardToggleSoftInputBtn,
keyboardShowDialogBtn
)
KeyboardUtils.registerSoftInputChangedListener(this) { height ->
SpanUtils.with(keyboardAboutTv)
......@@ -55,7 +57,7 @@ class KeyboardActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.keyboardHideSoftInputBtn -> KeyboardUtils.hideSoftInput(this)
R.id.keyboardShowSoftInputBtn -> KeyboardUtils.showSoftInput(keyboardEt)
......
......@@ -153,27 +153,29 @@ class LogActivity : CommonTitleActivity(),
logFileFilterCb.setOnCheckedChangeListener(this)
logFileFilterCb.text = String.format("FileFilter: %s", mConfig.fileFilter)
logNoTagBtn.setOnClickListener(this)
logWithTagBtn.setOnClickListener(this)
logInNewThreadBtn.setOnClickListener(this)
logNullBtn.setOnClickListener(this)
logManyParamsBtn.setOnClickListener(this)
logLongBtn.setOnClickListener(this)
logFileBtn.setOnClickListener(this)
logJsonBtn.setOnClickListener(this)
logXmlBtn.setOnClickListener(this)
logArrayBtn.setOnClickListener(this)
logThrowableBtn.setOnClickListener(this)
logBundleBtn.setOnClickListener(this)
logIntentBtn.setOnClickListener(this)
logArrayListBtn.setOnClickListener(this)
logMapBtn.setOnClickListener(this)
applyDebouncingClickListener(
logNoTagBtn,
logWithTagBtn,
logInNewThreadBtn,
logNullBtn,
logManyParamsBtn,
logLongBtn,
logFileBtn,
logJsonBtn,
logXmlBtn,
logArrayBtn,
logThrowableBtn,
logBundleBtn,
logIntentBtn,
logArrayListBtn,
logMapBtn
)
updateAboutLog()
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.logNoTagBtn -> {
LogUtils.v("verbose")
......
......@@ -46,5 +46,5 @@ class MetaDataActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -47,7 +47,7 @@ class NetworkActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
networkOpenWirelessSettingsBtn.setOnClickListener(this)
applyDebouncingClickListener(networkOpenWirelessSettingsBtn)
if (AppUtils.isAppSystem()) {
networkMobileDataEnabledCb.setOnCheckedChangeListener { buttonView, isChecked ->
......@@ -73,7 +73,7 @@ class NetworkActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.networkOpenWirelessSettingsBtn -> NetworkUtils.openWirelessSettings()
}
......
......@@ -83,5 +83,5 @@ class PathActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -43,12 +43,14 @@ class PermissionActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
permissionOpenAppSettingsBtn.setOnClickListener(this)
permissionRequestCalendarBtn.setOnClickListener(this)
permissionRequestRecordAudioBtn.setOnClickListener(this)
permissionRequestCalendarAndRecordAudioBtn.setOnClickListener(this)
permissionRequestWriteSettings.setOnClickListener(this)
permissionRequestDrawOverlays.setOnClickListener(this)
applyDebouncingClickListener(
permissionOpenAppSettingsBtn,
permissionRequestCalendarBtn,
permissionRequestRecordAudioBtn,
permissionRequestCalendarAndRecordAudioBtn,
permissionRequestWriteSettings,
permissionRequestDrawOverlays
)
val sb = StringBuilder()
for (s in PermissionUtils.getPermissions()) {
......@@ -64,7 +66,7 @@ class PermissionActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.permissionOpenAppSettingsBtn -> PermissionUtils.launchAppDetailsSettings()
R.id.permissionRequestCalendarBtn -> requestCalendar()
......
......@@ -60,15 +60,17 @@ class PhoneActivity : CommonTitleActivity() {
.append("getPhoneStatus: " + PhoneUtils.getPhoneStatus())
.create()
phoneDialBtn.setOnClickListener(this)
phoneCallBtn.setOnClickListener(this)
phoneSendSmsBtn.setOnClickListener(this)
phoneSendSmsSilentBtn.setOnClickListener(this)
applyDebouncingClickListener(
phoneDialBtn,
phoneCallBtn,
phoneSendSmsBtn,
phoneSendSmsSilentBtn
)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.phoneDialBtn -> PhoneUtils.dial("10000")
R.id.phoneCallBtn -> PhoneUtils.call("10000")
......
......@@ -38,7 +38,7 @@ class ProcessActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
processKillAllBackgroundProcesses.setOnClickListener(this)
applyDebouncingClickListener(processKillAllBackgroundProcesses)
val set = ProcessUtils.getAllBackgroundProcesses()
SpanUtils.with(processAboutTv)
.appendLine("getForegroundProcessName: " + ProcessUtils.getForegroundProcessName()!!)
......@@ -51,7 +51,7 @@ class ProcessActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.processKillAllBackgroundProcesses -> {
val bgSet = ProcessUtils.getAllBackgroundProcesses()
......
......@@ -46,7 +46,7 @@ class ReflectActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
override fun onDestroy() {
ReflectUtils.reflect(TestPrivateStaticFinal::class.java).field("I1", 1)
......
......@@ -41,8 +41,10 @@ class ResourceActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
resourceCopyFileFromAssets.setOnClickListener(this)
resourceCopyFileFromRaw.setOnClickListener(this)
applyDebouncingClickListener(
resourceCopyFileFromAssets,
resourceCopyFileFromRaw
)
SpanUtils.with(resourceAboutTv)
.appendLine("readAssets2String: " + ResourceUtils.readAssets2String("test/test.txt"))
......@@ -53,7 +55,7 @@ class ResourceActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.resourceCopyFileFromAssets -> ResourceUtils.copyFileFromAssets("test", Config.CACHE_PATH + "assets/test")
R.id.resourceCopyFileFromRaw -> ResourceUtils.copyFileFromRaw(R.raw.test, Config.CACHE_PATH + "raw/test.txt")
......
......@@ -45,5 +45,5 @@ class RomActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -53,19 +53,21 @@ class ScreenActivity : CommonTitleActivity() {
}
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
screenFullscreenBtn.setOnClickListener(this);
screenNonFullscreenBtn.setOnClickListener(this);
screenToggleFullscreenBtn.setOnClickListener(this);
screenLandscapeBtn.setOnClickListener(this);
screenPortraitBtn.setOnClickListener(this);
screenScreenshotBtn.setOnClickListener(this);
screenSetSleepDurationBtn.setOnClickListener(this);
applyDebouncingClickListener(
screenFullscreenBtn,
screenNonFullscreenBtn,
screenToggleFullscreenBtn,
screenLandscapeBtn,
screenPortraitBtn,
screenScreenshotBtn,
screenSetSleepDurationBtn
)
updateAboutScreen();
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.screenFullscreenBtn -> {
ScreenUtils.setFullScreen(this)
......
......@@ -47,5 +47,5 @@ class SDCardActivity : CommonTitleActivity() {
override fun doBusiness() {}
override fun onWidgetClick(view: View) {}
override fun onDebouncingClick(view: View) {}
}
......@@ -48,23 +48,25 @@ class SnackbarActivity : CommonTitleActivity() {
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
snackBarRootView = findViewById(android.R.id.content)
snackbarShowShortBtn.setOnClickListener(this)
snackbarShowShortWithActionBtn.setOnClickListener(this)
snackbarShowLongBtn.setOnClickListener(this)
snackbarShowLongWithActionBtn.setOnClickListener(this)
snackbarShowIndefiniteBtn.setOnClickListener(this)
snackbarShowIndefiniteWithActionBtn.setOnClickListener(this)
snackbarAddViewBtn.setOnClickListener(this)
snackbarAddViewWithActionBtn.setOnClickListener(this)
snackbarShowSuccessBtn.setOnClickListener(this)
snackbarShowWarningBtn.setOnClickListener(this)
snackbarShowErrorBtn.setOnClickListener(this)
snackbarDismissBtn.setOnClickListener(this)
applyDebouncingClickListener(
snackbarShowShortBtn,
snackbarShowShortWithActionBtn,
snackbarShowLongBtn,
snackbarShowLongWithActionBtn,
snackbarShowIndefiniteBtn,
snackbarShowIndefiniteWithActionBtn,
snackbarAddViewBtn,
snackbarAddViewWithActionBtn,
snackbarShowSuccessBtn,
snackbarShowWarningBtn,
snackbarShowErrorBtn,
snackbarDismissBtn
)
}
override fun doBusiness() {}
override fun onWidgetClick(view: View) {
override fun onDebouncingClick(view: View) {
when (view.id) {
R.id.snackbarShowShortBtn -> SnackbarUtils.with(snackBarRootView)
.setMessage(getMsg(R.string.snackbar_short))
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册