Comments (2)
Anyone any thought?
from android-target-tooltip.
You could store a reference to the currently displayed tooltipView, and onSaveInstanceState, save the id of the Tooltipview currently being displayed. Then, in onViewStateRestored, re-create the TooltipView from the saved id if it exists.
Something along the lines of:
View aView; // Anchor view
Tooltip.TooltipView currentTooltip; // reference to currently showing Tooltip
private static final int NO_TOOLTIP = -1;
private static final int TOOLTIP_ONE = 101; // id of tooltip 1
private static final int TOOLTIP_TWO = 102; // id of tooltip 2
private static final String TOOLTIP_RESUME_STATE = 101;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content);
aView = findViewById(R.id.anchor_view);
....
setTooltipOne();
}
...
// create and show your tooltip here
private void setTooltipOne() {
// set currentTooltip to the one you are showing
currentTooltip = Tooltip.make(this,
new Builder(TOOLTIP_ONE)
.anchor(aView, Gravity.BOTTOM)
.closePolicy(new ClosePolicy()
.insidePolicy(true, false)
.outsidePolicy(true, false), 3000)
.activateDelay(800)
.showDelay(300)
.text(R.string.hello_world)
.maxWidth(500)
.withArrow(true)
.withOverlay(true)
.typeface(mYourCustomFont)
.floatingAnimation(AnimationBuilder.DEFAULT)
.build()
).show();
}
private Tooltip.Callback tooltipCallback() {
return new Tooltip.Callback() {
@Override
public void onTooltipClose(Tooltip.TooltipView tooltipView, boolean b, boolean b1) {
currentTooltip = null; // reset the savedTooltip
setTooltipTwo();
}
@Override
public void onTooltipFailed(Tooltip.TooltipView tooltipView) {
}
@Override
public void onTooltipShown(Tooltip.TooltipView tooltipView) {
}
@Override
public void onTooltipHidden(Tooltip.TooltipView tooltipView) {
}
};
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (currentTooltip != null) {
// save the ID here and remove the tooltip
outState.putInt(TOOLTIP_RESUME_STATE, currentTooltip.getId());
currentTooltip.remove();
}
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// check if a tooltip has been stored and recreate it
if (savedInstanceState != null) {
int savedTooltipId = savedInstanceState.getInt(TOOLTIP_RESUME_STATE, NO_TOOLTIP);
if (savedTooltipId != NO_TOOLTIP) {
switch (savedTooltipId) {
case(TOOLTIP_ONE) :
setTooltipOne();
break;
case(TOOLTIP_TWO):
setTooltipTwo();
break;
...
}
}
}
You could also more cleanly do the switch from within a single method, but this is just a general idea.
from android-target-tooltip.
Related Issues (20)
- Gravity.TOP not honored with fitToScreen=True HOT 4
- Not able to click outside HOT 1
- How to have multiple gravity to the tooltip? HOT 1
- Does this work with ConstrainLayout? HOT 1
- There is a problem when Show In Multi Fragments
- Unable to show double values HOT 1
- Fix tooltip issue in RTL layout HOT 4
- How to you use in Java? HOT 2
- not working with status bar
- Missing documentation
- Latest version (2.0.5) not published in Jitpack HOT 1
- Positioning issues when upgrading from 1.x to 2.x
- Positioning Issue: Tip Window appear to be more bottom on Android 11 HOT 6
- Ripple effect is not animated in release build HOT 2
- How to set margin start
- Crashes when loading animation
- Type inference failed at new kotlin version
- Dependencies arent working HOT 1
- Arrow located is wrong on landscape on Samsung S10 API 31 HOT 1
- Stop Floating Animation of tooltip view
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-target-tooltip.