| |
---|
| | import android.os.IBinder |
---|
| | import android.support.v4.app.NotificationCompat |
---|
| | import android.view.* |
---|
| | import jackall.moncalc.Const |
---|
| | import jackall.moncalc.Contract.MainServiceContract |
---|
| | import jackall.moncalc.R |
---|
| | import jackall.moncalc.common.PreferenceKeys |
---|
| | import jackall.moncalc.common.PreferenceNames |
---|
| | import jackall.moncalc.databinding.RegistOverlayBinding |
---|
| |
---|
| | |
---|
| | /** |
---|
| | * Created by matsumoto_k on 2017/11/01. |
---|
| | */ |
---|
| | class MainService : Service() { |
---|
| | class MainService : Service(), MainServiceContract { |
---|
| | |
---|
| | val mySharedPref by lazy { MySharedPref(this, PreferenceNames.CONFIG) } |
---|
| | val moveOverlayView: ViewGroup by lazy { LayoutInflater.from(this).inflate(R.layout.move_overlay, null) as ViewGroup } |
---|
| | val registBinding by lazy { |
---|
| |
---|
| | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, |
---|
| | PixelFormat.TRANSLUCENT) |
---|
| | } |
---|
| | |
---|
| | registBinding.registViewModel = OverlayRegistViewModel() |
---|
| | registBinding.registViewModel = OverlayRegistViewModel(this as MainServiceContract) |
---|
| | |
---|
| | registViewParams?.gravity = Gravity.TOP |
---|
| | } |
---|
| | |
---|
| | private fun showMoveView() { |
---|
| | override fun showMoveView() { |
---|
| | moveViewParams?.x = mySharedPref.getValue(PreferenceKeys.VIEWX, Int::class.java, 0) as Int |
---|
| | moveViewParams?.y = mySharedPref.getValue(PreferenceKeys.VIEWY, Int::class.java, 0) as Int |
---|
| | |
---|
| | if (registBinding.root.isShown) { |
---|
| |
---|
| | |
---|
| | windowManager.addView(moveOverlayView, moveViewParams) |
---|
| | } |
---|
| | |
---|
| | private fun showRegistView() { |
---|
| | override fun showRegistView() { |
---|
| | if (moveOverlayView.isShown) { |
---|
| | windowManager.removeView(moveOverlayView) |
---|
| | } |
---|
| | |
---|
| |
---|
| | |
---|
| | override fun onBind(intent: Intent?): IBinder? { |
---|
| | return null |
---|
| | } |
---|
| | |
---|
| | |
---|
| | } |
---|
| | |