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);
}
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();
}
});
});
}
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();
}
});
}
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);
}
Aggregations