Skip to content

Commit

Permalink
二维码工具类与glide工具类修改
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-lii committed Sep 4, 2017
1 parent 1b486cd commit a59da17
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 223 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@
android:name=".TransitionActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />

<activity
android:name=".QRImageActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
</application>
</manifest>
10 changes: 9 additions & 1 deletion app/src/main/java/com/liyi/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import android.widget.Button;

import com.liyi.sutils.utils.app.AtyTransitionUtil;
import com.liyi.sutils.utils.other.QRCodeUtil;

public class MainActivity extends Activity implements View.OnClickListener {
private Button btn_systembar, btn_Atytransition;
private Button btn_systembar, btn_Atytransition,btn_qrcode;


@Override
Expand All @@ -23,11 +24,13 @@ protected void onCreate(Bundle savedInstanceState) {
private void initUI() {
btn_systembar = (Button) findViewById(R.id.btn_systembar);
btn_Atytransition = (Button) findViewById(R.id.btn_aty_transition);
btn_qrcode=(Button)findViewById(R.id.btn_qrcode);
}

private void addListeners() {
btn_systembar.setOnClickListener(this);
btn_Atytransition.setOnClickListener(this);
btn_qrcode.setOnClickListener(this);
}

@Override
Expand All @@ -43,6 +46,11 @@ public void onClick(View view) {
startActivity(intent1);
AtyTransitionUtil.enterFromRight(this);
break;
case R.id.btn_qrcode:
Intent intent2 = new Intent(this, QRImageActivity.class);
startActivity(intent2);
AtyTransitionUtil.enterFromTop(this);
break;
}
}
}
29 changes: 29 additions & 0 deletions app/src/main/java/com/liyi/example/QRImageActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.liyi.example;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.liyi.sutils.utils.app.DensityUtil;
import com.liyi.sutils.utils.graphic.ImageUtil;
import com.liyi.sutils.utils.other.QRCodeUtil;

/**
* 二维码页面
*/

public class QRImageActivity extends Activity {
private ImageView iv_qr;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qrimage);
iv_qr = (ImageView) findViewById(R.id.iv_qicode);
Bitmap qrImg = QRCodeUtil.generateQRImage("liyi", DensityUtil.dp2px(this,400), DensityUtil.dp2px(this,400));
Bitmap qrLogo=QRCodeUtil.addLogo(qrImg, ImageUtil.drawable2Bitmap(this, R.drawable.img_isooqi_holder));
iv_qr.setImageBitmap(qrLogo);
}
}
Binary file added app/src/main/res/drawable/img_isooqi_holder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@
android:layout_width="match_parent"
android:layout_height="45dp"
android:text="Activity过渡动画测试" />

<Button
android:id="@+id/btn_qrcode"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text="二维码生成" />
</LinearLayout>
</ScrollView>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_qrimage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#ffffff"
android:orientation="vertical">

<ImageView
android:id="@+id/iv_qicode"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
4 changes: 2 additions & 2 deletions sutils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 6
versionName "1.0.6"
versionCode 7
versionName "1.0.7"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
4 changes: 2 additions & 2 deletions sutils/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
**[] $VALUES;
public *;
}
# for DexGuard only
-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.liyi.sutils.utils.graphic.glide.transform.blur;
package com.liyi.sutils.utils.graphic.blur;


import android.graphics.Bitmap;


/**
* 国外一位大神写的图片模糊算法
*/
public class FastBlur {
public static Bitmap blur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {
Bitmap bitmap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.liyi.sutils.utils.graphic.glide.transform.blur;
package com.liyi.sutils.utils.graphic.blur;

import android.annotation.TargetApi;
import android.content.Context;
Expand All @@ -11,8 +11,12 @@
import android.renderscript.ScriptIntrinsicBlur;



/**
* 调用Android自己的RenderScript实现图片模糊
* 注:仅在 SDK >= 17 时有用
*/
public class RSBlur {

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap blur(Context context, Bitmap blurredBitmap, int radius) throws RSRuntimeException {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.liyi.sutils.utils.graphic.glide;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;


/**
* 应用程序会使用和AppGlideMoudle同一个包下的GlideApp类
*/
@GlideModule
public class CusGlideModule extends AppGlideModule {

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.liyi.sutils.utils.graphic.glide;


import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.view.View;

import com.liyi.sutils.utils.log.LogUtil;

/**
* glide的管理工具类
*/
public class GlideManager {

public static GlideRequests getRequests(@NonNull Object obj) {
GlideRequests requests = null;
if (obj instanceof Activity) {
requests = GlideApp.with((Activity) obj);
} else if (obj instanceof FragmentActivity) {
requests = GlideApp.with((FragmentActivity) obj);
} else if (obj instanceof android.app.Fragment) {
requests = GlideApp.with((android.app.Fragment) obj);
} else if (obj instanceof android.support.v4.app.Fragment) {
requests = GlideApp.with((android.support.v4.app.Fragment) obj);
} else if (obj instanceof Context) {
requests = GlideApp.with((Context) obj);
} else if (obj instanceof View) {
requests = GlideApp.with((View) obj);
} else {
LogUtil.e("GlideManager", "Glide中引入的上下文对象格式错误");
}
return requests;
}

/**
* 恢复请求,一般在停止滚动的时候
*/
public static void resumeRequests(Context context) {
GlideApp.with(context).resumeRequests();
}

/**
* 暂停请求 正在滚动的时候
*/
public static void pauseRequests(Context context) {
GlideApp.with(context).pauseRequests();
}

/**
* 清除磁盘缓存
* 注:需要在子线程中进行
*/
public static void clearDiskCache(final Context context) {
// 清理磁盘缓存 需要在子线程中执行
GlideApp.get(context).clearDiskCache();
}

/**
* 清除内存缓存
*/
public static void clearMemory(Context context) {
// 清理内存缓存 可以在UI主线程中进行
GlideApp.get(context).clearMemory();
}
}
Loading

0 comments on commit a59da17

Please sign in to comment.