18739b58f7860d8d03916b9a529d1fd5950937626Adam Powell/* 28739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * Copyright (C) 2012 The Android Open Source Project 38739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * 48739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 58739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * you may not use this file except in compliance with the License. 68739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * You may obtain a copy of the License at 78739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * 88739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * http://www.apache.org/licenses/LICENSE-2.0 98739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * 108739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * Unless required by applicable law or agreed to in writing, software 118739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * distributed under the License is distributed on an "AS IS" BASIS, 128739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * See the License for the specific language governing permissions and 148739b58f7860d8d03916b9a529d1fd5950937626Adam Powell * limitations under the License. 158739b58f7860d8d03916b9a529d1fd5950937626Adam Powell */ 168739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 178739b58f7860d8d03916b9a529d1fd5950937626Adam Powellpackage com.example.android.support.appnavigation.app; 188739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 198739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport com.example.android.support.appnavigation.R; 208739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 218739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.app.ActionBar; 228739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.app.Activity; 238739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.content.Intent; 248739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.os.Bundle; 258739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.support.v4.app.NavUtils; 268739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.view.MenuItem; 278739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.view.View; 288739b58f7860d8d03916b9a529d1fd5950937626Adam Powellimport android.widget.TextView; 298739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 308739b58f7860d8d03916b9a529d1fd5950937626Adam Powellpublic class PeerActivity extends Activity { 318739b58f7860d8d03916b9a529d1fd5950937626Adam Powell private static final String EXTRA_PEER_COUNT = 328739b58f7860d8d03916b9a529d1fd5950937626Adam Powell "com.example.android.appnavigation.EXTRA_PEER_COUNT"; 338739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 348739b58f7860d8d03916b9a529d1fd5950937626Adam Powell private int mPeerCount; 358739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 368739b58f7860d8d03916b9a529d1fd5950937626Adam Powell @Override 378739b58f7860d8d03916b9a529d1fd5950937626Adam Powell protected void onCreate(Bundle savedInstanceState) { 388739b58f7860d8d03916b9a529d1fd5950937626Adam Powell super.onCreate(savedInstanceState); 398739b58f7860d8d03916b9a529d1fd5950937626Adam Powell setContentView(R.layout.peer); 408739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 418739b58f7860d8d03916b9a529d1fd5950937626Adam Powell ActionBarCompat.setDisplayHomeAsUpEnabled(this, true); 428739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 438739b58f7860d8d03916b9a529d1fd5950937626Adam Powell mPeerCount = getIntent().getIntExtra(EXTRA_PEER_COUNT, 0) + 1; 44fa2e2acf79d791a90410025daad438968550d18cAlan Viverette TextView tv = findViewById(R.id.peer_counter); 458739b58f7860d8d03916b9a529d1fd5950937626Adam Powell tv.setText(getResources().getText(R.string.peer_count).toString() + mPeerCount); 468739b58f7860d8d03916b9a529d1fd5950937626Adam Powell } 478739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 488739b58f7860d8d03916b9a529d1fd5950937626Adam Powell @Override 498739b58f7860d8d03916b9a529d1fd5950937626Adam Powell public boolean onOptionsItemSelected(MenuItem item) { 508739b58f7860d8d03916b9a529d1fd5950937626Adam Powell if (item.getItemId() == android.R.id.home) { 518739b58f7860d8d03916b9a529d1fd5950937626Adam Powell NavUtils.navigateUpFromSameTask(this); 528739b58f7860d8d03916b9a529d1fd5950937626Adam Powell return true; 538739b58f7860d8d03916b9a529d1fd5950937626Adam Powell } 548739b58f7860d8d03916b9a529d1fd5950937626Adam Powell return super.onOptionsItemSelected(item); 558739b58f7860d8d03916b9a529d1fd5950937626Adam Powell } 568739b58f7860d8d03916b9a529d1fd5950937626Adam Powell 578739b58f7860d8d03916b9a529d1fd5950937626Adam Powell public void onLaunchPeer(View v) { 588739b58f7860d8d03916b9a529d1fd5950937626Adam Powell Intent target = new Intent(this, PeerActivity.class); 598739b58f7860d8d03916b9a529d1fd5950937626Adam Powell target.putExtra(EXTRA_PEER_COUNT, mPeerCount); 608739b58f7860d8d03916b9a529d1fd5950937626Adam Powell startActivity(target); 618739b58f7860d8d03916b9a529d1fd5950937626Adam Powell } 628739b58f7860d8d03916b9a529d1fd5950937626Adam Powell} 63