use of com.zimincom.mafiaonline.item.ResponseItem in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class GameRoomActivity method leaveRoom.
private void leaveRoom() {
mStompClient.send("/to/access/" + roomId, gson.toJson(new ClientAccess(userName, "exit"))).subscribe();
Call<ResponseItem> call = mafiaRemoteService.leaveRoom();
call.enqueue(new Callback<ResponseItem>() {
@Override
public void onResponse(Call<ResponseItem> call, Response<ResponseItem> response) {
if (response.isSuccessful()) {
Toast.makeText(getBaseContext(), "로비로 돌아왔습니다.", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<ResponseItem> call, Throwable t) {
t.printStackTrace();
Toast.makeText(getBaseContext(), "정상적으로 처리되지 않았습니다", Toast.LENGTH_SHORT).show();
}
});
}
use of com.zimincom.mafiaonline.item.ResponseItem 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.item.ResponseItem 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.item.ResponseItem in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class RoomListActivity method createRoom.
void createRoom() {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout newRoomLayout = (LinearLayout) vi.inflate(R.layout.layout_create_room, null);
final EditText roomTitleInput = (EditText) newRoomLayout.findViewById(R.id.room_title);
new AlertDialog.Builder(this).setTitle("방 만들기").setView(newRoomLayout).setNeutralButton("확인", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Call<ResponseItem> call = mafiaRemoteService.createNewRoom(roomTitleInput.getText().toString());
call.enqueue(new Callback<ResponseItem>() {
@Override
public void onResponse(Call<ResponseItem> call, Response<ResponseItem> response) {
Logger.d("방 만들기 성공");
Intent intent = new Intent(context, GameRoomActivity.class);
intent.putExtra("user", user);
intent.putExtra("roomId", response.body().getRoomId());
intent.putExtra("userName", user.getNickName());
context.startActivity(intent);
}
@Override
public void onFailure(Call<ResponseItem> call, Throwable t) {
t.printStackTrace();
}
});
}
}).show();
}
Aggregations