-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
106 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/hzy/weex/frame/weex/module/qrcode/QRCodeModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.hzy.weex.frame.weex.module.qrcode; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.blankj.utilcode.util.StringUtils; | ||
import com.blankj.utilcode.util.ToastUtils; | ||
import com.hzy.weex.frame.activity.QRScanActivity; | ||
import com.hzy.weex.frame.constant.AppConfig; | ||
import com.hzy.weex.frame.constant.RequestCode; | ||
import com.taobao.weex.annotation.JSMethod; | ||
import com.taobao.weex.bridge.JSCallback; | ||
import com.taobao.weex.common.WXModule; | ||
|
||
import java.util.Map; | ||
|
||
public class QRCodeModule extends WXModule { | ||
|
||
private Map<String, Object> mScanOptions; | ||
private JSCallback mCallback; | ||
|
||
@JSMethod | ||
@SuppressWarnings("unused") | ||
public boolean startScan(Map<String, Object> options, final JSCallback callback) { | ||
Context context = mWXSDKInstance.getContext(); | ||
if (!(context instanceof Activity)) { | ||
return false; | ||
} | ||
try { | ||
mScanOptions = options; | ||
Activity activity = (Activity) context; | ||
Intent intent = new Intent(activity, QRScanActivity.class); | ||
if (intent.resolveActivity(activity.getPackageManager()) != null) { | ||
activity.startActivityForResult(intent, RequestCode.REQUEST_CODE_MODULE_QR_SCAN); | ||
mCallback = callback; | ||
return true; | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
super.onActivityResult(requestCode, resultCode, data); | ||
if (requestCode == RequestCode.REQUEST_CODE_MODULE_QR_SCAN) { | ||
if (resultCode == Activity.RESULT_OK && data != null) { | ||
String content = data.getStringExtra(QRScanActivity.EXTRA_CONTENT); | ||
if (!StringUtils.isTrimEmpty(content)) { | ||
if (AppConfig.DEBUG) { | ||
ToastUtils.showShort(content); | ||
} | ||
JSONObject result = new JSONObject(); | ||
result.put("content", content); | ||
if (mCallback != null) { | ||
mCallback.invoke(result); | ||
} | ||
return; | ||
} | ||
} | ||
if (mCallback != null) { | ||
mCallback.invoke(null); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:duration="3000"> | ||
android:fillAfter="true"> | ||
<translate | ||
android:fromXDelta="0" | ||
android:toXDelta="-25%" /> | ||
android:duration="3000" | ||
android:fromXDelta="-20%" | ||
android:toXDelta="-5%" /> | ||
<scale | ||
android:duration="3000" | ||
android:fromXScale="1" | ||
android:fromYScale="1" | ||
android:toXScale="1.1" | ||
android:toYScale="1.1" /> | ||
android:toXScale="1.2" | ||
android:toYScale="1.2" /> | ||
<alpha | ||
android:duration="3000" | ||
android:fromAlpha="1" | ||
android:toAlpha="0.6" /> | ||
android:toAlpha="0.7" /> | ||
<alpha | ||
android:duration="1000" | ||
android:fromAlpha="0.7" | ||
android:startOffset="3000" | ||
android:toAlpha="1" /> | ||
<alpha | ||
android:duration="1000" | ||
android:fromAlpha="1" | ||
android:startOffset="4000" | ||
android:toAlpha="1" /> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:duration="3000"> | ||
android:duration="3000" | ||
android:fillAfter="true"> | ||
<scale | ||
android:fromXScale="0.8" | ||
android:fromYScale="0.8" | ||
android:fromXScale="0.4" | ||
android:fromYScale="0.4" | ||
android:toXScale="1" | ||
android:toYScale="1" /> | ||
<alpha | ||
android:fromAlpha="0.3" | ||
android:fromAlpha="0.2" | ||
android:toAlpha="1" /> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters