@Override public void onClick(View view) { switch (view.getId()) { case R.id.shop_top_right: ProgressRing.onProgeress(MainActivity.this, "智点", "正在定位..."); if (helper != null) { helper.InitGPS(); } break; case R.id.nouser_login: go2SignalActivity(SetLoginActivity.class); break; case R.id.nouser_register: go2SignalActivity(RegisterActivity.class); break; case R.id.headIcom: // TODO 判断是否登录 // 已登录 takePhoto(); // 未登录 go2SignalActivity(SetLoginActivity.class); break; case R.id.user_edit: // 修改个人信息 go2SignalActivity(PersonInfoActivity.class); break; } }
// 定位之后显示页面内容 private void initLayout() { // 初始化广告栏显示 lltopView = (LinearLayout) findViewById(R.id.lltopView); lltopView.removeAllViews(); // 界面显示 mdrawer = (SlidingDrawer) findViewById(R.id.slidingdrawer); center = (TextView) findViewById(R.id.high_rise); AdvertiseLayout(); // 当前地址 String localpos = EatParams.getInstance().getGpsAddr(); if (localpos == null || localpos.length() <= 0) { localpos = "未获取到您的位置"; } center.setText(localpos); // 抽屉组件 ListView sligv = (ListView) findViewById(R.id.SlidListView); sliAdapter = new SliListViewAdapter(MainActivity.this, helper.getApplyList()); sligv.setAdapter(sliAdapter); sligv.setOnItemClickListener(itemClickListener); // 切换位置 Button changCity = (Button) findViewById(R.id.shop_top_right); changCity.setOnClickListener(clickListener); drawerlistener(); // 抽屉响应事件 dataLoad = new DataLoading(); mScrollLayout = (ScrollLayout) findViewById(R.id.ScrollLayoutTest); initial(); }
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { Intent intent = new Intent(); if (helper.getApplyList().get(position).getLink().equals("ShareEatActivity")) { ProgressRing.onProgeress(MainActivity.this, "提示", "正在加载手机好友,请稍候....", 4000); } int lknum = Integer.valueOf(helper.getApplyList().get(position).getLknum()); helper.getApplyList().get(position).setLknum("" + (lknum + 1)); intent.setClassName( MainActivity.this, "com.gae.eat2013." + helper.getApplyList().get(position).getLink()); MainActivity.this.startActivity(intent); MainActivity.this.finish(); Toast.makeText( MainActivity.this, "跳转到" + helper.getApplyList().get(position).getLink(), Toast.LENGTH_SHORT) .show(); }
// 添加桌面应用 public void creatAddApply() { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.apply_adddialog, null); Button dele = (Button) layout.findViewById(R.id.dele); ListView dialoglist = (ListView) layout.findViewById(R.id.dialogListView); final SliListViewAdapter Adapter = new SliListViewAdapter(MainActivity.this, helper.getApplyList()); dialoglist.setAdapter(Adapter); dialoglist.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { helper.updatePlugin(arg2); Toast.makeText( MainActivity.this, "添加" + helper.getApplyList().get(arg2).getName(), Toast.LENGTH_SHORT) .show(); applyDialog.dismiss(); Intent intent = new Intent(); intent.setClass(MainActivity.this, MainActivity.class); // 刷新界面 startActivity(intent); finish(); } }); dele.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { applyDialog.dismiss(); } }); applyDialog = new Dialog(this); applyDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); applyDialog.setContentView(layout); applyDialog.show(); }
@Override protected void onDestroy() { helper.removeGPSListener(); super.onDestroy(); }
// 统计应用访问次数 private void appVisitNumChange(String appname) { if (helper != null) { helper.appVisitNumChange(appname); } }
// 创建app滑动页 private GridView createAppFragment(Context mContext, int i) { GridView appPage = new GridView(mContext); // get the "i" page data gridAdapter = new MainGridViewAdapter(mContext, helper.getApplygList(), i); appPage.setAdapter(gridAdapter); appPage.setNumColumns(3); // 每列的应用个数 appPage.setGravity(Gravity.CENTER); appPage.setPadding(0, 20, 0, 0); appPage.setHorizontalSpacing(10); appPage.setVerticalSpacing(30); appPage.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int num = mScrollLayout.getCurScreen(); // 第几页 int longdk = helper.getApplygList().size(); if (num * APP_PAGE_SIZE + arg2 == helper.getApplygList().size() - 1) { // 最后一个应用 Toast.makeText(MainActivity.this, "添加应用", Toast.LENGTH_SHORT).show(); creatAddApply(); } else { Intent intent = new Intent(); if (helper .getApplygList() .get((int) (num * APP_PAGE_SIZE + arg2)) .getLink() .equals("ShareEatActivity")) { ProgressRing.onProgeress(MainActivity.this, "提示", "正在加载手机好友,请稍候....", 4000); } String applink = helper.getApplygList().get((int) (num * APP_PAGE_SIZE + arg2)).getLink(); appVisitNumChange(applink); intent.setClassName(MainActivity.this, "com.gae.eat2013." + applink); MainActivity.this.startActivity(intent); } } }); appPage.setOnItemLongClickListener( new OnItemLongClickListener() { // 长按删除应用 @Override public boolean onItemLongClick( AdapterView<?> arg0, View arg1, final int arg2, long arg3) { final int num = mScrollLayout.getCurScreen(); // 第几页 if (num * APP_PAGE_SIZE + arg2 != helper.getApplygList().size() - 1) { AlertDialog.Builder built = new AlertDialog.Builder(MainActivity.this); built.setTitle("提示"); built.setMessage( "您确定要删除《" + helper.getApplygList().get((int) (num * APP_PAGE_SIZE + arg2)).getName() + "》桌面应用"); built.setNeutralButton( "确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { helper.deletePlugin((int) (num * APP_PAGE_SIZE + arg2)); finish(); dialog.dismiss(); } }); built.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); Dialog dialog = built.create(); dialog.show(); } return false; } }); return appPage; }
private void getAllApply() { if (helper != null) { helper.getAllApply(); } }
private void setLocation() { if (helper != null) { helper.setLocation(); } }