Android Open Source - ConnectedSpace Lobby Activity






From Project

Back to project page ConnectedSpace.

License

The source code is released under:

Copyright (c) 2015, Shreyas Raman <skraman1999@gmail.com>.

If you think the Android project ConnectedSpace listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.shreyasr.connected.android.activity;
//from w  ww .  j  a va 2  s  .c  o  m
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.net.InetAddress;
import java.net.UnknownHostException;

import me.shreyasr.connected.android.R;
import me.shreyasr.connected.android.networking.ConnectionThread;
import me.shreyasr.connected.android.networking.LobbyManager;
import me.shreyasr.connected.android.util.Client;

public class LobbyActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lobby);

        ListView listView = (ListView) this.findViewById(R.id.client_list);
        final ClientListAdapter adapter = new ClientListAdapter(this);
        listView.setAdapter(adapter);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Client client = (Client) adapter.getItem(position);
                try {
                    new Thread(new ConnectionThread(LobbyActivity.this, InetAddress.getByName(client.ip))).start();
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                }
            }
        });

        new LobbyManager(this, adapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_lobby, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

me.shreyasr.connected.ConnectedSpace.java
me.shreyasr.connected.android.AndroidLauncher.java
me.shreyasr.connected.android.activity.ClientListAdapter.java
me.shreyasr.connected.android.activity.LobbyActivity.java
me.shreyasr.connected.android.networking.BroadcastListenerThread.java
me.shreyasr.connected.android.networking.ConnectionThread.java
me.shreyasr.connected.android.networking.HeartbeatThread.java
me.shreyasr.connected.android.networking.LobbyManager.java
me.shreyasr.connected.android.networking.ServerSocketThread.java
me.shreyasr.connected.android.util.AndroidAddressUtils.java
me.shreyasr.connected.android.util.Client.java
me.shreyasr.connected.desktop.DesktopLauncher.java
me.shreyasr.connected.entities.Laser.java
me.shreyasr.connected.entities.Star.java
me.shreyasr.connected.network.NetworkHandler.java
me.shreyasr.connected.util.MathHelper.java
me.shreyasr.connected.util.SpriteSheet.java