@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { { if (State == 1) { // 创建退出对话框 AlertDialog isExit = new AlertDialog.Builder(this).create(); // 设置对话框标题 isExit.setTitle("系统提示"); // 设置对话框消息 isExit.setMessage("确定要退出吗"); // 添加选择按钮并注册监听 isExit.setButton("确定", listener); isExit.setButton2("取消", listener); // 显示对话框 isExit.show(); } else if (State == 0) { State = 1; deleteAlarm.setVisibility(View.GONE); adapter.TYPE = 1; adapter.notifyDataSetChanged(); } } return false; } return super.onKeyDown(keyCode, event); }
public void onEvent(GetTvEvent<AppreciatetvList> event) { aList = event.result; // 处理List返回内容 if (aList == null) return; // init frequency List<Appreciatetv> list = aList.getLists(); List<CategoryData> datas = list.get(list.size() - 1).getData(); mFrequencys.clear(); for (CategoryData data : datas) { mFrequencys.add(data.getCategoryurl()); } setViewsVisiable(View.VISIBLE); mProgressBar.setVisibility(View.GONE); mListViewAdapter.updateData(aList.getLists()); Appreciatetv tv = (Appreciatetv) mListViewAdapter.getItem(0); if (tv != null) { mGalleryAdapter.updateData(tv.getData()); mGallery.setSelection(Integer.MAX_VALUE / 2 - 1); } mListView.requestFocus(); }
// TODO // int[] channels = {58437, 77937, 110500, 112937, 58437, 77937, 110500, 58437, 77937, 110500}; @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent == mListView) { // Log.d("shine", "list onItemSelected pos=" + position); Appreciatetv tv = (Appreciatetv) mListViewAdapter.getItem(position); if (tv != null) { mGallery.removeAllViewsInLayout(); mGalleryAdapter.updateData(tv.getData()); mGalleySelectedPosition = Integer.MAX_VALUE / 2 - 1; mGallery.setSelection(mGalleySelectedPosition); mListSelected = position; mListViewAdapter.notifyDataSetChanged(); } } else { CategoryData data = mGalleryAdapter.getItem(position); mGalleySelectedPosition = position; mGalleryAdapter.notifyDataSetChanged(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_landlord_selected_tenant); tenantInfo = (ListView) findViewById(R.id.listViewSelectedTenant); adapter = new ListViewAdapter(this); adapter.addSectionHeaderItem("Contract"); adapter.addItem("Payment Info"); adapter.addItem("Contract Info"); adapter.addSectionHeaderItem("Maintenance"); adapter.addItem("Electricity"); adapter.addItem("Plumbing"); adapter.addItem("Cleaning"); tenantInfo.setAdapter(adapter); // use the extra from intent final String lastname = getIntent().getExtras().getString("tenantLastName"); final String firstname = getIntent().getExtras().getString("tenantFirstName"); getActionBar().setTitle(lastname + " " + firstname); tenantInfo.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View v, int position, long id) { String item = ((TextView) ((LinearLayout) v).getChildAt(0)).getText().toString(); /* if(item.equals("Payment Info") ){ //put extra tenant name Intent intent = new Intent(LandlordSelectedTenantActivity.this, TenantMaintenanceActivity.class); intent.putExtra("tenantLastName", lastname); startActivity(intent); } else if(item.equals("Contract Info")){ //put extra tenant name Intent intent = new Intent(LandlordSelectedTenantActivity.this,.class); intent.putExtra("tenantName", name); startActivity(intent); } else*/ if (position > 3 && position <= 6) { // Maintenance // putextra tenant name and category Intent intent = new Intent(LandlordSelectedTenantActivity.this, TenantMaintenanceActivity.class); intent.putExtra("type", 1); intent.putExtra("tenantLastName", lastname); intent.putExtra("tenantFirstName", firstname); intent.putExtra("maintenance", item); startActivity(intent); } } }); }
/* Load listView using custom listViewAdapter and people ArrayList */ private void loadListView() { ListViewAdapter adapter = new ListViewAdapter(MainActivity.this, android.R.layout.simple_list_item_1, people); adapter.setCustomButtonListener(this); listView.setAdapter(adapter); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1 && resultCode == RESULT_OK) { long TimeInMillis = (long) data.getBundleExtra("data").getSerializable("time"); Time atime = new Time(TimeInMillis); long realTimeInMillis = TimeUtils.changeTime(atime); Repeat RepeatDetail = (Repeat) data.getBundleExtra("data").getSerializable("repeat"); Intent intent = new Intent(MainActivity.this, AlarmReceiver.class); intent.putExtras(data.getBundleExtra("data")); if (clockManage == null) { clockManage = new ClockManage(MainActivity.this); } Log.d("build", clockManage.getClocks().size() + ""); PendingIntent pi = PendingIntent.getBroadcast( MainActivity.this, clockManage.getClocks().size(), intent, PendingIntent.FLAG_UPDATE_CURRENT); // 创建PendingIntent if (RepeatDetail == Repeat.ONLY_ONE) { alarmManager.set(AlarmManager.RTC_WAKEUP, realTimeInMillis, pi); // 设置闹钟 } else if (RepeatDetail == Repeat.EVERY_DAY) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi); } else if (RepeatDetail == Repeat.MON2FIR) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi); } // 刷新界面 adapter.TYPE = 1; adapter.refleshData(); adapter.notifyDataSetChanged(); } if (requestCode == 2 && resultCode == RESULT_OK) { boolean isopen = (boolean) data.getBundleExtra("data").getSerializable("isopen"); if (isopen) { // 是否开启 long TimeInMillis = (long) data.getBundleExtra("data").getSerializable("time"); Time atime = new Time(TimeInMillis); long realTimeInMillis = TimeUtils.changeTime(atime); Repeat RepeatDetail = (Repeat) data.getBundleExtra("data").getSerializable("repeat"); Intent intent = new Intent(MainActivity.this, AlarmReceiver.class); intent.putExtras(data.getBundleExtra("data")); if (clockManage == null) { clockManage = new ClockManage(MainActivity.this); } PendingIntent pi = PendingIntent.getBroadcast( MainActivity.this, clockManage.getClocks().size(), intent, PendingIntent.FLAG_UPDATE_CURRENT); // 创建PendingIntent if (RepeatDetail == Repeat.ONLY_ONE) { alarmManager.set(AlarmManager.RTC_WAKEUP, realTimeInMillis, pi); // 设置闹钟 } else if (RepeatDetail == Repeat.EVERY_DAY) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi); } else if (RepeatDetail == Repeat.MON2FIR) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi); } } // 刷新界面 adapter.TYPE = 1; adapter.refleshData(); adapter.notifyDataSetChanged(); } }