GNU General Public License for more details.\r
\r
You should have received a copy of the GNU General Public License\r
- along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
-->\r
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
android:id="@+id/ListItemLayout"\r
- android:layout_width="fill_parent"\r
- android:layout_height="160dp"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="match_parent"\r
+ android:layout_gravity="center_horizontal"\r
android:background="@drawable/list_selector"\r
- android:orientation="horizontal" >\r
+ android:gravity="center_horizontal"\r
+ android:orientation="vertical" >\r
\r
- <ImageView\r
+ <com.owncloud.android.ui.SquareImageView\r
android:id="@+id/imageView1"\r
- android:layout_width="150dp"\r
- android:layout_height="150dp"\r
- android:layout_marginBottom="5dp"\r
- android:layout_marginLeft="9dp"\r
- android:layout_marginTop="5dp"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="match_parent"\r
+ android:layout_gravity="fill"\r
+ android:paddingLeft="10dp"\r
+ android:paddingRight="10dp"\r
+ android:scaleType="centerCrop"\r
android:src="@drawable/ic_menu_archive" />\r
\r
- <ImageView\r
- android:id="@+id/imageView2"\r
- android:layout_width="40dp"\r
- android:layout_height="22dp"\r
- android:layout_marginLeft="22dp"\r
- android:src="@drawable/local_file_indicator" />\r
-\r
<FrameLayout\r
android:id="@+id/imageItemFrame"\r
- android:layout_width="56dp"\r
- android:layout_height="56dp"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="match_parent"\r
android:focusable="false"\r
android:focusableInTouchMode="false" >\r
\r
android:textSize="12dip" />\r
</FrameLayout>\r
\r
+ <ImageView\r
+ android:id="@+id/imageView2"\r
+ android:layout_width="40dp"\r
+ android:layout_height="22dp"\r
+ android:layout_marginLeft="22dp"\r
+ android:src="@drawable/local_file_indicator" />\r
+\r
</LinearLayout>
\ No newline at end of file
-->\r
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
android:id="@+id/ListItemLayout"\r
- android:layout_width="fill_parent"\r
- android:layout_height="160dp"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="match_parent"\r
+ android:layout_gravity="center_horizontal"\r
android:background="@drawable/list_selector"\r
+ android:gravity="center"\r
android:orientation="vertical" >\r
\r
<ImageView\r
android:id="@+id/imageView1"\r
android:layout_width="90dp"\r
- android:layout_height="93dp"\r
- android:layout_marginBottom="5dp"\r
- android:layout_marginLeft="9dp"\r
- android:layout_marginTop="5dp"\r
+ android:layout_height="90dp"\r
+ android:layout_marginLeft="10dp"\r
+ android:layout_marginRight="10dp"\r
android:src="@drawable/ic_menu_archive" />\r
\r
<TextView\r
android:id="@+id/Filename"\r
- android:layout_width="95dp"\r
+ android:layout_width="100dp"\r
android:layout_height="wrap_content"\r
+ android:layout_gravity="center_horizontal"\r
android:layout_marginLeft="4dp"\r
android:layout_marginRight="4dp"\r
android:ellipsize="middle"\r
+ android:gravity="center_horizontal"\r
android:singleLine="true"\r
android:text="TextView"\r
android:textColor="#303030"\r
android:id="@+id/list_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:columnWidth="160dp"
+ android:columnWidth="100dp"
android:gravity="center"
- android:horizontalSpacing="10dp"
+ android:horizontalSpacing="2dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
- android:verticalSpacing="10dp"
+ android:verticalSpacing="2dp"
android:visibility="visible" />
+
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.v4.widget.SwipeRefreshLayout
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.GridView;
-import android.widget.ListView;
/**
- * ListView allowing to specify the position of an item that should be centered in the visible area, if possible.
+ * GridView allowing to specify the position of an item that should be top left in the visible area, if possible.
*
* The cleanest way I found to overcome the problem due to getHeight() returns 0 until the view is really drawn.
*
*/
public class ExtendedListView extends GridView {
- private int mPositionToSetAndCenter;
+ private int mPositionToSetTopLeft;
public ExtendedListView(Context context) {
super(context);
public ExtendedListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
-
+
/**
* {@inheritDoc}
*
@Override
protected void onDraw (Canvas canvas) {
super.onDraw(canvas);
- if (mPositionToSetAndCenter > 0) {
- this.setSelection(mPositionToSetAndCenter);
- //this.setSelectionFromTop(mPositionToSetAndCenter, getHeight() / 2);
- mPositionToSetAndCenter = 0;
+ if (mPositionToSetTopLeft > 0) {
+ this.smoothScrollToPosition(mPositionToSetTopLeft);
+ mPositionToSetTopLeft = 0;
}
}
/**
- * Public method to set the position of the item that should be centered in the visible area of the view.
+ * Public method to set the position of the item that should be top left in the visible area of the view.
*
* The position is saved here and checked in onDraw().
*
- * @param position Position (in the list of items) of the item to center in the visible area.
+ * @param position Position (in the list of items) of the item to be top left in the visible area.
*/
- public void setAndCenterSelection(int position) {
- mPositionToSetAndCenter = position;
+ public void setSelectionAsTopLeft(int position) {
+ mPositionToSetTopLeft = position;
}
}
--- /dev/null
+package com.owncloud.android.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+public class SquareImageView extends ImageView {
+
+ public SquareImageView(Context context) {
+ super(context);
+ }
+
+ public SquareImageView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, widthMeasureSpec);
+ }
+}
localStateView.setVisibility(View.INVISIBLE);\r
}\r
\r
+ if (!fileView){\r
+ localStateView.setVisibility(View.GONE);\r
+ }\r
+ \r
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);\r
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);\r
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
int top = mTops.remove(mTops.size() - 1);
- imageView.setSelection(firstPosition);
+ imageView.smoothScrollToPosition(firstPosition);
// Move the scroll if the selection is not visible
int indexPosition = mHeightCell*index;
int height = imageView.getHeight();
if (indexPosition > height) {
- if (android.os.Build.VERSION.SDK_INT >= 11)
- {
- imageView.smoothScrollToPosition(index);
- }
- else if (android.os.Build.VERSION.SDK_INT >= 8)
- {
- imageView.setSelection(index);
- }
-
+ imageView.smoothScrollToPosition(index);
}
}
}