Skip to content

Commit

Permalink
Simplify unused code and use vector icons (getodk#1742)
Browse files Browse the repository at this point in the history
* Removed redundant casts
* Removed unused file types
* Replaced ic_download.png icon with vector
* Replaced ic_folder.png icon with vector
  • Loading branch information
grzesiek2010 authored and lognaturel committed Jan 6, 2018
1 parent fdaa850 commit daa6e0a
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,22 @@ public View getView(int position, View convertView, ViewGroup parent) {
.format(new Date(o.getDate().getValue()));
}

ImageView iv = (ImageView) v.findViewById(R.id.image);
CheckBox cb = (CheckBox) v.findViewById(R.id.checkbox);
ImageView iv = v.findViewById(R.id.image);
CheckBox cb = v.findViewById(R.id.checkbox);

if (o.getType() == 1) {
Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_download);
if (o.getType() == DriveListItem.FILE) {
Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_file_download);
iv.setImageDrawable(d);
cb.setVisibility(View.VISIBLE);
}
if (o.getType() == 3) {
Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_back);
iv.setImageDrawable(d);
cb.setVisibility(View.GONE);
}
if (o.getType() == 2 || o.getType() == 4 || o.getType() == 5) {
if (o.getType() == DriveListItem.DIR) {
Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_folder);
iv.setImageDrawable(d);
cb.setVisibility(View.GONE);
}

TextView t1 = (TextView) v.findViewById(R.id.text1);
TextView t2 = (TextView) v.findViewById(R.id.text2);
TextView t1 = v.findViewById(R.id.text1);
TextView t2 = v.findViewById(R.id.text2);

if (t1 != null) {
t1.setText(o.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ public class DriveListItem implements Comparable<DriveListItem>, Parcelable {
private DateTime date;
private int type;


public static final int FILE = 1;
public static final int DIR = 2;
public static final int UP = 3;
public static final int MY_DRIVE = 4;
public static final int SHARED_WITH_ME = 5;

public DriveListItem(String n, String d, DateTime dt, String p, String img, int type,
String driveId, String parentId) {
Expand Down
Binary file removed collect_app/src/main/res/drawable-hdpi/ic_back.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-hdpi/ic_download.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-hdpi/ic_folder.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-mdpi/ic_back.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-mdpi/ic_download.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-mdpi/ic_folder.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xhdpi/ic_back.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xhdpi/ic_download.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xhdpi/ic_folder.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xxhdpi/ic_back.png
Binary file not shown.
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xxhdpi/ic_folder.png
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xxxhdpi/ic_back.png
Binary file not shown.
Binary file not shown.
Binary file removed collect_app/src/main/res/drawable-xxxhdpi/ic_folder.png
Binary file not shown.
4 changes: 4 additions & 0 deletions collect_app/src/main/res/drawable/ic_file_download.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="36dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
</vector>
4 changes: 4 additions & 0 deletions collect_app/src/main/res/drawable/ic_folder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="36dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
</vector>

0 comments on commit daa6e0a

Please sign in to comment.