@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 友盟统计的crash报告信息 MobclickAgent.setUpdateOnlyWifi(false); MobclickAgent.update(this, 1000 * 60 * 60 * 6); MobclickAgent.onError(this); TheApplication.getInstance().setCurrentActivity(this); setContentView(R.layout.itjiaozi_the_main); mViewFlow = (ViewFlow) findViewById(R.id.viewflow); mViewFlow.setOnViewSwitchListener(this); mHelp = (TextView) findViewById(R.id.help); TaskViewManager.init(this); TaskViewManager.addTaskView("打电话", new TaskViewCall(this, null)); TaskViewManager.addTaskView("发短信", new TaskViewMessage(this, null)); TaskViewManager.addTaskView("打开应用", new TaskViewOpenApp(this, null)); TaskViewManager.addTaskView("网络搜索", new TaskViewWebSearch(this, null)); ContentAdapter ca = new ContentAdapter(); ca.addItemView(View.inflate(this, R.layout.itjiaozi_the_main_view_animator_child_btns, null)); ca.addItemView(TaskViewManager.getManagerView()); mViewFlow.setAdapter(ca); }
public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.ad: MobclickAgent.onEvent(this, Constant.UMENG_CLICK_AD_BTN, "进入全屏广告页面"); startActivity(new Intent(this, AdActivity.class)); // AdMogoLayout adMogoLayoutFull = new AdMogoLayout(this, // "5dc6b75be998489095b532f184072220", AdMogoTargeting.FULLSCREEN_AD); // FrameLayout.LayoutParams paramsFull = new // FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, // FrameLayout.LayoutParams.WRAP_CONTENT); // addContentView(adMogoLayoutFull, paramsFull); break; case R.id.itjiaozi_the_main_view_animator_child_btns_call: MobclickAgent.onEvent(this, Constant.UMENG_WITCH_TO_TASK_CALL, "通过点击"); TaskViewManager.setDisplayTaskView("打电话"); mViewFlow.snapToScreen(1); break; case R.id.itjiaozi_the_main_view_animator_child_btns_message: MobclickAgent.onEvent(this, Constant.UMENG_SWITCH_TO_TASK_MESSAGE, "通过点击"); TaskViewManager.setDisplayTaskView("发短信"); mViewFlow.snapToScreen(1); break; case R.id.itjiaozi_the_main_view_animator_child_btns_openapp: MobclickAgent.onEvent(this, Constant.UMENG_SWITCH_TO_TASK_OPENAPP, "通过点击"); TaskViewManager.setDisplayTaskView("打开应用"); mViewFlow.snapToScreen(1); break; case R.id.itjiaozi_the_main_view_animator_child_btns_websearch: MobclickAgent.onEvent(this, Constant.UMENG_SWITCH_TO_TASK_WEBSEARCH, "通过点击"); TaskViewManager.setDisplayTaskView("网络搜索"); mViewFlow.snapToScreen(1); break; case R.id.speekButton: if (mViewFlow.getSelectedItemPosition() > 0) { TaskViewManager.performSpeechClick((Button) v); } else { IFlySpeechUtil.startRecoginze( ETheAiType.All, new IRecoginzeResult() { @Override public void onCallback(SpeechError error, int confidence, String result) { if (null != error) { ToastUtil.showToast("无法识别命令"); } else { boolean needOpenTaskScreen = TaskViewManager.executeTask(error, confidence, result); if (needOpenTaskScreen) { mViewFlow.snapToScreen(1); } } } }); } break; default: break; } }
@Override public void finish() { TaskViewManager.unInit(); TheApplication.getInstance().setCurrentActivity(null); super.finish(); }