package com.sometrik.framework;

import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class FWPicker extends Spinner implements NativeMessageHandler {
  
  ArrayAdapter<String> adapter;

  public FWPicker(Context context) {
    super(context);
  adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item);
  }

  @Override
  public void handleMessage(NativeMessage message) {
    

    switch(message.getMessage()){
    case ADD_OPTION:
      adapter.add(message.getTextValue());
      setAdapter(adapter);
      break;
    }
  }

  @Override
  public void showView() {
    
  }

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

}

@@ -28,16 +28,74 @@
 ork;%0D%0A%0D%0A
+import java.util.ArrayList;%0D%0Aimport java.util.TreeMap;%0D%0A%0D%0A
 import a
@@ -299,16 +299,88 @@
 dapter;%0D
+%0A  ArrayList%3CInteger%3E numberList;%0D%0A  TreeMap%3CInteger, String%3E valueMap;%0D
 %0A%0D%0A  pub
@@ -433,16 +433,18 @@
 text);%0D%0A
+  
   adapte
@@ -517,24 +517,116 @@
 ner_item);%0D%0A
+    valueMap = new TreeMap%3CInteger, String%3E();%0D%0A    numberList = new ArrayList%3CInteger%3E();%0D%0A
   %7D%0D%0A%0D%0A  @Ov
@@ -693,18 +693,16 @@
 %0D%0A    %0D%0A
-%0D%0A
     swit
@@ -703,16 +703,17 @@
   switch
+ 
 (message
@@ -726,16 +726,17 @@
 ssage())
+ 
 %7B%0D%0A    c
@@ -762,70 +762,340 @@
     
-adapter.add(message.getTextValue());%0D%0A      setAdapter(adapter
+valueMap.put(message.getValue(), message.getTextValue());%0D%0A      numberList.add(message.getValue());%0D%0A      for (int i = 0; i %3C numberList.size(); i++) %7B%0D%0A%09adapter.add(valueMap.get(numberList.get(i)));%0D%0A      %7D%0D%0A      setAdapter(adapter);%0D%0A      break;%0D%0A    default:%0D%0A      System.out.println(%22Message couldn't be handled by Picker%22
 );%0D%0A

Add adapter option number sorting