mirror of https://github.com/BOINC/boinc.git
-android: UI responsiveness and robustness improvements
-android: generalization of loading layout -android: unified layout setup routine for Trans-, Projects-, Tasks-, EventLogActivity -android: optimization of EventLogActivity
This commit is contained in:
parent
7da22d39df
commit
895ba42eaf
|
@ -1,42 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is part of BOINC.
|
||||
http://boinc.berkeley.edu
|
||||
Copyright (C) 2012 University of California
|
||||
|
||||
BOINC is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation,
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
BOINC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:text="@string/attachproject_list_loading"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is part of BOINC.
|
||||
http://boinc.berkeley.edu
|
||||
Copyright (C) 2012 University of California
|
||||
|
||||
BOINC is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation,
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
BOINC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:text="@string/eventlog_loading"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is part of BOINC.
|
||||
http://boinc.berkeley.edu
|
||||
Copyright (C) 2012 University of California
|
||||
|
||||
BOINC is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation,
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
BOINC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:text="@string/prefs_unbound"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is part of BOINC.
|
||||
http://boinc.berkeley.edu
|
||||
Copyright (C) 2012 University of California
|
||||
|
||||
BOINC is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation,
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
BOINC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:text="@string/projects_loading"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is part of BOINC.
|
||||
http://boinc.berkeley.edu
|
||||
Copyright (C) 2012 University of California
|
||||
|
||||
BOINC is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation,
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
BOINC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:text="@string/trans_loading"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -31,6 +31,6 @@
|
|||
<bool name="tab_tasks">true</bool>
|
||||
<bool name="tab_transfers">true</bool>
|
||||
<bool name="tab_preferences">true</bool>
|
||||
<bool name="tab_messages">false</bool>
|
||||
<bool name="tab_eventlog">true</bool>
|
||||
<bool name="tab_debug">false</bool>
|
||||
</resources>
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
<string name="all_projects_list">all_projects_list.xml</string>
|
||||
<string name="global_prefs_override">global_prefs_override.xml</string>
|
||||
|
||||
<!-- generic. used by multiple Activities/tabs -->
|
||||
<string name="generic_loading">Loading! Please wait…</string>
|
||||
|
||||
<!-- attach project -->
|
||||
<!-- project list -->
|
||||
<string name="attachproject_list_loading">Loading supported projects…</string>
|
||||
|
@ -117,7 +120,7 @@
|
|||
<string name="enable_computation">Enable computation</string>
|
||||
|
||||
<!-- preferences tab strings -->
|
||||
<string name="prefs_unbound">Reading preferences…</string>
|
||||
<string name="prefs_loading">Reading preferences…</string>
|
||||
<string name="prefs_submit_button">OK</string>
|
||||
<string name="prefs_dialog_title">Please enter desired value for: </string>
|
||||
<string name="prefs_category_general">General</string>
|
||||
|
@ -166,6 +169,7 @@
|
|||
<string name="confirm_deletion_cancel">Cancel</string>
|
||||
|
||||
<!-- tasks tab strings -->
|
||||
<string name="tasks_loading">Reading tasks…</string>
|
||||
<string name="tasks_result_new">new</string>
|
||||
<string name="tasks_result_files_downloading">waiting for download</string>
|
||||
<string name="tasks_result_files_downloaded">download complete</string>
|
||||
|
|
|
@ -39,6 +39,7 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AttachProjectListActivity extends Activity implements android.view.View.OnClickListener{
|
||||
|
||||
|
@ -69,7 +70,9 @@ public class AttachProjectListActivity extends Activity implements android.view.
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.attach_project_list_layout_loading);
|
||||
setContentView(R.layout.generic_layout_loading);
|
||||
TextView loadingHeader = (TextView)findViewById(R.id.loading_header);
|
||||
loadingHeader.setText(R.string.attachproject_list_loading);
|
||||
|
||||
Log.d(TAG, "onCreate");
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ public class BOINCActivity extends TabActivity {
|
|||
tabHost.addTab(prefsSpec);
|
||||
}
|
||||
|
||||
if(res.getBoolean(R.bool.tab_messages)) {
|
||||
if(res.getBoolean(R.bool.tab_eventlog)) {
|
||||
TabSpec msgsSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_eventlog));
|
||||
msgsSpec.setIndicator(getResources().getString(R.string.tab_eventlog), getResources().getDrawable(R.drawable.icon_msgs_tab));
|
||||
Intent msgsIntent = new Intent(this, EventLogActivity.class);
|
||||
|
|
|
@ -20,59 +20,35 @@ package edu.berkeley.boinc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.lang.StringBuffer;
|
||||
|
||||
import edu.berkeley.boinc.adapter.EventLogListAdapter;
|
||||
import edu.berkeley.boinc.client.Monitor;
|
||||
import edu.berkeley.boinc.rpc.Message;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MenuInflater;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class EventLogActivity extends FragmentActivity {
|
||||
|
||||
private final String TAG = "BOINC EventLogActivity";
|
||||
|
||||
private Monitor monitor;
|
||||
private Boolean mIsBound;
|
||||
|
||||
private ListView lv;
|
||||
private EventLogListAdapter listAdapter;
|
||||
private ArrayList<Message> data = new ArrayList<Message>();
|
||||
private int lastSeqno = 0;
|
||||
|
||||
// Controls when to display the proper messages activity, by default we display a
|
||||
// view that says we are loading messages. When initialSetup is false, we have
|
||||
// something to display.
|
||||
//
|
||||
private Boolean initialSetup;
|
||||
|
||||
// This is called when the connection with the service has been established,
|
||||
// getService returns the Monitor object that is needed to call functions.
|
||||
//
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
monitor = ((Monitor.LocalBinder)service).getService();
|
||||
mIsBound = true;
|
||||
}
|
||||
|
||||
public void onServiceDisconnected(ComponentName className) {
|
||||
monitor = null;
|
||||
mIsBound = false;
|
||||
}
|
||||
};
|
||||
// Controls whether initialization of view elements of "projects_layout"
|
||||
// is required. This is the case, every time the layout switched.
|
||||
private Boolean initialSetupRequired = true;
|
||||
|
||||
// BroadcastReceiver event is used to update the UI with updated information from
|
||||
// the client. This is generally called once a second.
|
||||
|
@ -83,30 +59,7 @@ public class EventLogActivity extends FragmentActivity {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "ClientStatusChange - onReceive()");
|
||||
|
||||
// Read messages from state saved in ClientStatus
|
||||
ArrayList<Message> tmpA = Monitor.getClientStatus().getMessages();
|
||||
if(tmpA == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to a view that can actually display messages
|
||||
if (initialSetup) {
|
||||
initialSetup = false;
|
||||
setContentView(R.layout.eventlog_layout);
|
||||
lv = (ListView) findViewById(R.id.eventlogList);
|
||||
listAdapter = new EventLogListAdapter(EventLogActivity.this, lv, R.id.eventlogList, data);
|
||||
}
|
||||
|
||||
// Add new messages to the event log
|
||||
for (Message msg: tmpA) {
|
||||
if (msg.seqno > lastSeqno) {
|
||||
data.add(msg);
|
||||
lastSeqno = msg.seqno;
|
||||
}
|
||||
}
|
||||
|
||||
// Force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged();
|
||||
populateLayout();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -119,10 +72,6 @@ public class EventLogActivity extends FragmentActivity {
|
|||
Log.d(TAG, "onCreate()");
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Establish a connection with the service, onServiceConnected gets called when
|
||||
// (calling within Tab needs getApplicationContext() for bindService to work!)
|
||||
getApplicationContext().bindService(new Intent(this, Monitor.class), mConnection, Service.START_STICKY_COMPATIBILITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,9 +88,7 @@ public class EventLogActivity extends FragmentActivity {
|
|||
|
||||
super.onResume();
|
||||
|
||||
// Switch to the loading view until we have something to display
|
||||
initialSetup = true;
|
||||
setContentView(R.layout.eventlog_layout_loading);
|
||||
populateLayout();
|
||||
|
||||
registerReceiver(mClientStatusChangeRec, ifcsc);
|
||||
}
|
||||
|
@ -149,14 +96,51 @@ public class EventLogActivity extends FragmentActivity {
|
|||
@Override
|
||||
protected void onDestroy() {
|
||||
Log.d(TAG, "onDestroy()");
|
||||
|
||||
if (mIsBound) {
|
||||
getApplicationContext().unbindService(mConnection);
|
||||
mIsBound = false;
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void populateLayout() {
|
||||
try {
|
||||
// Read messages from state saved in ClientStatus
|
||||
ArrayList<Message> tmpA = Monitor.getClientStatus().getMessages();
|
||||
|
||||
if(tmpA == null) {
|
||||
setLayoutLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to a view that can actually display messages
|
||||
if (initialSetupRequired) {
|
||||
initialSetupRequired = false;
|
||||
setContentView(R.layout.eventlog_layout);
|
||||
lv = (ListView) findViewById(R.id.eventlogList);
|
||||
listAdapter = new EventLogListAdapter(EventLogActivity.this, lv, R.id.eventlogList, data);
|
||||
}
|
||||
|
||||
// Add new messages to the event log
|
||||
for (Message msg: tmpA) {
|
||||
if (msg.seqno > lastSeqno) {
|
||||
data.add(msg);
|
||||
lastSeqno = msg.seqno;
|
||||
}
|
||||
}
|
||||
|
||||
// Force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
} catch (Exception e) {
|
||||
// data retrieval failed, set layout to loading...
|
||||
setLayoutLoading();
|
||||
}
|
||||
}
|
||||
|
||||
private void setLayoutLoading() {
|
||||
setContentView(R.layout.generic_layout_loading);
|
||||
TextView loadingHeader = (TextView)findViewById(R.id.loading_header);
|
||||
loadingHeader.setText(R.string.eventlog_loading);
|
||||
initialSetupRequired = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
|
|
@ -184,7 +184,9 @@ public class PrefsActivity extends Activity implements OnClickListener {
|
|||
}
|
||||
|
||||
private void setDataOutdated() {
|
||||
setContentView(R.layout.prefs_layout_loading);
|
||||
setContentView(R.layout.generic_layout_loading);
|
||||
TextView loadingHeader = (TextView)findViewById(R.id.loading_header);
|
||||
loadingHeader.setText(R.string.prefs_loading);
|
||||
dataOutdated = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.view.Menu;
|
|||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class ProjectsActivity extends FragmentActivity {
|
||||
|
@ -55,11 +56,9 @@ public class ProjectsActivity extends FragmentActivity {
|
|||
private ProjectsListAdapter listAdapter;
|
||||
private ArrayList<Project> data = new ArrayList<Project>();
|
||||
|
||||
// Controls when to display the proper projects activity, by default we display a
|
||||
// view that says we are loading projects. When initialSetup is false, we have
|
||||
// something to display.
|
||||
//
|
||||
private Boolean initialSetup;
|
||||
// Controls whether initialization of view elements of "projects_layout"
|
||||
// is required. This is the case, every time the layout switched.
|
||||
private Boolean initialSetupRequired = true;
|
||||
|
||||
// This is called when the connection with the service has been established,
|
||||
// getService returns the Monitor object that is needed to call functions.
|
||||
|
@ -84,29 +83,7 @@ public class ProjectsActivity extends FragmentActivity {
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "ClientStatusChange - onReceive()");
|
||||
|
||||
// Read projects from state saved in ClientStatus
|
||||
ArrayList<Project> tmpA = Monitor.getClientStatus().getProjects();
|
||||
if(tmpA == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to a view that can actually display messages
|
||||
if (initialSetup) {
|
||||
initialSetup = false;
|
||||
setContentView(R.layout.projects_layout);
|
||||
lv = (ListView) findViewById(R.id.projectsList);
|
||||
listAdapter = new ProjectsListAdapter(ProjectsActivity.this, lv, R.id.projectsList, data);
|
||||
}
|
||||
|
||||
// Update Project data
|
||||
data.clear();
|
||||
for (Project tmp: tmpA) {
|
||||
data.add(tmp);
|
||||
}
|
||||
|
||||
// Force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged();
|
||||
populateLayout();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -136,9 +113,7 @@ public class ProjectsActivity extends FragmentActivity {
|
|||
|
||||
super.onResume();
|
||||
|
||||
// Switch to the loading view until we have something to display
|
||||
initialSetup = true;
|
||||
setContentView(R.layout.projects_layout_loading);
|
||||
populateLayout();
|
||||
|
||||
registerReceiver(mClientStatusChangeRec, ifcsc);
|
||||
}
|
||||
|
@ -155,6 +130,46 @@ public class ProjectsActivity extends FragmentActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void populateLayout() {
|
||||
try {
|
||||
// read projects from state saved in ClientStatus
|
||||
ArrayList<Project> tmpA = Monitor.getClientStatus().getProjects();
|
||||
|
||||
if(tmpA == null) {
|
||||
setLayoutLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to a view that can actually display messages
|
||||
if (initialSetupRequired) {
|
||||
initialSetupRequired = false;
|
||||
setContentView(R.layout.projects_layout);
|
||||
lv = (ListView) findViewById(R.id.projectsList);
|
||||
listAdapter = new ProjectsListAdapter(ProjectsActivity.this, lv, R.id.projectsList, data);
|
||||
}
|
||||
|
||||
// Update Project data
|
||||
data.clear();
|
||||
for (Project tmp: tmpA) {
|
||||
data.add(tmp);
|
||||
}
|
||||
|
||||
// Force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
} catch (Exception e) {
|
||||
// data retrieval failed, set layout to loading...
|
||||
setLayoutLoading();
|
||||
}
|
||||
}
|
||||
|
||||
private void setLayoutLoading() {
|
||||
setContentView(R.layout.generic_layout_loading);
|
||||
TextView loadingHeader = (TextView)findViewById(R.id.loading_header);
|
||||
loadingHeader.setText(R.string.projects_loading);
|
||||
initialSetupRequired = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
Log.d(TAG, "onCreateOptionsMenu()");
|
||||
|
|
|
@ -21,7 +21,6 @@ package edu.berkeley.boinc;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import edu.berkeley.boinc.adapter.TasksListAdapter;
|
||||
import edu.berkeley.boinc.client.ClientStatus;
|
||||
import edu.berkeley.boinc.client.Monitor;
|
||||
import edu.berkeley.boinc.rpc.Result;
|
||||
import android.app.Activity;
|
||||
|
@ -32,18 +31,20 @@ import android.content.IntentFilter;
|
|||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TasksActivity extends Activity {
|
||||
|
||||
private final String TAG = "BOINC TasksActivity";
|
||||
|
||||
private ClientStatus status; //client status, new information gets parsed by monitor, changes notified by "clientstatus" broadcast. read Result from here, to get information about tasks.
|
||||
|
||||
private ListView lv;
|
||||
private TasksListAdapter listAdapter;
|
||||
|
||||
private ArrayList<Result> data = new ArrayList<Result>(); //Adapter for list data
|
||||
private Boolean setup = false;
|
||||
|
||||
// Controls whether initialization of view elements of "tasks_layout"
|
||||
// is required. This is the case, every time the layout switched.
|
||||
private Boolean initialSetupRequired = true;
|
||||
|
||||
private BroadcastReceiver mClientStatusChangeRec = new BroadcastReceiver() {
|
||||
|
||||
|
@ -51,21 +52,13 @@ public class TasksActivity extends Activity {
|
|||
@Override
|
||||
public void onReceive(Context context,Intent intent) {
|
||||
Log.d(TAG,"onReceive");
|
||||
loadData(); // refresh list view
|
||||
populateLayout();
|
||||
}
|
||||
};
|
||||
private IntentFilter ifcsc = new IntentFilter("edu.berkeley.boinc.clientstatuschange");
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tasks_layout);
|
||||
|
||||
//get singleton client status from monitor
|
||||
status = Monitor.getClientStatus();
|
||||
|
||||
//load data model
|
||||
loadData();
|
||||
|
||||
|
||||
Log.d(TAG,"onCreate");
|
||||
}
|
||||
|
@ -75,7 +68,7 @@ public class TasksActivity extends Activity {
|
|||
//register noisy clientStatusChangeReceiver here, so only active when Activity is visible
|
||||
Log.d(TAG+"-onResume","register receiver");
|
||||
registerReceiver(mClientStatusChangeRec,ifcsc);
|
||||
loadData();
|
||||
populateLayout();
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
|
@ -86,31 +79,43 @@ public class TasksActivity extends Activity {
|
|||
}
|
||||
|
||||
|
||||
private void loadData() {
|
||||
|
||||
//setup list and adapter
|
||||
ArrayList<Result> tmpA = status.getTasks();
|
||||
if(tmpA!=null) { //can be null before first monitor status cycle (e.g. when not logged in or during startup)
|
||||
|
||||
private void populateLayout() {
|
||||
try {
|
||||
//setup list and adapter
|
||||
ArrayList<Result> tmpA = Monitor.getClientStatus().getTasks();
|
||||
|
||||
if(tmpA == null) {
|
||||
setLayoutLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
//deep copy, so ArrayList adapter actually recognizes the difference
|
||||
data.clear();
|
||||
for (Result tmp: tmpA) {
|
||||
data.add(tmp);
|
||||
}
|
||||
|
||||
if(!setup) {// first time we got proper results, setup adapter
|
||||
if(initialSetupRequired) {// first time we got proper results, setup adapter
|
||||
initialSetupRequired = false;
|
||||
setContentView(R.layout.tasks_layout);
|
||||
lv = (ListView) findViewById(R.id.tasksList);
|
||||
listAdapter = new TasksListAdapter(TasksActivity.this,R.id.tasksList,data);
|
||||
lv.setAdapter(listAdapter);
|
||||
|
||||
setup = true;
|
||||
}
|
||||
|
||||
Log.d(TAG,"loadData: array contains " + data.size() + " results.");
|
||||
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
|
||||
}else {
|
||||
Log.d(TAG, "loadData array is null");
|
||||
|
||||
} catch (Exception e) {
|
||||
// data retrieval failed, set layout to loading...
|
||||
setLayoutLoading();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setLayoutLoading() {
|
||||
setContentView(R.layout.generic_layout_loading);
|
||||
TextView loadingHeader = (TextView)findViewById(R.id.loading_header);
|
||||
loadingHeader.setText(R.string.tasks_loading);
|
||||
initialSetupRequired = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,10 @@
|
|||
package edu.berkeley.boinc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import edu.berkeley.boinc.adapter.TransListAdapter;
|
||||
import edu.berkeley.boinc.client.ClientStatus;
|
||||
import edu.berkeley.boinc.client.Monitor;
|
||||
import edu.berkeley.boinc.rpc.CcStatus;
|
||||
import edu.berkeley.boinc.rpc.Transfer;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.Service;
|
||||
|
@ -42,6 +39,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TransActivity extends FragmentActivity {
|
||||
|
||||
|
@ -55,12 +53,9 @@ public class TransActivity extends FragmentActivity {
|
|||
private ArrayList<Transfer> data = new ArrayList<Transfer>();
|
||||
private CcStatus status;
|
||||
|
||||
|
||||
// Controls when to display the proper projects activity, by default we display a
|
||||
// view that says we are loading projects. When initialSetup is false, we have
|
||||
// something to display.
|
||||
//
|
||||
private Boolean initialSetup;
|
||||
// Controls whether initialization of view elements of "projects_layout"
|
||||
// is required. This is the case, every time the layout switched.
|
||||
private Boolean initialSetupRequired = true;
|
||||
|
||||
// This is called when the connection with the service has been established,
|
||||
// getService returns the Monitor object that is needed to call functions.
|
||||
|
@ -86,32 +81,7 @@ public class TransActivity extends FragmentActivity {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "ClientStatusChange - onReceive()");
|
||||
|
||||
// Read transfers from state saved in ClientStatus
|
||||
ArrayList<Transfer> tmpA = Monitor.getClientStatus().getTransfers();
|
||||
if(tmpA == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Read core client status (net up/down, cpu suspended, network suspended) from
|
||||
// state saved in ClientStatus
|
||||
status = Monitor.getClientStatus().getClientStatus();
|
||||
|
||||
// Switch to a view that can actually display messages
|
||||
if (initialSetup) {
|
||||
initialSetup = false;
|
||||
setContentView(R.layout.trans_layout);
|
||||
lv = (ListView) findViewById(R.id.transList);
|
||||
listAdapter = new TransListAdapter(TransActivity.this, lv, R.id.projectsList, data, status);
|
||||
}
|
||||
|
||||
// Update Transfer data
|
||||
data.clear();
|
||||
for (Transfer tmp: tmpA) {
|
||||
data.add(tmp);
|
||||
}
|
||||
|
||||
// Force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged();
|
||||
populateLayout();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -138,8 +108,7 @@ public class TransActivity extends FragmentActivity {
|
|||
super.onResume();
|
||||
|
||||
// Switch to the loading view until we have something to display
|
||||
initialSetup = true;
|
||||
setContentView(R.layout.trans_layout_loading);
|
||||
populateLayout();
|
||||
|
||||
registerReceiver(mClientStatusChangeRec, ifcsc);
|
||||
}
|
||||
|
@ -156,6 +125,49 @@ public class TransActivity extends FragmentActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void populateLayout() {
|
||||
try {
|
||||
// Read transfers from state saved in ClientStatus
|
||||
ArrayList<Transfer> tmpA = Monitor.getClientStatus().getTransfers();
|
||||
|
||||
// Read core client status (net up/down, cpu suspended, network suspended) from
|
||||
// state saved in ClientStatus
|
||||
status = Monitor.getClientStatus().getClientStatus();
|
||||
|
||||
if(tmpA == null || status == null) {
|
||||
setLayoutLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to a view that can actually display messages
|
||||
if (initialSetupRequired) {
|
||||
initialSetupRequired = false;
|
||||
setContentView(R.layout.trans_layout);
|
||||
lv = (ListView) findViewById(R.id.transList);
|
||||
listAdapter = new TransListAdapter(TransActivity.this, lv, R.id.projectsList, data, status);
|
||||
}
|
||||
|
||||
// Update Transfer data
|
||||
data.clear();
|
||||
for (Transfer tmp: tmpA) {
|
||||
data.add(tmp);
|
||||
}
|
||||
|
||||
// Force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged();
|
||||
} catch (Exception e) {
|
||||
// data retrieval failed, set layout to loading...
|
||||
setLayoutLoading();
|
||||
}
|
||||
}
|
||||
|
||||
private void setLayoutLoading() {
|
||||
setContentView(R.layout.generic_layout_loading);
|
||||
TextView loadingHeader = (TextView)findViewById(R.id.loading_header);
|
||||
loadingHeader.setText(R.string.trans_loading);
|
||||
initialSetupRequired = true;
|
||||
}
|
||||
|
||||
public void onTransferClicked(String url, String name) {
|
||||
Log.d(TAG, "onTransferClicked()");
|
||||
}
|
||||
|
|
|
@ -521,7 +521,7 @@ public class Monitor extends Service {
|
|||
GlobalPreferences clientPrefs = rpc.getGlobalPrefsWorkingStruct();
|
||||
ArrayList<Message> msgs = new ArrayList<Message>();
|
||||
// retrieve messages only, if tabs are actually enabled. very resource intense with logging on emulator!
|
||||
if(getResources().getBoolean(R.bool.tab_messages) || getResources().getBoolean(R.bool.tab_debug)) {
|
||||
if(getResources().getBoolean(R.bool.tab_eventlog) || getResources().getBoolean(R.bool.tab_debug)) {
|
||||
Integer count = rpc.getMessageCount();
|
||||
msgs = rpc.getMessages(count - 250); //get the most recent 250 messages
|
||||
if(showRpcCommands) Log.d(TAG, "getMessages, count: " + count);
|
||||
|
|
Loading…
Reference in New Issue