Skip to content

Instantly share code, notes, and snippets.

View Logan676's full-sized avatar
:bowtie:
Coding

书虫 Logan676

:bowtie:
Coding
View GitHub Profile
@Logan676
Logan676 / ClearBackgroundDrawable.java
Created August 14, 2017 10:28
把系统自带的背景去掉
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"
@Logan676
Logan676 / BestPractice.java
Last active March 11, 2017 05:22
项目最佳实践
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)
@Logan676
Logan676 / 优雅地启动activity的方法.java
Created March 11, 2017 05:20
优雅地启动activity的方法
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());
}
@Logan676
Logan676 / FileSplit.java
Created January 22, 2016 07:27
Read portions of bytes to byte array and store them in new files when buffer is full or it is end of file
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
@Logan676
Logan676 / CircularRevealAnimation.java
Created January 8, 2016 08:28
circular reveal animation
/**
* 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 支付

AndroidStudio使用教程(第七弹)

本文讲解一下Gradle的应用,大家都知道Gradle使用起来非常方便,那他究竟方便在哪里?                          

  • 很多时候我们在打印Log日志的时候都是需要在Debug版本中进行打印,而在正式版本中关闭。 通常我们都是用一个Config文件来配置,不知道大家有没有遇到过正式版中忘记关闭Log日志的情况。
  • 多渠道包非常让人头疼。现在国内市场这么多。一个个的打多麻烦,虽然我们会用友盟打包工具等。 怎么破?
/**
* 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();