mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* Fixing 3203 App crash when rotating the screen * Add java comments for issue #3203 * Add if-else curly braces for issue #3203
This commit is contained in:
parent
891d9ec41c
commit
9b15a327c5
1 changed files with 32 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ import android.widget.Button;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
|
@ -40,6 +40,12 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
@BindView(R.id.button_no)
|
||||
Button noButton;
|
||||
|
||||
// Constant variable used to store user's key name for onSaveInstanceState method
|
||||
private final String SAVED_USER = "saved_user";
|
||||
|
||||
//Variable that stores the value of user
|
||||
private String user;
|
||||
|
||||
public void update(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
|
@ -68,7 +74,7 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
position = getArguments().getInt("position");
|
||||
View layoutView = inflater.inflate(R.layout.fragment_review_image, container,
|
||||
false);
|
||||
ButterKnife.bind(this,layoutView);
|
||||
ButterKnife.bind(this, layoutView);
|
||||
|
||||
String question, explanation, yesButtonText, noButtonText;
|
||||
switch (position) {
|
||||
|
|
@ -106,7 +112,16 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
case THANKS:
|
||||
enableButtons();
|
||||
question = getString(R.string.review_thanks);
|
||||
explanation = getString(R.string.review_thanks_explanation, getReviewActivity().reviewController.firstRevision.getUser());
|
||||
|
||||
//Get existing user name if it is already saved using savedInstanceState else get from reviewController
|
||||
if (savedInstanceState == null) {
|
||||
user = getReviewActivity().reviewController.firstRevision.getUser();
|
||||
} else {
|
||||
user = savedInstanceState.getString(SAVED_USER);
|
||||
}
|
||||
|
||||
explanation = getString(R.string.review_thanks_explanation, user);
|
||||
|
||||
yesButtonText = getString(R.string.review_thanks_yes_button_text);
|
||||
noButtonText = getString(R.string.review_thanks_no_button_text);
|
||||
yesButton.setTextColor(Color.parseColor("#228b22"));
|
||||
|
|
@ -131,6 +146,20 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
return layoutView;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method will be called when configuration changes happen
|
||||
*
|
||||
* @param outState
|
||||
*/
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
//Save user name when configuration changes happen
|
||||
outState.putString(SAVED_USER, user);
|
||||
}
|
||||
|
||||
private ReviewController.ReviewCallback getReviewCallback() {
|
||||
return new ReviewController
|
||||
.ReviewCallback() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue