Commit 0939032c authored by Gandha Ryanto's avatar Gandha Ryanto

Initial commit

parents
*.iml
/local.properties
/.idea
.DS_Store
/build
/captures
gradlew.*
.externalNativeBuild
### Android template
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
#Mon Sep 06 18:58:46 ICT 2021
gradle.version=6.7.1
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0'
}
}
greendao {
schemaVersion 2
daoPackage 'com.sunmi.sunmit2demo.bean'
targetGenDir 'src/main/java'
}
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.sunmi.sunmit2demo"
minSdkVersion 21
targetSdkVersion 22
versionCode 235
versionName "2.0.35"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
// 设置支持的SO库架构
abiFilters 'armeabi', 'x86', 'armeabi-v7a'//, 'x86_64', 'arm64-v8a'
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dataBinding {
enabled true
}
// Specifies a flavor dimension.
flavorDimensions "demo"
buildTypes {
release {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
S {
dimension "demo"
applicationId "com.sunmi.sunmit2demo.s"
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
sourceSets {
main {
jni.srcDirs = [] //这一行加不加都可以
jniLibs.srcDirs = ['libs']
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.sunmi:DS_Lib:1.0.16'
implementation 'com.flipboard:bottomsheet-core:1.5.3'
// implementation 'com.tencent.bugly:crashreport:latest.release'
//其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如2.1.9
// implementation 'com.tencent.bugly:nativecrashreport:latest.release'
// compile 'com.github.bumptech.glide:glide:3.7.0'
//其中latest.release指代最新Bugly NDK版本号,也可以指定明确的版本号,例如3.0
// compile 'com.j256.ormlite:ormlite-android:5.0'
// compile 'com.stepstone.stepper:material-stepper:4.3.1'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'org.greenrobot:greendao:3.3.0'
implementation 'org.greenrobot:greendao-generator:3.3.0'
implementation 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar'
implementation 'com.android.support:design:26.1.0'
implementation('com.sunmi:SunmiWidgetLib:1.0.1') {
exclude group: 'com.android.support'
exclude module: 'support-annotations:'
}
implementation 'com.sunmi:printerlibrary:1.0.5'
implementation 'com.sunmi:SunmiOpenService:1.0.2'
}
# 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
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sunmi.sunmit2demo">
<!-- 显示系统窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 在 屏幕最顶部显示addview -->
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.MoreActivity"
android:configChanges="orientation|keyboardHidden|screenSize|keyboard"
/>
<service android:name="com.sunmi.sunmit2demo.unlock.UnlockServer" />
<service android:name=".unlock.BleService"/>
<activity
android:name="com.sunmi.sunmit2demo.ui.UnlockActivity"
android:launchMode="singleTask"
/>
<activity
android:name="com.sunmi.sunmit2demo.dialog.ExclusiveModeDialog"
/>
</application>
</manifest>
\ No newline at end of file
package com.sunmi.sunmit2demo;
import android.app.Presentation;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
/**
* Created by zhicheng.liu on 2018/4/2
* address :liuzhicheng@sunmi.com
* description :
*/
public abstract class BasePresentation extends Presentation implements View.OnClickListener {
private static final String TAG = "BasePresentation";
public boolean isShow;
int index;
public View.OnClickListener onClickListener;
public BasePresentationHelper helper = BasePresentationHelper.getInstance();
public BasePresentation(Context outerContext, Display display) {
super(outerContext, display);
index = helper.add(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public void setOnClickListener(@Nullable View.OnClickListener l) {
onClickListener = l;
}
@Override
public void hide() {
super.hide();
helper.hide(this);
isShow = false;
Log.i(TAG, "hide");
}
@Override
public void show() {
// getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
super.show();
Log.i(TAG, "show");
helper.show(index);
isShow = true;
}
@Override
public void dismiss() {
isShow = false;
Log.i(TAG, "dismiss");
super.dismiss();
}
@Override
public void onClick(View v) {
if(onClickListener!=null){
onClickListener.onClick(v);
}
}
public abstract void onSelect(boolean isShow);
}
package com.sunmi.sunmit2demo;
import android.os.Handler;
import android.os.Message;
import android.util.SparseArray;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhicheng.liu on 2018/4/2
* address :liuzhicheng@sunmi.com
* description : 双屏异显管理类
*/
public class BasePresentationHelper {
private static final String TAG = BasePresentationHelper.class.getName();
private SparseArray<BasePresentation> sparseArray;
private static volatile BasePresentationHelper helper;
private int key = -1;
private int lastKey = -1;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (sparseArray == null || sparseArray.size() == 0) {
return;
}
if (sparseArray.get(lastKey) == null) {
lastKey = msg.what;
return;
}
if (lastKey == msg.what) {
return;
}
if (lastKey == 0 && msg.what > 0) {
sparseArray.get(0).hide();
}
if (lastKey > 0) {
sparseArray.get(lastKey).hide();
}
lastKey = msg.what;
}
};
public static BasePresentationHelper getInstance() {
BasePresentationHelper basePresentationHelper = helper;
if (helper == null) {
synchronized (BasePresentationHelper.class) {
basePresentationHelper = helper;
if (helper == null) {
basePresentationHelper = new BasePresentationHelper();
helper = basePresentationHelper;
}
}
}
return basePresentationHelper;
}
private BasePresentationHelper() {
sparseArray = new SparseArray<>();
}
public int add(BasePresentation basePresentation) {
key++;
sparseArray.put(key, basePresentation);
return key;
}
public void hide(BasePresentation basePresentation) {
}
public void show(int i) {
for (int j = 0; j < sparseArray.size(); j++) {
int key = sparseArray.keyAt(j);
if (key != i && sparseArray.get(key) != null) {
sparseArray.get(key).onSelect(false);
}
}
sparseArray.get(i).onSelect(true);
handler.sendEmptyMessageDelayed(i, 200);
}
public void dismissAll() {
if (sparseArray == null || sparseArray.size() == 0) {
return;
}
for (int i = 0; i < sparseArray.size(); i++) {
int key = sparseArray.keyAt(i);
if (sparseArray.get(key) != null) {
sparseArray.get(key).dismiss();
}
}
sparseArray.clear();
handler.removeCallbacksAndMessages(null);
}
public void dismiss() {
int key = sparseArray.keyAt(lastKey);
if (sparseArray.get(key) != null) {
sparseArray.get(key).dismiss();
sparseArray.remove(key);
}
}
public void onStop() {
if (sparseArray == null || sparseArray.size() == 0) {
return;
}
for (int i = 0; i < sparseArray.size(); i++) {
int key = sparseArray.keyAt(i);
if (sparseArray.get(key) != null && sparseArray.get(key).isShow) {
sparseArray.get(key).hide();
}
}
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.adapter;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.sunmi.sunmit2demo.R;
import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersAdapter;
import de.hdodenhof.circleimageview.CircleImageView;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class BraceletHeaderAdapter extends Adapter<ViewHolder> implements StickyRecyclerHeadersAdapter<ViewHolder> {
private List<BraceletHeaderAdapter.MyBluetoothDevice> items;
private BraceletHeaderAdapter.OnAddListener listener;
public BraceletHeaderAdapter(List<BraceletHeaderAdapter.MyBluetoothDevice> var1) {
this.items = var1;
this.setHasStableIds(true);
}
public void add(int var1, BraceletHeaderAdapter.MyBluetoothDevice var2) {
this.items.add(var1, var2);
this.notifyDataSetChanged();
}
public void add(BraceletHeaderAdapter.MyBluetoothDevice var1) {
this.items.add(var1);
this.notifyDataSetChanged();
}
public void addAll(Collection<? extends BraceletHeaderAdapter.MyBluetoothDevice> var1) {
if (var1 != null) {
this.items.addAll(var1);
this.notifyDataSetChanged();
}
}
public void addAll(BraceletHeaderAdapter.MyBluetoothDevice... var1) {
this.addAll((Collection) Arrays.asList(var1));
}
public void clear() {
this.items.clear();
this.notifyDataSetChanged();
}
public long getHeaderId(int var1) {
return this.getItem(var1).isAdd() ? 0L : 1L;
}
public BraceletHeaderAdapter.MyBluetoothDevice getItem(int var1) {
return (BraceletHeaderAdapter.MyBluetoothDevice) this.items.get(var1);
}
public int getItemCount() {
return this.items.size();
}
public long getItemId(int var1) {
return (long) this.getItem(var1).hashCode();
}
public void onBindHeaderViewHolder(ViewHolder var1, int var2) {
TextView var3 = (TextView) var1.itemView;
if (this.getItem(var2).isAdd()) {
var3.setText(R.string.more_bracelet_connected_devices);
var3.setTextColor(Color.parseColor("#FF000000"));
} else {
var3.setText(R.string.more_bracelet_connect_devices);
var3.setTextColor(Color.parseColor("#FFFF6900"));
}
}
public void onBindViewHolder(final ViewHolder var1, int var2) {
((TextView) var1.itemView.findViewById(R.id.tv_ble_name)).setText(this.getItem(var2).getName());
((TextView) var1.itemView.findViewById(R.id.tv_ble_mac)).setText(this.getItem(var2).getAddress());
if (this.getItem(var2).isCheck()) {
var1.itemView.setBackgroundColor(Color.parseColor("#FFF6F7F9"));
} else {
var1.itemView.setBackgroundColor(Color.TRANSPARENT);
}
Button var3 = (Button) var1.itemView.findViewById(R.id.btn_ble_connect);
var3.setTag(var2);
if (this.getItem(var2).isAdd()) {
var3.setText(R.string.more_bracelet_remove);
var3.setBackgroundResource(R.drawable.more_btn_normal_bg);
var3.setTextColor(Color.parseColor("#99000000"));
} else {
var3.setText(R.string.more_bracelet_add);
var3.setBackgroundResource(R.drawable.more_btn_click_bg);
var3.setTextColor(Color.parseColor("#FFFF6000"));
}
CircleImageView var4 = (CircleImageView) var1.itemView.findViewById(R.id.civ_head_icon);
if (this.getItem(var2).getIcon() != 0) {
var4.setImageResource(this.getItem(var2).getIcon());
} else {
var4.setImageResource(R.drawable.more_bracelet_default_icon_1);
}
var3.setOnClickListener(new OnClickListener() {
public void onClick(View var1x) {
BraceletHeaderAdapter.this.listener.onClick(var1.getLayoutPosition(), BraceletHeaderAdapter.this.getItem(var1.getLayoutPosition()).isAdd());
}
});
var1.itemView.setOnClickListener(new OnClickListener() {
public void onClick(View var1x) {
BraceletHeaderAdapter.this.listener.onItemClick(var1.getLayoutPosition());
}
});
}
public ViewHolder onCreateHeaderViewHolder(ViewGroup var1) {
return new ViewHolder(LayoutInflater.from(var1.getContext()).inflate(R.layout.header_bracelet, var1, false)) {
};
}
public ViewHolder onCreateViewHolder(ViewGroup var1, int var2) {
return new ViewHolder(LayoutInflater.from(var1.getContext()).inflate(R.layout.item_bracelet, var1, false)) {
};
}
public void remove(BraceletHeaderAdapter.MyBluetoothDevice var1) {
this.items.remove(var1);
this.notifyDataSetChanged();
}
public void setOnAddClickListener(@NonNull BraceletHeaderAdapter.OnAddListener var1) {
this.listener = var1;
}
public static class MyBluetoothDevice {
private String address;
private int icon;
private boolean isAdd;
private boolean isCheck;
private String name;
public MyBluetoothDevice() {
}
public MyBluetoothDevice(String var1, boolean var2) {
this.address = var1;
this.isAdd = var2;
}
public String getAddress() {
return this.address;
}
public int getIcon() {
return this.icon;
}
public String getName() {
return this.name;
}
public boolean isAdd() {
return this.isAdd;
}
public boolean isCheck() {
return this.isCheck;
}
public void setAdd(boolean var1) {
this.isAdd = var1;
}
public void setAddress(String var1) {
this.address = var1;
}
public void setCheck(boolean var1) {
this.isCheck = var1;
}
public void setIcon(int var1) {
this.icon = var1;
}
public void setName(String var1) {
this.name = var1;
}
}
public interface OnAddListener {
void onClick(int var1, boolean var2);
void onItemClick(int var1);
}
}
package com.sunmi.sunmit2demo.adapter;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.bean.GvBeans;
import com.sunmi.sunmit2demo.utils.ResourcesUtils;
import java.io.File;
import java.util.List;
public class GoodsAdapter extends RecyclerView.Adapter<GoodsAdapter.ViewHold> {
private List<GvBeans> list;
private GoodsAdapter.OnItemClickListener listener;
private int mFlag;
private int selectPosition = -1;
public GoodsAdapter(List<GvBeans> gvBeans, int flag) {
this.list = gvBeans;
this.mFlag = flag;
}
public GoodsAdapter(List<GvBeans> var1) {
this.list = var1;
}
public void setNewData(List<GvBeans> list) {
this.list = list;
notifyDataSetChanged();
}
public List<GvBeans> getList() {
return list;
}
public int getItemCount() {
return this.list.size();
}
public void onBindViewHolder(final ViewHold hold, final int position) {
if (TextUtils.isEmpty(list.get(position).getImgUrl())) {
hold.ivPhoto.setImageResource(list.get(position).getImgId());
} else {
hold.ivPhoto.setImageBitmap(getDiskBitmap(list.get(position).getImgUrl()));
}
hold.tvName.setText(list.get(position).getName());
hold.tvPrice.setText(list.get(position).getPrice());
switch (mFlag) {
case 1:
hold.tvUnit.setText("/" + ResourcesUtils.getString(R.string.units_tin));
break;
case 2:
hold.tvUnit.setText("/" + ResourcesUtils.getString(R.string.units_kg));
break;
case 3:
hold.tvUnit.setText("/" + ResourcesUtils.getString(R.string.units_bag));
break;
default:
hold.tvUnit.setText("/" + list.get(position).getUnit());
break;
}
if (mFlag == 2) {
if (selectPosition == position) {
hold.ivBorder.setSelected(true);
} else {
hold.ivBorder.setSelected(false);
}
}
if (this.listener != null) {
hold.itemView.setOnClickListener(new View.OnClickListener() {
public void onClick(View var1) {
GoodsAdapter.this.listener.onItemClick(var1, position);
}
});
if (mFlag == 2) {
// hold.ivCar.setOnClickListener(new View.OnClickListener() {
// public void onClick(View var1) {
// if (position == selectPosition) {
// GoodsAdapter.this.listener.onItemCarClick(var1, position);
// }
// }
// });
}
}
}
public void setSelectPosition(int selectPosition) {
this.selectPosition = selectPosition;
}
public ViewHold onCreateViewHolder(ViewGroup var1, int var2) {
return new ViewHold(LayoutInflater.from(var1.getContext()).inflate(R.layout.gv_menus_layout, var1, false)) {
};
}
public void setOnItemClickListener(OnItemClickListener var1) {
this.listener = var1;
}
/**
* 加载本地图片
* http://bbs.3gstdy.com
*
* @param pathString
* @return
*/
private Bitmap getDiskBitmap(String pathString) {
Bitmap bitmap = null;
try {
File file = new File(pathString);
if (file.exists()) {
bitmap = BitmapFactory.decodeFile(pathString);
}
} catch (Exception e) {
// TODO: handle exception
}
return bitmap;
}
public static class OnItemClickListener {
public void onItemClick(View view, int position) {
}
public void onItemCarClick(View view, int position) {
}
}
public static class ViewHold extends RecyclerView.ViewHolder {
public ImageView ivPhoto;
public TextView tvName;
public TextView tvPrice;
public TextView tvUnit;
public ImageView ivCar;
public ImageView ivBorder;
public ViewHold(View itemView) {
super(itemView);
ivPhoto = itemView.findViewById(R.id.iv_photo);
tvName = itemView.findViewById(R.id.tv_name);
tvPrice = itemView.findViewById(R.id.tv_price);
tvUnit = itemView.findViewById(R.id.tv_unit);
ivCar = itemView.findViewById(R.id.iv_car);
ivBorder = itemView.findViewById(R.id.iv_border);
}
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.adapter;
import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.adapter.UnlockAllUserAdapter.UnlockUser;
import de.hdodenhof.circleimageview.CircleImageView;
import java.util.ArrayList;
import java.util.List;
public class LayoutTransitionAdapter {
private static final String TAG = LayoutTransitionAdapter.class.getSimpleName();
private int addChangeCount = 0;
private List<UnlockUser> addIndex = new ArrayList();
private int addTempChange = 0;
public int count = 0;
private long duration = 400L;
private Handler handler = new Handler(Looper.getMainLooper());
private List<UnlockUser> list;
private LayoutTransitionAdapter.OnItemClickListener listener;
private Context mContext;
private LayoutTransitionAdapter.OnAnimationListener onAnimationListener;
private int removeChangeCount = 0;
private List<UnlockUser> removeIndex = new ArrayList();
private int removeTempChange = 0;
private long stagger = 100;
private ViewGroup viewGroup;
public LayoutTransitionAdapter(Context var1, ViewGroup var2, List<UnlockUser> var3) {
this.mContext = var1;
this.viewGroup = var2;
this.list = var3;
}
private void addMore() {
if (this.addTempChange == this.addChangeCount) {
this.addTempChange = 0;
if (this.onAnimationListener != null) {
this.handler.postDelayed(new Runnable() {
public void run() {
onAnimationListener.end(2);
}
}, this.duration);
}
} else {
add(addIndex.get(addTempChange), count);
addTempChange++;
this.handler.postDelayed(new Runnable() {
public void run() {
LayoutTransitionAdapter.this.addMore();
}
}, stagger);
}
}
private void removeMore() {
if (this.removeTempChange == this.removeChangeCount) {
this.removeTempChange = 0;
if (this.onAnimationListener != null) {
this.handler.postDelayed(new Runnable() {
public void run() {
LayoutTransitionAdapter.this.onAnimationListener.end(2);
}
}, this.duration);
}
} else {
this.handler.postDelayed(new Runnable() {
public void run() {
LayoutTransitionAdapter.this.remove((UnlockUser) LayoutTransitionAdapter.this.removeIndex.get(LayoutTransitionAdapter.this.removeTempChange));
removeTempChange++;
LayoutTransitionAdapter.this.removeMore();
}
}, (long) this.stagger);
}
}
public void add(UnlockUser var1, int var2) {
this.list.add(var2, var1);
this.onBindView(var2);
}
public void addAll(List<UnlockUser> var1) {
Log.e(TAG, "transitionListener==addAll== " + var1.size() + " " + this.count);
if (this.onAnimationListener != null) {
this.onAnimationListener.start(2);
}
this.addChangeCount = var1.size();
this.addTempChange = 0;
this.addIndex.clear();
this.addIndex.addAll(var1);
this.addMore();
}
public void clear() {
this.list.clear();
this.addChangeCount = 0;
this.removeChangeCount = 0;
this.count = 0;
this.addTempChange = 0;
this.viewGroup.removeAllViews();
if (this.onAnimationListener != null) {
this.onAnimationListener.end(1);
}
}
public View findViewByPosition(int var1) {
return this.viewGroup.getChildAt(var1);
}
public long getStagger() {
return stagger;
}
public LayoutTransition initTransition(ViewGroup var1) {
LayoutTransition var2 = new LayoutTransition();
var1.setLayoutTransition(var2);
return var2;
}
public void onBindView(final int var1) {
View var2 = this.onCreateView(this.viewGroup);
CircleImageView var3 = (CircleImageView) var2.findViewById(R.id.iv_user);
TextView var4 = (TextView) var2.findViewById(R.id.tv_user_name);
var3.setImageResource(((UnlockUser) this.list.get(var1)).getIcon());
var4.setText(((UnlockUser) this.list.get(var1)).getName());
var2.setTag(this.list.get(var1));
if (this.listener != null) {
var2.setOnClickListener(new OnClickListener() {
public void onClick(View var1x) {
LayoutTransitionAdapter.this.listener.onItemClick(var1x, var1);
}
});
}
this.viewGroup.addView(var2);
++this.count;
}
public View onCreateView(ViewGroup var1) {
View var2 = View.inflate(this.mContext, R.layout.item_unlock_user, (ViewGroup) null);
var2.setScaleX(0.0F);
var2.setScaleY(0.0F);
return var2;
}
public void onRemoveView(int var1) {
if (this.onAnimationListener != null) {
this.onAnimationListener.start(3);
}
if (this.count >= 0 && var1 >= 0 && this.list.size() > 0) {
this.list.remove(var1);
this.viewGroup.removeViewAt(var1);
--this.count;
}
}
public void remove(UnlockUser var1) {
this.onRemoveView(this.list.indexOf(var1));
}
public void removeAll(List<UnlockUser> var1) {
Log.e(TAG, "transitionListener==removeAll== " + this.list.size());
if (this.onAnimationListener != null) {
this.onAnimationListener.start(2);
}
this.removeChangeCount = var1.size();
this.removeIndex.clear();
this.removeIndex.addAll(var1);
this.removeTempChange = 0;
this.remove((UnlockUser) this.removeIndex.get(this.removeTempChange));
++this.removeTempChange;
this.removeMore();
}
public void setDuration(long var1) {
this.duration = var1;
}
public void setOnAnimationListener(LayoutTransitionAdapter.OnAnimationListener var1) {
this.onAnimationListener = var1;
}
public void setOnItemClickListener(LayoutTransitionAdapter.OnItemClickListener var1) {
this.listener = var1;
}
public void setStagger(int var1) {
this.stagger = var1;
}
public void setTransitioner(LayoutTransition var1) {
var1.setDuration(this.duration);
AnimatorSet var2 = new AnimatorSet();
ObjectAnimator var3 = ObjectAnimator.ofFloat((Object) null, "scaleX", new float[]{0.0F, 1.0F});
ObjectAnimator var4 = ObjectAnimator.ofFloat((Object) null, "scaleY", new float[]{0.0F, 1.0F});
var2.play(var3).with(var4);
var1.setAnimator(LayoutTransition.APPEARING, var2);
var2 = new AnimatorSet();
var3 = ObjectAnimator.ofFloat((Object) null, "scaleX", new float[]{1.0F, 0.0F});
var4 = ObjectAnimator.ofFloat((Object) null, "scaleY", new float[]{1.0F, 0.0F});
var2.play(var3).with(var4);
var1.setAnimator(LayoutTransition.DISAPPEARING, var2);
}
public interface OnAnimationListener {
void end(int var1);
void start(int var1);
}
public interface OnItemClickListener {
void onItemClick(View var1, int var2);
}
}
package com.sunmi.sunmit2demo.adapter;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.bean.MenusBean;
import com.sunmi.sunmit2demo.utils.ScreenManager;
import java.util.List;
/**
* Created by highsixty on 2018/3/9.
* mail gaolulin@sunmi.com
*/
public class PresentMenusAdapter extends BaseAdapter {
private Context mContext;
private List<MenusBean> mMenus;
public PresentMenusAdapter(Context context, List<MenusBean> menus) {
this.mContext = context;
this.mMenus = menus;
}
@Override
public int getCount() {
return mMenus == null ? 0 : mMenus.size();
}
@Override
public Object getItem(int position) {
return mMenus == null ? null : mMenus.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHold hold = null;
if (convertView == null) {
hold = new ViewHold();
if (ScreenManager.getInstance().isMinScreen()) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.menus_presentation_min_layout, null);
}else {
convertView = LayoutInflater.from(mContext).inflate(R.layout.menus_presentation_layout, null);
}
hold.tvId = (TextView) convertView.findViewById(R.id.tvId);
hold.tvName = (TextView) convertView.findViewById(R.id.tvName);
hold.tvMoney = (TextView) convertView.findViewById(R.id.tvMoney);
hold.llyBg = (LinearLayout) convertView.findViewById(R.id.lly_bg);
convertView.setTag(hold);
} else {
hold = (ViewHold) convertView.getTag();
}
Log.d("Sunmi", "getView: ------->" + (hold.tvId == null) + " " + (mMenus == null));
hold.tvId.setText(mMenus.get(position).getId());
hold.tvName.setText(mMenus.get(position).getName());
hold.tvMoney.setText(mMenus.get(position).getMoney());
if ((position + 1) % 2 == 0) {
hold.llyBg.setBackgroundColor(Color.parseColor("#F1F5F6"));
} else {
hold.llyBg.setBackgroundColor(Color.parseColor("#FFFFFF"));
}
return convertView;
}
class ViewHold {
private TextView tvId;
private TextView tvName;
private TextView tvMoney;
private LinearLayout llyBg;
}
public void update(List<MenusBean> menus) {
this.mMenus = menus;
notifyDataSetChanged();
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.adapter;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.sunmi.sunmit2demo.R;
import de.hdodenhof.circleimageview.CircleImageView;
import java.util.List;
import java.util.Objects;
public class UnlockAllUserAdapter extends Adapter<ViewHolder> {
private List<UnlockAllUserAdapter.UnlockUser> list;
private UnlockAllUserAdapter.OnItemClickListener listener;
public UnlockAllUserAdapter(List<UnlockAllUserAdapter.UnlockUser> var1) {
this.list = var1;
}
public int getItemCount() {
return this.list.size();
}
public void onBindViewHolder(ViewHolder var1, final int var2) {
CircleImageView var3 = (CircleImageView)var1.itemView.findViewById(R.id.iv_user);
TextView var4 = (TextView)var1.itemView.findViewById(R.id.tv_user_name);
var3.setImageResource(((UnlockAllUserAdapter.UnlockUser)this.list.get(var2)).getIcon());
var4.setText(((UnlockAllUserAdapter.UnlockUser)this.list.get(var2)).getName());
if (this.listener != null) {
var1.itemView.setOnClickListener(new OnClickListener() {
public void onClick(View var1) {
UnlockAllUserAdapter.this.listener.onItemClick(var1, var2);
}
});
}
}
public ViewHolder onCreateViewHolder(ViewGroup var1, int var2) {
return new ViewHolder(LayoutInflater.from(var1.getContext()).inflate(R.layout.item_unlock_alluser, var1, false)) {
};
}
public void setOnItemClickListener(UnlockAllUserAdapter.OnItemClickListener var1) {
this.listener = var1;
}
public interface OnItemClickListener {
void onItemClick(View var1, int var2);
}
public static class UnlockUser {
public int icon;
public String mac;
public String name;
public UnlockUser() {
}
public boolean equals(Object var1) {
if (this != var1) {
if (var1 != null && this.getClass() == var1.getClass()) {
UnlockAllUserAdapter.UnlockUser var2 = (UnlockAllUserAdapter.UnlockUser)var1;
if (this.icon == var2.icon && Objects.equals(this.name, var2.name) && Objects.equals(this.mac, var2.mac)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return true;
}
}
public int getIcon() {
return this.icon;
}
public String getMac() {
return this.mac;
}
public String getName() {
return this.name;
}
public int hashCode() {
return Objects.hash(new Object[]{this.name, this.icon, this.mac});
}
public void setIcon(int var1) {
this.icon = var1;
}
public void setMac(String var1) {
this.mac = var1;
}
public void setName(String var1) {
this.name = var1;
}
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.dialog;
import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.os.Build.VERSION;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnSystemUiVisibilityChangeListener;
import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.dialog.SunmiCheckPwd.SunmiUpdateInterface;
public class ExclusiveModeDialog extends Activity implements SunmiUpdateInterface, OnClickListener {
private LinearLayout mAnimation;
private Button mBT0;
private Button mBT1;
private Button mBT2;
private Button mBT3;
private Button mBT4;
private Button mBT5;
private Button mBT6;
private Button mBT7;
private Button mBT8;
private Button mBT9;
private Button mBTND;
private Button mBack;
private final Handler mHandler = new Handler() {
public void handleMessage(Message var1) {
if (var1 != null && var1.what == 241) {
ExclusiveModeDialog.this.update_pwd_dot(ExclusiveModeDialog.this.mSunmiCheckPwd.getPwdInputNum());
}
}
};
private ImageView mPwdDotA;
private ImageView mPwdDotB;
private ImageView mPwdDotC;
private ImageView mPwdDotD;
private SunmiCheckPwd mSunmiCheckPwd;
CountDownTimer timer = new CountDownTimer(30000L, 1000L) {
public void onFinish() {
ExclusiveModeDialog.this.setResult(0);
ExclusiveModeDialog.this.dismiss();
}
public void onTick(long var1) {
ExclusiveModeDialog.this.tvPwdUnlockTime.setText(var1 / 1000L + "s");
}
};
private TextView tvPwdUnlockTime;
public ExclusiveModeDialog() {
}
private void initView() {
this.mSunmiCheckPwd = new SunmiCheckPwd(this, this);
mBT1 = (Button)findViewById(R.id.m_n1);
mBT1.setOnClickListener(this);
mBT2 = (Button)findViewById(R.id.m_n2);
mBT2.setOnClickListener(this);
mBT3 = (Button)findViewById(R.id.m_n3);
mBT3.setOnClickListener(this);
mBT4 = (Button)findViewById(R.id.m_n4);
mBT4.setOnClickListener(this);
mBT5 = (Button)findViewById(R.id.m_n5);
mBT5.setOnClickListener(this);
mBT6 = (Button)findViewById(R.id.m_n6);
mBT6.setOnClickListener(this);
mBT7 = (Button)findViewById(R.id.m_n7);
mBT7.setOnClickListener(this);
mBT8 = (Button)findViewById(R.id.m_n8);
mBT8.setOnClickListener(this);
mBT9 = (Button)findViewById(R.id.m_n9);
mBT9.setOnClickListener(this);
mBT0 = (Button)findViewById(R.id.m_n0);
mBT0.setOnClickListener(this);
mBTND = (Button)findViewById(R.id.m_nd);
mBTND.setOnClickListener(this);
mBack = (Button)findViewById(R.id.m_back_bt);
mBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
dismiss();
}
});
mPwdDotA = (ImageView)findViewById(R.id.m_pwd_dot_a);
mPwdDotB = (ImageView)findViewById(R.id.m_pwd_dot_b);
mPwdDotC = (ImageView)findViewById(R.id.m_pwd_dot_c);
mPwdDotD = (ImageView)findViewById(R.id.m_pwd_dot_d);
mAnimation = (LinearLayout)findViewById(R.id.m_pwd_dot_line);
((TextView)this.findViewById(R.id.tv_cancel)).setOnClickListener(new OnClickListener() {
public void onClick(View var1) {
ExclusiveModeDialog.this.setResult(0);
ExclusiveModeDialog.this.dismiss();
}
});
this.tvPwdUnlockTime = (TextView)this.findViewById(R.id.tv_pwd_unlock_time);
}
private void update_pwd_dot(int var1) {
switch(var1) {
case 0:
{
mPwdDotA.setBackgroundResource(R.drawable.pwd_dot_empty);
mPwdDotB.setBackgroundResource(R.drawable.pwd_dot_empty);
mPwdDotC.setBackgroundResource(R.drawable.pwd_dot_empty);
mPwdDotD.setBackgroundResource(R.drawable.pwd_dot_empty);
break;
}
case 1:
{
mPwdDotA.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotB.setBackgroundResource(R.drawable.pwd_dot_empty);
mPwdDotC.setBackgroundResource(R.drawable.pwd_dot_empty);
mPwdDotD.setBackgroundResource(R.drawable.pwd_dot_empty);
break;
}
case 2:
{
mPwdDotA.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotB.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotC.setBackgroundResource(R.drawable.pwd_dot_empty);
mPwdDotD.setBackgroundResource(R.drawable.pwd_dot_empty);
break;
}
case 3:
{
mPwdDotA.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotB.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotC.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotD.setBackgroundResource(R.drawable.pwd_dot_empty);
break;
}
case 4: {
mPwdDotA.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotB.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotC.setBackgroundResource(R.drawable.pwd_dot_normal);
mPwdDotD.setBackgroundResource(R.drawable.pwd_dot_normal);
break;
}
default:
}
}
public void dismiss() {
this.timer.cancel();
this.finish();
}
public void hideNavigationBar() {
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE;
try {
this.getWindow().getDecorView().setSystemUiVisibility(uiOptions);
} catch (Exception var3) {
;
}
}
public void onClick(View var1) {
this.mSunmiCheckPwd.onClick(var1);
}
protected void onCreate(@Nullable Bundle var1) {
super.onCreate(var1);
this.getWindow().setFlags(1024, 1024);
this.setContentView(R.layout.exclusive_dialog);
this.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {
public void onSystemUiVisibilityChange(int var1) {
ExclusiveModeDialog.this.hideNavigationBar();
}
});
this.initView();
this.timer.start();
}
public void updatepwd(int var1, int var2) {
this.update_pwd_dot(var1);
if (var2 == 1) {
this.update_pwd_dot(0);
this.setResult(RESULT_OK);
this.dismiss();
} else if (var2 == 2) {
Toast.makeText(this, "密码错误", Toast.LENGTH_SHORT).show();
TranslateAnimation var3 = new TranslateAnimation(20.0F, -20.0F, 0.0F, 0.0F);
var3.setInterpolator(new OvershootInterpolator());
var3.setDuration(20L);
var3.setRepeatCount(5);
var3.setRepeatMode(2);
var3.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation var1) {
ExclusiveModeDialog.this.mHandler.sendEmptyMessageDelayed(241, 300L);
}
public void onAnimationRepeat(Animation var1) {
}
public void onAnimationStart(Animation var1) {
mPwdDotA.setBackgroundResource(R.drawable.pwd_dot_add);
mPwdDotB.setBackgroundResource(R.drawable.pwd_dot_add);
mPwdDotC.setBackgroundResource(R.drawable.pwd_dot_add);
mPwdDotD.setBackgroundResource(R.drawable.pwd_dot_add);
}
});
this.mAnimation.startAnimation(var3);
return;
}
}
}
This diff is collapsed.
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.dialog;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import com.sunmi.sunmit2demo.utils.SharePreferenceUtil;
public class SunmiCheckPwd {
private static final String TAG = "SunmiCheckPwd";
private Context mContext;
private SunmiCheckPwd.SunmiUpdateInterface mSunmiUpdateInterface;
private String mTempPwd = "";
public SunmiCheckPwd(SunmiCheckPwd.SunmiUpdateInterface var1, Context var2) {
this.mSunmiUpdateInterface = var1;
this.mContext = var2;
}
public int getPwdInputNum() {
return this.mTempPwd.length();
}
public void onClick(View view)
{
if(view==null) return;
String tag = (String)view.getTag();
if(tag!=null)
{
switch (tag)
{
case "N1":
{
mTempPwd+="1";
break;
}
case "N2":
{
mTempPwd+="2";
break;
}
case "N3":
{
mTempPwd+="3";
break;
}
case "N4":
{
mTempPwd+="4";
break;
}
case "N5":
{
mTempPwd+="5";
break;
}
case "N6":
{
mTempPwd+="6";
break;
}
case "N7":
{
mTempPwd+="7";
break;
}
case "N8":
{
mTempPwd+="8";
break;
}
case "N9":
{
mTempPwd+="9";
break;
}
case "N0":
{
mTempPwd+="0";
break;
}
case "ND":
{
if(mTempPwd.length()>=1)
{
mTempPwd = mTempPwd.substring(0,mTempPwd.length()-1);
}
break;
}
}
}
if(mTempPwd.length()==4)
{
String pwd = "1111";
try {
pwd = (String)SharePreferenceUtil.getParam(this.mContext, "BLE_PWD_KEY", "1111");
}catch (Exception e){
Log.d(TAG,"Exception e:"+e);
}
if (TextUtils.isEmpty(pwd)){
pwd = "1111";
}
if(mTempPwd.equals(pwd))
{
mSunmiUpdateInterface.updatepwd(mTempPwd.length(),1);
mTempPwd="";
}
else
{
mSunmiUpdateInterface.updatepwd(mTempPwd.length(),2);
mTempPwd="";
}
}
else
{
mSunmiUpdateInterface.updatepwd(mTempPwd.length(),0);
}
//Log.e("ZHANGZEYUAN","=======>mTempPwd="+mTempPwd);
}
public interface SunmiUpdateInterface {
void updatepwd(int var1, int var2);
}
}
package com.sunmi.sunmit2demo.eventbus;
public class InstallSmileEvent {
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.eventbus;
public class UnlockSingValueCalEvent {
private String address;
private int singValue;
public UnlockSingValueCalEvent(int var1, String var2) {
this.singValue = var1;
this.address = var2;
}
public String getAddress() {
return this.address;
}
public int getSingValue() {
return this.singValue;
}
public void setSingValue(int var1) {
this.singValue = var1;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.eventbus;
public class UnlockSuccessEvent {
private String address;
public UnlockSuccessEvent(String var1) {
this.address = var1;
}
public String getAddress() {
return this.address;
}
public void setAddress(String var1) {
this.address = var1;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.eventbus;
public class UpdateUnLockUserEvent {
int icon;
String name;
boolean showAnim;
String user;
public UpdateUnLockUserEvent(String var1, int var2, String var3, boolean var4) {
this.user = var1;
this.icon = var2;
this.name = var3;
this.showAnim = var4;
}
public int getIcon() {
return this.icon;
}
public String getName() {
return this.name;
}
public String getUser() {
return this.user;
}
public boolean isShowAnim() {
return this.showAnim;
}
public void setIcon(int var1) {
this.icon = var1;
}
public void setName(String var1) {
this.name = var1;
}
public void setShowAnim(boolean var1) {
this.showAnim = var1;
}
public void setUser(String var1) {
this.user = var1;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sunmi.sunmit2demo.eventbus;
import android.content.Intent;
public class UpdateUnlockStateEvent {
private Intent intent;
public UpdateUnlockStateEvent(Intent var1) {
this.intent = var1;
}
public Intent getIntent() {
return this.intent;
}
public void setIntent(Intent var1) {
this.intent = var1;
}
}
package com.sunmi.sunmit2demo.fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import com.sunmi.sunmit2demo.BaseFragment;
import com.sunmi.sunmit2demo.ui.MoreActivity;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.utils.SharePreferenceUtil;
public class GoodsManagerFragment extends BaseFragment {
Switch scale, face;
public final static String GOODSMODE_KEY1 = "GOODSMODE_KEY1";
public final static String GOODSMODE_KEY2 = "GOODSMODE_KEY2";
public final static boolean default_KEY1 = true;
public final static boolean default_KEY2 = false;
@Override
protected int setView() {
return R.layout.fragment_goods_setting;
}
@Override
protected void init(View view) {
scale = view.findViewById(R.id.sw_scale);
face = view.findViewById(R.id.sw_face);
boolean isShowDrinks = (boolean) SharePreferenceUtil.getParam(getContext(),
GoodsManagerFragment.GOODSMODE_KEY1, GoodsManagerFragment.default_KEY1);
boolean isShowScaleProduct = (boolean) SharePreferenceUtil.getParam(getContext(),
GoodsManagerFragment.GOODSMODE_KEY2, GoodsManagerFragment.default_KEY2);
face.setChecked(isShowDrinks);
scale.setChecked(isShowScaleProduct);
}
@Override
protected void initData(Bundle savedInstanceState) {
face.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharePreferenceUtil.setParam(getContext(), GOODSMODE_KEY1, isChecked);
}
});
scale.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharePreferenceUtil.setParam(getContext(), GOODSMODE_KEY2, isChecked);
}
});
}
}
package com.sunmi.sunmit2demo.fragment;
import android.os.Bundle;
import android.view.View;
import com.sunmi.sunmit2demo.BaseFragment;
public class HandSettingFragment extends BaseFragment{
@Override
protected int setView() {
return 0;
}
@Override
protected void init(View view) {
}
@Override
protected void initData(Bundle savedInstanceState) {
}
}
package com.sunmi.sunmit2demo.fragment;
import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import com.sunmi.sunmit2demo.BaseFragment;
import com.sunmi.sunmit2demo.MyApplication;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.dialog.PayDialog;
import com.sunmi.sunmit2demo.ui.MainActivity;
import com.sunmi.sunmit2demo.utils.InstallApkUtils;
import com.sunmi.sunmit2demo.utils.SharePreferenceUtil;
import com.sunmi.sunmit2demo.view.CustomDialog;
public class PayModeSettingFragment extends BaseFragment {
Switch face;
private Switch swVipFace;
private Switch swPaymentFace;
private Switch swPaymentReal;
public final static String VIP_PAY_KEY = "VIP_PAY_KEY";
public final static String PAYMENT_PAY_KEY = "PAYMENT_PAY_KEY";
public final static String IS_REAL_DEAL = "IS_REAL_DEAL";
CustomDialog customDialog;
public final static boolean default_SunmiPay = false;
public final static boolean default_isRealDeal = false;//是否真实交易,true表示按 显示金额扣款
@Override
protected int setView() {
return R.layout.fragment_pay_mode_setting;
}
@Override
protected void init(View view) {
swVipFace = view.findViewById(R.id.sw_vip_face);
swPaymentFace = view.findViewById(R.id.sw_payment_face);
swPaymentReal = view.findViewById(R.id.sw_payment_real);
face = view.findViewById(R.id.sw_face);
int payMode = (int) SharePreferenceUtil.getParam(getContext(), PayDialog.PAY_MODE_KEY, 7);
switch (payMode) {
case PayDialog.PAY_FACE:
face.setChecked(true);
break;
case PayDialog.PAY_FACE | PayDialog.PAY_CODE | PayDialog.PAY_CASH:
face.setChecked(false);
break;
}
boolean vip = (boolean) SharePreferenceUtil.getParam(getContext(), PayModeSettingFragment.VIP_PAY_KEY, false);
boolean payment = (boolean) SharePreferenceUtil.getParam(getContext(), PayModeSettingFragment.PAYMENT_PAY_KEY, default_SunmiPay);
boolean isRealDeal = (boolean) SharePreferenceUtil.getParam(getContext(), PayModeSettingFragment.IS_REAL_DEAL, default_isRealDeal);
swVipFace.setChecked(vip);
swPaymentFace.setChecked(payment);
swPaymentReal.setChecked(!isRealDeal);
}
@Override
protected void initData(Bundle savedInstanceState) {
face.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
if (MainActivity.isVertical || MyApplication.getInstance().isHaveCamera()) {
SharePreferenceUtil.setParam(getContext(), PayDialog.PAY_MODE_KEY, PayDialog.PAY_FACE);
}
} else {
if (MainActivity.isVertical) {
SharePreferenceUtil.setParam(getContext(), PayDialog.PAY_MODE_KEY, PayDialog.PAY_FACE | PayDialog.PAY_CODE);
} else {
SharePreferenceUtil.setParam(getContext(), PayDialog.PAY_MODE_KEY, PayDialog.PAY_FACE | PayDialog.PAY_CODE | PayDialog.PAY_CASH);
}
}
}
});
swVipFace.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharePreferenceUtil.setParam(getContext(), PayModeSettingFragment.VIP_PAY_KEY, isChecked);
}
});
swPaymentFace.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (InstallApkUtils.checkApkExist(getContext(), InstallApkUtils.SunmiPayPkgName)) {
SharePreferenceUtil.setParam(getContext(), PayModeSettingFragment.PAYMENT_PAY_KEY, isChecked);
} else {
if (isChecked) {
if (customDialog == null) {
swPaymentFace.setChecked(false);
customDialog = new CustomDialog(getContext());
customDialog.setOnClickListener(tipsListener);
customDialog.show();
TextView tv_content = customDialog.findViewById(R.id.tv_content);
tv_content.setText(R.string.pay_sunmipay_tip);
} else if (!customDialog.isShowing()) {
customDialog.show();
}
swPaymentFace.setChecked(false);
}
}
}
});
swPaymentReal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharePreferenceUtil.setParam(getContext(), PayModeSettingFragment.IS_REAL_DEAL, !isChecked);
}
});
}
private View.OnClickListener tipsListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_cancel:
customDialog.dismiss();
break;
default:
break;
case R.id.tv_confirm:
customDialog.dismiss();
break;
}
}
};
}
package com.sunmi.sunmit2demo.player;
import android.view.SurfaceHolder;
import android.view.View;
/**
* Description:
*/
public interface IMDisplay extends IMPlayListener {
View getDisplayView();
SurfaceHolder getHolder();
}
package com.sunmi.sunmit2demo.player;
/**
* Description:
*/
public interface IMPlayListener {
void onStart(IMPlayer player);
void onPause(IMPlayer player);
void onResume(IMPlayer player);
void onComplete(IMPlayer player);
}
package com.sunmi.sunmit2demo.player;
/**
* Description:
*/
public interface IMPlayer {
/**
* 设置资源
*
* @param url 资源路径
* @throws MPlayerException
*/
void setSource(String url, int position) throws MPlayerException;
/**
* 设置显示视频的载体
*
* @param display 视频播放的载体及相关界面
*/
void setDisplay(IMDisplay display);
/**
* 播放视频
*
* @throws MPlayerException
*/
void play() throws MPlayerException;
/**
* 暂停视频
*/
void pause();
void onPause();
void onResume();
void onDestroy();
}
package com.sunmi.sunmit2demo.player;
import android.media.MediaPlayer;
import android.text.TextUtils;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import java.io.IOException;
/**
* Description:
*/
public class MPlayer implements IMPlayer, MediaPlayer.OnBufferingUpdateListener,
MediaPlayer.OnCompletionListener, MediaPlayer.OnVideoSizeChangedListener,
MediaPlayer.OnPreparedListener, MediaPlayer.OnSeekCompleteListener,
MediaPlayer.OnErrorListener, SurfaceHolder.Callback {
private MediaPlayer player;
private String source;
private IMDisplay display;
private boolean isVideoSizeMeasured = false; //视频宽高是否已获取,且不为0
private boolean isMediaPrepared = false; //视频资源是否准备完成
private boolean isSurfaceCreated = false; //Surface是否被创建
private boolean isResumed = false; //是否在Resume状态
private boolean mIsCrop = false;
private boolean isSeekComplete = false;// 是否定位完成
private IMPlayListener mPlayListener;
private int currentVideoWidth; //当前视频宽度
private int currentVideoHeight; //当前视频高度
private int positon = 0;
/**
* 检查是否需要重新创建资源
*/
private void createPlayerIfNeed() {
if (null == player) {
player = new MediaPlayer();
player.setScreenOnWhilePlaying(true);
player.setOnBufferingUpdateListener(this);
player.setOnVideoSizeChangedListener(this);
player.setOnCompletionListener(this);
player.setOnPreparedListener(this);
player.setOnSeekCompleteListener(this);
player.setOnErrorListener(this);
}
}
/**
* 开始播放
*/
private void playStart() {
if (isVideoSizeMeasured && isMediaPrepared && isSurfaceCreated && isResumed) {
player.setDisplay(display.getHolder());
player.start();
// player.setLooping(true);
display.onStart(this);
if (mPlayListener != null) {
mPlayListener.onStart(this);
}
}
}
/**
* 暂停播放
*/
private void playPause() {
if (player != null && player.isPlaying()) {
player.pause();
display.onPause(this);
if (mPlayListener != null) {
mPlayListener.onPause(this);
}
}
}
/**
* 检测资源是否合法
*
* @return
*/
private boolean checkPlay() {
if (source == null || source.length() == 0) {
return false;
}
return true;
}
public void setPlayListener(IMPlayListener listener) {
this.mPlayListener = listener;
}
/**
* 设置是否裁剪视频,若裁剪,则视频按照DisplayView的父布局大小显示。
* 若不裁剪,视频居中于DisplayView的父布局显示
*
* @param isCrop 是否裁剪视频
*/
public void setCrop(boolean isCrop) {
this.mIsCrop = isCrop;
if (display != null && currentVideoWidth > 0 && currentVideoHeight > 0) {
tryResetSurfaceSize(display.getDisplayView(), currentVideoWidth, currentVideoHeight);
}
}
public boolean isCrop() {
return mIsCrop;
}
/**
* 视频状态
*
* @return 视频是否正在播放
*/
public boolean isPlaying() {
return player != null && player.isPlaying();
}
//根据设置和视频尺寸,调整视频播放区域的大小
private void tryResetSurfaceSize(final View view, int videoWidth, int videoHeight) {
ViewGroup parent = (ViewGroup) view.getParent();
int width = parent.getWidth();
int height = parent.getHeight();
if (width > 0 && height > 0) {
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
if (mIsCrop) {
float scaleVideo = videoWidth / (float) videoHeight;
float scaleSurface = width / (float) height;
if (scaleVideo < scaleSurface) {
params.width = width;
params.height = (int) (width / scaleVideo);
params.setMargins(0, (height - params.height) / 2, 0, (height - params.height) / 2);
} else {
params.height = height;
params.width = (int) (height * scaleVideo);
params.setMargins((width - params.width) / 2, 0, (width - params.width) / 2, 0);
}
} else {
if (videoWidth > width || videoHeight > height) {
float scaleVideo = videoWidth / (float) videoHeight;
float scaleSurface = width / height;
if (scaleVideo > scaleSurface) {
params.width = width;
params.height = (int) (width / scaleVideo);
params.setMargins(0, (height - params.height) / 2, 0, (height - params.height) / 2);
} else {
params.height = height;
params.width = (int) (height * scaleVideo);
params.setMargins((width - params.width) / 2, 0, (width - params.width) / 2, 0);
}
}
}
view.setLayoutParams(params);
}
}
@Override
public void setSource(String url, int position) throws MPlayerException {
this.source = url;
this.positon = position;
if (!checkPlay()) {
throw new MPlayerException("Please setSource");
}
createPlayerIfNeed();
isMediaPrepared = false;
isVideoSizeMeasured = false;
currentVideoWidth = 0;
currentVideoHeight = 0;
player.reset();
try {
player.setDataSource(url);
player.prepareAsync();
} catch (IOException e) {
Log.d("SUNMI", "setSource: ------------->" + e.getMessage());
throw new MPlayerException("set source error", e);
}
}
@Override
public void setDisplay(IMDisplay display) {
if (this.display != null && this.display.getHolder() != null) {
this.display.getHolder().removeCallback(this);
}
this.display = display;
this.display.getHolder().addCallback(this);
}
@Override
public void play() throws MPlayerException {
}
@Override
public void pause() {
playPause();
}
@Override
public void onPause() {
isResumed = false;
playPause();
}
@Override
public void onResume() {
isResumed = true;
playStart();
}
@Override
public void onDestroy() {
if (player != null) {
player.release();
}
}
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
}
@Override
public void onCompletion(MediaPlayer mp) {
display.onComplete(this);
if (mPlayListener != null) {
mPlayListener.onComplete(this);
}
}
@Override
public void onPrepared(MediaPlayer mp) {
Log.d("FILE", "onPrepared: -------------->");
isMediaPrepared = true;
player.seekTo(positon);
}
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
log("视频大小被改变->" + width + "/" + height);
if (width > 0 && height > 0) {
this.currentVideoWidth = width;
this.currentVideoHeight = height;
tryResetSurfaceSize(display.getDisplayView(), width, height);
isVideoSizeMeasured = true;
playStart();
}
}
@Override
public void onSeekComplete(MediaPlayer mp) {
Log.d("FILE", "onSeekComplete: --------->");
isSeekComplete = true;
playStart();
}
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
return false;
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d("GLL", "surfaceCreated: ----------->" + (player != null));
if (display != null && holder == display.getHolder()) {
isSurfaceCreated = true;
if (TextUtils.isEmpty(source)) {
return;
}
try {
setSource(source, positon);
} catch (MPlayerException e) {
e.printStackTrace();
}
log("surface被创建");
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
log("surface大小改变");
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (display != null && holder == display.getHolder()) {
log("surface被销毁");
isSurfaceCreated = false;
positon = player.getCurrentPosition();
player.stop();
player.release();
player = null;
}
}
private void log(String content) {
Log.e("MPlayer", content);
}
public int getPosition() {
if (player != null) {
positon = player.getCurrentPosition();
return positon;
}
return 0;
}
}
package com.sunmi.sunmit2demo.player;
/**
* Description:
*/
public class MPlayerException extends Exception {
public MPlayerException(String detailMessage) {
super(detailMessage);
}
public MPlayerException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public MPlayerException(Throwable throwable) {
super(throwable);
}
}
package com.sunmi.sunmit2demo.player;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
/**
* Description:
*/
public class MinimalDisplay implements IMDisplay {
private SurfaceView surfaceView;
public MinimalDisplay(SurfaceView surfaceView){
this.surfaceView=surfaceView;
}
@Override
public View getDisplayView() {
return surfaceView;
}
@Override
public SurfaceHolder getHolder() {
return surfaceView.getHolder();
}
@Override
public void onStart(IMPlayer player) {
}
@Override
public void onPause(IMPlayer player) {
}
@Override
public void onResume(IMPlayer player) {
}
@Override
public void onComplete(IMPlayer player) {
}
}
package com.sunmi.sunmit2demo.present;
import android.app.Presentation;
import android.content.Context;
import android.graphics.Outline;
import android.graphics.drawable.AnimationDrawable;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.RelativeSizeSpan;
import android.view.Display;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.sunmi.sunmit2demo.BasePresentation;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.dialog.PayDialog;
import com.sunmi.sunmit2demo.ui.MainActivity;
import com.sunmi.sunmit2demo.utils.ResourcesUtils;
import com.sunmi.sunmit2demo.utils.ScreenManager;
import com.sunmi.sunmit2demo.utils.SharePreferenceUtil;
/**
* Created by highsixty on 2018/3/23.
* mail gaolulin@sunmi.com
*/
public class TextDisplay extends BasePresentation {
private LinearLayout root;
private TextView tvTitle;
private TextView tv;
private LinearLayout llPresentChoosePayMode;
private LinearLayout llPresentInfo;
private TextView tvPaySuccess;
private TextView paymodeOne;
private TextView paymodeTwo;
private TextView paymodeThree;
private ImageView ivTitle;
private ProgressBar presentProgress;
private LinearLayout llPresentPayFail;
private TextView presentFailOne;
private TextView presentFailTwo;
private TextView presentFailThree;
public int state;
public TextDisplay(Context outerContext, Display display) {
super(outerContext, display);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (ScreenManager.getInstance().isMinScreen()) {
setContentView(R.layout.vice_text_min_layout);
}else {
setContentView(R.layout.vice_text_layout);
}
root = (LinearLayout) findViewById(R.id.root);
tvTitle = (TextView) findViewById(R.id.tv_title);
tv = (TextView) findViewById(R.id.tv);
llPresentChoosePayMode = (LinearLayout) findViewById(R.id.ll_present_choose_pay_mode);
tvPaySuccess = (TextView) findViewById(R.id.tv_pay_success);
paymodeOne = (TextView) findViewById(R.id.paymode_one);
paymodeTwo = (TextView) findViewById(R.id.paymode_two);
paymodeThree = (TextView) findViewById(R.id.paymode_three);
ivTitle = (ImageView) findViewById(R.id.iv_title);
llPresentInfo = (LinearLayout) findViewById(R.id.ll_present_info);
llPresentPayFail = (LinearLayout) findViewById(R.id.ll_present_pay_fail);
presentFailOne = (TextView) findViewById(R.id.present_fail_one);
presentFailTwo = (TextView) findViewById(R.id.present_fail_two);
presentFailThree = (TextView) findViewById(R.id.present_fail_three);
paymodeOne.setOnClickListener(this);
paymodeTwo.setOnClickListener(this);
paymodeThree.setOnClickListener(this);
presentFailOne.setOnClickListener(this);
presentFailTwo.setOnClickListener(this);
presentFailThree.setOnClickListener(this);
presentProgress = (ProgressBar) findViewById(R.id.present_progress);
root.setClipToOutline(true);
root.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 15);
}
});
}
public void update(String tip) {
update(tip, 0);
}
public void update(String tip, final int state) {
this.state = state;
String unit = ResourcesUtils.getString(R.string.units_money_units);
String[] strings = tip.split(unit);
if(unit.equals("$")){
strings = tip.split("\\$");
}
llPresentPayFail.setVisibility(View.GONE);
presentProgress.setVisibility(View.GONE);
switch (state) {
case 0:
llPresentInfo.setVisibility(View.VISIBLE);
tvPaySuccess.setVisibility(View.GONE);
llPresentChoosePayMode.setVisibility(View.VISIBLE);
root.setBackgroundResource(R.drawable.present_bg_text1);
ivTitle.setImageResource(R.drawable.present_pay_iv1);
setSelect(0);
tvTitle.setText(strings[0].replace(":", ""));
tv.setText(zoomString(unit + strings[1]));
tv.setTextSize(ScreenManager.getInstance().isMinScreen()?136:68);
break;
case 1:
tvPaySuccess.setVisibility(View.VISIBLE);
llPresentChoosePayMode.setVisibility(View.GONE);
root.setBackgroundResource(R.drawable.present_bg_text2);
ivTitle.setImageResource(R.drawable.present_pay_iv2);
tvTitle.setText(strings[0].replace(":", ""));
tvPaySuccess.setText(R.string.pay_thank_you);
tv.setText(zoomString(unit + strings[1]));
tv.setTextSize(ScreenManager.getInstance().isMinScreen()?136:68);
playAnim();
break;
case 2:
llPresentInfo.setVisibility(View.GONE);
root.setBackgroundResource(R.drawable.present_bg_text3);
ivTitle.setImageResource(R.drawable.present_pay_iv3);
tvTitle.setText(ResourcesUtils.getString(R.string.tips_bye_again));
tv.setText(tip);
tv.setTextSize(ScreenManager.getInstance().isMinScreen()?90:45);
break;
case 3:
tvTitle.setText(R.string.pay_paying);
tv.setText(zoomString(tip));
presentProgress.setVisibility(View.VISIBLE);
tvPaySuccess.setVisibility(View.VISIBLE);
llPresentChoosePayMode.setVisibility(View.GONE);
llPresentPayFail.setVisibility(View.GONE);
root.setBackgroundResource(R.drawable.present_bg_text1);
ivTitle.setImageResource(R.drawable.present_pay_iv1);
tvPaySuccess.setText(R.string.pay_paying_wait);
break;
case 4:
tvTitle.setText(R.string.pay_fail);
tv.setText(zoomString(tip));
llPresentInfo.setVisibility(View.VISIBLE);
presentProgress.setVisibility(View.GONE);
tvPaySuccess.setVisibility(View.GONE);
llPresentChoosePayMode.setVisibility(View.GONE);
llPresentPayFail.setVisibility(View.VISIBLE);
setSelect(0);
root.setBackgroundResource(R.drawable.present_bg_text4);
ivTitle.setImageResource(R.drawable.present_pay_iv4);
break;
}
}
private SpannableString zoomString(String strings){
SpannableString ss = new SpannableString(strings);
ss.setSpan(new RelativeSizeSpan(0.65f), 0, 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); // set size
return ss;
}
void playAnim(){
AnimationDrawable animationDrawable = (AnimationDrawable) ivTitle.getDrawable();
animationDrawable.start();
}
public void setSelect(int index) {
paymodeOne.setSelected(index == 0 ? true : false);
paymodeTwo.setSelected(index == 1 ? true : false);
paymodeThree.setSelected(index == 2 ? true : false);
}
@Override
public void show() {
super.show();
int payMode = (int) SharePreferenceUtil.getParam(getContext(), PayDialog.PAY_MODE_KEY, 7);
switch (payMode) {
case PayDialog.PAY_FACE:
paymodeOne.setVisibility(View.GONE);
paymodeTwo.setVisibility(View.GONE);
paymodeThree.setVisibility(View.VISIBLE);
presentFailTwo.setVisibility(View.GONE);
break;
case PayDialog.PAY_CODE |PayDialog.PAY_FACE:
paymodeOne.setVisibility(View.GONE);
paymodeTwo.setVisibility(View.VISIBLE);
paymodeThree.setVisibility(View.VISIBLE);
presentFailTwo.setVisibility(View.VISIBLE);
break;
case PayDialog.PAY_FACE | PayDialog.PAY_CODE | PayDialog.PAY_CASH:
paymodeOne.setVisibility(View.VISIBLE);
paymodeTwo.setVisibility(View.VISIBLE);
paymodeThree.setVisibility(View.VISIBLE);
presentFailTwo.setVisibility(View.VISIBLE);
break;
}
}
@Override
public void onClick(View v) {
super.onClick(v);
switch (v.getId()) {
case R.id.paymode_one:
setSelect(0);
break;
case R.id.paymode_two:
setSelect(1);
break;
case R.id.paymode_three:
setSelect(2);
break;
case R.id.present_fail_one:
break;
case R.id.present_fail_two:
break;
case R.id.present_fail_three:
break;
}
}
@Override
public void onSelect(boolean isShow) {
}
}
package com.sunmi.sunmit2demo.present;
import android.app.Presentation;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Display;
import android.view.SurfaceView;
import android.view.View;
import android.widget.FrameLayout;
import com.sunmi.sunmit2demo.BasePresentation;
import com.sunmi.sunmit2demo.R;
import com.sunmi.sunmit2demo.player.IMPlayListener;
import com.sunmi.sunmit2demo.player.IMPlayer;
import com.sunmi.sunmit2demo.player.MPlayer;
import com.sunmi.sunmit2demo.player.MPlayerException;
import com.sunmi.sunmit2demo.player.MinimalDisplay;
import com.sunmi.sunmit2demo.ui.MainActivity;
import java.io.File;
/**
* Created by highsixty on 2018/3/7.
* mail gaolulin@sunmi.com
*/
public class VideoDisplay extends BasePresentation {
private SurfaceView mPlayerView;
private MPlayer player;
private final String TAG = "SUNMI";
private String path;
private FrameLayout container;
public static int positon = 0;
private Handler myHandle = new Handler(Looper.getMainLooper());
public VideoDisplay(Context context, Display display, String path) {
super(context, display);
this.path = path;
Log.d(TAG, "VideoDisplay: ------------>" + path);
File file = new File(path);
Log.d(TAG, "VideoDisplay: --------->" + file.exists());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vice_video_layout);
mPlayerView = (SurfaceView) findViewById(R.id.mPlayerView);
container = (FrameLayout) findViewById(R.id.playerContainer);
initPlayer();
Log.d(TAG, "onCreate: ------------>" + (player == null));
}
private void initPlayer() {
player = new MPlayer();
player.setDisplay(new MinimalDisplay(mPlayerView));
player.setPlayListener(new IMPlayListener() {
@Override
public void onStart(IMPlayer player) {
}
@Override
public void onPause(IMPlayer player) {
}
@Override
public void onResume(IMPlayer player) {
}
@Override
public void onComplete(IMPlayer player) {
try {
player.setSource(path, 0);
} catch (MPlayerException e) {
e.printStackTrace();
}
}
});
}
@Override
public void onSelect(boolean isShow) {
if(player != null){
if (isShow) {
try {
player.setSource(path, positon);
player.onResume();
} catch (MPlayerException e) {
e.printStackTrace();
myHandle.postDelayed(new Runnable() {
@Override
public void run() {
try {
player.setSource(path, 0);
player.onResume();
} catch (MPlayerException e1) {
e1.printStackTrace();
}
}
}, 3000);
Log.d(TAG, "onCreate: ---------->" + e.getMessage());
}
}else {
if(player.getPosition()!=0)
positon = player.getPosition();
}
}
}
@Override
public void onDisplayRemoved() {
super.onDisplayRemoved();
// player.onDestroy();
}
}
package com.sunmi.sunmit2demo.ui;
import android.content.Context;
import android.os.Environment;
import android.os.storage.StorageManager;
import android.util.Log;
import com.sunmi.sunmit2demo.utils.SharePreferenceUtil;
import java.util.ArrayList;
import java.util.List;
import static com.sunmi.sunmit2demo.ui.BackupTask.COMMAND_BACKUP;
import static com.sunmi.sunmit2demo.ui.BackupTask.COMMAND_RESTORE;
import static com.sunmi.sunmit2demo.ui.BackupTask.isRecover;
/**
* Copyright (C), 2018-2019, 商米科技有限公司
* FileName: BackHelper
*
* @author: liuzhicheng
* Date: 19-5-8
* Description: ${DESCRIPTION}
* History:
*/
public class BackHelper {
public interface OnBackCallBack {
void onSuccess();
void onFail();
}
static String dbPath = "ble_bracelet";
static String savePath = "/sunmiDb/sunmiBackUp";
// 数据恢复
public static void dataRecover(Context context,OnBackCallBack onBackCallBack) {
// TODO Auto-generated method stub
if (!isRecover(context)) {
List<String> list = getUSBPaths(context);
if (!list.isEmpty()) {
new BackupTask(context,onBackCallBack).execute(COMMAND_RESTORE, list.get(0) + "/Android/data/" + context.getPackageName() + savePath, dbPath);
}
}
}
// 数据备份
public static void dataBackup(Context context,OnBackCallBack onBackCallBack) {
// TODO Auto-generated method stub
List<String> list = getUSBPaths(context);
if (!list.isEmpty()) {
new BackupTask(context,onBackCallBack).execute(COMMAND_BACKUP, list.get(0) + "/Android/data/" + context.getPackageName() + savePath, dbPath);
}
}
private static boolean isRecover(Context context) {
return (boolean) SharePreferenceUtil.getParam(context, isRecover, false);
}
public static List<String> getUSBPaths(Context con) {//反射获取路径
String[] paths = null;
List<String> data = new ArrayList();
StorageManager storageManager = (StorageManager) con.getSystemService(Context.STORAGE_SERVICE);
try {
paths = (String[]) StorageManager.class.getMethod("getVolumePaths", null).invoke(storageManager, null);
for (String path : paths) {
String state = (String) StorageManager.class.getMethod("getVolumeState", String.class).invoke(storageManager, path);
if (state.equals(Environment.MEDIA_MOUNTED) && !path.contains("emulated")) {
data.add(path);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment