use of se.oort.diplicity.apigen.SingleContainer in project android-diplicity by zond.
the class UserView method setupUserDialog.
private static void setupUserDialog(final RetrofitActivity retrofitActivity, AlertDialog dialog, final SingleContainer<UserStats> userStats, final SingleContainer<Ban> ban) {
((UserStatsTable) dialog.findViewById(R.id.user_stats)).setUserStats(retrofitActivity, userStats.Properties);
((UserView) dialog.findViewById(R.id.user)).setUser(retrofitActivity, userStats.Properties.User, true);
final CheckBox bannedCheckBox = (CheckBox) dialog.findViewById(R.id.banned);
if (userStats.Properties.UserId.equals(retrofitActivity.getLoggedInUser().Id)) {
bannedCheckBox.setVisibility(GONE);
} else {
bannedCheckBox.setVisibility(VISIBLE);
bannedCheckBox.setChecked(ban != null);
bannedCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Ban ban = new Ban();
ban.UserIds = new ArrayList<String>();
ban.UserIds.add(userStats.Properties.UserId);
ban.UserIds.add(retrofitActivity.getLoggedInUser().Id);
retrofitActivity.handleReq(retrofitActivity.banService.BanCreate(ban, retrofitActivity.getLoggedInUser().Id), new Sendable<SingleContainer<Ban>>() {
@Override
public void send(SingleContainer<Ban> banSingleContainer) {
}
}, retrofitActivity.getResources().getString(R.string.updating));
} else {
retrofitActivity.handleReq(retrofitActivity.banService.BanDelete(retrofitActivity.getLoggedInUser().Id, userStats.Properties.UserId), new Sendable<SingleContainer<Ban>>() {
@Override
public void send(SingleContainer<Ban> banSingleContainer) {
}
}, retrofitActivity.getResources().getString(R.string.updating));
}
}
});
}
dialog.findViewById(R.id.muted).setVisibility(GONE);
((Button) dialog.findViewById(R.id.other_finished_game_button)).setOnClickListener(getOtherGamesClickListener(retrofitActivity, userStats.Properties.User, MainActivity.FINISHED));
((Button) dialog.findViewById(R.id.other_staging_game_button)).setOnClickListener(getOtherGamesClickListener(retrofitActivity, userStats.Properties.User, MainActivity.STAGING));
((Button) dialog.findViewById(R.id.other_started_game_button)).setOnClickListener(getOtherGamesClickListener(retrofitActivity, userStats.Properties.User, MainActivity.STARTED));
}
use of se.oort.diplicity.apigen.SingleContainer in project android-diplicity by zond.
the class PressActivity method onPostCreate.
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setContentView(R.layout.activity_press);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
byte[] serializedMember = getIntent().getByteArrayExtra(SERIALIZED_MEMBER_KEY);
if (serializedMember != null) {
member = (Member) unserialize(serializedMember);
}
byte[] serializedChannel = getIntent().getByteArrayExtra(SERIALIZED_CHANNEL_KEY);
channel = (ChannelService.Channel) unserialize(serializedChannel);
byte[] serializedGame = getIntent().getByteArrayExtra(SERIALIZED_GAME_KEY);
game = (Game) unserialize(serializedGame);
((TextView) findViewById(R.id.multi_line_title)).setText(TextUtils.join(", ", channel.Members));
if (member == null) {
findViewById(R.id.send_message_button).setVisibility(View.GONE);
findViewById(R.id.new_message_body).setVisibility(View.GONE);
} else {
final TextInputEditText body = (TextInputEditText) findViewById(R.id.new_message_body);
body.setText(prefs.getString(draftKey(), ""));
body.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
prefs.edit().putString(draftKey(), body.getText().toString()).apply();
}
});
((FloatingActionButton) findViewById(R.id.send_message_button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Message message = new Message();
message.Body = ((EditText) findViewById(R.id.new_message_body)).getText().toString();
message.ChannelMembers = channel.Members;
message.CreatedAt = new Date();
message.Age = new Ticker(new Date(), (long) 0);
message.GameID = channel.GameID;
message.Sender = member.Nation;
handleReq(messageService.MessageCreate(message, channel.GameID), new Sendable<SingleContainer<Message>>() {
@Override
public void send(SingleContainer<Message> messageSingleContainer) {
((EditText) findViewById(R.id.new_message_body)).setText("");
prefs.edit().putString(draftKey(), "").apply();
loadMessages(false);
}
}, getResources().getString(R.string.sending_message));
}
});
}
loadMessages(true);
Toast.makeText(this, R.string.all_press_becomes_public, Toast.LENGTH_SHORT).show();
}
Aggregations