Search in sources :

Example 1 with MafiaRemoteService

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

the class RoomListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_room_list);
    mafiaRemoteService = ServiceGenerator.createService(MafiaRemoteService.class, context);
    user = (User) getIntent().getSerializableExtra("user");
    roomCreate = (Button) findViewById(R.id.create_room);
    logout = (Button) findViewById(R.id.logout);
    nickNameText = (TextView) findViewById(R.id.userName);
    roomCreate.setOnClickListener(this);
    logout.setOnClickListener(this);
    nickNameText.setText(user.getNickName());
    roomListView = (RecyclerView) findViewById(R.id.room_list);
    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    RoomAdapter roomAdapter = new RoomAdapter(context, rooms, user, R.layout.item_room);
    roomListView.setLayoutManager(layoutManager);
    roomListView.setItemAnimator(new DefaultItemAnimator());
    roomListView.setAdapter(roomAdapter);
    roomUpdateTask = new RoomUpdateTask(handler);
    timer = new Timer();
    timer.schedule(roomUpdateTask, 0, 500);
}
Also used : Timer(java.util.Timer) MafiaRemoteService(com.zimincom.mafiaonline.remote.MafiaRemoteService) RoomUpdateTask(com.zimincom.mafiaonline.tasks.RoomUpdateTask) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RoomAdapter(com.zimincom.mafiaonline.adapter.RoomAdapter) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 2 with MafiaRemoteService

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

the class SignUpActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    nickNameInput = (EditText) findViewById(R.id.nickname_input);
    emailInput = (EditText) findViewById(R.id.email_input);
    passwordInput = (EditText) findViewById(R.id.password);
    passwordCheckInput = (EditText) findViewById(R.id.password_check);
    signInButton = (Button) findViewById(R.id.signin);
    signInButton.setOnClickListener(view -> {
        String nickName = nickNameInput.getText().toString();
        String email = emailInput.getText().toString();
        String password = passwordInput.getText().toString();
        User user = new User(nickName, email, password);
        MafiaRemoteService mafiaRemoteService = ServiceGenerator.createService(MafiaRemoteService.class, getBaseContext());
        Call<ResponseItem> call = mafiaRemoteService.sendSignUpInfo(user);
        call.enqueue(new Callback<ResponseItem>() {

            @Override
            public void onResponse(Call<ResponseItem> call, Response<ResponseItem> response) {
                Logger.d(response.body());
                ResponseItem responseItem = response.body();
                if (responseItem.isOk()) {
                    Toast.makeText(context, "회원가입 성공!", Toast.LENGTH_LONG).show();
                    finish();
                } else if (responseItem.getStatus().equals("EmailExits")) {
                    Toast.makeText(context, "가입된 이메일 입니다", Toast.LENGTH_LONG).show();
                }
            }

            @Override
            public void onFailure(Call<ResponseItem> call, Throwable t) {
                t.printStackTrace();
            }
        });
    });
}
Also used : User(com.zimincom.mafiaonline.item.User) MafiaRemoteService(com.zimincom.mafiaonline.remote.MafiaRemoteService) ResponseItem(com.zimincom.mafiaonline.item.ResponseItem)

Example 3 with MafiaRemoteService

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

the class LoginActivity method sendUserData.

void sendUserData(String userEmail, String userPassword) {
    User user = new User(userEmail, userPassword);
    MafiaRemoteService mafiaRemoteService = ServiceGenerator.createService(MafiaRemoteService.class, getBaseContext());
    Call<ResponseItem> call = mafiaRemoteService.sendLoginInput(user);
    call.enqueue(new Callback<ResponseItem>() {

        @Override
        public void onResponse(Call<ResponseItem> call, Response<ResponseItem> response) {
            if (response.isSuccessful()) {
                ResponseItem responseItem = response.body();
                User user = responseItem.getUser();
                Logger.i(user.toString());
                if (responseItem.isOk()) {
                    Toast.makeText(context, user.getNickName() + "님 환영합니다 ", Toast.LENGTH_LONG).show();
                    Intent intent = new Intent(context, RoomListActivity.class);
                    intent.putExtra("user", user);
                    startActivity(intent);
                } else if (responseItem.isEmailNotFound()) {
                    Toast.makeText(context, "존재하지 않는 이메일입니다.", Toast.LENGTH_LONG).show();
                } else if (responseItem.isPasswordInvaild()) {
                    Toast.makeText(context, "잘못된 비밀번호 입니다.", Toast.LENGTH_LONG).show();
                }
            }
        }

        @Override
        public void onFailure(Call<ResponseItem> call, Throwable t) {
            Log.d("response", "error");
            t.printStackTrace();
        }
    });
}
Also used : User(com.zimincom.mafiaonline.item.User) MafiaRemoteService(com.zimincom.mafiaonline.remote.MafiaRemoteService) Intent(android.content.Intent) ResponseItem(com.zimincom.mafiaonline.item.ResponseItem)

Example 4 with MafiaRemoteService

use of com.zimincom.mafiaonline.remote.MafiaRemoteService 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)

Aggregations

MafiaRemoteService (com.zimincom.mafiaonline.remote.MafiaRemoteService)4 User (com.zimincom.mafiaonline.item.User)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 ResponseItem (com.zimincom.mafiaonline.item.ResponseItem)2 Intent (android.content.Intent)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)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 RoomAdapter (com.zimincom.mafiaonline.adapter.RoomAdapter)1 GameConfig (com.zimincom.mafiaonline.item.GameConfig)1 RoomUpdateTask (com.zimincom.mafiaonline.tasks.RoomUpdateTask)1 ArrayList (java.util.ArrayList)1 Timer (java.util.Timer)1