Skip to content

Commit

Permalink
Merge pull request nickbutcher#242 from alexjlockwood/cleanup2
Browse files Browse the repository at this point in the history
General cleanup nickbutcher#2
  • Loading branch information
nickbutcher authored Dec 22, 2017
2 parents 8ba9a72 + 7818723 commit 526067c
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 52 deletions.
7 changes: 4 additions & 3 deletions app/src/main/java/io/plaidapp/ui/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ static class AboutPagerAdapter extends PagerAdapter {
markdown = new Bypass(host, new Bypass.Options());
}

@NonNull
@Override
public Object instantiateItem(ViewGroup collection, int position) {
public Object instantiateItem(@NonNull ViewGroup collection, int position) {
View layout = getPage(position, collection);
collection.addView(layout);
return layout;
}

@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
public void destroyItem(@NonNull ViewGroup collection, int position, @NonNull Object view) {
collection.removeView((View) view);
}

Expand All @@ -133,7 +134,7 @@ public int getCount() {
}

@Override
public boolean isViewFromObject(View view, Object object) {
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}

Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/io/plaidapp/ui/DesignerNewsStory.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (collapsingToolbar != null) { // narrow device: collapsing toolbar
collapsingToolbar.addOnLayoutChangeListener(titlebarLayout);
collapsingToolbar.setTitle(story.title);
final Toolbar toolbar = (Toolbar) findViewById(R.id.story_toolbar);
final Toolbar toolbar = findViewById(R.id.story_toolbar);
toolbar.setNavigationOnClickListener(backClick);
commentsList.addOnScrollListener(headerScrollListener);

Expand All @@ -181,7 +181,7 @@ public void onSharedElementEnd(List<String> sharedElementNames, List<View>
});

} else { // w600dp configuration: content card scrolls over title bar
final TextView title = (TextView) findViewById(R.id.story_title);
final TextView title = findViewById(R.id.story_title);
title.setText(story.title);
findViewById(R.id.back).setOnClickListener(backClick);
}
Expand Down Expand Up @@ -514,8 +514,8 @@ public void onClick(View v) {
private View setupCommentField() {
View enterCommentView = getLayoutInflater()
.inflate(R.layout.designer_news_enter_comment, commentsList, false);
enterComment = (EditText) enterCommentView.findViewById(R.id.comment);
postComment = (ImageButton) enterCommentView.findViewById(R.id.post_comment);
enterComment = enterCommentView.findViewById(R.id.comment);
postComment = enterCommentView.findViewById(R.id.post_comment);
postComment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -1073,16 +1073,16 @@ private static class CommentAnimator extends SlideInItemAnimator {
public static final int COLLAPSE_COMMENT = 2;

@Override
public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) {
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
return true;
}

@NonNull
@Override
public ItemHolderInfo recordPreLayoutInformation(RecyclerView.State state,
RecyclerView.ViewHolder viewHolder,
public ItemHolderInfo recordPreLayoutInformation(@NonNull RecyclerView.State state,
@NonNull RecyclerView.ViewHolder viewHolder,
int changeFlags,
List<Object> payloads) {
@NonNull List<Object> payloads) {
CommentItemHolderInfo info = (CommentItemHolderInfo)
super.recordPreLayoutInformation(state, viewHolder, changeFlags, payloads);
info.doExpand = payloads.contains(EXPAND_COMMENT);
Expand All @@ -1091,10 +1091,10 @@ public ItemHolderInfo recordPreLayoutInformation(RecyclerView.State state,
}

@Override
public boolean animateChange(RecyclerView.ViewHolder oldHolder,
RecyclerView.ViewHolder newHolder,
ItemHolderInfo preInfo,
ItemHolderInfo postInfo) {
public boolean animateChange(@NonNull RecyclerView.ViewHolder oldHolder,
@NonNull RecyclerView.ViewHolder newHolder,
@NonNull ItemHolderInfo preInfo,
@NonNull ItemHolderInfo postInfo) {
if (newHolder instanceof CommentHolder && preInfo instanceof CommentItemHolderInfo) {
final CommentHolder holder = (CommentHolder) newHolder;
final CommentItemHolderInfo info = (CommentItemHolderInfo) preInfo;
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/io/plaidapp/ui/DribbbleShot.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ protected void onCreate(final Bundle savedInstanceState) {
shotSpacer = shotDescription.findViewById(R.id.shot_spacer);
title = shotDescription.findViewById(R.id.shot_title);
description = shotDescription.findViewById(R.id.shot_description);
likeCount = (Button) shotDescription.findViewById(R.id.shot_like_count);
viewCount = (Button) shotDescription.findViewById(R.id.shot_view_count);
share = (Button) shotDescription.findViewById(R.id.shot_share_action);
playerName = (TextView) shotDescription.findViewById(R.id.player_name);
playerAvatar = (ImageView) shotDescription.findViewById(R.id.player_avatar);
shotTimeAgo = (TextView) shotDescription.findViewById(R.id.shot_time_ago);
likeCount = shotDescription.findViewById(R.id.shot_like_count);
viewCount = shotDescription.findViewById(R.id.shot_view_count);
share = shotDescription.findViewById(R.id.shot_share_action);
playerName = shotDescription.findViewById(R.id.player_name);
playerAvatar = shotDescription.findViewById(R.id.player_avatar);
shotTimeAgo = shotDescription.findViewById(R.id.shot_time_ago);

setupCommenting();
commentsList.addOnScrollListener(scrollListener);
Expand Down Expand Up @@ -476,7 +476,7 @@ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable>
https://code.google.com/p/android/issues/detail?id=191013 */
.generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
public void onGenerated(@NonNull Palette palette) {
boolean isDark;
@ColorUtils.Lightness int lightness = ColorUtils.isDark(palette);
if (lightness == ColorUtils.LIGHTNESS_UNKNOWN) {
Expand Down Expand Up @@ -529,7 +529,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
.clearFilters()
.generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
public void onGenerated(@NonNull Palette palette) {
// color the ripple on the image spacer (default is grey)
shotSpacer.setBackground(
ViewUtils.createRipple(palette, 0.25f, 0.5f,
Expand Down Expand Up @@ -709,8 +709,8 @@ private void setupCommenting() {
commentFooter = getLayoutInflater().inflate(R.layout.dribbble_enter_comment,
commentsList, false);
userAvatar = (ForegroundImageView) commentFooter.findViewById(R.id.avatar);
enterComment = (EditText) commentFooter.findViewById(R.id.comment);
postComment = (ImageButton) commentFooter.findViewById(R.id.post_comment);
enterComment = commentFooter.findViewById(R.id.comment);
postComment = commentFooter.findViewById(R.id.post_comment);
enterComment.setOnFocusChangeListener(enterCommentFocus);
} else if (!allowComment && commentFooter != null) {
adapter.removeCommentingFooter();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/plaidapp/ui/FeedAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
};
}

@NonNull
@Override
public List<Shot> getPreloadItems(int position) {
PlaidItem item = getItem(position);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/io/plaidapp/ui/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private void setNoFiltersEmptyTextVisibility(int visibility) {
if (visibility == View.VISIBLE) {
if (noFiltersEmptyText == null) {
// create the no filters empty text
ViewStub stub = (ViewStub) findViewById(R.id.stub_no_filters);
ViewStub stub = findViewById(R.id.stub_no_filters);
noFiltersEmptyText = (TextView) stub.inflate();
String emptyText = getString(R.string.no_filters_selected);
int filterPlaceholderStart = emptyText.indexOf('\u08B4');
Expand Down Expand Up @@ -808,7 +808,7 @@ private void checkConnectivity() {
if (!connected) {
loading.setVisibility(View.GONE);
if (noConnection == null) {
final ViewStub stub = (ViewStub) findViewById(R.id.stub_no_connection);
final ViewStub stub = findViewById(R.id.stub_no_connection);
noConnection = (ImageView) stub.inflate();
}
final AnimatedVectorDrawable avd =
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/io/plaidapp/ui/HomeGridItemAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class HomeGridItemAnimator extends SlideInItemAnimator {
private Pair<FeedAdapter.DesignerNewsStoryHolder, AnimatorSet> runningStoryCommentsReturn;

@Override
public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) {
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
return true;
}

Expand All @@ -63,10 +63,10 @@ public ItemHolderInfo obtainHolderInfo() {

@NonNull
@Override
public ItemHolderInfo recordPreLayoutInformation(RecyclerView.State state,
RecyclerView.ViewHolder viewHolder,
public ItemHolderInfo recordPreLayoutInformation(@NonNull RecyclerView.State state,
@NonNull RecyclerView.ViewHolder viewHolder,
int changeFlags,
List<Object> payloads) {
@NonNull List<Object> payloads) {
ItemHolderInfo info =
super.recordPreLayoutInformation(state, viewHolder, changeFlags, payloads);
if (info instanceof HomeGridItemHolderInfo) {
Expand All @@ -79,10 +79,10 @@ public ItemHolderInfo recordPreLayoutInformation(RecyclerView.State state,
}

@Override
public boolean animateChange(RecyclerView.ViewHolder oldHolder,
RecyclerView.ViewHolder newHolder,
ItemHolderInfo preInfo,
ItemHolderInfo postInfo) {
public boolean animateChange(@NonNull RecyclerView.ViewHolder oldHolder,
@NonNull RecyclerView.ViewHolder newHolder,
@NonNull ItemHolderInfo preInfo,
@NonNull ItemHolderInfo postInfo) {
boolean runPending = super.animateChange(oldHolder, newHolder, preInfo, postInfo);

if (preInfo instanceof HomeGridItemHolderInfo) {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/io/plaidapp/ui/PlayerSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.os.Bundle;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;

/**
* A drawable showing the depth of a threaded conversation
Expand Down Expand Up @@ -62,7 +63,7 @@ public void setDepth(int depth) {
}

@Override
public void draw(Canvas canvas) {
public void draw(@NonNull Canvas canvas) {
for (int thread = 0; thread < threads; thread++) {
int left = halfThreadWidth + (thread * (threadWidth + gap));
canvas.drawLine(left, 0, left, getBounds().bottom, paint);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/plaidapp/ui/span/PlayerSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public PlayerSpan(String url,
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), PlayerActivity.class);
intent.putExtra(PlayerActivity.EXTRA_PLAYER_NAME, playerName);
if (playerId > 0l) {
if (playerId > 0L) {
intent.putExtra(PlayerActivity.EXTRA_PLAYER_ID, playerId);
}
if (!TextUtils.isEmpty(playerUsername)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Path getPath(float startX, float startY, float endX, float endY) {
// Distance squared between end point and mid point is (1/2 hypotenuse)^2
float midDist2 = h2 * 0.25f;

float minimumArcDist2 = 0;
float minimumArcDist2;

if (Math.abs(deltaX) < Math.abs(deltaY)) {
// Similar triangles bfa and bde mean that (ab/fb = eb/bd)
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/io/plaidapp/ui/widget/BottomSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.support.animation.DynamicAnimation;
import android.support.animation.SpringAnimation;
import android.support.animation.SpringForce;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
Expand Down Expand Up @@ -266,34 +267,34 @@ public void onAnimationUpdate(DynamicAnimation animation, float value, float vel
private final ViewDragHelper.Callback dragHelperCallbacks = new ViewDragHelper.Callback() {

@Override
public boolean tryCaptureView(View child, int pointerId) {
public boolean tryCaptureView(@NonNull View child, int pointerId) {
return child == sheet;
}

@Override
public int clampViewPositionVertical(View child, int top, int dy) {
public int clampViewPositionVertical(@NonNull View child, int top, int dy) {
return Math.min(Math.max(top, sheetExpandedTop), sheetBottom);
}

@Override
public int clampViewPositionHorizontal(View child, int left, int dx) {
public int clampViewPositionHorizontal(@NonNull View child, int left, int dx) {
return sheet.getLeft();
}

@Override
public int getViewVerticalDragRange(View child) {
public int getViewVerticalDragRange(@NonNull View child) {
return sheetBottom - sheetExpandedTop;
}

@Override
public void onViewPositionChanged(View child, int left, int top, int dx, int dy) {
public void onViewPositionChanged(@NonNull View child, int left, int top, int dx, int dy) {
// notify the offset helper that the sheets offsets have been changed externally
sheetOffsetHelper.resyncOffsets();
dispatchPositionChangedCallback();
}

@Override
public void onViewReleased(View releasedChild, float velocityX, float velocityY) {
public void onViewReleased(@NonNull View releasedChild, float velocityX, float velocityY) {
// dismiss on downward fling, otherwise settle back to expanded position
final boolean dismiss = velocityY >= SCALED_MIN_FLING_DISMISS_VELOCITY;
animateSettle(dismiss ? dismissOffset : 0, velocityY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.ViewOutlineProvider;
Expand Down Expand Up @@ -61,7 +62,7 @@ public boolean hasOverlappingRendering() {
}

@Override
protected boolean verifyDrawable(Drawable who) {
protected boolean verifyDrawable(@NonNull Drawable who) {
return super.verifyDrawable(who) || (who == foreground);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.LinearLayout;

Expand Down Expand Up @@ -53,7 +54,7 @@ public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle)
}

@Override
protected boolean verifyDrawable(Drawable who) {
protected boolean verifyDrawable(@NonNull Drawable who) {
return super.verifyDrawable(who) || (who == mForeground);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.ViewOutlineProvider;
import android.widget.RelativeLayout;
Expand Down Expand Up @@ -60,7 +61,7 @@ public boolean hasOverlappingRendering() {
}

@Override
protected boolean verifyDrawable(Drawable who) {
protected boolean verifyDrawable(@NonNull Drawable who) {
return super.verifyDrawable(who) || (who == foreground);
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/io/plaidapp/ui/widget/InkPageIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ public void onAnimationEnd(Animator animation) {
});
// slightly delay the start to give the joins a chance to run
// unless dot isn't in position yet – then don't delay!
moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4l : 0l);
moveSelected.setDuration(animDuration * 3l / 4l);
moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4L : 0L);
moveSelected.setDuration(animDuration * 3L / 4L);
moveSelected.setInterpolator(interpolator);
return moveSelected;
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/io/plaidapp/ui/widget/PasswordEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.support.annotation.NonNull;
import android.support.design.widget.TextInputEditText;
import android.text.TextPaint;
import android.text.method.PasswordTransformationMethod;
Expand Down Expand Up @@ -170,7 +171,7 @@ Animator createHideMaskAnimator(CharSequence password) {
}

@Override
public void draw(Canvas canvas) {
public void draw(@NonNull Canvas canvas) {
if (characters != null && morphProgress != NO_PROGRESS) {
final int saveCount = canvas.save();
canvas.translate(insetStart, baseline);
Expand Down

0 comments on commit 526067c

Please sign in to comment.