title: ionic 2 create adapter like android?
body: <p>Since 1 week i have started with ionic2 and angular2 , because i wanted to develop for android and ios at the same time. I have written a Chat application for android in Java and now i would like to write this application new in Ionic2.
  But i have one problem , namely the adapter. I have in Java an Adapter like this</p>
  
  <pre><code>public class ChatFirebaseAdapter extends FirebaseRecyclerAdapter&lt;ChatModel, ChatFirebaseAdapter.MyChatViewHolder&gt; {
  
  private static final int RIGHT_MSG = 0;
  private static final int RIGHT_MSG_LOW = 7;
  private static final int LEFT_MSG = 1;
  private static final int LEFT_MSG_LOW = 6;
  private static final int RIGHT_MSG_IMG = 2;
  private static final int LEFT_MSG_IMG = 3;
  
  public ChatFirebaseAdapter(DatabaseReference ref, String nameUser, String IdUser, ClickListenerChatFirebase mClickListenerChatFirebase, Context context, ContentResolver cr, String id) {
      super(ChatModel.class, R.layout.item_message_left, ChatFirebaseAdapter.MyChatViewHolder.class, ref);
      this.nameUser = nameUser;
      this.idUser = IdUser;
      this.mClickListenerChatFirebase = mClickListenerChatFirebase;
      this.context = context;
      this.cr = cr;
      this.groupID = id;
  
  }
  
  @Override
  public MyChatViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view;
      if (viewType == RIGHT_MSG) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right, parent, false);
          return new MyChatViewHolder(view);
      } else if (viewType == LEFT_MSG) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_left_single, parent, false);
          return new MyChatViewHolder(view);
      } else if (viewType == RIGHT_MSG_IMG) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right_img, parent, false);
          return new MyChatViewHolder(view);
      } else if (viewType == LEFT_MSG_IMG) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_left_img, parent, false);
          return new MyChatViewHolder(view);
      } else if (viewType == RIGHT_EMJI) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right_emji, parent, false);
          return new MyChatViewHolder(view);
      } else if (viewType == RIGHT_MSG_LOW) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right_low, parent, false);
          return new MyChatViewHolder(view);
      } else {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_messages_left_low, parent, false);
          return new MyChatViewHolder(view);
      }
  }
  </code></pre>
  
  <p>And populate viewholder and so on..</p>
  
  <p>And i use a Model : </p>
  
  <pre><code>public class ChatModel {
  
  private String id;
  private String user;
  private String username;
  private String userphoto;
  private boolean send;
  private boolean delivered;
  private boolean seen;
  private boolean isEmji;
  private String userModel;
  private String message;
  private String timeStamp;
  private FileModel file;
  private MapModel mapModel;
  
  public ChatModel() {
  }
  
  public ChatModel(String senderID, String message, String timeStamp, FileModel file, boolean send, boolean delivered , boolean seen ,String ID , String username , String userphoto , Boolean isEmji) {
      this.userModel = senderID;
      this.message = message;
      this.timeStamp = timeStamp;
      this.file = file;
      this.send = send;
      this.id = ID;
      this.username = username;
      this.userphoto =  userphoto;
      this.isEmji = isEmji;
      this.delivered = delivered;
      this.seen = seen;
  
  }
  
  public ChatModel(String senderID, String timeStamp, MapModel mapModel, boolean send, boolean delivered , boolean seen , String ID , String username , String userphoto , Boolean isEmji) {
      this.userModel = senderID;
      this.timeStamp = timeStamp;
      this.mapModel = mapModel;
      this.send = send;
      this.id = ID;
      this.username = username;
      this.userphoto = userphoto;
      this.isEmji = isEmji;
      this.delivered = delivered;
      this.seen = seen;
  
  } ....
  </code></pre>
  
  <p>On Android I create a new Instance and apply the adapter :</p>
  
  <pre><code>        final ListUserFirebaseAdapter firebaseAdapter = new ListUserFirebaseAdapter(mFirebaseDatabaseReference.child("users/" + id + "/Chats/").orderByChild("lastTimeStamp").getRef(), name, id , getActivity() ,this , getContext());
  
          rvListMessage.setAdapter(firebaseAdapter);
  </code></pre>
  
  <p>How can i now do this on ionic 2 ? I cannot find any suggestion on the Internet :(</p>
  
  <p>Hopefully you can help me :)
  (Sry for my bad english i´m from germany :|)</p>
  
  <p>MFG Cem</p>