This shows you the differences between two versions of the page.
eim:colocvii:colocviu01 [2020/03/29 20:10] andrei.bolojan [Rezolvări] |
eim:colocvii:colocviu01 [2020/03/29 20:33] (current) andrei.bolojan |
||
---|---|---|---|
Line 314: | Line 314: | ||
setContentView(R.layout.activity_practical_test01_main); | setContentView(R.layout.activity_practical_test01_main); | ||
- | leftEditText = (EditText)findViewById(R.id.left_edit_text); | + | leftEditText = (EditText)findViewById(R.id.left_edit_text); |
- | rightEditText = (EditText)findViewById(R.id.right_edit_text); | + | rightEditText = (EditText)findViewById(R.id.right_edit_text); |
- | pressMeButton = (Button)findViewById(R.id.press_me_button); | + | pressMeButton = (Button)findViewById(R.id.press_me_button); |
- | pressMeTooButton = (Button)findViewById(R.id.press_me_too_button); | + | pressMeTooButton = (Button)findViewById(R.id.press_me_too_button); |
leftEditText.setText(String.valueOf(0)); | leftEditText.setText(String.valueOf(0)); | ||
Line 354: | Line 354: | ||
break; | break; | ||
case R.id.press_me_too_button: | case R.id.press_me_too_button: | ||
- | rightNumberOfClicks++; | + | rightNumberOfClicks++; |
- | rightEditText.setText(String.valueOf(rightNumberOfClicks)); | + | rightEditText.setText(String.valueOf(rightNumberOfClicks)); |
- | break; | + | break; |
} | } | ||
} | } | ||
Line 421: | Line 421: | ||
if (savedInstanceState != null) { | if (savedInstanceState != null) { | ||
- | if (savedInstanceState.containsKey(Constants.LEFT_COUNT)) { | + | if (savedInstanceState.containsKey(Constants.LEFT_COUNT)) { |
- | leftEditText.setText(savedInstanceState.getString(Constants.LEFT_COUNT)); | + | leftEditText.setText(savedInstanceState.getString(Constants.LEFT_COUNT)); |
- | } else { | + | } else { |
- | leftEditText.setText(String.valueOf(0)); | + | |
- | } | + | |
- | if (savedInstanceState.containsKey(Constants.RIGHT_COUNT)) { | + | |
- | rightEditText.setText(savedInstanceState.getString(Constants.RIGHT_COUNT)); | + | |
- | } else { | + | |
- | rightEditText.setText(String.valueOf(0)); | + | |
- | } | + | |
- | } else { | + | |
leftEditText.setText(String.valueOf(0)); | leftEditText.setText(String.valueOf(0)); | ||
+ | } | ||
+ | if (savedInstanceState.containsKey(Constants.RIGHT_COUNT)) { | ||
+ | rightEditText.setText(savedInstanceState.getString(Constants.RIGHT_COUNT)); | ||
+ | } else { | ||
rightEditText.setText(String.valueOf(0)); | rightEditText.setText(String.valueOf(0)); | ||
+ | } | ||
+ | } else { | ||
+ | leftEditText.setText(String.valueOf(0)); | ||
+ | rightEditText.setText(String.valueOf(0)); | ||
} | } | ||
} | } | ||
Line 446: | Line 446: | ||
protected void onRestoreInstanceState(Bundle savedInstanceState) { | protected void onRestoreInstanceState(Bundle savedInstanceState) { | ||
if (savedInstanceState.containsKey(Constants.LEFT_COUNT)) { | if (savedInstanceState.containsKey(Constants.LEFT_COUNT)) { | ||
- | leftEditText.setText(savedInstanceState.getString(Constants.LEFT_COUNT)); | + | leftEditText.setText(savedInstanceState.getString(Constants.LEFT_COUNT)); |
} else { | } else { | ||
- | leftEditText.setText(String.valueOf(0)); | + | leftEditText.setText(String.valueOf(0)); |
} | } | ||
if (savedInstanceState.containsKey(Constants.RIGHT_COUNT)) { | if (savedInstanceState.containsKey(Constants.RIGHT_COUNT)) { | ||
- | rightEditText.setText(savedInstanceState.getString(Constants.RIGHT_COUNT)); | + | rightEditText.setText(savedInstanceState.getString(Constants.RIGHT_COUNT)); |
} else { | } else { | ||
- | rightEditText.setText(String.valueOf(0)); | + | rightEditText.setText(String.valueOf(0)); |
} | } | ||
} | } | ||
Line 491: | Line 491: | ||
<manifest ... > | <manifest ... > | ||
<application ... > | <application ... > | ||
- | <activity | + | <activity android:name=".view.PracticalTest01SecondaryActivity"> |
- | android:name=".PracticalTest01SecondaryActivity" | + | |
- | android:label="@string/title_activity_practical_test01_secondary" > | + | |
<intent-filter> | <intent-filter> | ||
- | <action android:name="ro.pub.cs.systems.eim.intent.action.PracticalTest01SecondaryActivity" /> | + | <action android:name="ro.pub.cs.systems.eim.practicaltest01.intent.action.PracticalTest01SecondaryActivity" /> |
<category android:name="android.intent.category.DEFAULT" /> | <category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | </intent-filter> | ||
Line 571: | Line 569: | ||
private ButtonClickListener buttonClickListener = new ButtonClickListener(); | private ButtonClickListener buttonClickListener = new ButtonClickListener(); | ||
private class ButtonClickListener implements View.OnClickListener { | private class ButtonClickListener implements View.OnClickListener { | ||
- | @Override | + | @Override |
- | public void onClick(View view) { | + | public void onClick(View view) { |
- | switch (view.getId()) { | + | switch (view.getId()) { |
- | case R.id.ok_button: | + | case R.id.ok_button: |
- | setResult(RESULT_OK, null); | + | setResult(RESULT_OK, null); |
- | break; | + | break; |
- | case R.id.cancel_button: | + | case R.id.cancel_button: |
- | setResult(RESULT_CANCELED, null); | + | setResult(RESULT_CANCELED, null); |
- | break; | + | break; |
- | } | + | } |
- | finish(); | + | finish(); |
} | } | ||
} | } | ||
Line 587: | Line 585: | ||
@Override | @Override | ||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||
- | super.onCreate(savedInstanceState); | + | super.onCreate(savedInstanceState); |
- | setContentView(R.layout.activity_practical_test01_secondary); | + | setContentView(R.layout.activity_practical_test01_secondary); |
- | numberOfClicksTextView = (TextView)findViewById(R.id.number_of_clicks_text_view); | + | numberOfClicksTextView = (TextView)findViewById(R.id.number_of_clicks_text_view); |
- | Intent intent = getIntent(); | + | Intent intent = getIntent(); |
- | if (intent != null && intent.getExtras().containsKey(Constants.NUMBER_OF_CLICKS)) { | + | if (intent != null && intent.getExtras().containsKey(Constants.NUMBER_OF_CLICKS)) { |
- | int numberOfClicks = intent.getIntExtra(Constants.NUMBER_OF_CLICKS, -1); | + | int numberOfClicks = intent.getIntExtra(Constants.NUMBER_OF_CLICKS, -1); |
- | numberOfClicksTextView.setText(String.valueOf(numberOfClicks)); | + | numberOfClicksTextView.setText(String.valueOf(numberOfClicks)); |
- | } | + | } |
- | okButton = (Button)findViewById(R.id.ok_button); | + | okButton = (Button)findViewById(R.id.ok_button); |
- | okButton.setOnClickListener(buttonClickListener); | + | okButton.setOnClickListener(buttonClickListener); |
- | cancelButton = (Button)findViewById(R.id.cancel_button); | + | cancelButton = (Button)findViewById(R.id.cancel_button); |
- | cancelButton.setOnClickListener(buttonClickListener); | + | cancelButton.setOnClickListener(buttonClickListener); |
} | } | ||
} | } | ||
Line 679: | Line 677: | ||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { | protected void onActivityResult(int requestCode, int resultCode, Intent intent) { | ||
if (requestCode == Constants.SECONDARY_ACTIVITY_REQUEST_CODE) { | if (requestCode == Constants.SECONDARY_ACTIVITY_REQUEST_CODE) { | ||
- | Toast.makeText(this, "The activity returned with result " + resultCode, Toast.LENGTH_LONG).show(); | + | Toast.makeText(this, "The activity returned with result " + resultCode, Toast.LENGTH_LONG).show(); |
} | } | ||
} | } | ||
Line 700: | Line 698: | ||
<application ...> | <application ...> | ||
<!-- other components --> | <!-- other components --> | ||
- | <service | + | <service |
- | android:name="ro.pub.cs.systems.eim.PracticalTest01Service" | + | android:name=".service.PracticalTest01Service" |
android:enabled="true" | android:enabled="true" | ||
android:exported="false" /> | android:exported="false" /> |