海信PDA兼容
This commit is contained in:
@ -10,6 +10,7 @@ package chaoran.business;
|
|||||||
|
|
||||||
public enum BrandEnum {
|
public enum BrandEnum {
|
||||||
//枚举名即为valueOf()
|
//枚举名即为valueOf()
|
||||||
|
HISENSE("海信", "hisense"),
|
||||||
UROBO("优博讯", "urobo"),
|
UROBO("优博讯", "urobo"),
|
||||||
ROCKCHIP("瑞芯微电子", "rockchip"),
|
ROCKCHIP("瑞芯微电子", "rockchip"),
|
||||||
TEST("测试设备", "test"),
|
TEST("测试设备", "test"),
|
||||||
|
|||||||
@ -92,6 +92,8 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
break;
|
break;
|
||||||
case ZEBRA_TECHNOLOGIES:
|
case ZEBRA_TECHNOLOGIES:
|
||||||
adapter = new ZebraAdapter(this, this);
|
adapter = new ZebraAdapter(this, this);
|
||||||
|
case HISENSE:
|
||||||
|
adapter = new HisenseAdapter(this, this);
|
||||||
}
|
}
|
||||||
if (null != adapter) {
|
if (null != adapter) {
|
||||||
adapter.start();
|
adapter.start();
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
package chaoran.business.adapter;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
|
||||||
|
import chaoran.business.activity.ResultListener;
|
||||||
|
import chaoran.business.strategy.Strategy;
|
||||||
|
|
||||||
|
public class HisenseAdapter implements Adapter {
|
||||||
|
private Context context;
|
||||||
|
private ResultListener resultListener;
|
||||||
|
private Strategy strategy;
|
||||||
|
|
||||||
|
|
||||||
|
public HisenseAdapter(Context context, ResultListener resultListener) {
|
||||||
|
this.context = context;
|
||||||
|
this.resultListener = resultListener;
|
||||||
|
strategy = new Receiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
strategy.executeStrategy(resultListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
strategy.exclusiveStrategy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Receiver extends BroadcastReceiver implements Strategy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
resultListener.result(intent.getStringExtra("msg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeStrategy(ResultListener resultListener) {
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction("chaoran");
|
||||||
|
filter.setPriority(2);
|
||||||
|
context.registerReceiver(this, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exclusiveStrategy() {
|
||||||
|
context.unregisterReceiver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user