mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Added size in FeedItemlist
This commit is contained in:
@ -1,11 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="fill_parent" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvItemname"
|
android:id="@+id/txtvItemname"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
/>
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvItemsize"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/txtvItemname"
|
||||||
|
/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package de.podfetcher.adapter;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.podfetcher.feed.FeedItem;
|
import de.podfetcher.feed.FeedItem;
|
||||||
|
import de.podfetcher.util.Converter;
|
||||||
import de.podfetcher.R;
|
import de.podfetcher.R;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -29,6 +30,7 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
|
|||||||
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
convertView = inflater.inflate(R.layout.feeditemlist_item, null);
|
convertView = inflater.inflate(R.layout.feeditemlist_item, null);
|
||||||
holder.title = (TextView) convertView.findViewById(R.id.txtvItemname);
|
holder.title = (TextView) convertView.findViewById(R.id.txtvItemname);
|
||||||
|
holder.size = (TextView) convertView.findViewById(R.id.txtvItemsize);
|
||||||
|
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
@ -36,11 +38,13 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.title.setText(item.getTitle());
|
holder.title.setText(item.getTitle());
|
||||||
|
holder.size.setText(Converter.byteToString(item.getMedia().getSize()));
|
||||||
return convertView;
|
return convertView;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Holder {
|
static class Holder {
|
||||||
TextView title;
|
TextView title;
|
||||||
|
TextView size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/de/podfetcher/util/Converter.java
Normal file
34
src/de/podfetcher/util/Converter.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package de.podfetcher.util;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/** Provides methods for converting various units */
|
||||||
|
public class Converter {
|
||||||
|
private static final String TAG = "Converter";
|
||||||
|
|
||||||
|
public static String byteToString(long input) {
|
||||||
|
int i = 0;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
for(i = 0; i < 4; i++) {
|
||||||
|
result = (int) (input / Math.pow(1024, i));
|
||||||
|
if(result < 1000) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(i) {
|
||||||
|
case 0:
|
||||||
|
return result + " B";
|
||||||
|
case 1:
|
||||||
|
return result + " KB";
|
||||||
|
case 2:
|
||||||
|
return result + " MB";
|
||||||
|
case 3:
|
||||||
|
return result + " GB";
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Error happened in byteToString");
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user