Skip to content
Permalink
Browse files

appmonitor: add the current time usage

Also format it properly depending on the value.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
  • Loading branch information
Blechd0se committed Jun 12, 2015
1 parent 8205d4d commit 051d2fa624db0d166e7233c9905f7bee87620d91
@@ -7,19 +7,29 @@
android:padding="5dp"
android:descendantFocusability="beforeDescendants">

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowimage"
android:layout_width="42dp"
android:layout_height="42dp"
android:padding="2dp"
android:layout_alignParentLeft="true"/>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowimage"
android:layout_width="42dp"
android:layout_height="42dp"
android:padding="2dp"
android:layout_alignParentLeft="true"/>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowtext"
android:layout_width="wrap_content"
android:textColor="@color/light_grey"
android:textSize="16sp"
android:padding="2dp"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/rowimage"/>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowtime"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="16sp"
android:layout_alignParentRight="true"
android:focusable="false"
android:padding="10dp" />

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowtext"
android:layout_width="wrap_content"
android:textColor="@color/light_grey"
android:textSize="16sp"
android:padding="2dp"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/rowimage"/>
</RelativeLayout>
@@ -12,6 +12,7 @@

import com.aero.control.R;
import com.aero.control.helpers.PerApp.AppMonitor.model.AppElement;
import com.aero.control.helpers.Util;

import java.util.List;

@@ -35,6 +36,7 @@ public AppDataAdapter(Context context, int layoutResourceId, List<AppElement> da
public static class Holder {
ImageView image;
TextView text;
TextView textTime;
}

@Override
@@ -61,7 +63,9 @@ public View getView(final int position, View convertView, ViewGroup parent) {
holder = new Holder();
holder.image = (ImageView) row.findViewById(R.id.rowimage);
holder.text = (TextView) row.findViewById((R.id.rowtext));
holder.textTime = (TextView) row.findViewById(R.id.rowtime);
holder.text.setTypeface(font);
holder.textTime.setTypeface(font);


row.setTag(holder);
@@ -74,6 +78,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
if (data != null) {

holder.text.setText(overview.getRealName() + "\n" + overview.getName());
holder.textTime.setText(Util.convertMsToHours(overview.getUsage()));
holder.image.setImageDrawable(overview.getImage());
holder.image.setTag(position);

@@ -6,6 +6,7 @@

import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
* Created by Alexander Christ on 25.05.15.
@@ -34,4 +35,25 @@ public static CharSequence getRandomLoadingText(Context context) {
return context.getText(randomData.get(new Random().nextInt(randomData.size())));
}

/**
* Shows different output depending on the passed value.
* @param milliseconds long, Time in milliseconds.
* @return String
*/
public static String convertMsToHours(long milliseconds) {
if (milliseconds >= 60000) {
// If we are just above one minute
return String.format("%d min",
TimeUnit.MILLISECONDS.toMinutes(milliseconds));
} else if (milliseconds >= 3600000) {
// If we are above one hour;
return String.format("%dh",
TimeUnit.MILLISECONDS.toHours(milliseconds));
} else {
// Fall through, should actually never appear
return String.format("%d secs",
TimeUnit.MILLISECONDS.toSeconds(milliseconds));
}
}

}

0 comments on commit 051d2fa

Please sign in to comment.
You can’t perform that action at this time.