From c506e2baea4035b420cd2f7af568a320567c0d6a Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Wed, 6 Aug 2014 13:46:08 +0200 Subject: [PATCH] Added dynamic upload and download images. --- .../gui/fragments/StatusFragment.java | 34 +++++++++++++++++++ app/src/main/res/layout/fragment_status.xml | 8 ++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java index a6af508..553d720 100755 --- a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java +++ b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java @@ -8,10 +8,13 @@ import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; import android.telephony.TelephonyManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; @@ -32,20 +35,28 @@ import com.jjoe64.graphview.LineGraphView; * Created by ezivkoc on 2014-07-15. */ public class StatusFragment extends Fragment { + private ImageView down_img; private TextView down_speed; + private ImageView up_img; private TextView up_speed; private TextView rat_type; private GraphViewSeries downGraph; private GraphViewSeries upGraph; + private int x = 0; + private Handler handler; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + handler = new Handler(); + // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_status, container, false); + down_img = (ImageView) view.findViewById(R.id.down_img); down_speed = (TextView) view.findViewById(R.id.down_speed); + up_img = (ImageView) view.findViewById(R.id.up_img); up_speed = (TextView) view.findViewById(R.id.up_speed); rat_type = (TextView) view.findViewById(R.id.rat_type); @@ -86,10 +97,33 @@ public class StatusFragment extends Fragment { x++; MainActivity.logThroughput(downThroughput, upThroughput); + startActivityTimer(); } }); } }; + + private void startActivityTimer(){ + // Set active images + if(down_img != null) + down_img.setImageResource(R.drawable.stat_download); + if(up_img != null) + up_img.setImageResource(R.drawable.stat_upload); + + // Start reset timer + if(handler != null) { + handler.removeMessages(0); + handler.postDelayed(new Runnable() { + public void run() { + if (down_img != null) + down_img.setImageResource(R.drawable.stat_download_static); + if (up_img != null) + up_img.setImageResource(R.drawable.stat_upload_static); + } + }, 2000); + } + } + public UeControlExecutor.ThroughputListener getThroughputListener(){ return throughputListener; } diff --git a/app/src/main/res/layout/fragment_status.xml b/app/src/main/res/layout/fragment_status.xml index 4882fc6..a833010 100755 --- a/app/src/main/res/layout/fragment_status.xml +++ b/app/src/main/res/layout/fragment_status.xml @@ -19,8 +19,8 @@ + android:id="@+id/down_img" + android:src="@drawable/stat_download_static" /> + android:id="@+id/up_img" + android:src="@drawable/stat_upload_static" />