Added dynamic upload and download images.

This commit is contained in:
Ziver Koc 2014-08-06 13:46:08 +02:00
parent 1ed6ad198b
commit c506e2baea
2 changed files with 38 additions and 4 deletions

View file

@ -8,10 +8,13 @@ import android.net.NetworkInfo;
import android.net.wifi.WifiInfo; import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams; import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView; import android.widget.TextView;
@ -32,20 +35,28 @@ import com.jjoe64.graphview.LineGraphView;
* Created by ezivkoc on 2014-07-15. * Created by ezivkoc on 2014-07-15.
*/ */
public class StatusFragment extends Fragment { public class StatusFragment extends Fragment {
private ImageView down_img;
private TextView down_speed; private TextView down_speed;
private ImageView up_img;
private TextView up_speed; private TextView up_speed;
private TextView rat_type; private TextView rat_type;
private GraphViewSeries downGraph; private GraphViewSeries downGraph;
private GraphViewSeries upGraph; private GraphViewSeries upGraph;
private int x = 0; private int x = 0;
private Handler handler;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
handler = new Handler();
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_status, container, false); 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); 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); up_speed = (TextView) view.findViewById(R.id.up_speed);
rat_type = (TextView) view.findViewById(R.id.rat_type); rat_type = (TextView) view.findViewById(R.id.rat_type);
@ -86,10 +97,33 @@ public class StatusFragment extends Fragment {
x++; x++;
MainActivity.logThroughput(downThroughput, upThroughput); 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(){ public UeControlExecutor.ThroughputListener getThroughputListener(){
return throughputListener; return throughputListener;
} }

View file

@ -19,8 +19,8 @@
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/imageView2" android:id="@+id/down_img"
android:src="@drawable/stat_download" /> android:src="@drawable/stat_download_static" />
<TextView <TextView
android:layout_width="160dp" android:layout_width="160dp"
@ -41,8 +41,8 @@
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/imageView3" android:id="@+id/up_img"
android:src="@drawable/stat_upload" /> android:src="@drawable/stat_upload_static" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"