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