Search in sources :

Example 6 with User

use of com.zimincom.mafiaonline.item.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.

the class GameRoomActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game_room);
    ButterKnife.bind(this);
    toolbar.setTitle("입장대기중");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    gson = new Gson();
    mafiaRemoteService = ServiceGenerator.createService(MafiaRemoteService.class, getBaseContext());
    bgm = MediaPlayer.create(getBaseContext(), day);
    bgm.setLooping(true);
    bgm.start();
    gConfigs = new ArrayList<>();
    gConfigs.add(new GameConfig(5, GameConfig.GameState.WAITING, "시작 대기중입니다."));
    gConfigs.add(new GameConfig(60, GameConfig.GameState.DAY, "의심되는 플레이어를 선택하세요"));
    gConfigs.add(new GameConfig(5, GameConfig.GameState.WAITING, "결과 처리중입니다."));
    gConfigs.add(new GameConfig(30, GameConfig.GameState.NIGHT, "역할에 따라 선택하세요."));
    gConfigs.add(new GameConfig(5, GameConfig.GameState.WAITING, "결과 처리중입니다."));
    ArrayList<User> users = new ArrayList<>();
    messages = new ArrayList<>();
    intent = getIntent();
    user = (User) intent.getSerializableExtra("user");
    roomId = intent.getStringExtra("roomId");
    userName = intent.getStringExtra("userName");
    enterRoom(roomId);
    playerAdapter = new PlayerAdapter(getBaseContext(), users, R.layout.item_player, userName, " ", gameHandler);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getBaseContext(), 4);
    gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL);
    playerListView.setLayoutManager(gridLayoutManager);
    playerListView.setItemAnimator(new DefaultItemAnimator());
    playerListView.setAdapter(playerAdapter);
    messageAdapter = new MessageAdapter(getBaseContext(), messages, R.layout.my_chat, userName);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getBaseContext(), LinearLayoutManager.VERTICAL, false);
    messageContainer.setLayoutManager(linearLayoutManager);
    messageContainer.setItemAnimator(new DefaultItemAnimator());
    messageContainer.setAdapter(messageAdapter);
    slidingLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }

        @Override
        public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
        }
    });
    sendButton.setOnClickListener(this);
    slideButton.setOnClickListener(this);
}
Also used : MessageAdapter(com.zimincom.mafiaonline.adapter.MessageAdapter) User(com.zimincom.mafiaonline.item.User) PlayerAdapter(com.zimincom.mafiaonline.adapter.PlayerAdapter) SlidingUpPanelLayout(com.sothree.slidinguppanel.SlidingUpPanelLayout) MafiaRemoteService(com.zimincom.mafiaonline.remote.MafiaRemoteService) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GameConfig(com.zimincom.mafiaonline.item.GameConfig) GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 7 with User

use of com.zimincom.mafiaonline.item.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.

the class PlayerAdapter method addItemByNickName.

public void addItemByNickName(String nickName) {
    User user = new User(nickName, User.Status.NOT_READY);
    users.add(user);
    notifyDataSetChanged();
}
Also used : User(com.zimincom.mafiaonline.item.User)

Example 8 with User

use of com.zimincom.mafiaonline.item.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.

the class PlayerAdapter method killByNickName.

public void killByNickName(String nickName) {
    int targetPosition = 0;
    for (User user : users) {
        if (user.getNickName().equals(nickName)) {
            users.get(targetPosition).setKilled(true);
            notifyItemChanged(targetPosition);
            break;
        }
        targetPosition++;
    }
}
Also used : User(com.zimincom.mafiaonline.item.User)

Aggregations

User (com.zimincom.mafiaonline.item.User)8 MafiaRemoteService (com.zimincom.mafiaonline.remote.MafiaRemoteService)3 ResponseItem (com.zimincom.mafiaonline.item.ResponseItem)2 Intent (android.content.Intent)1 Drawable (android.graphics.drawable.Drawable)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 Gson (com.google.gson.Gson)1 SlidingUpPanelLayout (com.sothree.slidinguppanel.SlidingUpPanelLayout)1 MessageAdapter (com.zimincom.mafiaonline.adapter.MessageAdapter)1 PlayerAdapter (com.zimincom.mafiaonline.adapter.PlayerAdapter)1 GameConfig (com.zimincom.mafiaonline.item.GameConfig)1 ArrayList (java.util.ArrayList)1