Created
September 21, 2016 01:56
-
-
Save yareally/86c4fb32fdc355a2be2a67bc0689e588 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MainActivity extends BaseActivity { | |
private lazy val signalStr : PhoneStateListener = onSignalChanged((signalStrength) ⇒ { | |
if (signalStrength != null) { | |
lazy val signalWrapper = new SignalArrayWrapper(signalStrength.toString) | |
filteredSignals = signalWrapper.filterSignals(signalStrength.toString) | |
displayDebugInfo(signalWrapper) | |
displaySignalInfo(filteredSignals) | |
} | |
}) | |
private var filteredSignals: Array[String] = null | |
private var sigInfoIds : TypedArray = null | |
private var tm : TelephonyManager = null | |
/** | |
* Property for our telephony manager. | |
* Some stupid phones kill this service on resume (chinese phones...looking at you...) | |
* so in order to avoid that, we'll make sure it's never null | |
* | |
* @return | |
*/ | |
private def Tm: TelephonyManager = { | |
tm = if (tm == null) this.service[TelephonyManager](Context.TELEPHONY_SERVICE) else tm | |
tm | |
} | |
} | |
object MainActivity { | |
def onSignalChanged(callback: (SignalStrength) ⇒ Unit): PhoneStateListener = new PhoneStateListener { | |
override def onSignalStrengthsChanged(signalStrength: SignalStrength) = callback(signalStrength) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment