本文讲解一下Gradle
的应用,大家都知道Gradle
使用起来非常方便,那他究竟方便在哪里?
- 很多时候我们在打印
Log
日志的时候都是需要在Debug
版本中进行打印,而在正式版本中关闭。 通常我们都是用一个Config
文件来配置,不知道大家有没有遇到过正式版中忘记关闭Log
日志的情况。 - 多渠道包非常让人头疼。现在国内市场这么多。一个个的打多麻烦,虽然我们会用友盟打包工具等。 怎么破?
getWindow().setBackgroundDrawable(new ColorDrawable(0)); | |
try { | |
getWindow().getDecorView().setBackgroundDrawable(null); | |
} catch (Throwable e){ | |
} |
<?xml version="1.0" encoding="utf-8"?> | |
<me.relex.photodraweeview.PhotoDraweeView xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/iv_gallery_photo" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:fadeDuration="1000" | |
app:failureImage="@drawable/works_list_default_img" | |
app:failureImageScaleType="centerInside" | |
app:placeholderImage="@drawable/loading_everyday" |
public static void start(Activity context, BooksBean positionData, ImageView imageView) { | |
Intent intent = new Intent(context, BookDetailActivity.class); | |
intent.putExtra(EXTRA_PARAM, positionData); | |
ActivityOptionsCompat options = | |
ActivityOptionsCompat.makeSceneTransitionAnimation(context, | |
imageView, CommonUtils.getString(R.string.transition_book_img));//与xml文件对应 | |
ActivityCompat.startActivity(context, intent, options.toBundle()); | |
} | |
RxBus.getDefault().toObservable(RxCodeConstants.JUMP_TYPE_TO_ONE, RxBusBaseMessage.class) |
public static void start(Activity context, BooksBean positionData, ImageView imageView) { | |
Intent intent = new Intent(context, BookDetailActivity.class); | |
intent.putExtra(EXTRA_PARAM, positionData); | |
ActivityOptionsCompat options = | |
ActivityOptionsCompat.makeSceneTransitionAnimation(context, | |
imageView, CommonUtils.getString(R.string.transition_book_img));//与xml文件对应 | |
ActivityCompat.startActivity(context, intent, options.toBundle()); | |
} |
class FileSplit { | |
public static void splitFile(File f) throws IOException { | |
int partCounter = 1;//I like to name parts from 001, 002, 003, ... | |
//you can change it to 0 if you want 000, 001, ... | |
int sizeOfFiles = 1024 * 1024;// 1MB | |
byte[] buffer = new byte[sizeOfFiles]; | |
try (BufferedInputStream bis = new BufferedInputStream( | |
new FileInputStream(f))) {//try-with-resources to ensure closing stream |
/** | |
* On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing | |
* the search panel. | |
*/ | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
private void doEnterAnim() { | |
// Fade in a background scrim as this is a floating window. We could have used a | |
// translucent window background but this approach allows us to turn off window animation & | |
// overlap the fade with the reveal animation – making it feel snappier. | |
View scrim = findViewById(R.id.scrim); |
提示:默认情况下,当您将 EditText 元素设置为使用 "textPassword" 输入类型时,字体系列将设置为固定宽度。因此,您应该将其字体系列更改为 "sans-serif",以便两个文本字段都使用匹配的字体样式。 | |
``` | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content"> | |
<ImageView | |
android:src="@drawable/header_logo" | |
android:layout_width="match_parent" |
/** JSAPI支付 */ | |
public JSONObject jsPay() { | |
JSONObject obj = new JSONObject(); | |
WeixinMpAccount weixinAccount = JSON.parseObject( | |
ConfigUtil.getValue("account"), WeixinMpAccount.class); | |
// V3 支付 | |
PayPackage payPackage = new PayPackageV3(weixinAccount, "用户openid", | |
"商品描述", "系统内部订单号", 1d, "IP地址", TradeType.JSAPI); | |
// V2 支付 |
/** | |
* Attempts to open a file for viewing. | |
* | |
* @param fileholder The holder of the file to open. | |
*/ | |
public static void openFile(FileHolder fileholder, Context c) { | |
Intent intent = new Intent(android.content.Intent.ACTION_VIEW); | |
Uri data = FileUtils.getUri(fileholder.getFile()); | |
String type = fileholder.getMimeType(); |