Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking out every service of the project #2

Open
wants to merge 34 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
18a57d9
convert Marquee java to kt and apply kotlin plugin
lynring24 Jul 22, 2017
7132a98
convert text.LogTextBox1 java to kt
lynring24 Jul 22, 2017
9d24dc9
convert LogTextBox && Link java to kt
lynring24 Jul 22, 2017
92054df
found </a> missing
lynring24 Jul 22, 2017
48bfdd1
modified a depreciated Html.fromHtml() by version
lynring24 Jul 22, 2017
eb2138c
convert SeekBar java to kt
lynring24 Jul 29, 2017
2d22fac
converted AlarmController java to kt
lynring24 Jul 29, 2017
4baef90
removed comment
lynring24 Aug 11, 2017
01b8e36
used by lazy for t2(textView)
lynring24 Aug 11, 2017
b1d8c18
used lazy for t3 (textView)
lynring24 Aug 11, 2017
fed790f
used lazy for val t4
lynring24 Aug 11, 2017
88ec3ae
used lazy to init var mText and removed !!.apend
lynring24 Aug 11, 2017
3793084
use Kotlin synthetic property instead of java calendar.set()
lynring24 Aug 11, 2017
f965748
apply plugin: 'kotlin-android-extensions'
lynring24 Aug 11, 2017
b3a28ad
used extention code instead of findViewById
lynring24 Aug 11, 2017
1ae905e
convert AlarmService to kt
lynring24 Aug 11, 2017
aa830bf
FragmentAlertDialog converted to kt
lynring24 Aug 12, 2017
294f902
simplify DialogInterface.OnClickListener with Lamda
lynring24 Aug 12, 2017
5c595f5
add string resource for Fragment Alert Dialog msg
lynring24 Aug 12, 2017
9fd3753
used extention code instead of findViewById
lynring24 Aug 12, 2017
957b74d
applied lamda to onClickListener
lynring24 Aug 12, 2017
fe87cba
used kotlin properies instead
lynring24 Aug 12, 2017
829252c
fixed FragmentAlertDialog::doPositiceClick to (activity as Fragment) …
lynring24 Aug 12, 2017
dad4a72
Convert AlarmService_service to kotlin
lynring24 Aug 26, 2017
94cabb8
Convert IsolatedService to Kotlin
lynring24 Aug 26, 2017
f186edd
Convert IsolatedService2 to Kotlin
lynring24 Aug 26, 2017
df13761
Convert LocalService to Kotlin
lynring24 Aug 26, 2017
5f54bf2
Import Context
lynring24 Aug 26, 2017
45480b8
Convert LocalServiceActivies to Kotlin
lynring24 Aug 26, 2017
61d55d8
Convert NotificationBackgroundService to Kotlin
lynring24 Aug 26, 2017
a5e599a
changed to extension code
lynring24 Aug 26, 2017
c980368
Convert NotifyingController to Kotlin
lynring24 Aug 26, 2017
a0398a3
Convert NotifyingService to Kotlin
lynring24 Aug 26, 2017
9c90694
Convert ServiceStartArguments to Kotlin
lynring24 Aug 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// vim: ts=4 sts=4 sw=4 expandtab

buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
7 changes: 6 additions & 1 deletion mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
Expand Down Expand Up @@ -27,4 +28,8 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:26.0.0-beta2'
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
168 changes: 0 additions & 168 deletions mobile/src/main/java/com/example/android/apis/app/AlarmController.java

This file was deleted.

152 changes: 152 additions & 0 deletions mobile/src/main/java/com/example/android/apis/app/AlarmController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.android.apis.app

// Need the following import to get access to the app resources, since this
// class is in a sub-package.
import com.example.android.apis.R

import android.app.Activity
import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Intent
import android.os.SystemClock
import android.os.Bundle
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button
import android.widget.Toast

import java.util.Calendar

/**
* Example of scheduling one-shot and repeating alarms. See
* [OneShotAlarm] for the code run when the one-shot alarm goes off, and
* [RepeatingAlarm] for the code run when the repeating alarm goes off.
* <h4>Demo</h4>
* App/Service/Alarm Controller

* <h4>Source files</h4>
* <table class="LinkTable">
* <tr>
* <td class="LinkColumn">src/com.example.android.apis/app/AlarmController.java</td>
* <td class="DescrColumn">The activity that lets you schedule alarms</td>
</tr> *
* <tr>
* <td class="LinkColumn">src/com.example.android.apis/app/OneShotAlarm.java</td>
* <td class="DescrColumn">This is an intent receiver that executes when the
* one-shot alarm goes off</td>
</tr> *
* <tr>
* <td class="LinkColumn">src/com.example.android.apis/app/RepeatingAlarm.java</td>
* <td class="DescrColumn">This is an intent receiver that executes when the
* repeating alarm goes off</td>
</tr> *
* <tr>
* <td class="LinkColumn">/res/any/layout/alarm_controller.xml</td>
* <td class="DescrColumn">Defines contents of the screen</td>
</tr> *
</table> *
*/

class AlarmController : Activity (){
var mToast: Toast? = null
override fun onCreate(savedInstanceState:Bundle?) : Unit {
super.onCreate(savedInstanceState)
setContentView(R.layout.alarm_controller)

// Watch for button clicks.
var button = findViewById<View>(R.id.one_shot)
button.setOnClickListener(mOneShotListener)
button = findViewById<View>(R.id.start_repeating)
button.setOnClickListener(mStartRepeatingListener)
button = findViewById<View>(R.id.stop_repeating)
button.setOnClickListener(mStopRepeatingListener)
}
val mOneShotListener = OnClickListener{
// When the alarm goes off, we want to broadcast an Intent to our
// BroadcastReceiver. Here we make an Intent with an explicit class
// name to have our own receiver (which has been published in
// AndroidManifest.xml) instantiated and called, and then create an
// IntentSender to have the intent executed as a broadcast.
val intent:Intent = Intent(this@AlarmController, OneShotAlarm::class.java)
val sender:PendingIntent = PendingIntent.getBroadcast(this@AlarmController, 0, intent, 0)

// We want the alarm to go off 30 seconds from now.
var calendar:Calendar = Calendar.getInstance()
calendar.timeInMillis=System.currentTimeMillis()
calendar.add(Calendar.SECOND, 30)

// Schedule the alarm!
val am:AlarmManager = getSystemService(ALARM_SERVICE) as (AlarmManager)
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender)

// Tell the user about what we did.
if (mToast != null) {
mToast!!.cancel()
}
mToast = Toast.makeText(this@AlarmController, R.string.one_shot_scheduled,Toast.LENGTH_LONG)
mToast!!.show()

};
val mStartRepeatingListener = OnClickListener{
// When the alarm goes off, we want to broadcast an Intent to our
// BroadcastReceiver. Here we make an Intent with an explicit class
// name to have our own receiver (which has been published in
// AndroidManifest.xml) instantiated and called, and then create an
// IntentSender to have the intent executed as a broadcast.
// Note that unlike above, this IntentSender is configured to
// allow itself to be sent multiple times.
val intent:Intent = Intent(this@AlarmController, RepeatingAlarm::class.java)
val sender:PendingIntent = PendingIntent.getBroadcast(this@AlarmController,0, intent, 0)

// We want the alarm to go off 30 seconds from now.
var firstTime : Long = SystemClock.elapsedRealtime()
firstTime += 15*1000L

// Schedule the alarm!
val am:AlarmManager = getSystemService(ALARM_SERVICE) as AlarmManager
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, 15*1000, sender)

// Tell the user about what we did.
if (mToast != null) {
mToast!!.cancel()
}
mToast = Toast.makeText(this@AlarmController, R.string.repeating_scheduled, Toast.LENGTH_LONG)
mToast!!.show()

};
val mStopRepeatingListener = OnClickListener {
// Create the same intent, and thus a matching IntentSender, for
// the one that was scheduled.
val intent:Intent = Intent(this@AlarmController, RepeatingAlarm::class.java)
val sender:PendingIntent = PendingIntent.getBroadcast(this@AlarmController, 0, intent, 0)

// And cancel the alarm.
val am :AlarmManager= getSystemService(ALARM_SERVICE) as (AlarmManager)
am.cancel(sender)

// Tell the user about what we did.
if (mToast != null) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mToast ?.let 이나 run으로 처리가능지만, 시인성이 어디가 좋을지는 매번 어려운부분같네요

mToast!!.cancel();
}
mToast = Toast.makeText(this@AlarmController, R.string.repeating_unscheduled,Toast.LENGTH_LONG)
mToast!!.show()

};
}

Loading