Appease checkstyle
Can be run via `gradle checkstyle`. Mostly: * Removing one line if statements in favour of braces. * Whitespace between typecast and expression.
This commit is contained in:
parent
539455bd16
commit
1f83cf1eca
@ -488,7 +488,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
AppDetails2.this.finish();
|
||||
return;
|
||||
}
|
||||
AppDetailsRecyclerViewAdapter adapter = (AppDetailsRecyclerViewAdapter)mRecyclerView.getAdapter();
|
||||
AppDetailsRecyclerViewAdapter adapter = (AppDetailsRecyclerViewAdapter) mRecyclerView.getAdapter();
|
||||
adapter.updateItems(mApp);
|
||||
supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
@ -598,8 +598,7 @@ public final class Utils {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static int dpToPx(int dp, Context ctx)
|
||||
{
|
||||
public static int dpToPx(int dp, Context ctx) {
|
||||
Resources r = ctx.getResources();
|
||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
|
||||
}
|
||||
|
@ -49,22 +49,31 @@ import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.support.v7.widget.RecyclerView.NO_POSITION;
|
||||
|
||||
public class AppDetailsRecyclerViewAdapter
|
||||
extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
public interface AppDetailsRecyclerViewAdapterCallbacks {
|
||||
|
||||
boolean isAppDownloading();
|
||||
|
||||
void enableAndroidBeam();
|
||||
|
||||
void disableAndroidBeam();
|
||||
|
||||
void openUrl(String url);
|
||||
|
||||
void installApk();
|
||||
|
||||
void installApk(Apk apk);
|
||||
|
||||
void upgradeApk();
|
||||
|
||||
void uninstallApk();
|
||||
|
||||
void installCancel();
|
||||
|
||||
void launchApk();
|
||||
|
||||
}
|
||||
|
||||
private static final int VIEWTYPE_HEADER = 0;
|
||||
@ -106,10 +115,11 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
}
|
||||
|
||||
if (mItems == null)
|
||||
if (mItems == null) {
|
||||
mItems = new ArrayList<>();
|
||||
else
|
||||
} else {
|
||||
mItems.clear();
|
||||
}
|
||||
addItem(VIEWTYPE_HEADER);
|
||||
addItem(VIEWTYPE_SCREENSHOTS);
|
||||
addItem(VIEWTYPE_WHATS_NEW);
|
||||
@ -133,12 +143,10 @@ public class AppDetailsRecyclerViewAdapter
|
||||
private void addItem(int item) {
|
||||
// Gives us a chance to hide sections that are not used, e.g. the donate section when
|
||||
// we have no donation links.
|
||||
if (item == VIEWTYPE_DONATE) {
|
||||
if (!shouldShowDonate())
|
||||
return;
|
||||
} else if (item == VIEWTYPE_PERMISSIONS) {
|
||||
if (!shouldShowPermissions())
|
||||
return;
|
||||
if (item == VIEWTYPE_DONATE && !shouldShowDonate()) {
|
||||
return;
|
||||
} else if (item == VIEWTYPE_PERMISSIONS && !shouldShowPermissions()) {
|
||||
return;
|
||||
}
|
||||
mItems.add(item);
|
||||
}
|
||||
@ -298,8 +306,9 @@ public class AppDetailsRecyclerViewAdapter
|
||||
vh.recyclerView.setAdapter(adapter);
|
||||
vh.recyclerView.setHasFixedSize(true);
|
||||
vh.recyclerView.setNestedScrollingEnabled(false);
|
||||
if (vh.snapHelper != null)
|
||||
if (vh.snapHelper != null) {
|
||||
vh.snapHelper.attachToRecyclerView(null);
|
||||
}
|
||||
vh.snapHelper = new LinearLayoutManagerSnapHelper(lm);
|
||||
vh.snapHelper.setLinearSnapHelperListener(adapter);
|
||||
vh.snapHelper.attachToRecyclerView(vh.recyclerView);
|
||||
@ -334,7 +343,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean shouldBeVisible = (vh.contentView.getVisibility() != View.VISIBLE);
|
||||
boolean shouldBeVisible = vh.contentView.getVisibility() != View.VISIBLE;
|
||||
vh.contentView.setVisibility(shouldBeVisible ? View.VISIBLE : View.GONE);
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(vh.headerView, R.drawable.ic_website, 0, shouldBeVisible ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0);
|
||||
}
|
||||
@ -374,7 +383,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
vh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean shouldBeVisible = (vh.contentView.getVisibility() != View.VISIBLE);
|
||||
boolean shouldBeVisible = vh.contentView.getVisibility() != View.VISIBLE;
|
||||
vh.contentView.setVisibility(shouldBeVisible ? View.VISIBLE : View.GONE);
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(vh.headerView, R.drawable.ic_lock_24dp_grey600, 0, shouldBeVisible ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0);
|
||||
}
|
||||
@ -398,7 +407,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
} else if (viewType == VIEWTYPE_VERSION) {
|
||||
final VersionViewHolder vh = (VersionViewHolder) holder;
|
||||
java.text.DateFormat df = DateFormat.getDateFormat(mContext);
|
||||
final Apk apk = (Apk)mItems.get(position);
|
||||
final Apk apk = (Apk) mItems.get(position);
|
||||
|
||||
vh.version.setText(mContext.getString(R.string.version)
|
||||
+ " " + apk.versionName
|
||||
@ -503,9 +512,10 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mItems.get(position) instanceof Apk)
|
||||
if (mItems.get(position) instanceof Apk) {
|
||||
return VIEWTYPE_VERSION;
|
||||
return (Integer)mItems.get(position);
|
||||
}
|
||||
return (Integer) mItems.get(position);
|
||||
}
|
||||
|
||||
public class HeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -557,10 +567,10 @@ public class AppDetailsRecyclerViewAdapter
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Remember current scroll position so that we can restore it
|
||||
LinearLayoutManager lm = (LinearLayoutManager)mRecyclerView.getLayoutManager();
|
||||
LinearLayoutManager lm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||
int pos = lm.findFirstVisibleItemPosition();
|
||||
int posOffset = 0;
|
||||
if (pos != NO_POSITION) {
|
||||
if (pos != RecyclerView.NO_POSITION) {
|
||||
View firstChild = mRecyclerView.getChildAt(0);
|
||||
posOffset = (firstChild == null) ? 0 : (firstChild.getTop()); // - mRecyclerView.getPaddingTop());
|
||||
}
|
||||
@ -571,7 +581,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
descriptionView.setMaxLines(Integer.MAX_VALUE);
|
||||
descriptionMoreView.setText(R.string.less);
|
||||
}
|
||||
if (pos != NO_POSITION) {
|
||||
if (pos != RecyclerView.NO_POSITION) {
|
||||
// Restore scroll position
|
||||
lm.scrollToPositionWithOffset(pos, posOffset);
|
||||
}
|
||||
@ -771,10 +781,11 @@ public class AppDetailsRecyclerViewAdapter
|
||||
};
|
||||
|
||||
private boolean uriIsSetAndCanBeOpened(String s) {
|
||||
if (TextUtils.isEmpty(s))
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s));
|
||||
return (intent.resolveActivity(mContext.getPackageManager()) != null);
|
||||
return intent.resolveActivity(mContext.getPackageManager()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
* @param position Adapter position of the snapped to view (or NO_POSITION if none)
|
||||
*/
|
||||
void onSnappedToView(View view, int position);
|
||||
};
|
||||
}
|
||||
|
||||
private LinearLayoutManager mLlm;
|
||||
private OrientationHelper mOrientationHelper;
|
||||
@ -28,7 +28,7 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
public LinearLayoutManagerSnapHelper(LinearLayoutManager llm) {
|
||||
this.mLlm = llm;
|
||||
this.mOrientationHelper = OrientationHelper.createHorizontalHelper(mLlm);
|
||||
};
|
||||
}
|
||||
|
||||
public void setLinearSnapHelperListener(LinearSnapHelperListener listener) {
|
||||
mListener = listener;
|
||||
@ -93,8 +93,9 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
}
|
||||
if (mListener != null) {
|
||||
int snappedPosition = 0;
|
||||
if (snappedView != null)
|
||||
if (snappedView != null) {
|
||||
snappedPosition = mLlm.getPosition(snappedView);
|
||||
}
|
||||
mListener.onSnappedToView(snappedView, snappedPosition);
|
||||
}
|
||||
return snappedView;
|
||||
|
@ -44,8 +44,9 @@ public class ScreenShotsRecyclerViewAdapter extends RecyclerView.Adapter<Recycle
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
ScreenShotViewHolder vh = (ScreenShotViewHolder) holder;
|
||||
setViewSelected(vh.itemView, position == selectedPosition);
|
||||
if (position == selectedPosition)
|
||||
if (position == selectedPosition) {
|
||||
this.selectedView = vh.itemView;
|
||||
}
|
||||
ImageLoader.getInstance().displayImage(app.iconUrlLarge, vh.image, displayImageOptions);
|
||||
}
|
||||
|
||||
@ -74,11 +75,12 @@ public class ScreenShotsRecyclerViewAdapter extends RecyclerView.Adapter<Recycle
|
||||
|
||||
private void setViewSelected(View view, boolean selected) {
|
||||
if (view != null) {
|
||||
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams)view.getLayoutParams();
|
||||
if (selected)
|
||||
lp.setMargins(0,selectedItemElevation,0,selectedItemElevation);
|
||||
else
|
||||
lp.setMargins(0,unselectedItemMargin,0,unselectedItemMargin);
|
||||
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
if (selected) {
|
||||
lp.setMargins(0, selectedItemElevation, 0, selectedItemElevation);
|
||||
} else {
|
||||
lp.setMargins(0, unselectedItemMargin, 0, unselectedItemMargin);
|
||||
}
|
||||
ViewCompat.setElevation(view, selected ? selectedItemElevation : selectedItemElevation / 2);
|
||||
view.setLayoutParams(lp);
|
||||
}
|
||||
|
@ -43,9 +43,13 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
private boolean mShowNearby;
|
||||
|
||||
public interface ShareChooserDialogListener {
|
||||
|
||||
void onNearby();
|
||||
|
||||
void onResolvedShareIntent(Intent shareIntent);
|
||||
|
||||
}
|
||||
|
||||
private ShareChooserDialogListener mListener;
|
||||
|
||||
public ShareChooserDialog() {
|
||||
@ -67,8 +71,7 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
if (resInfo != null && resInfo.size() > 0) {
|
||||
for (ResolveInfo resolveInfo : resInfo) {
|
||||
String packageName = resolveInfo.activityInfo.packageName;
|
||||
if (!packageName.equals(BuildConfig.APPLICATION_ID)) // Remove ourselves
|
||||
{
|
||||
if (!packageName.equals(BuildConfig.APPLICATION_ID)) { // Remove ourselves
|
||||
mTargets.add(resolveInfo);
|
||||
}
|
||||
}
|
||||
@ -99,7 +102,7 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
}
|
||||
|
||||
private void setupView(View v) {
|
||||
mRecyclerView = (RecyclerView)v.findViewById(R.id.recycler_view_apps);
|
||||
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view_apps);
|
||||
|
||||
// Figure out how many columns that fit in the given parent width. Give them 100dp.
|
||||
int appWidth = Utils.dpToPx(80, getContext());
|
||||
@ -121,17 +124,17 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
});
|
||||
mRecyclerView.setLayoutManager(glm);
|
||||
|
||||
|
||||
class VH extends RecyclerView.ViewHolder {
|
||||
public final ImageView icon;
|
||||
public final TextView label;
|
||||
|
||||
public VH(View itemView) {
|
||||
VH(View itemView) {
|
||||
super(itemView);
|
||||
icon = (ImageView) itemView.findViewById(R.id.ivShare);
|
||||
label = (TextView) itemView.findViewById(R.id.tvShare);
|
||||
}
|
||||
}
|
||||
|
||||
mRecyclerView.setAdapter(new RecyclerView.Adapter<VH>() {
|
||||
|
||||
private ArrayList<ResolveInfo> mIntents;
|
||||
@ -149,8 +152,9 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mIntents.get(position) == null)
|
||||
if (mIntents.get(position) == null) {
|
||||
return VIEWTYPE_SWAP;
|
||||
}
|
||||
return VIEWTYPE_INTENT;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user