Currently I build learning app for children. This app learn alphabet from "A" to "Z". If click the next button the alphabet will switch from A to B, B to C, and etc. But, I want if "A" the previous button (ImageButton) will be hide and if "Z" the next button will be hide.
public class ScrBelajarHuruf extends AppCompatActivity implements View.OnClickListener {
TextView txtHuruf;
ImageButton btnAudioHuruf, btnNextHuruf, btnPreviousHuruf;
MediaPlayer mediaPlayer;
int counterHurufList;
int counter = 0;
int counterAudioHurufList;
int[] stringHurufList = {
R.string.huruf_a,
R.string.huruf_b,
R.string.huruf_c,
R.string.huruf_d,
R.string.huruf_e,
R.string.huruf_f,
R.string.huruf_g,
R.string.huruf_h,
R.string.huruf_i,
R.string.huruf_j,
R.string.huruf_k,
R.string.huruf_l,
R.string.huruf_m,
R.string.huruf_n,
R.string.huruf_o,
R.string.huruf_p,
R.string.huruf_q,
R.string.huruf_r,
R.string.huruf_s,
R.string.huruf_t,
R.string.huruf_u,
R.string.huruf_v,
R.string.huruf_w,
R.string.huruf_x,
R.string.huruf_y,
R.string.huruf_z,
};
int[] rawAudioHurufList = {
R.raw.a,
R.raw.b,
R.raw.c,
R.raw.d,
R.raw.e,
R.raw.f,
R.raw.g,
R.raw.h,
R.raw.i,
R.raw.j,
R.raw.k,
R.raw.l,
R.raw.m,
R.raw.n,
R.raw.o,
R.raw.p,
R.raw.q,
R.raw.r,
R.raw.s,
R.raw.t,
R.raw.u,
R.raw.v,
R.raw.w,
R.raw.x,
R.raw.y,
R.raw.z,
};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scr_belajar_huruf);
txtHuruf = findViewById(R.id.txtHuruf);
btnAudioHuruf = findViewById(R.id.btnAudioHuruf);
btnNextHuruf = findViewById(R.id.btnNextHuruf);
btnPreviousHuruf = findViewById(R.id.btnPreviousHuruf);
btnAudioHuruf.setOnClickListener(this);
btnNextHuruf.setOnClickListener(this);
btnPreviousHuruf.setOnClickListener(this);
mediaPlayer = MediaPlayer.create(this, R.raw.a);
mediaPlayer.start();
if(counterHurufList == 0) {
btnPreviousHuruf.setVisibility(View.INVISIBLE);
}
}
public void onClick(View view) {
int id = view.getId();
if(id == R.id.btnNextHuruf && counterHurufList < stringHurufList.length - 1 && counterAudioHurufList < rawAudioHurufList.length - 1) {
mediaPlayer.stop();
counterHurufList++;
counterAudioHurufList++;
} else if (id == R.id.btnPreviousHuruf && counterHurufList > 0 && counterAudioHurufList > 0) {
mediaPlayer.stop();
counterHurufList--;
counterAudioHurufList--;
}
txtHuruf.setText(stringHurufList[counterHurufList]);
mediaPlayer = MediaPlayer.create(this, rawAudioHurufList[counterAudioHurufList]);
mediaPlayer.start();
}
}
I tried with
if(counterHurufList == 0) {
btnPreviousHuruf.setVisibility(View.INVISIBLE);
}
But give the previous button hide from "A" to "Z"
Haven't run this code so hopefully it works, but here are my thoughts from what you've shown:
You only perform the check to hide the button in onCreate, so it'll only do it once when the activity is created
You only hide the go back button
You only hide the button, and don't try to make it visible again
In your onCreate method, remove the check
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scr_belajar_huruf);
txtHuruf = findViewById(R.id.txtHuruf);
btnAudioHuruf = findViewById(R.id.btnAudioHuruf);
btnNextHuruf = findViewById(R.id.btnNextHuruf);
btnPreviousHuruf = findViewById(R.id.btnPreviousHuruf);
btnAudioHuruf.setOnClickListener(this);
btnNextHuruf.setOnClickListener(this);
btnPreviousHuruf.setOnClickListener(this);
mediaPlayer = MediaPlayer.create(this, R.raw.a);
mediaPlayer.start();
}
And in your onClick method, make sure you address all the points I mentioned above:
public void onClick(View view) {
int id = view.getId();
if(id == R.id.btnNextHuruf && counterHurufList < stringHurufList.length - 1 && counterAudioHurufList < rawAudioHurufList.length - 1) {
mediaPlayer.stop();
counterHurufList++;
counterAudioHurufList++;
} else if (id == R.id.btnPreviousHuruf && counterHurufList > 0 && counterAudioHurufList > 0) {
mediaPlayer.stop();
counterHurufList--;
counterAudioHurufList--;
}
txtHuruf.setText(stringHurufList[counterHurufList]);
mediaPlayer = MediaPlayer.create(this, rawAudioHurufList[counterAudioHurufList]);
mediaPlayer.start();
// New parts
btnPreviousHuruf.setVisibility(View.VISIBLE);
btnNextHuruf.setVisibility(View.VISIBLE);
if (counterHurufList == 0)
btnPreviousHuruf.setVisibility(View.INVISIBLE);
if (counterHurufList == 25)
btnNextHuruf.setVisibility(View.INVISIBLE);
}
Obviously modify however you like, but ensure that you meet the three criteria :)
switch (stringHurufList[counterHurufList]) {
case "A":
btnPreviousHuruf.setVisibility(View.INVISIBLE);
break;
case "Z":
btnNextHuruf.setVisibility(View.INVISIBLE);
break;
default:
btnPreviousHuruf.setVisibility(View.VISIBLE);
btnNextHuruf.setVisibility(View.VISIBLE);
}
But give the previous button hide from "A" to "Z"
Its because you forgot to return btn visibility to VISIBLE.
Declare an instance variable let's say int currentPosition = 0;. First time make previous button invisible prevBtn.setVisibility(View.INVISIBLE); Use this single position for both next and previous functionality. Like:
public void onClick(View view) {
int id = view.getId();
if(id == R.id.btnNextHuruf) {
currentPosition++;
prevBtn.setVisibility(View.VISIBLE);
if (currentPosition == 25){
nextBtn.setVisibility(View.INVISIBLE);
mediaPlayer.stop();
}
//counterHurufList++;
//counterAudioHurufList++;
} else if (id == R.id.btnPreviousHuruf) {
currentPosition--;
nextBtn.setVisibility(View.VISIBLE);
if (currentPosition == 0){
prevBtn.setVisibility(View.INVISIBLE);
mediaPlayer.stop();
}
}
txtHuruf.setText(stringHurufList[currentPosition]);
mediaPlayer = MediaPlayer.create(this, rawAudioHurufList[currentPosition]);
mediaPlayer.start();
}
Related
i'm trying to compile 4 integers from 4 different activities. the first activity is one of the 4 integer. the second activity is where i compile them.. I don't know what's the best way to send a value from different activites. Most of the intent methods i saw uses startActivity but still won't work.
public class QuizSecond extends AppCompatActivity implements View.OnClickListener{
TextView totalQuestionsTextView2;
TextView questionTextView2;
Button ansA2, ansB2, ansC2, ansD2;
Button submitBtn2;
int score= 0;
int totalQuestion2 = QuestionAnswer2.question2.length;
int currentQuestionIndex2 = 0;
String selectedAnswer2 = "";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_second);
totalQuestionsTextView2 = findViewById(R.id.total_question2);
questionTextView2 = findViewById(R.id.question_preview);
ansA2 = findViewById(R.id.ans_A2);
ansB2 = findViewById(R.id.ans_B2);
ansC2 = findViewById(R.id.ans_C2);
ansD2 = findViewById(R.id.ans_D2);
submitBtn2 = findViewById(R.id.submit_btn2);
ansA2.setOnClickListener(this);
ansB2.setOnClickListener(this);
ansC2.setOnClickListener(this);
ansD2.setOnClickListener(this);
submitBtn2.setOnClickListener(this);
totalQuestionsTextView2.setText("Total questions : "+totalQuestion2);
loadNewQuestion();
}
#Override
public void onClick(View view) {
ansA2.setBackgroundColor(Color.WHITE);
ansB2.setBackgroundColor(Color.WHITE);
ansC2.setBackgroundColor(Color.WHITE);
ansD2.setBackgroundColor(Color.WHITE);
Button clickedButton = (Button) view;
if(clickedButton.getId()==R.id.submit_btn2){
if(selectedAnswer2.equals(QuestionAnswer2.correctAnswers2[currentQuestionIndex2])) {
score++;
}
currentQuestionIndex2++;
loadNewQuestion();
Intent quizIntent = new Intent(QuizSecond.this,ComputeActivity.class);
quizIntent.putExtra("EXTRA_NUMBER",score);
}
else{
//choices button clicked
selectedAnswer2 = clickedButton.getText().toString();
clickedButton.setBackgroundColor(Color.MAGENTA);
}
}
void loadNewQuestion(){
if(currentQuestionIndex2 == totalQuestion2 ){
startActivity(new Intent(QuizSecond.this, ComputeActivity.class));
return;
}
questionTextView2.setText(QuestionAnswer2.question2[currentQuestionIndex2]);
ansA2.setText(QuestionAnswer2.choices2[currentQuestionIndex2][0]);
ansB2.setText(QuestionAnswer2.choices2[currentQuestionIndex2][1]);
ansC2.setText(QuestionAnswer2.choices2[currentQuestionIndex2][2]);
ansD2.setText(QuestionAnswer2.choices2[currentQuestionIndex2][3]);
}
}
second activity:
int number = getIntent().getIntExtra("EXTRA_NUMBER",0); if (number > 3){ Toast.makeText(ComputeActivity.this, "Your Message", Toast.LENGHT_LONG).show();}
Update this
Intent quizIntent = new Intent(QuizSecond.this, ComputeActivity.class);
quizIntent.putExtra("TRANSFER_NUMBER", score);
startActivity(quizIntent);
My ticTacToe Assigment picture
In onClickListener, I have line button00.setImageResource(R.drawable.x_sign);
but it will be executed only when listener is finished.
How can I force this command to execute immediately?
Condition in onClickListener for imageButton is:
if ((opField[x][y] == 0) && covekNext){ // field is empty and man have turn
button00.setImageResource(R.drawable.x_sign);
} else return;
When In this situation I play field 21 ( second row, first column).
button00.setImageResource(R.drawable.x_sign);
Images wouldnt be swaped! blank field stay blank, not X.
Bug or my coding error.
Thanks.
final ImageButton button00 = findViewById(R.id.imageButton00);
button00.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
x=0;
y=0;
if ((opField[x][y] == 0) && covekNext){
button00.setImageResource(R.drawable.x_sign);
} else return;
covekNext = false;
opField[x][y]= 1;
if(++opWinLines[0]==3|++opWinLines[3]==3|++opWinLines[6]==3){
covekWin(); //button00.setImageResource(R.drawable.x_sign); //command not executed
return;
}
if (++zauzeto<9) {
computerMove(); //button00.setImageResource(R.drawable.x_sign); //command not executed
} else {
nereseno(); //button00.setImageResource(R.drawable.x_sign); //command not executed
}
}
}); // button00.setImageResource(R.drawable.x_sign); executed
I think you are looking for something like this :
final ImageButton button00 = findViewById(R.id.imageButton00);
button00.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
x=0;
y=0;
if ((opField[x][y] == 0) && covekNext){
button00.setImageResource(R.drawable.x_sign);
} else return;
covekNext = false;
opField[x][y]= 1;
if(++opWinLines[0]==3|++opWinLines[3]==3|++opWinLines[6]==3){
button00.setImageResource(R.drawable.x_sign);
covekWin();
return;
}
if (++zauzeto<9) {
button00.setImageResource(R.drawable.x_sign);
computerMove();
} else {
button00.setImageResource(R.drawable.x_sign);
nereseno();
}
}
});
its because u use returnin your code
clicklisteners suppose to listen to clicks while user works with activity's ui
It works in most of cases but not always
You are only swapped the imageResource in first if condition. So when first else part is executed, image is not being swapped. If you want this line to execute every time, place it as first line in onClickListener as follows.
final ImageButton button00 = findViewById(R.id.imageButton00);
button00.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
x=0;
y=0;
//Set the imageResource here
button00.setImageResource(R.drawable.x_sign);
if ((opField[x][y] == 0) && covekNext){
} else return;
covekNext = false;
opField[x][y]= 1;
if(++opWinLines[0]==3|++opWinLines[3]==3|++opWinLines[6]==3){
covekWin();
return;
}
if (++zauzeto<9) {
computerMove();
} else {
nereseno();
}
}
});
Cheers :)
Everybody, thanks a lot!!!!
Everything about this question was my mistake made within some false call in methods: covekWin(); computerWin(); nereseno().
So this part of code is correct, and this question can be erased!
Thanks again!
This question already has answers here:
Android coding with switch (String)
(6 answers)
Closed 5 years ago.
I want to create a switch statement to assign different audio files to statements inputted into the keyboard, which are received by the char array.
Code:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.keybutton);
button.setOnClickListener(MainActivity.this);
}
#Override
public void onClick(View v) {
EditText keyInput = (EditText) findViewById(R.id.key);
String notes = keyInput.getText().toString();
char[] charArray;
for (char c : charArray = notes.toCharArray()) {
I Need HELP RIGHT HERE
switch ((Boolean) View.()) {/*what do i do here?()) {
case:
/*that a certain key is pressed
*/
AND HERE
MediaPlayer mp1 = MediaPlayer.create(getApplicationContext(), R.raw.sample1);
mp1.start();
break;
/* above (and/or others) happens on button click
*/
}
;
}
;
help?
If your issue is the char array, don't use a char array
String notes = keyInput.getText().toString();
for (int i = 0: i < notes.length(); i++) {
String c = ""+notes.charAt(i);
switch (c.toLowerCase()) {
case "a":
// play the note
break;
}
}
Other solutions without a switch
1) You can have a Map<Character, Integer> to store a (character, song) pairing, which is cleaner code than a massive switch statement
map.put('a', R.raw.note_a); // Name your resources based on the notes
...
char noteChar = 'a'; // For example
Integer note = map.get(noteChar);
if (note != null) {
MediaPlayer mp = MediaPlayer.create(MainActivity.this, note);
mp.start();
}
2) You can use dynamic resource lookups
// This returns 'R.raw.note_a', for example
int note = getResources().getIdentifier("note_"+noteChar, "raw", getPackageName());
if (resourceID != 0) {
MediaPlayer mp = MediaPlayer.create(MainActivity.this, note);
mp.start();
}
i want to use my PlayerClick(view v) inside a if condition . but it gives me null Exception. it has to retrieve button id.
//Main Code where i wan to call
while (gameLoop > 0){
while(PlayerClick(null) != 1){
if( WinnerCheck(currentUser.getSymbolValue()) == 1 || WinnerCheck(currentUser.getSymbolValue()) == 0 ){
return currentUser;
}
if (gameLoop % 2 == 0)
currentUser = me;
else
currentUser = opponent;
}
gameLoop--;
}
Function Is here
public int PlayerClick(View v) {
//
switch(v.getId()){
case R.id.btnone:
return -1;
case R.id.btntwo:
return -1;
}
return 1;
}
Aim to do this just to pause a while loop while right button is being clicked
im using android:onclick = "PlayerClick" for four buttons in XML
i want to use my PlayerClick(view v) inside a if condition . but it
gives me null Exception.
Because you are passing null to PlayerClick method.
To get it work you should pass Button view which is pressed by user as parameter in PlayerClick method.
findViewById(android.R.id.yourlayout) pass this in PlayerClick()
like
PlayerClick(findViewById(android.R.id.yourlayout))
Do
button.setOnClickListener(this);
Let your activity implement OnClickListener
And when you get onClick(View v) of activity, do as below
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_nativex:
PlayerClick(v);
break;
default:
break;
}
}
public int mPlayerClick;
public void PlayerClick(View v) {
int viewId = v.getId();
if (viewId == R.id.btnone) { mPlayerClick = -1; }
if (viewId == R.id.btntwo) { mPlayerClick = -1; }
else mPlayerClick = 1;
}
And then.
while (gameLoop > 0){
while(mPlayerClick != 1){
...
I don't understand what you are trying to do though, so this might be wrong. This way mPlayerClick will be set to 1 (and stop your loop) only if the user clicks on some button that is not either btnone or btntwo.
Of course all of your buttons need to call PlayerClick() on click.
So I have a class that will play some songs via the MediaPlayer. I have the following code that When a Radiobutton is selected should play a song, However this does not work, could anyone tell me why?
I do not get any errors, the music just does not play.
Code from the OnCheckedChange Method:
break;
case R.id.rFolk1: //setting up sub radiogroup buttons
if(fsong1.isPlaying() == false)
fsong1.start();
break;
case R.id.rFolk2: //setting up sub radiogroup buttons
if(fsong2.isPlaying() == false)
fsong2.start();
break;
Other code for the songs:
fsong1 = MediaPlayer.create(this, R.raw.folk1);
fsong2 = MediaPlayer.create(this, R.raw.folk2);
Fullcode:
public class Music extends Activity implements OnCheckedChangeListener, OnClickListener{
Button playpause;
RadioGroup selectionList, Folk, Rock, Pop, NewWave, Pipe;//define the radiogroup
RadioButton folk1, folk2, rock1, rock2, pop1, pop2, newwave1, newwave2, pipe1, pipe2; //define radiobuttons
MediaPlayer fsong1, fsong2, rsong1, rsong2, psong1, psong2, nwsong1, nwsong2, pisong1, pisong2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set fullscreen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN );
setContentView(R.layout.music); //set layout
initialize(); //call this method
}
public void initialize(){
// set up the radiogroups
selectionList = (RadioGroup) findViewById(R.id.rgMusic);
Folk = (RadioGroup) findViewById(R.id.rgFolk);
Rock = (RadioGroup) findViewById(R.id.rgRock);
Pop = (RadioGroup) findViewById(R.id.rgPop);
Pipe = (RadioGroup) findViewById(R.id.rgPipe);
folk1 = (RadioButton) findViewById(R.id.rFolk1);
folk2 = (RadioButton) findViewById(R.id.rFolk2);
rock1 = (RadioButton) findViewById(R.id.rRock1);
rock2 = (RadioButton) findViewById(R.id.rRock2);
pipe1 = (RadioButton) findViewById(R.id.rPipe1);
pipe2 = (RadioButton) findViewById(R.id.rPipe2);
pop1 = (RadioButton) findViewById(R.id.rPop1);
pop2 = (RadioButton) findViewById(R.id.rPop2);
newwave1 = (RadioButton) findViewById(R.id.rNewWave1);
newwave2 = (RadioButton) findViewById(R.id.rNewWave2);
NewWave = (RadioGroup) findViewById(R.id.rgNewWave);
//settting up on check changed
selectionList.setOnCheckedChangeListener(this);
playpause = (Button) findViewById(R.id.bPlayPause);
playpause.setOnClickListener(this);
fsong1 = MediaPlayer.create(this, R.raw.folk1);
fsong2 = MediaPlayer.create(this, R.raw.folk2);
}
#Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
//case statement for onCheckChange to open a new class/layout
//
//This also hides radiogroups and shows others
switch(arg1){
case R.id.rFolk:
Folk.setVisibility(View.VISIBLE); //shows rg for folk
//hides all the rest of the radiogroups if visible
if(Pipe.getVisibility() == View.VISIBLE){
Pipe.setVisibility(View.GONE);
}
if(Rock.getVisibility() == View.VISIBLE){
Rock.setVisibility(View.GONE);
}
if(Pop.getVisibility() == View.VISIBLE){
Pop.setVisibility(View.GONE);
}
if(NewWave.getVisibility() == View.VISIBLE){
NewWave.setVisibility(View.GONE);
}
break;
case R.id.rPipe:
Pipe.setVisibility(View.VISIBLE);//shows rg for pipe
//hides all the rest of the radiogroups if visible
if(Folk.getVisibility() == View.VISIBLE){
Folk.setVisibility(View.GONE);
}
if(Rock.getVisibility() == View.VISIBLE){
Rock.setVisibility(View.GONE);
}
if(Pop.getVisibility() == View.VISIBLE){
Pop.setVisibility(View.GONE);
}
if(NewWave.getVisibility() == View.VISIBLE){
NewWave.setVisibility(View.GONE);
}
break;
case R.id.rRock:
Rock.setVisibility(View.VISIBLE);//shows rg for rock
//hides all the rest of the radiogroups if visible
if(Folk.getVisibility() == View.VISIBLE){
Folk.setVisibility(View.GONE);
}
if(Pipe.getVisibility() == View.VISIBLE){
Pipe.setVisibility(View.GONE);
}
if(Pop.getVisibility() == View.VISIBLE){
Pop.setVisibility(View.GONE);
}
if(NewWave.getVisibility() == View.VISIBLE){
NewWave.setVisibility(View.GONE);
}
break;
case R.id.rPop:
Pop.setVisibility(View.VISIBLE);//shows rg for pop
//hides all the rest of the radiogroups if visible
if(Folk.getVisibility() == View.VISIBLE){
Folk.setVisibility(View.GONE);
}
if(Pipe.getVisibility() == View.VISIBLE){
Pipe.setVisibility(View.GONE);
}
if(Rock.getVisibility() == View.VISIBLE){
Rock.setVisibility(View.GONE);
}
if(NewWave.getVisibility() == View.VISIBLE){
NewWave.setVisibility(View.GONE);
}
break;
case R.id.rNewWave:
NewWave.setVisibility(View.VISIBLE);//shows rg for newwave
//hides all the rest of the radiogroups if visible
if(Folk.getVisibility() == View.VISIBLE){
Folk.setVisibility(View.GONE);
}
if(Pipe.getVisibility() == View.VISIBLE){
Pipe.setVisibility(View.GONE);
}
if(Rock.getVisibility() == View.VISIBLE){
Rock.setVisibility(View.GONE);
}
if(Pop.getVisibility() == View.VISIBLE){
Pop.setVisibility(View.GONE);
}
break;
case R.id.rFolk1: //setting up sub radiogroup buttons
if(fsong1.isPlaying() == false){
fsong1.start();
}
break;
case R.id.rFolk2: //setting up sub radiogroup buttons
if(fsong2.isPlaying() == false){
fsong2.start();
}
}
}
#Override
public void onClick(View view) {
// setting the onclick listener for the buttons for play/pause stop
// check for already playing
if(fsong1.isPlaying()){
fsong1.pause();
// Changing button image to play button
playpause.setBackgroundResource(R.drawable.play_button);
}else{
// Resume song
fsong1.start();
// Changing button image to pause button
playpause.setBackgroundResource(R.drawable.pause_button);
}
}
}
I'd advise against creating so many MediaPlayers . They may very well be the cause of your troubles: When you instance too many of them they don't work well.
And you should take a look at the lifecycle of MediaPlayer as well.
In it you'll find one way to remove your multiple instances of MediaPlayers. You could, for instance change your playing to:
Boolean fsong1, fsong2, rsong1, rsong2, psong1, psong2, nwsong1, nwsong2, pisong1, pisong2;
Boolean isPlaying=false;
//lots of more code
case R.id.rFolk1: //setting up sub radiogroup buttons
if ((isPlaying) && !fsong1){
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
}
if (!fsong1){
//reset all other types of songs!
fsong1=true;
isPlaying = true;
mediaPlayer=MediaPlayer.create(this, R.raw.folk1);
mediaPlayer.start();
}
break;
Warning: I'm not giving you the whole change you'd have to apply!