Skip to content

Commit

Permalink
Fixed #45
Browse files Browse the repository at this point in the history
  • Loading branch information
WrichikBasu committed Apr 1, 2021
1 parent 946e28e commit 73fdde7
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
R.array.shakeAndPowerOptions, android.R.layout.simple_spinner_item);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
shakeOpSpinner.setAdapter(arrayAdapter);
shakeOpSpinner.setSelection(sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_SHAKE_OPERATION,ConstantsAndStatics.SNOOZE));
shakeOpSpinner.setSelection(sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_SHAKE_OPERATION,
ConstantsAndStatics.SNOOZE));
shakeOpSpinner.setOnItemSelectedListener(this);

/////////////////////////////////////////////////////////
Expand Down Expand Up @@ -308,6 +309,8 @@ public void afterTextChanged(Editable editable) {

}

//-----------------------------------------------------------------------------------------------------

@Override
protected void onResume() {
super.onResume();
Expand All @@ -316,6 +319,8 @@ protected void onResume() {
}
}

//-----------------------------------------------------------------------------------------------------

@Override
protected void onPause() {
super.onPause();
Expand All @@ -342,8 +347,12 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
* @return {@code true} if the file exists, otherwise {@code false}.
*/
private boolean doesFileExist(Uri uri) {
try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) {
return cursor != null;
try {
try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) {
return cursor != null;
}
} catch (java.lang.SecurityException exception) {
return false;
}
}

Expand Down Expand Up @@ -420,7 +429,7 @@ private void setDefaultTone(Uri uri) {
//-----------------------------------------------------------------------------------------------------

/**
* Sets the volume in the {@link #volumeImageView} as per the progress in the volume seekbar.
* Sets the image in the {@link #volumeImageView} as per the progress in the volume seekbar.
*
* @param volume The current volume (or progress in volume SeekBar.
*/
Expand All @@ -434,6 +443,12 @@ private void setVolumeImageView(int volume) {

//----------------------------------------------------------------------------------------------------

/**
* Change the image in {@link #shakeImageView}.
*
* @param state The state of the shake ExpandableLayout. Either {@link ExpandableLayout.State#EXPANDED} or {@link
* ExpandableLayout.State#COLLAPSED}.
*/
private void setShakeImageView(int state) {
if (state == ExpandableLayout.State.EXPANDED) {
shakeImageView.setImageResource(R.drawable.ic_collapse);
Expand All @@ -444,6 +459,12 @@ private void setShakeImageView(int state) {

//----------------------------------------------------------------------------------------------------

/**
* Change the image in {@link #snoozeImageView}.
*
* @param state The state of the snooze ExpandableLayout. Either {@link ExpandableLayout.State#EXPANDED} or {@link
* ExpandableLayout.State#COLLAPSED}.
*/
private void setSnoozeImageView(int state) {
if (state == ExpandableLayout.State.EXPANDED) {
snoozeImageView.setImageResource(R.drawable.ic_collapse);
Expand Down

0 comments on commit 73fdde7

Please sign in to comment.