Remove redundant casts from findViewById.

This commit is contained in:
akwizgran
2017-10-11 18:22:14 +01:00
parent b56724dee5
commit 43ee3246f6
63 changed files with 218 additions and 232 deletions

View File

@@ -38,7 +38,7 @@ public class StartupFailureActivity extends BaseActivity {
}
// show proper error message
TextView view = (TextView) findViewById(R.id.errorView);
TextView view = findViewById(R.id.errorView);
if (result.equals(StartResult.DB_ERROR)) {
view.setText(getText(R.string.startup_failed_db_error));
} else if (result.equals(StartResult.SERVICE_ERROR)) {

View File

@@ -85,7 +85,7 @@ public abstract class BriarActivity extends BaseActivity {
@Nullable
protected Toolbar setUpCustomToolbar(boolean ownLayout) {
// Custom Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar ab = getSupportActionBar();
if (ab != null) {

View File

@@ -58,7 +58,7 @@ abstract class BasePostFragment extends BaseFragment {
View view = inflater.inflate(R.layout.fragment_blog_post, container,
false);
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
progressBar = view.findViewById(R.id.progressBar);
progressBar.setVisibility(VISIBLE);
ui = new BlogPostViewHolder(view, true, new OnBlogPostClickListener() {
@Override

View File

@@ -92,7 +92,7 @@ public class BlogFragment extends BaseFragment
View v = inflater.inflate(R.layout.fragment_blog, container, false);
adapter = new BlogPostAdapter(getActivity(), this);
list = (BriarRecyclerView) v.findViewById(R.id.postList);
list = v.findViewById(R.id.postList);
list.setLayoutManager(new LinearLayoutManager(getActivity()));
list.setAdapter(adapter);
list.showProgressBar();

View File

@@ -59,13 +59,12 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
this.listener = listener;
ctx = v.getContext();
layout = (ViewGroup) v.findViewById(R.id.postLayout);
reblogger = (AuthorView) v.findViewById(R.id.rebloggerView);
author = (AuthorView) v.findViewById(R.id.authorView);
reblogButton = (ImageView) v.findViewById(R.id.commentView);
body = (TextView) v.findViewById(R.id.bodyView);
commentContainer =
(ViewGroup) v.findViewById(R.id.commentContainer);
layout = v.findViewById(R.id.postLayout);
reblogger = v.findViewById(R.id.rebloggerView);
author = v.findViewById(R.id.authorView);
reblogButton = v.findViewById(R.id.commentView);
body = v.findViewById(R.id.bodyView);
commentContainer = v.findViewById(R.id.commentContainer);
}
void setVisibility(int visibility) {
@@ -135,7 +134,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
ActivityOptionsCompat options =
makeSceneTransitionAnimation((Activity) ctx, layout,
getTransitionName(item.getId()));
ActivityCompat.startActivity((Activity) ctx, i,
ActivityCompat.startActivity(ctx, i,
options.toBundle());
} else {
// work-around for android bug #224270
@@ -173,8 +172,8 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
.inflate(R.layout.list_item_blog_comment,
commentContainer, false);
AuthorView author = (AuthorView) v.findViewById(R.id.authorView);
TextView body = (TextView) v.findViewById(R.id.bodyView);
AuthorView author = v.findViewById(R.id.authorView);
TextView body = v.findViewById(R.id.bodyView);
author.setAuthor(c.getAuthor());
author.setAuthorStatus(c.getAuthorStatus());

View File

@@ -77,7 +77,7 @@ public class FeedFragment extends BaseFragment implements
adapter = new BlogPostAdapter(getActivity(), this);
layoutManager = new LinearLayoutManager(getActivity());
list = (BriarRecyclerView) v.findViewById(R.id.postList);
list = v.findViewById(R.id.postList);
list.setLayoutManager(layoutManager);
list.setAdapter(adapter);
list.setEmptyText(R.string.blogs_feed_empty_state);

View File

@@ -154,8 +154,8 @@ public class ReblogFragment extends BaseFragment implements TextInputListener {
private final TextInputView input;
private ViewHolder(View v) {
scrollView = (ScrollView) v.findViewById(R.id.scrollView);
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
scrollView = v.findViewById(R.id.scrollView);
progressBar = v.findViewById(R.id.progressBar);
post = new BlogPostViewHolder(v.findViewById(R.id.postLayout),
true, new OnBlogPostClickListener() {
@Override
@@ -168,7 +168,7 @@ public class ReblogFragment extends BaseFragment implements TextInputListener {
// probably don't want to allow author clicks here
}
});
input = (TextInputView) v.findViewById(R.id.inputText);
input = v.findViewById(R.id.inputText);
}
}
}

View File

@@ -104,13 +104,13 @@ class RssFeedAdapter extends BriarAdapter<Feed, RssFeedAdapter.FeedViewHolder> {
super(v);
layout = v;
title = (TextView) v.findViewById(R.id.titleView);
delete = (ImageButton) v.findViewById(R.id.deleteButton);
imported = (TextView) v.findViewById(R.id.importedView);
updated = (TextView) v.findViewById(R.id.updatedView);
author = (TextView) v.findViewById(R.id.authorView);
authorLabel = (TextView) v.findViewById(R.id.author);
description = (TextView) v.findViewById(R.id.descriptionView);
title = v.findViewById(R.id.titleView);
delete = v.findViewById(R.id.deleteButton);
imported = v.findViewById(R.id.importedView);
updated = v.findViewById(R.id.updatedView);
author = v.findViewById(R.id.authorView);
authorLabel = v.findViewById(R.id.author);
description = v.findViewById(R.id.descriptionView);
}
}

View File

@@ -54,7 +54,7 @@ public class RssFeedImportActivity extends BriarActivity {
setContentView(R.layout.activity_rss_feed_import);
urlInput = (EditText) findViewById(R.id.urlInput);
urlInput = findViewById(R.id.urlInput);
urlInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
@@ -72,10 +72,10 @@ public class RssFeedImportActivity extends BriarActivity {
}
});
importButton = (Button) findViewById(R.id.importButton);
importButton = findViewById(R.id.importButton);
importButton.setOnClickListener(v -> publish());
progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar = findViewById(R.id.progressBar);
}
@Override

View File

@@ -49,7 +49,7 @@ public class RssFeedManageActivity extends BriarActivity
adapter = new RssFeedAdapter(this, this);
list = (BriarRecyclerView) findViewById(R.id.feedList);
list = findViewById(R.id.feedList);
list.setLayoutManager(new LinearLayoutManager(this));
list.setAdapter(adapter);
}

View File

@@ -69,7 +69,7 @@ public class WriteBlogPostActivity extends BriarActivity
setContentView(R.layout.activity_write_blog_post);
input = (TextInputView) findViewById(R.id.bodyInput);
input = findViewById(R.id.bodyInput);
input.setSendButtonEnabled(false);
input.addTextChangedListener(new TextWatcher() {
@Override
@@ -89,7 +89,7 @@ public class WriteBlogPostActivity extends BriarActivity
});
input.setListener(this);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar = findViewById(R.id.progressBar);
}
@Override

View File

@@ -31,10 +31,10 @@ public class ContactItemViewHolder<I extends ContactItem>
super(v);
layout = (ViewGroup) v;
avatar = (ImageView) v.findViewById(R.id.avatarView);
name = (TextView) v.findViewById(R.id.nameView);
avatar = v.findViewById(R.id.avatarView);
name = v.findViewById(R.id.nameView);
// this can be null as not all layouts that use this ViewHolder have it
bulb = (ImageView) v.findViewById(R.id.bulbView);
bulb = v.findViewById(R.id.bulbView);
}
protected void bind(I item, @Nullable OnContactClickListener<I> listener) {

View File

@@ -143,7 +143,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
}
};
adapter = new ContactListAdapter(getContext(), onContactClickListener);
list = (BriarRecyclerView) contentView.findViewById(R.id.list);
list = contentView.findViewById(R.id.list);
list.setLayoutManager(new LinearLayoutManager(getContext()));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.no_contacts));

View File

@@ -24,8 +24,8 @@ class ContactListItemViewHolder extends ContactItemViewHolder<ContactListItem> {
ContactListItemViewHolder(View v) {
super(v);
unread = (TextView) v.findViewById(R.id.unreadCountView);
date = (TextView) v.findViewById(R.id.dateView);
unread = v.findViewById(R.id.unreadCountView);
date = v.findViewById(R.id.dateView);
}
@Override

View File

@@ -14,7 +14,6 @@ import android.util.SparseArray;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -100,7 +99,7 @@ import javax.inject.Inject;
import de.hdodenhof.circleimageview.CircleImageView;
import im.delight.android.identicons.IdenticonDrawable;
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt;
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt.OnHidePromptListener;
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt.PromptStateChangeListener;
import static android.support.v4.view.ViewCompat.setTransitionName;
import static android.support.v7.util.SortedList.INVALID_POSITION;
@@ -112,6 +111,8 @@ import static org.briarproject.briar.android.settings.SettingsFragment.SETTINGS_
import static org.briarproject.briar.android.util.UiUtils.getAvatarTransitionName;
import static org.briarproject.briar.android.util.UiUtils.getBulbTransitionName;
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
import static uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt.STATE_DISMISSED;
import static uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt.STATE_FINISHED;
@MethodsNotNullByDefault
@ParametersNotNullByDefault
@@ -199,23 +200,21 @@ public class ConversationActivity extends BriarActivity
// Custom Toolbar
toolbar = setUpCustomToolbar(true);
if (toolbar != null) {
toolbarAvatar =
(CircleImageView) toolbar.findViewById(R.id.contactAvatar);
toolbarStatus =
(ImageView) toolbar.findViewById(R.id.contactStatus);
toolbarTitle = (TextView) toolbar.findViewById(R.id.contactName);
toolbarAvatar = toolbar.findViewById(R.id.contactAvatar);
toolbarStatus = toolbar.findViewById(R.id.contactStatus);
toolbarTitle = toolbar.findViewById(R.id.contactName);
}
setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId));
setTransitionName(toolbarStatus, getBulbTransitionName(contactId));
adapter = new ConversationAdapter(this, this);
list = (BriarRecyclerView) findViewById(R.id.conversationView);
list = findViewById(R.id.conversationView);
list.setLayoutManager(new LinearLayoutManager(this));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.no_private_messages));
textInputView = (TextInputView) findViewById(R.id.text_input_container);
textInputView = findViewById(R.id.text_input_container);
textInputView.setListener(this);
}
@@ -393,7 +392,7 @@ public class ConversationActivity extends BriarActivity
/**
* Creates ConversationItems from headers loaded from the database.
*
* <p>
* Attention: Call this only after contactName has been initialized.
*/
@SuppressWarnings("ConstantConditions")
@@ -562,6 +561,7 @@ public class ConversationActivity extends BriarActivity
addConversationItem(item);
});
}
@Override
public void onFailure(Throwable exception) {
runOnUiThreadUnlessDestroyed(
@@ -580,6 +580,7 @@ public class ConversationActivity extends BriarActivity
addConversationItem(item);
});
}
@Override
public void onFailure(Throwable exception) {
runOnUiThreadUnlessDestroyed(
@@ -598,6 +599,7 @@ public class ConversationActivity extends BriarActivity
addConversationItem(item);
});
}
@Override
public void onFailure(Throwable exception) {
runOnUiThreadUnlessDestroyed(
@@ -616,6 +618,7 @@ public class ConversationActivity extends BriarActivity
addConversationItem(item);
});
}
@Override
public void onFailure(Throwable exception) {
runOnUiThreadUnlessDestroyed(
@@ -778,25 +781,25 @@ public class ConversationActivity extends BriarActivity
return;
}
OnHidePromptListener listener = new OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent motionEvent,
boolean focalClicked) {
introductionOnboardingSeen();
}
PromptStateChangeListener listener = new PromptStateChangeListener() {
@Override
public void onPromptStateChanged(
MaterialTapTargetPrompt prompt, int state) {
if (state == STATE_DISMISSED ||
state == STATE_FINISHED) {
introductionOnboardingSeen();
}
}
};
new MaterialTapTargetPrompt.Builder(ConversationActivity.this,
R.style.OnboardingDialogTheme).setTarget(target)
.setPrimaryText(R.string.introduction_onboarding_title)
.setSecondaryText(R.string.introduction_onboarding_text)
.setIcon(R.drawable.ic_more_vert_accent)
.setPromptStateChangeListener(listener)
.show();
@Override
public void onHidePromptComplete() {
}
};
new MaterialTapTargetPrompt.Builder(ConversationActivity.this)
.setTarget(target)
.setPrimaryText(R.string.introduction_onboarding_title)
.setSecondaryText(R.string.introduction_onboarding_text)
.setBackgroundColourFromRes(R.color.briar_primary)
.setIcon(R.drawable.ic_more_vert_accent)
.setOnHidePromptListener(listener)
.show();
});
}

View File

@@ -22,9 +22,9 @@ class ConversationItemViewHolder extends ViewHolder {
ConversationItemViewHolder(View v) {
super(v);
layout = (ViewGroup) v.findViewById(R.id.layout);
text = (TextView) v.findViewById(R.id.text);
time = (TextView) v.findViewById(R.id.time);
layout = v.findViewById(R.id.layout);
text = v.findViewById(R.id.text);
time = v.findViewById(R.id.time);
}
@CallSuper

View File

@@ -19,7 +19,7 @@ class ConversationNoticeInViewHolder extends ConversationItemViewHolder {
ConversationNoticeInViewHolder(View v) {
super(v);
msgText = (TextView) v.findViewById(R.id.msgText);
msgText = v.findViewById(R.id.msgText);
}
@Override

View File

@@ -19,7 +19,7 @@ class ConversationNoticeOutViewHolder extends ConversationOutItemViewHolder {
ConversationNoticeOutViewHolder(View v) {
super(v);
msgText = (TextView) v.findViewById(R.id.msgText);
msgText = v.findViewById(R.id.msgText);
}
@Override

View File

@@ -16,7 +16,7 @@ abstract class ConversationOutItemViewHolder
ConversationOutItemViewHolder(View v) {
super(v);
status = (ImageView) v.findViewById(R.id.status);
status = v.findViewById(R.id.status);
}
@Override

View File

@@ -20,8 +20,8 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
ConversationRequestViewHolder(View v) {
super(v);
acceptButton = (Button) v.findViewById(R.id.acceptButton);
declineButton = (Button) v.findViewById(R.id.declineButton);
acceptButton = v.findViewById(R.id.acceptButton);
declineButton = v.findViewById(R.id.declineButton);
}
void bind(ConversationItem conversationItem,

View File

@@ -67,7 +67,7 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
View contentView = inflater.inflate(R.layout.list, container, false);
list = (BriarRecyclerView) contentView.findViewById(R.id.list);
list = contentView.findViewById(R.id.list);
list.setLayoutManager(new LinearLayoutManager(getActivity()));
list.setEmptyText(getString(R.string.no_contacts_selector));
adapter = getAdapter(getContext(), this);

View File

@@ -24,8 +24,8 @@ public class BaseSelectableContactHolder<I extends SelectableContactItem>
public BaseSelectableContactHolder(View v) {
super(v);
checkBox = (CheckBox) v.findViewById(R.id.checkBox);
info = (TextView) v.findViewById(R.id.infoView);
checkBox = v.findViewById(R.id.checkBox);
info = v.findViewById(R.id.infoView);
}
@Override

View File

@@ -54,9 +54,8 @@ public class CreateForumActivity extends BriarActivity {
setContentView(R.layout.activity_create_forum);
nameEntryLayout =
(TextInputLayout) findViewById(R.id.createForumNameLayout);
nameEntry = (EditText) findViewById(R.id.createForumNameEntry);
nameEntryLayout = findViewById(R.id.createForumNameLayout);
nameEntry = findViewById(R.id.createForumNameEntry);
nameEntry.addTextChangedListener(new TextWatcher() {
@Override
@@ -79,10 +78,10 @@ public class CreateForumActivity extends BriarActivity {
return true;
});
createForumButton = (Button) findViewById(R.id.createForumButton);
createForumButton = findViewById(R.id.createForumButton);
createForumButton.setOnClickListener(v -> createForum());
progress = (ProgressBar) findViewById(R.id.createForumProgressBar);
progress = findViewById(R.id.createForumProgressBar);
}
@Override

View File

@@ -133,10 +133,10 @@ class ForumListAdapter
super(v);
layout = (ViewGroup) v;
avatar = (TextAvatarView) v.findViewById(R.id.avatarView);
name = (TextView) v.findViewById(R.id.forumNameView);
postCount = (TextView) v.findViewById(R.id.postCountView);
date = (TextView) v.findViewById(R.id.dateView);
avatar = v.findViewById(R.id.avatarView);
name = v.findViewById(R.id.forumNameView);
postCount = v.findViewById(R.id.postCountView);
date = v.findViewById(R.id.dateView);
}
}
}

View File

@@ -92,7 +92,7 @@ public class ForumListFragment extends BaseEventFragment implements
adapter = new ForumListAdapter(getActivity());
list = (BriarRecyclerView) contentView.findViewById(R.id.forumList);
list = contentView.findViewById(R.id.forumList);
list.setLayoutManager(new LinearLayoutManager(getActivity()));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.no_forums));

View File

@@ -78,7 +78,7 @@ public class ContactChooserFragment extends BaseFragment {
};
adapter = new ContactListAdapter(getActivity(), onContactClickListener);
list = (BriarRecyclerView) contentView.findViewById(R.id.list);
list = contentView.findViewById(R.id.list);
list.setLayoutManager(new LinearLayoutManager(getActivity()));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.no_contacts));

View File

@@ -211,13 +211,12 @@ public class IntroductionMessageFragment extends BaseFragment
private final TextInputView message;
private ViewHolder(View v) {
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
avatar1 = (CircleImageView) v.findViewById(R.id.avatarContact1);
avatar2 = (CircleImageView) v.findViewById(R.id.avatarContact2);
contactName1 = (TextView) v.findViewById(R.id.nameContact1);
contactName2 = (TextView) v.findViewById(R.id.nameContact2);
message = (TextInputView) v
.findViewById(R.id.introductionMessageView);
progressBar = v.findViewById(R.id.progressBar);
avatar1 = v.findViewById(R.id.avatarContact1);
avatar2 = v.findViewById(R.id.avatarContact2);
contactName1 = v.findViewById(R.id.nameContact1);
contactName2 = v.findViewById(R.id.nameContact2);
message = v.findViewById(R.id.introductionMessageView);
}
}
}

View File

@@ -63,7 +63,7 @@ public class IntroFragment extends BaseFragment {
View v = inflater.inflate(R.layout.fragment_keyagreement_id, container,
false);
scrollView = (ScrollView) v.findViewById(R.id.scrollView);
scrollView = v.findViewById(R.id.scrollView);
View button = v.findViewById(R.id.continueButton);
button.setOnClickListener(view -> screenSeenListener.showNextScreen());
return v;

View File

@@ -75,7 +75,7 @@ public class KeyAgreementActivity extends BriarActivity implements
super.onCreate(state);
setContentView(R.layout.activity_fragment_container_toolbar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@@ -124,14 +124,12 @@ public class ShowQrCodeFragment extends BaseEventFragment
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
cameraView = (CameraView) view.findViewById(R.id.camera_view);
cameraView = view.findViewById(R.id.camera_view);
statusView = view.findViewById(R.id.status_container);
status = (TextView) view.findViewById(R.id.connect_status);
qrCode = (ImageView) view.findViewById(R.id.qr_code);
mainProgressTitle =
(TextView) view.findViewById(R.id.title_progress_bar);
mainProgressContainer =
(ViewGroup) view.findViewById(R.id.container_progress);
status = view.findViewById(R.id.connect_status);
qrCode = view.findViewById(R.id.qr_code);
mainProgressTitle = view.findViewById(R.id.title_progress_bar);
mainProgressContainer = view.findViewById(R.id.container_progress);
}
@Override

View File

@@ -35,11 +35,9 @@ public class AuthorNameFragment extends SetupFragment {
getActivity().setTitle(getString(R.string.setup_title));
View v = inflater.inflate(R.layout.fragment_setup_author_name,
container, false);
authorNameWrapper =
(TextInputLayout) v.findViewById(R.id.nickname_entry_wrapper);
authorNameInput =
(TextInputEditText) v.findViewById(R.id.nickname_entry);
nextButton = (Button) v.findViewById(R.id.next);
authorNameWrapper = v.findViewById(R.id.nickname_entry_wrapper);
authorNameInput = v.findViewById(R.id.nickname_entry);
nextButton = v.findViewById(R.id.next);
authorNameInput.addTextChangedListener(this);
nextButton.setOnClickListener(this);

View File

@@ -49,20 +49,16 @@ public class ChangePasswordActivity extends BaseActivity
setContentView(R.layout.activity_change_password);
currentPasswordEntryWrapper =
(TextInputLayout) findViewById(
R.id.current_password_entry_wrapper);
newPasswordEntryWrapper =
(TextInputLayout) findViewById(R.id.new_password_entry_wrapper);
findViewById(R.id.current_password_entry_wrapper);
newPasswordEntryWrapper = findViewById(R.id.new_password_entry_wrapper);
newPasswordConfirmationWrapper =
(TextInputLayout) findViewById(
R.id.new_password_confirm_wrapper);
currentPassword = (EditText) findViewById(R.id.current_password_entry);
newPassword = (EditText) findViewById(R.id.new_password_entry);
newPasswordConfirmation =
(EditText) findViewById(R.id.new_password_confirm);
strengthMeter = (StrengthMeter) findViewById(R.id.strength_meter);
changePasswordButton = (Button) findViewById(R.id.change_password);
progress = (ProgressBar) findViewById(R.id.progress_wheel);
findViewById(R.id.new_password_confirm_wrapper);
currentPassword = findViewById(R.id.current_password_entry);
newPassword = findViewById(R.id.new_password_entry);
newPasswordConfirmation = findViewById(R.id.new_password_confirm);
strengthMeter = findViewById(R.id.strength_meter);
changePasswordButton = findViewById(R.id.change_password);
progress = findViewById(R.id.progress_wheel);
TextWatcher tw = new TextWatcher() {

View File

@@ -37,8 +37,8 @@ public class DozeFragment extends SetupFragment {
getActivity().setTitle(getString(R.string.setup_doze_title));
View v = inflater.inflate(R.layout.fragment_setup_doze, container,
false);
dozeButton = (Button) v.findViewById(R.id.dozeButton);
progressBar = (ProgressBar) v.findViewById(R.id.progress);
dozeButton = v.findViewById(R.id.dozeButton);
progressBar = v.findViewById(R.id.progress);
dozeButton.setOnClickListener(view -> askForDozeWhitelisting());

View File

@@ -53,10 +53,10 @@ public class PasswordActivity extends BaseActivity {
}
setContentView(R.layout.activity_password);
signInButton = (Button) findViewById(R.id.btn_sign_in);
progress = (ProgressBar) findViewById(R.id.progress_wheel);
input = (TextInputLayout) findViewById(R.id.password_layout);
password = (EditText) findViewById(R.id.edit_password);
signInButton = findViewById(R.id.btn_sign_in);
progress = findViewById(R.id.progress_wheel);
input = findViewById(R.id.password_layout);
password = findViewById(R.id.edit_password);
password.setOnEditorActionListener((v, actionId, event) -> {
validatePassword();
return true;

View File

@@ -40,16 +40,14 @@ public class PasswordFragment extends SetupFragment {
View v = inflater.inflate(R.layout.fragment_setup_password, container,
false);
strengthMeter = (StrengthMeter) v.findViewById(R.id.strength_meter);
passwordEntryWrapper =
(TextInputLayout) v.findViewById(R.id.password_entry_wrapper);
passwordEntry = (TextInputEditText) v.findViewById(R.id.password_entry);
strengthMeter = v.findViewById(R.id.strength_meter);
passwordEntryWrapper = v.findViewById(R.id.password_entry_wrapper);
passwordEntry = v.findViewById(R.id.password_entry);
passwordConfirmationWrapper =
(TextInputLayout) v.findViewById(R.id.password_confirm_wrapper);
passwordConfirmation =
(TextInputEditText) v.findViewById(R.id.password_confirm);
nextButton = (Button) v.findViewById(R.id.next);
progressBar = (ProgressBar) v.findViewById(R.id.progress);
v.findViewById(R.id.password_confirm_wrapper);
passwordConfirmation = v.findViewById(R.id.password_confirm);
nextButton = v.findViewById(R.id.next);
progressBar = v.findViewById(R.id.progress);
passwordEntry.addTextChangedListener(this);
passwordConfirmation.addTextChangedListener(this);

View File

@@ -113,10 +113,10 @@ public class NavDrawerActivity extends BriarActivity implements
exitIfStartupFailed(getIntent());
setContentView(R.layout.activity_nav_drawer);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigation = (NavigationView) findViewById(R.id.navigation);
GridView transportsView = (GridView) findViewById(R.id.transportsView);
Toolbar toolbar = findViewById(R.id.toolbar);
drawerLayout = findViewById(R.id.drawer_layout);
navigation = findViewById(R.id.navigation);
GridView transportsView = findViewById(R.id.transportsView);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -282,12 +282,12 @@ public class NavDrawerActivity extends BriarActivity implements
if (daysUntilExpiry < 0) signOut();
// show expiry warning text
ViewGroup expiryWarning = (ViewGroup) findViewById(R.id.expiryWarning);
ViewGroup expiryWarning = findViewById(R.id.expiryWarning);
TextView expiryWarningText =
(TextView) expiryWarning.findViewById(R.id.expiryWarningText);
expiryWarning.findViewById(R.id.expiryWarningText);
// make close button functional
ImageView expiryWarningClose =
(ImageView) expiryWarning.findViewById(R.id.expiryWarningClose);
expiryWarning.findViewById(R.id.expiryWarningClose);
// show a different snackbar in green if this is an update
if (expiry == UPDATE) {
@@ -388,12 +388,12 @@ public class NavDrawerActivity extends BriarActivity implements
android.R.color.tertiary_text_light);
}
ImageView icon = (ImageView) view.findViewById(R.id.imageView);
ImageView icon = view.findViewById(R.id.imageView);
icon.setImageDrawable(ContextCompat
.getDrawable(NavDrawerActivity.this, t.iconId));
icon.setColorFilter(c);
TextView text = (TextView) view.findViewById(R.id.textView);
TextView text = view.findViewById(R.id.textView);
text.setText(getString(t.textId));
return view;

View File

@@ -43,7 +43,7 @@ public class CreateGroupFragment extends BaseFragment {
View v = inflater.inflate(R.layout.fragment_create_group, container,
false);
nameEntry = (EditText) v.findViewById(R.id.name);
nameEntry = v.findViewById(R.id.name);
nameEntry.addTextChangedListener(new TextWatcher() {
@Override
@@ -66,12 +66,12 @@ public class CreateGroupFragment extends BaseFragment {
return true;
});
nameLayout = (TextInputLayout) v.findViewById(R.id.nameLayout);
nameLayout = v.findViewById(R.id.nameLayout);
createGroupButton = (Button) v.findViewById(R.id.button);
createGroupButton = v.findViewById(R.id.button);
createGroupButton.setOnClickListener(v1 -> createGroup());
progress = (ProgressBar) v.findViewById(R.id.progressBar);
progress = v.findViewById(R.id.progressBar);
return v;
}

View File

@@ -68,7 +68,7 @@ public class GroupListFragment extends BaseFragment implements
View v = inflater.inflate(R.layout.list, container, false);
adapter = new GroupListAdapter(getContext(), this);
list = (BriarRecyclerView) v.findViewById(R.id.list);
list = v.findViewById(R.id.list);
list.setEmptyText(R.string.groups_list_empty);
list.setLayoutManager(new LinearLayoutManager(getContext()));
list.setAdapter(adapter);

View File

@@ -41,13 +41,13 @@ class GroupViewHolder extends RecyclerView.ViewHolder {
super(v);
layout = (ViewGroup) v;
avatar = (TextAvatarView) v.findViewById(R.id.avatarView);
name = (TextView) v.findViewById(R.id.nameView);
creator = (TextView) v.findViewById(R.id.creatorView);
postCount = (TextView) v.findViewById(R.id.messageCountView);
date = (TextView) v.findViewById(R.id.dateView);
status = (TextView) v.findViewById(R.id.statusView);
remove = (Button) v.findViewById(R.id.removeButton);
avatar = v.findViewById(R.id.avatarView);
name = v.findViewById(R.id.nameView);
creator = v.findViewById(R.id.creatorView);
postCount = v.findViewById(R.id.messageCountView);
date = v.findViewById(R.id.dateView);
status = v.findViewById(R.id.statusView);
remove = v.findViewById(R.id.removeButton);
}
void bindView(Context ctx, GroupItem group,

View File

@@ -48,13 +48,13 @@ public class GroupMemberListActivity extends BriarActivity {
if (b == null) throw new IllegalStateException("No GroupId in intent.");
groupId = new GroupId(b);
list = (BriarRecyclerView) findViewById(R.id.list);
list = findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
list.setLayoutManager(linearLayoutManager);
adapter = new MemberListAdapter(this);
list.setAdapter(adapter);
TextView info = (TextView) findViewById(R.id.info);
TextView info = findViewById(R.id.info);
info.setText(R.string.sharing_status_groups);
}

View File

@@ -22,9 +22,9 @@ class MemberListItemHolder extends RecyclerView.ViewHolder {
MemberListItemHolder(View v) {
super(v);
author = (AuthorView) v.findViewById(R.id.authorView);
bulb = (ImageView) v.findViewById(R.id.bulbView);
creator = (TextView) v.findViewById(R.id.creatorView);
author = v.findViewById(R.id.authorView);
bulb = v.findViewById(R.id.bulbView);
creator = v.findViewById(R.id.creatorView);
}
protected void bind(MemberListItem item) {

View File

@@ -52,7 +52,7 @@ public class RevealContactsActivity extends ContactSelectorActivity
if (b == null) throw new IllegalStateException("No GroupId");
groupId = new GroupId(b);
button = (Button) findViewById(R.id.revealButton);
button = findViewById(R.id.revealButton);
button.setOnClickListener(this);
button.setEnabled(false);

View File

@@ -25,7 +25,7 @@ class RevealableContactViewHolder
RevealableContactViewHolder(View v) {
super(v);
icon = (ImageView) v.findViewById(R.id.visibilityView);
icon = v.findViewById(R.id.visibilityView);
}
@Override

View File

@@ -90,15 +90,15 @@ public class DevReportActivity extends BaseCrashReportDialog
getDelegate().setContentView(R.layout.activity_dev_report);
Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
Toolbar tb = findViewById(R.id.toolbar);
getDelegate().setSupportActionBar(tb);
View requestReport = findViewById(R.id.request_report);
userCommentView = (EditText) findViewById(R.id.user_comment);
userEmailView = (EditText) findViewById(R.id.user_email);
includeDebugReport = (CheckBox) findViewById(R.id.include_debug_report);
chevron = (Button) findViewById(R.id.chevron);
report = (LinearLayout) findViewById(R.id.report_content);
userCommentView = findViewById(R.id.user_comment);
userEmailView = findViewById(R.id.user_email);
includeDebugReport = findViewById(R.id.include_debug_report);
chevron = findViewById(R.id.chevron);
report = findViewById(R.id.report_content);
progress = findViewById(R.id.progress_wheel);
//noinspection ConstantConditions
@@ -262,7 +262,7 @@ public class DevReportActivity extends BaseCrashReportDialog
boolean excluded = excludedFields.contains(field);
View v = inflater.inflate(R.layout.list_item_crash,
report, false);
CheckBox cb = (CheckBox) v
CheckBox cb = v
.findViewById(R.id.include_in_report);
cb.setTag(field);
cb.setChecked(required || !excluded);

View File

@@ -40,7 +40,7 @@ public abstract class BaseMessageFragment extends BaseFragment
// inflate view
View v = inflater.inflate(R.layout.fragment_message, container,
false);
message = (LargeTextInputView) v.findViewById(R.id.messageView);
message = v.findViewById(R.id.messageView);
message.setButtonText(getString(getButtonText()));
message.setHint(getHintText());
message.setListener(this);

View File

@@ -44,7 +44,7 @@ public abstract class InvitationActivity<I extends InvitationItem>
setContentView(R.layout.list);
adapter = getAdapter(this, this);
list = (BriarRecyclerView) findViewById(R.id.list);
list = findViewById(R.id.list);
if (list != null) {
list.setLayoutManager(new LinearLayoutManager(this));
list.setAdapter(adapter);

View File

@@ -29,12 +29,12 @@ public class InvitationViewHolder<I extends InvitationItem>
public InvitationViewHolder(View v) {
super(v);
avatar = (TextAvatarView) v.findViewById(R.id.avatarView);
name = (TextView) v.findViewById(R.id.forumNameView);
sharedBy = (TextView) v.findViewById(R.id.sharedByView);
subscribed = (TextView) v.findViewById(R.id.forumSubscribedView);
accept = (Button) v.findViewById(R.id.acceptButton);
decline = (Button) v.findViewById(R.id.declineButton);
avatar = v.findViewById(R.id.avatarView);
name = v.findViewById(R.id.forumNameView);
sharedBy = v.findViewById(R.id.sharedByView);
subscribed = v.findViewById(R.id.forumSubscribedView);
accept = v.findViewById(R.id.acceptButton);
decline = v.findViewById(R.id.declineButton);
}
@CallSuper

View File

@@ -54,13 +54,13 @@ abstract class SharingStatusActivity extends BriarActivity {
if (b == null) throw new IllegalStateException("No GroupId");
groupId = new GroupId(b);
list = (BriarRecyclerView) findViewById(R.id.list);
list = findViewById(R.id.list);
adapter = new SharingStatusAdapter(this);
list.setLayoutManager(new LinearLayoutManager(this));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.nobody));
TextView info = (TextView) findViewById(R.id.info);
TextView info = findViewById(R.id.info);
info.setText(getInfoText());
}

View File

@@ -34,9 +34,9 @@ public abstract class BaseThreadItemViewHolder<I extends ThreadItem>
public BaseThreadItemViewHolder(View v) {
super(v);
layout = (ViewGroup) v.findViewById(R.id.layout);
textView = (TextView) v.findViewById(R.id.text);
author = (AuthorView) v.findViewById(R.id.author);
layout = v.findViewById(R.id.layout);
textView = v.findViewById(R.id.text);
author = v.findViewById(R.id.author);
}
@CallSuper

View File

@@ -85,9 +85,9 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
groupId = new GroupId(b);
getController().setGroupId(groupId);
textInput = (TextInputView) findViewById(R.id.text_input_container);
textInput = findViewById(R.id.text_input_container);
textInput.setListener(this);
list = (BriarRecyclerView) findViewById(R.id.list);
list = findViewById(R.id.list);
layoutManager = new LinearLayoutManager(this);
list.setLayoutManager(layoutManager);
adapter = createAdapter(layoutManager);
@@ -114,8 +114,8 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
}
}
});
upButton = (UnreadMessageButton) findViewById(R.id.upButton);
downButton = (UnreadMessageButton) findViewById(R.id.downButton);
upButton = findViewById(R.id.upButton);
downButton = findViewById(R.id.downButton);
upButton.setOnClickListener(v -> {
int position = adapter.getVisibleUnreadPosTop();
if (position != NO_POSITION) {

View File

@@ -28,7 +28,7 @@ public class ThreadPostViewHolder<I extends ThreadItem>
public ThreadPostViewHolder(View v) {
super(v);
lvlText = (TextView) v.findViewById(R.id.nested_line_text);
lvlText = v.findViewById(R.id.nested_line_text);
lvls = new View[nestedLineIds.length];
for (int i = 0; i < lvls.length; i++) {
lvls[i] = v.findViewById(nestedLineIds[i]);

View File

@@ -53,12 +53,12 @@ public class AuthorView extends RelativeLayout {
.getSystemService(LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.author_view, this, true);
avatar = (CircleImageView) findViewById(R.id.avatar);
avatarIcon = (ImageView) findViewById(R.id.avatarIcon);
authorName = (TextView) findViewById(R.id.authorName);
avatar = findViewById(R.id.avatar);
avatarIcon = findViewById(R.id.avatarIcon);
authorName = findViewById(R.id.authorName);
authorNameTypeface = authorName.getTypeface();
date = (TextView) findViewById(R.id.dateView);
trustIndicator = (TrustIndicatorView) findViewById(R.id.trustIndicator);
date = findViewById(R.id.dateView);
trustIndicator = findViewById(R.id.trustIndicator);
TypedArray attributes =
context.obtainStyledAttributes(attrs, R.styleable.AuthorView);

View File

@@ -67,9 +67,9 @@ public class BriarRecyclerView extends FrameLayout {
View v = LayoutInflater.from(getContext()).inflate(
R.layout.briar_recycler_view, this, true);
recyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
emptyView = (TextView) v.findViewById(R.id.emptyView);
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
recyclerView = v.findViewById(R.id.recyclerView);
emptyView = v.findViewById(R.id.emptyView);
progressBar = v.findViewById(R.id.progressBar);
showProgressBar();

View File

@@ -58,8 +58,7 @@ public class LargeTextInputView extends TextInputView {
if (buttonText != null) setButtonText(buttonText);
if (maxLines > 0) ui.editText.setMaxLines(maxLines);
if (fillHeight) {
LinearLayout layout =
(LinearLayout) findViewById(R.id.input_layout);
LinearLayout layout = findViewById(R.id.input_layout);
LayoutParams params = (LayoutParams) layout.getLayoutParams();
params.height = 0;
params.weight = 1;

View File

@@ -33,11 +33,10 @@ public class TextAvatarView extends FrameLayout {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater
.inflate(R.layout.text_avatar_view, this, true);
character = (AppCompatTextView) findViewById(R.id.textAvatarView);
background = (CircleImageView) findViewById(R.id.avatarBackground);
badge = (TextView) findViewById(R.id.unreadCountView);
inflater.inflate(R.layout.text_avatar_view, this, true);
character = findViewById(R.id.textAvatarView);
background = findViewById(R.id.avatarBackground);
badge = findViewById(R.id.unreadCountView);
badge.setVisibility(INVISIBLE);
}

View File

@@ -193,9 +193,9 @@ public class TextInputView extends KeyboardAwareLinearLayout
final EmojiDrawer emojiDrawer;
private ViewHolder() {
emojiToggle = (EmojiToggle) findViewById(R.id.emoji_toggle);
editText = (EmojiEditText) findViewById(R.id.input_text);
emojiDrawer = (EmojiDrawer) findViewById(R.id.emoji_drawer);
emojiToggle = findViewById(R.id.emoji_toggle);
editText = findViewById(R.id.input_text);
emojiDrawer = findViewById(R.id.emoji_drawer);
sendButton = findViewById(R.id.btn_send);
}
}

View File

@@ -39,8 +39,8 @@ public class UnreadMessageButton extends FrameLayout {
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.unread_message_button, this, true);
fab = (FloatingActionButton) findViewById(R.id.fab);
unread = (TextView) findViewById(R.id.unreadCountView);
fab = findViewById(R.id.fab);
unread = findViewById(R.id.unreadCountView);
TypedArray attributes = context.obtainStyledAttributes(attrs,
R.styleable.UnreadMessageButton);

View File

@@ -48,7 +48,7 @@ public class LinkDialogFragment extends DialogFragment {
View v = inflater.inflate(R.layout.fragment_link_dialog, container,
false);
TextView urlView = (TextView) v.findViewById(R.id.urlView);
TextView urlView = v.findViewById(R.id.urlView);
urlView.setText(url);
// prepare normal intent or intent chooser
@@ -60,13 +60,13 @@ public class LinkDialogFragment extends DialogFragment {
Intent intent = choice ? Intent.createChooser(i,
getString(R.string.link_warning_open_link)) : i;
Button openButton = (Button) v.findViewById(R.id.openButton);
Button openButton = v.findViewById(R.id.openButton);
openButton.setOnClickListener(v1 -> {
startActivity(intent);
getDialog().dismiss();
});
Button cancelButton = (Button) v.findViewById(R.id.cancelButton);
Button cancelButton = v.findViewById(R.id.cancelButton);
cancelButton.setOnClickListener(v1 -> getDialog().cancel());
return v;

View File

@@ -72,11 +72,10 @@ public class EmojiDrawer extends LinearLayout {
}
private void initializeResources(View v) {
this.pager = (ViewPager) v.findViewById(R.id.emoji_pager);
this.strip = (PagerSlidingTabStrip) v.findViewById(R.id.tabs);
this.pager = v.findViewById(R.id.emoji_pager);
this.strip = v.findViewById(R.id.tabs);
RepeatableImageKey backspace =
(RepeatableImageKey) v.findViewById(R.id.backspace);
RepeatableImageKey backspace = v.findViewById(R.id.backspace);
backspace.setOnKeyEventListener(() -> {
if (listener != null) listener.onKeyEvent(DELETE_KEY_EVENT);
});

View File

@@ -35,7 +35,7 @@ public class EmojiPageView extends FrameLayout {
super(context, attrs, defStyleAttr);
View view = LayoutInflater.from(getContext())
.inflate(R.layout.emoji_grid_layout, this, true);
grid = (GridView) view.findViewById(R.id.emoji);
grid = view.findViewById(R.id.emoji);
grid.setColumnWidth(getResources()
.getDimensionPixelSize(R.dimen.emoji_drawer_size) + 2 *
getResources().getDimensionPixelSize(

View File

@@ -55,17 +55,17 @@ public class ChangePasswordActivityTest {
MockitoAnnotations.initMocks(this);
changePasswordActivity =
Robolectric.setupActivity(TestChangePasswordActivity.class);
passwordConfirmationWrapper = (TextInputLayout) changePasswordActivity
passwordConfirmationWrapper = changePasswordActivity
.findViewById(R.id.new_password_confirm_wrapper);
currentPassword = (EditText) changePasswordActivity
currentPassword = changePasswordActivity
.findViewById(R.id.current_password_entry);
newPassword = (EditText) changePasswordActivity
newPassword = changePasswordActivity
.findViewById(R.id.new_password_entry);
newPasswordConfirmation = (EditText) changePasswordActivity
newPasswordConfirmation = changePasswordActivity
.findViewById(R.id.new_password_confirm);
strengthMeter = (StrengthMeter) changePasswordActivity
strengthMeter = changePasswordActivity
.findViewById(R.id.strength_meter);
changePasswordButton = (Button) changePasswordActivity
changePasswordButton = changePasswordActivity
.findViewById(R.id.change_password);
}

View File

@@ -48,12 +48,12 @@ public class PasswordFragmentTest {
startFragment(passwordFragment, SetupActivity.class);
View v = passwordFragment.getView();
passwordEntry = (EditText) v.findViewById(R.id.password_entry);
passwordConfirmation = (EditText) v.findViewById(R.id.password_confirm);
passwordEntry = v.findViewById(R.id.password_entry);
passwordConfirmation = v.findViewById(R.id.password_confirm);
passwordConfirmationWrapper =
(TextInputLayout) v.findViewById(R.id.password_confirm_wrapper);
strengthMeter = (StrengthMeter) v.findViewById(R.id.strength_meter);
createAccountButton = (Button) v.findViewById(R.id.next);
v.findViewById(R.id.password_confirm_wrapper);
strengthMeter = v.findViewById(R.id.strength_meter);
createAccountButton = v.findViewById(R.id.next);
}
@Test

View File

@@ -45,10 +45,9 @@ public class SetupActivityTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
setupActivity = Robolectric.setupActivity(SetupActivity.class);
nicknameEntryWrapper = (TextInputLayout) setupActivity
.findViewById(R.id.nickname_entry_wrapper);
nicknameEntry =
(EditText) setupActivity.findViewById(R.id.nickname_entry);
nicknameEntryWrapper =
setupActivity.findViewById(R.id.nickname_entry_wrapper);
nicknameEntry = setupActivity.findViewById(R.id.nickname_entry);
}
@Test