diff --git a/android/android.main/src/main/java/sneer/android/ipc/PluginActivities.java b/android/android.main/src/main/java/sneer/android/ipc/PluginActivities.java index f2e746ddb..1622dc6e3 100644 --- a/android/android.main/src/main/java/sneer/android/ipc/PluginActivities.java +++ b/android/android.main/src/main/java/sneer/android/ipc/PluginActivities.java @@ -6,7 +6,6 @@ import rx.functions.Action1; import sneer.android.utils.AndroidUtils; -import sneer.convos.Convo; import sneer.convos.SessionHandle; import sneer.convos.Sessions; @@ -17,26 +16,26 @@ public class PluginActivities { - public static void start(final Context context, Plugin plugin, Convo convo) { - start(context, plugin, convo, null); + public static void start(final Context context, Plugin plugin, long convoId) { + start(context, plugin, convoId, null); } - public static void open(Context context, SessionHandle session, Convo convo) { + public static void open(Context context, SessionHandle session, long convoId) { Plugin plugin = Plugins.forSessionType(context, session.type); if (plugin == null) Toast.makeText(context, "Please install an app for " + session.type, Toast.LENGTH_LONG).show(); else - start(context, plugin, convo, session); + start(context, plugin, convoId, session); } - private static void start(final Context context, final Plugin plugin, Convo convo, SessionHandle session) { + private static void start(final Context context, final Plugin plugin, long convoId, SessionHandle session) { final Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClassName(plugin.packageName, plugin.activityName); - intent.putExtra(SEND_MESSAGE, SendMessage.intentFor(convo)); + intent.putExtra(SEND_MESSAGE, SendMessage.intentFor(convoId)); if (plugin.partnerSessionType != null && session == null) - request(Sessions.Actions.startSession(convo.id, plugin.partnerSessionType)).subscribe(new Action1() { + request(Sessions.Actions.startSession(convoId, plugin.partnerSessionType)).subscribe(new Action1() { @Override public void call(Long sessionId) { startActivity(context, intent, new SessionHandle(sessionId, plugin.partnerSessionType, true)); diff --git a/android/android.main/src/main/java/sneer/android/ipc/SendMessage.java b/android/android.main/src/main/java/sneer/android/ipc/SendMessage.java index 2f654cf23..abdcf85ac 100644 --- a/android/android.main/src/main/java/sneer/android/ipc/SendMessage.java +++ b/android/android.main/src/main/java/sneer/android/ipc/SendMessage.java @@ -4,11 +4,8 @@ import android.content.Intent; import android.util.Log; -import rx.functions.Action1; import sneer.convos.Convo; -import sneer.convos.Convos; -import static sneer.android.SneerAndroidContainer.component; import static sneer.android.SneerAndroidFlux.dispatch; public class SendMessage extends IntentService { @@ -20,10 +17,10 @@ public SendMessage() { } - static Intent intentFor(Convo convo) { + static Intent intentFor(long convoId) { return new Intent() .setClassName("sneer.main", SendMessage.class.getName()) - .putExtra(TOKEN, convo.id); + .putExtra(TOKEN, convoId); } diff --git a/android/android.main/src/main/java/sneer/android/ui/ConvoActivityWithTabs.java b/android/android.main/src/main/java/sneer/android/ui/ConvoActivityWithTabs.java index 48bf3bf09..880fc5935 100644 --- a/android/android.main/src/main/java/sneer/android/ui/ConvoActivityWithTabs.java +++ b/android/android.main/src/main/java/sneer/android/ui/ConvoActivityWithTabs.java @@ -26,10 +26,7 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.ImageButton; -import android.widget.ListView; -import android.widget.TextView; +import android.widget.*; import java.util.ArrayList; import java.util.List; @@ -37,9 +34,11 @@ import rx.Observable; import rx.Subscription; import rx.functions.Action1; +import sneer.android.ipc.PluginActivities; import sneer.convos.ChatMessage; import sneer.convos.Convo; import sneer.convos.Convos; +import sneer.convos.SessionSummary; import sneer.main.R; import static android.text.TextUtils.isEmpty; @@ -252,7 +251,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa private void setupSessionsList() { sessionsAdapter = new SessionListAdapter(this); - ((ListView) sessionsView.findViewById(R.id.sessionList)).setAdapter(sessionsAdapter); + ListView sessions = (ListView) sessionsView.findViewById(R.id.sessionList); + sessions.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + SessionSummary summary = sessionsAdapter.getItem(position); + System.out.println("=============== " + summary); + PluginActivities.open(ConvoActivityWithTabs.this, summary, convoId); + } + }); + sessions.setAdapter(sessionsAdapter); } diff --git a/android/android.main/src/main/java/sneer/android/ui/StartPluginDialogFragment.java b/android/android.main/src/main/java/sneer/android/ui/StartPluginDialogFragment.java index c7606786b..df100c488 100644 --- a/android/android.main/src/main/java/sneer/android/ui/StartPluginDialogFragment.java +++ b/android/android.main/src/main/java/sneer/android/ui/StartPluginDialogFragment.java @@ -63,7 +63,7 @@ public View getView(int position, View convertView, ViewGroup parent) { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { dialog.dismiss(); - PluginActivities.start(activity, plugins.get(position), convoProvider.getConvo()); + PluginActivities.start(activity, plugins.get(position), convoProvider.getConvo().id); }}); dialog.setView(listView, 0, 0, 0, 0);