package com.sometrik.framework;

import com.sometrik.framework.NativeCommand.Selector;

import android.graphics.Bitmap;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.PopupMenu;

public class FWActionSheet extends PopupMenu implements NativeCommandHandler {

  private FrameWork frame;
  private MenuInflater inflater;
  private Menu menu;
  private int id;
  
  public FWActionSheet(FrameWork frame, View anchor, int id) {
    super(frame, anchor);
    this.id = id;
    inflater = new MenuInflater(frame);
    menu = getMenu();
  }

  @Override
  public void onScreenOrientationChange(boolean isLandscape) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void addChild(View view) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void addOption(int optionId, String text) {
    menu.add(Menu.NONE, optionId, Menu.NONE, text);
  }

  @Override
  public void addColumn(String text, int columnType) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void addData(String text, int row, int column, int sheet) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void setValue(String v) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void setBitmap(Bitmap bitmap) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void addImageUrl(String url, int width, int height) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void setValue(int v) {
    if (v > 0) {
      show();
    }
  }

  @Override
  public void reshape(int value, int size) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void reshape(int size) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void setViewVisibility(boolean visible) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void setStyle(Selector selector, String key, String value) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void setError(boolean hasError, String errorText) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void clear() {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void flush() {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void deinitialize() {
    // TODO Auto-generated method stub
    
  }

  @Override
  public int getElementId() {
    return id;
  }

}

package com.sometrik.framework;

import com.sometrik.framework.NativeCommand.Selector;

import android.graphics.Bitmap;
import android.view.Menu;
import android.view.View;
import android.widget.PopupMenu;

public class FWActionSheet extends PopupMenu implements NativeCommandHandler {

  private FrameWork frame;
  private int id;
  private boolean hasEntries = false;
  
  public FWActionSheet(FrameWork frame, View anchor, int id) {
    super(frame, anchor);
    this.id = id;
   
    // Add dummy entry, or the menu will not have any width
    getMenu().add("No menu entries");
    show();
  }

  @Override
  public void onScreenOrientationChange(boolean isLandscape) { }

  @Override
  public void addChild(View view) { }

  @Override
  public void addOption(int optionId, String text) {
    if (!hasEntries) {
      getMenu().clear();
      hasEntries = true;      
    }
    System.out.println("ActionSheet adding option " + optionId + " " + text);
    getMenu().add(Menu.NONE, optionId, Menu.NONE, text);
  }

  @Override
  public void addColumn(String text, int columnType) { }

  @Override
  public void addData(String text, int row, int column, int sheet) { }

  @Override
  public void setValue(String v) { }

  @Override
  public void setBitmap(Bitmap bitmap) { }

  @Override
  public void addImageUrl(String url, int width, int height) { }

  @Override
  public void setValue(int v) { }

  @Override
  public void reshape(int value, int size) { }

  @Override
  public void reshape(int size) { }

  @Override
  public void setViewVisibility(boolean visible) { }

  @Override
  public void setStyle(Selector selector, String key, String value) { }

  @Override
  public void setError(boolean hasError, String errorText) { }

  @Override
  public void clear() { }

  @Override
  public void flush() { }

  @Override
  public void deinitialize() {
    dismiss();
  }

  @Override
  public int getElementId() {
    return id;
  }

}

make the ActionSheet work