Android Open Source - Resonos-Android-Framework Popup Windows3 D






From Project

Back to project page Resonos-Android-Framework.

License

The source code is released under:

Apache License

If you think the Android project Resonos-Android-Framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.resonos.apps.library.widget;
/*from   w w w  .java 2 s.c  o  m*/
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.widget.PopupWindow;

/**
 * Custom popup window. From the QuickAction3D library.
 * 
 * @author Lorensius W. L. T <lorenz@londatiga.net>
 *
 */
public abstract class PopupWindows3D {
  protected Context mContext;
  protected PopupWindow mWindow;
  protected View mRootView;
  protected Drawable mBackground = null;
  protected WindowManager mWindowManager;
  
  /**
   * Constructor.
   * 
   * @param context Context
   */
  public PopupWindows3D(Context context) {
    mContext  = context;
    mWindow   = new PopupWindow(context);

    mWindow.setTouchInterceptor(new OnTouchListener() {
      @Override
      public boolean onTouch(View v, MotionEvent event) {
              final int x = (int) event.getX();
              final int y = (int) event.getY();
              
              if ((event.getAction() == MotionEvent.ACTION_DOWN)
                      && ((x < 0) || (x >= mWindow.getWidth()) || (y < 0) || (y >= mWindow.getHeight()))) {
          aboutToDismiss();
              } else if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
          aboutToDismiss();
          mWindow.dismiss();
          return true;
        }
        
        return false;
      }
    });

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  }
  
  protected abstract void aboutToDismiss();

  /**
   * On dismiss
   */
  protected void onDismiss() {    
  }
  
  /**
   * On show
   */
  protected void onShow() {    
  }

  /**
   * On pre show
   */
  protected void preShow() {
    if (mRootView == null) 
      throw new IllegalStateException("setContentView was not called with a view to display.");
  
    onShow();

    if (mBackground == null) 
      mWindow.setBackgroundDrawable(new BitmapDrawable(mContext.getResources()));
    else 
      mWindow.setBackgroundDrawable(mBackground);

    mWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    mWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    mWindow.setTouchable(true);
    mWindow.setFocusable(true);
    mWindow.setOutsideTouchable(true);

    mWindow.setContentView(mRootView);
  }

  /**
   * Set background drawable.
   * 
   * @param background Background drawable
   */
  public void setBackgroundDrawable(Drawable background) {
    mBackground = background;
  }

  /**
   * Set content view.
   * 
   * @param root Root view
   */
  public void setContentView(View root) {
    mRootView = root;
    
    mWindow.setContentView(root);
  }

  /**
   * Set content view.
   * 
   * @param layoutResID Resource id
   */
  public void setContentView(int layoutResID) {
    LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
    setContentView(inflator.inflate(layoutResID, null));
  }

  /**
   * Set listener on window dismissed.
   * 
   * @param listener
   */
  public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
    mWindow.setOnDismissListener(listener);  
  }

  /**
   * Dismiss the popup window.
   */
  public void dismiss() {
    mWindow.dismiss();
  }
}




Java Source Code List

com.resonos.apps.library.Action.java
com.resonos.apps.library.AlertFragment.java
com.resonos.apps.library.App.java
com.resonos.apps.library.BaseFragment.java
com.resonos.apps.library.FragmentBaseActivity.java
com.resonos.apps.library.file.AltAndroidFileHandle.java
com.resonos.apps.library.file.AltAndroidFiles.java
com.resonos.apps.library.file.AltFileHandle.java
com.resonos.apps.library.file.FileCache.java
com.resonos.apps.library.media.AudioVisualizer.java
com.resonos.apps.library.media.BitmapMemoryCache.java
com.resonos.apps.library.media.HueColorFilter.java
com.resonos.apps.library.media.ImageLoader.java
com.resonos.apps.library.media.MediaScannerNotifier.java
com.resonos.apps.library.model.Coord.java
com.resonos.apps.library.model.ImmutableCoord.java
com.resonos.apps.library.tabviewpager.CustomViewPager.java
com.resonos.apps.library.tabviewpager.PageIndicator.java
com.resonos.apps.library.tabviewpager.TabPageIndicator.java
com.resonos.apps.library.tabviewpager.TabViewPagerAdapter.java
com.resonos.apps.library.tabviewpager.TabViewPagerFragment.java
com.resonos.apps.library.tabviewpager.TitleProvider.java
com.resonos.apps.library.util.AppUtils.java
com.resonos.apps.library.util.ErrorReporter.java
com.resonos.apps.library.util.LifecycleTaskQueue.java
com.resonos.apps.library.util.M.java
com.resonos.apps.library.util.NetworkClient.java
com.resonos.apps.library.util.NetworkRequest.java
com.resonos.apps.library.util.ParameterList.java
com.resonos.apps.library.util.SensorReader.java
com.resonos.apps.library.util.TouchViewWorker.java
com.resonos.apps.library.util.ViewServer.java
com.resonos.apps.library.widget.DashboardLayout.java
com.resonos.apps.library.widget.FormBuilder.java
com.resonos.apps.library.widget.FormElement.java
com.resonos.apps.library.widget.ListFormBuilder.java
com.resonos.apps.library.widget.PopupWindows3D.java
com.resonos.apps.library.widget.QuickAction3D.java
com.resonos.apps.library.widget.RangeSeekBar.java
com.resonos.apps.library.widget.SeekBar.java
com.resonos.apps.library.widget.ToolBarButton.java
com.resonos.apps.library.widget.ToolBar.java