blob: 2cf02ea9798cb8da0de91773c8ae812d9bf095f7 [file] [log] [blame]
Alexandre Lision666b3772013-10-28 17:42:48 -04001package org.sflphone.fragments;
2
3import org.sflphone.R;
4import org.sflphone.adapters.DiscussArrayAdapter;
5import org.sflphone.model.Conference;
6import org.sflphone.model.SipMessage;
7import org.sflphone.service.ISipService;
8
9import android.app.Activity;
10import android.app.Fragment;
11import android.content.Intent;
12import android.os.Bundle;
13import android.view.LayoutInflater;
14import android.view.View;
15import android.view.ViewGroup;
16import android.widget.ListView;
17
18public class IMFragment extends Fragment {
19 static final String TAG = CallListFragment.class.getSimpleName();
20
21 private Callbacks mCallbacks = sDummyCallbacks;
22
23 DiscussArrayAdapter mAdapter;
24 ListView list;
25
26 public static final int REQUEST_TRANSFER = 10;
27 public static final int REQUEST_CONF = 20;
28
29 @Override
30 public void onCreate(Bundle savedBundle) {
31 super.onCreate(savedBundle);
32
33 mAdapter = new DiscussArrayAdapter(getActivity());
34
35 }
36
37 /**
38 * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
39 */
40 private static Callbacks sDummyCallbacks = new Callbacks() {
41
42 @Override
43 public ISipService getService() {
44 return null;
45 }
46
47 };
48
49 /**
50 * The Activity calling this fragment has to implement this interface
51 *
52 */
53 public interface Callbacks {
54 public ISipService getService();
55
56 }
57
58 @Override
59 public void onAttach(Activity activity) {
60 super.onAttach(activity);
61
62 if (!(activity instanceof Callbacks)) {
63 throw new IllegalStateException("Activity must implement fragment's callbacks.");
64 }
65
66 mCallbacks = (Callbacks) activity;
67 }
68
69 @Override
70 public void onDetach() {
71 super.onDetach();
72 mCallbacks = sDummyCallbacks;
73 }
74
75
76
77 @Override
78 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
79 ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_imessaging, container, false);
80
81 list = (ListView) rootView.findViewById(R.id.message_list);
82 list.setAdapter(mAdapter);
83
84 return rootView;
85 }
86
87 @Override
88 public void onActivityResult(int requestCode, int resultCode, Intent data) {
89 super.onActivityResult(requestCode, resultCode, data);
90 }
91
92 public void putMessage(SipMessage msg) {
93 mAdapter.add(msg);
94 }
95}