forked from ganadist/AndroidApiDemo
-
Notifications
You must be signed in to change notification settings - Fork 3
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
lynring24
wants to merge
34
commits into
kotlin-korea:next
Choose a base branch
from
lynring24:next
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 7132a98
convert text.LogTextBox1 java to kt
lynring24 9d24dc9
convert LogTextBox && Link java to kt
lynring24 92054df
found </a> missing
lynring24 48bfdd1
modified a depreciated Html.fromHtml() by version
lynring24 eb2138c
convert SeekBar java to kt
lynring24 2d22fac
converted AlarmController java to kt
lynring24 4baef90
removed comment
lynring24 01b8e36
used by lazy for t2(textView)
lynring24 b1d8c18
used lazy for t3 (textView)
lynring24 fed790f
used lazy for val t4
lynring24 88ec3ae
used lazy to init var mText and removed !!.apend
lynring24 3793084
use Kotlin synthetic property instead of java calendar.set()
lynring24 f965748
apply plugin: 'kotlin-android-extensions'
lynring24 b3a28ad
used extention code instead of findViewById
lynring24 1ae905e
convert AlarmService to kt
lynring24 aa830bf
FragmentAlertDialog converted to kt
lynring24 294f902
simplify DialogInterface.OnClickListener with Lamda
lynring24 5c595f5
add string resource for Fragment Alert Dialog msg
lynring24 9fd3753
used extention code instead of findViewById
lynring24 957b74d
applied lamda to onClickListener
lynring24 fe87cba
used kotlin properies instead
lynring24 829252c
fixed FragmentAlertDialog::doPositiceClick to (activity as Fragment) …
lynring24 dad4a72
Convert AlarmService_service to kotlin
lynring24 94cabb8
Convert IsolatedService to Kotlin
lynring24 f186edd
Convert IsolatedService2 to Kotlin
lynring24 df13761
Convert LocalService to Kotlin
lynring24 5f54bf2
Import Context
lynring24 45480b8
Convert LocalServiceActivies to Kotlin
lynring24 61d55d8
Convert NotificationBackgroundService to Kotlin
lynring24 a5e599a
changed to extension code
lynring24 c980368
Convert NotifyingController to Kotlin
lynring24 a0398a3
Convert NotifyingService to Kotlin
lynring24 9c90694
Convert ServiceStartArguments to Kotlin
lynring24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
168 changes: 0 additions & 168 deletions
168
mobile/src/main/java/com/example/android/apis/app/AlarmController.java
This file was deleted.
Oops, something went wrong.
152 changes: 152 additions & 0 deletions
152
mobile/src/main/java/com/example/android/apis/app/AlarmController.kt
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 |
---|---|---|
@@ -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) { | ||
mToast!!.cancel(); | ||
} | ||
mToast = Toast.makeText(this@AlarmController, R.string.repeating_unscheduled,Toast.LENGTH_LONG) | ||
mToast!!.show() | ||
|
||
}; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mToast ?.let 이나 run으로 처리가능지만, 시인성이 어디가 좋을지는 매번 어려운부분같네요