michaelye / EasyDialog

A lightweight, flexible tip dialog in Android
Other
705 stars 191 forks source link

tool tip not showing on first run of the app #29

Closed kumarbanty closed 8 years ago

kumarbanty commented 8 years ago

I used this library in my app and it worked fine, but when I am using the same code inside a shared pref function to display a tool tip on first run of the app, the tooltip is not showing up.

Please help me with this issue

michaelye commented 8 years ago

Hi,could you post your code here for helping fix your issue?

kumarbanty commented 8 years ago

public class MainActivity extends AppCompatActivity {

Button b;
SharedPreferences pref = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    b = (Button) findViewById(R.id.tooltip_button);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showToolTip();
        }
    });
    pref = getSharedPreferences("firstrun", MODE_PRIVATE);
}
@Override
protected void onResume() {
    super.onResume();
    if (pref.getBoolean("firstrun", true)) {
        showToolTip();
        pref.edit().putBoolean("firstrun", false).commit();
    }
}

public void showToolTip() {
    //Code for top-bottom tooltip animation
    new EasyDialog(MainActivity.this)
            .setLayoutResourceId(R.layout.tooltip_layout)
            .setBackgroundColor(MainActivity.this.getResources().getColor(R.color.tooltip_background_color))
            .setLocationByAttachedView(b)
            .setAnimationTranslationShow(EasyDialog.DIRECTION_Y, 250, -170, 0)
            .setAnimationTranslationDismiss(EasyDialog.DIRECTION_Y, 500, 0, -200)
            .setGravity(EasyDialog.GRAVITY_TOP)
            .setTouchOutsideDismiss(true)
            .setMatchParent(false)
            .setMarginLeftAndRight(24, 24)
            .setAnimationAlphaShow(300, 0.0f, 1.0f)
            .setAnimationAlphaDismiss(300, 1.0f, 0.0f)
            .show();
}

}

kumarbanty commented 8 years ago

Hi, I figured out the cause of the issue. There is nothing wrong with the module's implementation, the issue is with my code. Tooltip is not showing up because, at the first run, the anchor view has not been created. So i put a wait to render the views completely and then displayed the tooltip and it worked like a charm.

Thank you for creating such awesome library.

michaelye commented 8 years ago

Enjoy it : )

On Tue, Jul 12, 2016 at 9:50 PM kumarbanty notifications@github.com wrote:

Hi, I figured out the cause of the issue. There is nothing wrong with the module's implementation, the issue is with my code. Tooltip is not showing up because at the first run, the anchor view has not been created. So i put a wait to render the views completely and then displayed the tooltip and it worked like a charm

Thank you for creating such awesome library.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/michaelye/EasyDialog/issues/29#issuecomment-232053222, or mute the thread https://github.com/notifications/unsubscribe/AA38ugPsr_iBS3lcvVc2XPylOpOaCP8Gks5qU5uqgaJpZM4JKTKP .