okay i'm going try make simple possible keep getting confused thinking it. i'm using library called achievementunlocked can find here github link
so yeah i'll post code below need access method below method in activity.
method need access:
public void notification() { int seconds = integer.parseint(duration); notificationstatus = "active"; final achievementunlocked achievementunlocked = new achievementunlocked(mainactivity.this).settitle(title). setsubtitlecolor(color.parsecolor(colortxt)). setsubtitle(text). setduration(settings.time). setbackgroundcolor(color.parsecolor(colorbg)). settitlecolor(color.parsecolor(colortxt)). seticon(getdrawablefromres(image1)). islarge(settings.largepref).build(); view iconiv = achievementunlocked.geticonview(); objectanimator outx = objectanimator.offloat(iconiv, "scalex", 0.9f, 0.7f); objectanimator outy = objectanimator.offloat(iconiv, "scaley", 0.9f, 0.7f); objectanimator inx = objectanimator.offloat(iconiv, "scalex", 0.7f, 0.9f); objectanimator iny = objectanimator.offloat(iconiv, "scaley", 0.7f, 0.9f); final animatorset outset = new animatorset(); final animatorset ani = new animatorset(); final animatorset inset = new animatorset(); outx.setduration(1000); outy.setduration(1000); inx.setduration(1000); iny.setduration(1000); ani.addlistener(new animatorlisteneradapter() { @override public void onanimationend(animator animation) { super.onanimationend(animation); ani.start(); } }); outset.playtogether(outx, outy); inset.playtogether(inx, iny); (achievementunlocked.getachievementview()).setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { achievementunlocked.dismiss(); notificationservice.run(); } }); achievementunlocked.getachievementview().setontouchlistener(gesturelistener); ani.play(outset).before(inset); achievementunlocked.setachievementlistener(new achievementunlocked.achievementlistener() { @override public void onachievementbeingcreated(achievementunlocked achievement, boolean created) { } @override public void onachievementexpanding(achievementunlocked achievement, boolean expanded) { if (expanded) ani.start(); } @override public void onachievementshrinking(achievementunlocked achievement, boolean shrunken) { if (!shrunken) { if (ani.isrunning()) ani.cancel(); notificationstatus = "unactive"; log.i("status set unactive", notificationstatus); } } @override public void onachievementbeingdestroyed(achievementunlocked achievement, boolean destroyed) { } }); achievementunlocked.show(); }
i need access method section of code:
class mygesturedetector extends gesturedetector.simpleongesturelistener { @override public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) { try { if (math.abs(e1.gety() - e2.gety()) > swipe_max_off_path) return false; // left right swipe if(e2.getx() - e1.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) { **rightswipe();** } // right left swipe else if (e1.getx() - e2.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) { **leftswipe();** } } catch (exception e) { // nothing } return false; } }
so main question how can act i'm inside original method second method because function achievementunlocked.dismiss();
not accessible outside of main method see first . appreciate help!
add setter mygesturedetector
takes achievementunlocked
parameter. store achievementunlocked
in field in mygesturedetector
. call setter notification()
. then, mygesturedetector
has access achievementunlocked
instance , can call dismiss()
on it.
Comments
Post a Comment