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
package board | |
import java.lang.IllegalArgumentException | |
data class Cell(val i: Int, val j: Int) { | |
override fun toString() = "($i, $j)" | |
} | |
enum class Direction { | |
UP, DOWN, RIGHT, LEFT; |
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
package rationals | |
import java.math.BigInteger | |
data class Rational(val n: BigInteger, val d: BigInteger): Comparable<Rational> { | |
init { require(d != BigInteger.ZERO ) {"Zero is not allowed in the denominator"} } | |
override fun toString(): String { | |
if (this.d == BigInteger.ONE) return "${this.n}" |
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
fun main() { | |
println(palindromeIndex("aaa")) | |
} | |
fun palindromeIndex(s: String): Int { | |
val reversed = s.reversed() | |
if (s == reversed) return -1 | |
for (i in 0 until s.length) { | |
var countLeft = 0 |
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
<metadata> | |
<!-- Some Metadata.xml fixes for binding "Java WebSockets" (https://github.com/TooTallNate/Java-WebSocket/) in Xamarin.Android --> | |
<!-- This is a case of http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types | |
Error CS0102: The type `Org.Java_websocket.WebsocketMessageEventArgs' | |
already contains a definition for `p0' --> | |
<attr path="/api/package[@name='org.java_websocket']/interface[@name='WebSocketListener']/method[@name='onWebsocketMessage' and count(parameter)=2 and parameter[1][@type='org.java_websocket.WebSocket'] and parameter[2][@type='java.nio.ByteBuffer']]" name="argsType">WebsocketMessageByteBufferEventArgs</attr> | |
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
<metadata> | |
<!-- Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android | |
Note that this is not a complete set of fixes. These changes only address the first round of compile errors. --> | |
<!-- Fixes for duplicate EventArgs, as discussed on: | |
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types | |
Error message: Error CS0102: The type `SomeClass` already contains a definition for `p0' (CS0102) --> | |
<attr path="/api/package[@name='com.socialize.auth.twitter']/interface[@name='TwitterAuthListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='com.socialize.error.SocializeException']]" name="argsType">AuthTwitterErrorEventArgs</attr> | |
<attr path="/api/package[@name='com.socialize.facebook']/interface[@name='Facebook.DialogListener']/method[@name='onComplete' and count(parameter)=1 and parameter[1][@type='android.os.Bundle |
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
<metadata> | |
<!-- Error CS0234: The type or namespace name `QuadCorners' does not exist in the namespace `DE.Neom.Neoreadersdk'. Are you missing an assembly reference? | |
This problem is caused by the default unspecified visibility of | |
the QuadCorners Java class. | |
Note in particular the very end of the following line from | |
`obj/Debug/api.xml`: | |
<class abstract="false" deprecated="not deprecated" extends="java.lang.Object" extends-generic-aware="java.lang.Object" final="false" name="QuadCorners" static="false" visibility=""> |
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
<metadata> | |
<!-- Some Metadata.xml fixes for binding the "Brother Print SDK for | |
Android" (http://www.brother.com/product/dev/mobile/android/) in | |
Xamarin.Android. --> | |
<!-- Warning BG8401: Skipping Com.Brother.Ptouch.Sdk.LabelInfo.LabelColor, due to a duplicate field, method or nested type name | |
This one is a bit tricky. Let's first just try removing the whole | |
LabelColor nested class: |
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 is an example of http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding-a-java-library/troubleshooting-bindings/#Problem_Duplicate_custom_EventArgs_types | |
In this particular case, the conflicting definition is in | |
`Com.Adtech.Mobilesdk.Publisher.Vast.Player.ILinearAdPlayer`. | |
That interface also defines an "onError" method. | |
Error CS0102: The type | |
`Com.Adtech.Mobilesdk.Publisher.Vast.Player.ErrorEventArgs' | |
already contains a definition for `p0' --> | |
<attr path="/api/package[@name='com.adtech.mobilesdk.publisher.vast.player']/interface[@name='VideoPlayerListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='java.lang.Exception']]" name="argsType">VideoPlayerListenerOnErrorArgs</attr> |
One of the best ways to investigate a problematic Xamarin.Android Binding is to first ensure you have the proper tooling available:
- Diagnostic MSBuild Output Enabled(Instructions)
- Java Decompiler(http://jd.benow.ca/)
- .NET Decompiler(https://www.jetbrains.com/decompiler/)
- Binding SDK Documentation
NewerOlder