This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,12 @@ | |
import android.content.Context; | ||
import android.os.Vibrator; | ||
import android.widget.Toast; | ||
|
||
import io.lerk.lrkFM.consts.PreferenceEntity; | ||
|
||
/** | ||
* Vibrating Toast. | ||
* | ||
* <p> | ||
* Based on: https://stackoverflow.com/a/6109644/1979736 | ||
* | ||
* @author Lukas Fülling ([email protected]) | ||
|
@@ -16,8 +17,11 @@ public class VibratingToast extends Toast { | |
|
||
public VibratingToast(Context context, CharSequence text, int duration) { | ||
super(context); | ||
if(new Pref<Boolean>(PreferenceEntity.VIBRATING_TOASTS).getValue()) { | ||
((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(120); | ||
if (new Pref<Boolean>(PreferenceEntity.VIBRATING_TOASTS).getValue()) { | ||
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); | ||
if (vibrator != null) { | ||
vibrator.vibrate(120); | ||
} | ||
} | ||
makeText(context, text, duration).show(); | ||
} | ||
|