use of com.zimincom.mafiaonline.item.User 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.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class PlayerAdapter method ready.
public void ready(String nickName) {
int targetPosition = 0;
for (User user : users) {
if (user.getNickName().equals(nickName)) {
if (!user.isReady()) {
user.setStatus(User.Status.READY);
notifyItemChanged(targetPosition);
break;
} else {
user.setStatus(User.Status.NOT_READY);
notifyItemChanged(targetPosition);
break;
}
}
targetPosition++;
}
}
use of com.zimincom.mafiaonline.item.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class PlayerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
int readyColor = context.getResources().getColor(R.color.colorPrimary);
User selectedUser = users.get(position);
holder.nickname.setText(users.get(position).getNickName());
if (selectedUser.isReady())
holder.readyState.setTextColor(readyColor);
if (selectedUser.isKilled()) {
Drawable overlay = context.getDrawable(R.drawable.bullet_hole);
holder.container.getOverlay().add(overlay);
}
if (selectedUser.getVoted()) {
holder.container.setSelected(true);
Logger.d("user seleted");
} else {
holder.container.setSelected(false);
}
// if day -> 타이머가 종료될때 서버에 메시지를 보낸다 .
if (gameState != null && gameState.equals("day")) {
holder.readyState.setVisibility(View.GONE);
holder.container.setOnClickListener(view -> {
if (lastVotedUser == null) {
lastVotedUser = users.get(position);
}
Logger.d("last votedUser: %s", lastVotedUser.getNickName());
lastVotedUser.setVoted(false);
lastVotedUser = users.get(position);
users.get(position).setVoted(true);
notifyDataSetChanged();
});
} else {
holder.itemView.setOnClickListener(view -> {
if (selectedUser.getNickName().equals(userName)) {
if (!selectedUser.isReady()) {
holder.readyState.setTextColor(readyColor);
selectedUser.setStatus(User.Status.READY);
handler.sendEmptyMessage(READY_MESSAGE);
Logger.d("im ready");
} else {
holder.readyState.setTextColor(Color.WHITE);
selectedUser.setStatus(User.Status.NOT_READY);
handler.sendEmptyMessage(READY_MESSAGE);
Logger.d("ready canceled");
}
}
});
}
}
use of com.zimincom.mafiaonline.item.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class PlayerAdapter method removeItemByNickName.
public void removeItemByNickName(String nickName) {
int targetPosition = 0;
for (User user : users) {
if (user.getNickName().equals(nickName)) {
Logger.d(nickName);
Logger.d(targetPosition);
users.remove(targetPosition);
notifyItemRemoved(targetPosition);
break;
}
targetPosition++;
}
}
use of com.zimincom.mafiaonline.item.User 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();
}
});
}
Aggregations