OSDN Git Service

Abstract logic for setting components enabled / disabled
[android-x86/packages-apps-Taskbar.git] / app / src / main / java / com / farmerbb / taskbar / util / ToastFrameworkImpl.java
1 /* Copyright 2017 Braden Farmer
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 package com.farmerbb.taskbar.util;
17
18 import android.annotation.SuppressLint;
19 import android.content.Context;
20 import android.view.Gravity;
21 import android.widget.Toast;
22
23 import com.farmerbb.taskbar.R;
24
25 class ToastFrameworkImpl implements ToastInterface {
26     private Toast toast;
27
28     @SuppressLint("ShowToast")
29     ToastFrameworkImpl(Context context, String message, int length) {
30         toast = Toast.makeText(context, message, length);
31         toast.setGravity(
32                 Gravity.BOTTOM | Gravity.CENTER_VERTICAL,
33                 0,
34                 context.getResources().getDimensionPixelSize(R.dimen.tb_toast_y_offset));
35     }
36
37     @Override
38     public void show() {
39         toast.show();
40     }
41
42     @Override
43     public void cancel() {
44         toast.cancel();
45     }
46 }