|
|
@@ -5,6 +5,9 @@ import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.content.ServiceConnection;
|
|
|
+import android.content.SharedPreferences;
|
|
|
+import android.net.ConnectivityManager;
|
|
|
+import android.net.NetworkInfo;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
import android.support.annotation.LayoutRes;
|
|
|
@@ -14,6 +17,7 @@ import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
@@ -23,8 +27,10 @@ import android.widget.ImageButton;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.usai.util.RAUploadManager;
|
|
|
+import com.usai.util.dbgUtil;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
@@ -285,20 +291,20 @@ public class TaskActivity extends AppCompatActivity {
|
|
|
holder = (ViewHolder)cell.getTag();
|
|
|
Log.d("_LIST", "getView: " + holder);
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
// cell = LayoutInflater.from(getApplicationContext()).inflate(resourceId,null);
|
|
|
- cell = View.inflate(getApplicationContext(),R.layout.upload_list_cell,null);
|
|
|
+ cell = View.inflate(getApplicationContext(), R.layout.upload_list_cell, null);
|
|
|
holder = new ViewHolder();
|
|
|
- holder.name_tv = (TextView)cell.findViewById(R.id.upload_name_tv);
|
|
|
- holder.progressBar = (ProgressBar)cell.findViewById(R.id.upload_progressBar);
|
|
|
- holder.state_tv = (TextView)cell.findViewById(R.id.upload_state_tv);
|
|
|
- holder.progress_tv = (TextView)cell.findViewById(R.id.upload_progress_tv);
|
|
|
- holder.err_tv = (TextView)cell.findViewById(R.id.upload_err_tv);
|
|
|
- holder.btn_reload=(ImageButton) cell.findViewById(R.id.btn_reload);
|
|
|
-
|
|
|
-
|
|
|
+ holder.name_tv = (TextView) cell.findViewById(R.id.upload_name_tv);
|
|
|
+ holder.progressBar = (ProgressBar) cell.findViewById(R.id.upload_progressBar);
|
|
|
+ holder.state_tv = (TextView) cell.findViewById(R.id.upload_state_tv);
|
|
|
+ holder.progress_tv = (TextView) cell.findViewById(R.id.upload_progress_tv);
|
|
|
+ holder.err_tv = (TextView) cell.findViewById(R.id.upload_err_tv);
|
|
|
+ holder.btn_reload = (ImageButton) cell.findViewById(R.id.btn_reload);
|
|
|
+ cell.setTag(holder);
|
|
|
+ }
|
|
|
holder.btn_reload.setImageResource(R.drawable.ic_action_reload);
|
|
|
- if(istatus!= RAUploadManager.TaskStatus.TaskStatusError)
|
|
|
+ if(istatus!= RAUploadManager.TaskStatus.TaskStatusError&& istatus!= RAUploadManager.TaskStatus.TaskStatusStop)
|
|
|
{
|
|
|
holder.btn_reload.setVisibility(View.GONE);
|
|
|
}
|
|
|
@@ -314,13 +320,75 @@ public class TaskActivity extends AppCompatActivity {
|
|
|
Bundle task = task_arr.get(position);
|
|
|
|
|
|
Log.d("_LIST", "retry: " + task.getString("file","file is null") +"position" + position);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ boolean canstart = true;
|
|
|
+
|
|
|
+ ConnectivityManager connManager = (ConnectivityManager) RedAntApplication.getInstance()
|
|
|
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
+
|
|
|
+ NetworkInfo networkInfo = connManager
|
|
|
+ .getActiveNetworkInfo();
|
|
|
+ if (networkInfo == null)
|
|
|
+ {
|
|
|
+ dbgUtil.Logd(
|
|
|
+ "Current Network info",
|
|
|
+ "can not get Active NetworkInfo!");
|
|
|
+ canstart = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NetworkInfo.State netState = networkInfo
|
|
|
+ .getState();
|
|
|
+ if (netState != NetworkInfo.State.CONNECTED)
|
|
|
+ {
|
|
|
+ dbgUtil.Logd(
|
|
|
+ "Current Network info",
|
|
|
+ "not Connected!State="
|
|
|
+ + netState);
|
|
|
+ canstart = false;
|
|
|
+ }
|
|
|
+ int iconntype = -1;
|
|
|
+ iconntype = networkInfo
|
|
|
+ .getType();
|
|
|
+
|
|
|
+ SharedPreferences pref = RedAntApplication
|
|
|
+ .getInstance()
|
|
|
+ .getSharedPreferences(
|
|
|
+ "UploadManager",
|
|
|
+ 0);
|
|
|
+ boolean
|
|
|
+ wifi_only
|
|
|
+ =pref.getBoolean("wifi_only",
|
|
|
+ true);
|
|
|
+ if(wifi_only == true
|
|
|
+ && iconntype !=
|
|
|
+ ConnectivityManager.TYPE_WIFI
|
|
|
+ && iconntype !=
|
|
|
+ 9/* earthnet */)
|
|
|
+ {
|
|
|
+ canstart = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!canstart)
|
|
|
+ {
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ "App is set to upload via WIFI only. Please change your setting or try upload manually later.",
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ v.setVisibility(View.GONE);
|
|
|
uploadManager.startTask(task);
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- cell.setTag(holder);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
holder.name_tv.setText(name);
|
|
|
// holder.progressBar.setProgress(100 *(int)percent);
|