Back to project page Do-not-get-annoyed.
The source code is released under:
Apache License
If you think the Android project Do-not-get-annoyed listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package mn100013d.pmu.services; // www. j a v a2s . c o m import mn100013d.pmu.R; import android.app.Activity; import android.content.Context; import android.view.View; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.RelativeLayout; public abstract class PopupService { public static final int NEW_GAME = 1; public static final int GAME_PAUSE = 2; public static final int SETTINGS = 3; public static final int PLEASE_WAIT = 4; private View view; private Context context; private View popup; public PopupService(int name, View view, Context context) { RelativeLayout popup = new RelativeLayout(context); View menu = null; switch (name){ case NEW_GAME: menu = ((Activity) context).getLayoutInflater().inflate( R.layout.fragment_gametype, null); break; case GAME_PAUSE: menu = ((Activity) context).getLayoutInflater().inflate( R.layout.pausegamelayout, null); break; case SETTINGS: menu = ((Activity) context).getLayoutInflater().inflate( R.layout.fragment_settings, null); break; case PLEASE_WAIT: menu = ((Activity) context).getLayoutInflater().inflate( R.layout.pleasewaitlayout, null); break; } popup.addView(menu); this.popup = popup; this.view = view; this.context = context; } public void show() { ((RelativeLayout) view).addView(popup); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) popup .getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); popup.setLayoutParams(layoutParams); if (setHideOnOutsideClick()){ view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hide(); } }); } onShow(); } public void hide() { ((RelativeLayout) view).removeView(popup); onHide(); } public abstract void onHide(); public abstract void onShow(); public abstract Boolean setHideOnOutsideClick(); }