I found a library that fits my purpose, but it is written on Kotlin. Can i use it in Java project?
Framework: https://github.com/mpetlyuk/initial_tips
Usage on Kotlin:
// Create view for your tip
val inflater = LayoutInflater.from(Context)
val tipView = DataBindingUtil.inflate<ViewDataBinding>(inflater, R.layout.item_tooltip, null, false).getRoot()
// Create tip
val tip = Tooltip.Builder()
.attachTooltipView(tipView)
.withEnterAnimation(AnimationComposer(FadeInAnimator()).duration(ANIM_DURATION))
.withExitAnimation(AnimationComposer(FadeOutAnimator()).duration(ANIM_DURATION))
.withGravity(TipVerticalGravity.BOTTOM, TipHorizontalGravity.LEFT)
.withAnchorView(/* anchor view */)
.build()
// Create a queue of tips
val tooltipsQueue = LinkedBlockingQueue<Tip>(listOf(tip))
// Create a queue of tips
TipsManager.showTips(binding.root as ViewGroup, ContextCompat.getColor(this, 0 /* your resource color for dimming */)) { tooltipsQueue }
Android Studio provides full support for Kotlin, enabling you to add Kotlin files to your existing project and convert Java language code to Kotlin. You can then use all of Android Studio's existing tools with your Kotlin code, including autocomplete, lint checking, refactoring, debugging, and more.
Adding Kotlin to an existing Java Android project is easy. Just include a few Gradle dependencies, apply a plugin, and you can start programming in the language.
As a quick refresher, Kotlin is a modern, statically typed language that compiles down for use on the JVM. It's often used wherever you'd reach for Java, including Android apps and backend servers (using Java Spring or Kotlin's own Ktor).
Converting a Kotlin file to Java file involves two steps i.e. compiling the Kotlin code to the JVM bytecode and then decompile the bytecode to the Java code. Steps to convert your Kotlin source file to Java source file: Open your Kotlin project in the Android Studio.
You first need to add support Kotlin in your app. Just create temp kotlin file, android studio will guide you how to do it.
TextView tipView = (TextView) LayoutInflater.from(this).inflate(R.layout.item_tooltip, null, false).getRootView();
Tooltip tip = new Tooltip.Builder()
.attachTooltipView(tipView)
.withEnterAnimation(new AnimationComposer<BaseViewAnimator>(new FadeInAnimator()).duration(500))
.withExitAnimation(new AnimationComposer<BaseViewAnimator>(new FadeOutAnimator()).duration(500))
.withGravity(TipVerticalGravity.BOTTOM, TipHorizontalGravity.LEFT)
.withAnchorView(loginButton)
.build();
List<Tip> tips = new ArrayList<>();
tips.add(tip);
final LinkedBlockingQueue<Tip> tooltipsQueue = new LinkedBlockingQueue<>(tips);
TipsManager.showTips(rootView, R.color.colorAccent, new Function0<Queue<Tip>>() {
@Override
public Queue<Tip> invoke() {
return tooltipsQueue;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With