updated resources
improved media preview layout fixed media preview
|
@ -84,37 +84,37 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public ImageLoaderWrapper getImageLoader() {
|
||||
public final ImageLoaderWrapper getImageLoader() {
|
||||
return mImageLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
public final Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageLoadingHandler getImageLoadingHandler() {
|
||||
public final ImageLoadingHandler getImageLoadingHandler() {
|
||||
return mLoadingHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProfileImageStyle() {
|
||||
public final int getProfileImageStyle() {
|
||||
return mProfileImageStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMediaPreviewStyle() {
|
||||
public final int getMediaPreviewStyle() {
|
||||
return mMediaPreviewStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
public final AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return mTwitterWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextSize() {
|
||||
public final float getTextSize() {
|
||||
return mTextSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,11 +54,6 @@ public class ParcelableStatusesAdapter extends AbsStatusesAdapter<List<Parcelabl
|
|||
return mData.get(position).id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMediaPreviewStyle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setData(List<ParcelableStatus> data) {
|
||||
mData = data;
|
||||
notifyDataSetChanged();
|
||||
|
|
|
@ -42,6 +42,8 @@ import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
|
|||
*/
|
||||
public class CardMediaContainer extends ViewGroup implements Constants {
|
||||
|
||||
private static final float WIDTH_HEIGHT_RATIO = 0.5f;
|
||||
|
||||
private final int mMaxColumns;
|
||||
private final int mHorizontalSpacing, mVerticalSpacing;
|
||||
private int[] mTempIndices;
|
||||
|
@ -139,30 +141,90 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
|||
final int[] childIndices = createChildIndices();
|
||||
final int childCount = getChildIndicesInLayout(this, childIndices);
|
||||
if (childCount > 0) {
|
||||
final double childSqrt = Math.sqrt(childCount);
|
||||
final int columnCount = (int) (childSqrt % 1 == 0 ? Math.ceil(childSqrt) : Math.min(childCount, mMaxColumns));
|
||||
final int rowCount = (int) Math.ceil(childCount / (double) columnCount);
|
||||
final int firstRowColumnCount = childCount - (columnCount * (rowCount - 1));
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
final int currColumnCount = i == 0 ? firstRowColumnCount : columnCount;
|
||||
final int childT;
|
||||
if (i == 0) {
|
||||
childT = getPaddingTop();
|
||||
} else if (i == 1) {
|
||||
childT = getChildAt(childIndices[0]).getBottom() + mVerticalSpacing;
|
||||
} else {
|
||||
childT = getChildAt(childIndices[firstRowColumnCount + columnCount * (i - 1)]).getBottom() + mVerticalSpacing;
|
||||
}
|
||||
for (int j = 0; j < currColumnCount; j++) {
|
||||
final int childIdx = i == 0 ? j : firstRowColumnCount + columnCount * (i - 1) + j;
|
||||
final View child = getChildAt(childIndices[childIdx]);
|
||||
final int childL = j == 0 ? getPaddingLeft() : (getChildAt(childIndices[childIdx - 1]).getRight() + mHorizontalSpacing);
|
||||
child.layout(childL, childT, childL + child.getMeasuredWidth(), childT + child.getMeasuredHeight());
|
||||
}
|
||||
if (childCount == 1) {
|
||||
layout1Media(childIndices);
|
||||
} else if (childCount == 3) {
|
||||
layout3Media(mHorizontalSpacing, mVerticalSpacing, childIndices);
|
||||
} else {
|
||||
layoutGridMedia(childCount, 2, mHorizontalSpacing, mVerticalSpacing, childIndices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void measure1Media(int contentWidth, int[] childIndices) {
|
||||
final View child = getChildAt(childIndices[0]);
|
||||
final int childHeight = Math.round(contentWidth * WIDTH_HEIGHT_RATIO);
|
||||
final int widthSpec = MeasureSpec.makeMeasureSpec(contentWidth, MeasureSpec.EXACTLY);
|
||||
final int heightSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY);
|
||||
child.measure(widthSpec, heightSpec);
|
||||
}
|
||||
|
||||
private void layout1Media(int[] childIndices) {
|
||||
final View child = getChildAt(childIndices[0]);
|
||||
final int left = getPaddingLeft(), top = getPaddingTop();
|
||||
final int right = left + child.getMeasuredWidth(), bottom = top + child.getMeasuredHeight();
|
||||
child.layout(left, top, right, bottom);
|
||||
}
|
||||
|
||||
private int measureGridMedia(int childCount, int columnCount, int contentWidth,
|
||||
float widthHeightRatio, int horizontalSpacing, int verticalSpacing,
|
||||
int[] childIndices) {
|
||||
final int childWidth = (contentWidth - horizontalSpacing * (columnCount - 1)) / columnCount;
|
||||
final int childHeight = Math.round(childWidth * widthHeightRatio);
|
||||
final int widthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
|
||||
final int heightSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY);
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
getChildAt(childIndices[i]).measure(widthSpec, heightSpec);
|
||||
}
|
||||
final int rowsCount = (int) Math.ceil(childCount / (double) columnCount);
|
||||
return rowsCount * childHeight + (rowsCount - 1) * verticalSpacing;
|
||||
}
|
||||
|
||||
private void layoutGridMedia(int childCount, int columnCount, int horizontalSpacing,
|
||||
int verticalSpacing, int[] childIndices) {
|
||||
final int initialLeft = getPaddingLeft();
|
||||
int left = initialLeft, top = getPaddingTop();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final int colIdx = i % columnCount;
|
||||
final View child = getChildAt(childIndices[i]);
|
||||
child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
|
||||
if (colIdx == columnCount - 1) {
|
||||
// Last item in this row, set top of next row to last view bottom + verticalSpacing
|
||||
top = child.getBottom() + verticalSpacing;
|
||||
// And reset left to initial left
|
||||
left = initialLeft;
|
||||
} else {
|
||||
// The left of next item is right + horizontalSpacing of previous item
|
||||
left = child.getRight() + horizontalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void measure3Media(int contentWidth, int horizontalSpacing, int[] childIndices) {
|
||||
final View child0 = getChildAt(childIndices[0]), child1 = getChildAt(childIndices[1]),
|
||||
child2 = getChildAt(childIndices[2]);
|
||||
final int childWidth = (contentWidth - horizontalSpacing) / 2;
|
||||
final int sizeSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
|
||||
child0.measure(sizeSpec, sizeSpec);
|
||||
final int childRightHeight = Math.round(childWidth - horizontalSpacing) / 2;
|
||||
final int heightSpec = MeasureSpec.makeMeasureSpec(childRightHeight, MeasureSpec.EXACTLY);
|
||||
child1.measure(sizeSpec, heightSpec);
|
||||
child2.measure(sizeSpec, heightSpec);
|
||||
}
|
||||
|
||||
private void layout3Media(int horizontalSpacing, int verticalSpacing, int[] childIndices) {
|
||||
final int left = getPaddingLeft(), top = getPaddingTop();
|
||||
final View child0 = getChildAt(childIndices[0]), child1 = getChildAt(childIndices[1]),
|
||||
child2 = getChildAt(childIndices[2]);
|
||||
child0.layout(left, top, left + child0.getMeasuredWidth(), top + child0.getMeasuredHeight());
|
||||
final int rightColLeft = child0.getRight() + horizontalSpacing;
|
||||
child1.layout(rightColLeft, top, rightColLeft + child1.getMeasuredWidth(),
|
||||
top + child1.getMeasuredHeight());
|
||||
final int child2Top = child1.getBottom() + verticalSpacing;
|
||||
child2.layout(rightColLeft, child2Top, rightColLeft + child2.getMeasuredWidth(),
|
||||
child2Top + child2.getMeasuredHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
final int measuredWidth = resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec);
|
||||
|
@ -171,26 +233,23 @@ public class CardMediaContainer extends ViewGroup implements Constants {
|
|||
final int childCount = getChildIndicesInLayout(this, childIndices);
|
||||
int heightSum = 0;
|
||||
if (childCount > 0) {
|
||||
final double childSqrt = Math.sqrt(childCount);
|
||||
final int columnCount = (int) (childSqrt % 1 == 0 ? Math.ceil(childSqrt) : Math.min(childCount, mMaxColumns));
|
||||
final int rowCount = (int) Math.ceil(childCount / (double) columnCount);
|
||||
final int firstRowColumnCount = childCount - (columnCount * (rowCount - 1));
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
final int currColumnCount = i == 0 ? firstRowColumnCount : columnCount;
|
||||
final int columnWidth = (contentWidth - (mHorizontalSpacing * (currColumnCount - 1))) / currColumnCount;
|
||||
final int columnHeight = columnWidth;
|
||||
heightSum = heightSum + columnHeight;
|
||||
final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(columnWidth, MeasureSpec.EXACTLY);
|
||||
final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(columnHeight, MeasureSpec.EXACTLY);
|
||||
for (int j = 0; j < currColumnCount; j++) {
|
||||
final int childIdx = i == 0 ? j : firstRowColumnCount + columnCount * (i - 1) + j;
|
||||
getChildAt(childIndices[childIdx]).measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||
}
|
||||
if (childCount == 1) {
|
||||
measure1Media(contentWidth, childIndices);
|
||||
heightSum = Math.round(contentWidth * WIDTH_HEIGHT_RATIO);
|
||||
} else if (childCount == 2) {
|
||||
measureGridMedia(childCount, 2, contentWidth, 1, mHorizontalSpacing, mVerticalSpacing,
|
||||
childIndices);
|
||||
heightSum = Math.round(contentWidth * WIDTH_HEIGHT_RATIO);
|
||||
} else if (childCount == 3) {
|
||||
measure3Media(contentWidth, mHorizontalSpacing, childIndices);
|
||||
heightSum = Math.round(contentWidth * WIDTH_HEIGHT_RATIO);
|
||||
} else {
|
||||
heightSum = measureGridMedia(childCount, 2, contentWidth, WIDTH_HEIGHT_RATIO,
|
||||
mHorizontalSpacing, mVerticalSpacing, childIndices);
|
||||
}
|
||||
heightSum = heightSum + (mVerticalSpacing * rowCount - 1);
|
||||
}
|
||||
heightSum = heightSum + getPaddingTop() + getPaddingBottom();
|
||||
setMeasuredDimension(widthMeasureSpec, MeasureSpec.makeMeasureSpec(heightSum, MeasureSpec.EXACTLY));
|
||||
final int height = heightSum + getPaddingTop() + getPaddingBottom();
|
||||
setMeasuredDimension(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
private int[] createChildIndices() {
|
||||
|
|
|
@ -427,6 +427,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
|||
|
||||
public void setupViewOptions() {
|
||||
setTextSize(adapter.getTextSize());
|
||||
mediaPreviewContainer.setStyle(adapter.getMediaPreviewStyle());
|
||||
}
|
||||
|
||||
private void displayExtraTypeIcon(String cardName, ParcelableMedia[] media, ParcelableLocation location) {
|
||||
|
|
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 36 KiB |
|
@ -91,8 +91,7 @@
|
|||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
android:contentDescription="@string/profile_image"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/profile_image_nyan_sakamoto"/>
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<org.mariotaku.twidere.view.BoundsImageView
|
||||
android:id="@+id/profile_type"
|
||||
|
|
|
@ -77,8 +77,7 @@
|
|||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_below="@+id/reply_retweet_status"
|
||||
android:contentDescription="@string/profile_image"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/profile_image_nyan_sakamoto"/>
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<org.mariotaku.twidere.view.BoundsImageView
|
||||
android:id="@+id/profile_type"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
-->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@ -28,8 +27,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/media"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/profile_image_nyan_sakamoto"/>
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/media_preview_progress"
|
||||
|
|
|
@ -31,12 +31,11 @@
|
|||
android:text="@string/phishing_link_warning_message_1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
<org.mariotaku.twidere.view.AutoAdjustHeightImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/phishing_site_warning_example"/>
|
||||
<!--<org.mariotaku.twidere.view.AutoAdjustHeightImageView-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_marginBottom="8dp"-->
|
||||
<!--android:layout_marginTop="8dp"/>-->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 54 KiB |