List of usage examples for android.widget TextView sendAccessibilityEvent
public void sendAccessibilityEvent(int eventType)
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*/*from ww w .j a v a 2 s. c o m*/ * device = (DeviceDescription) getIntent().getSerializableExtra( * Constants.INTENT_EXTRA_DEVICE); isCurrentDevice = * getIntent().getBooleanExtra( * Constants.INTENT_EXTRA_IS_CURRENT_DEVICE, false); * * List<DeviceDescription> devices = AppSettings.getInstance() * .getDevices(); String imei = * PhoneIdentityDataCollector.getImei(this); currentDevice = new * CurrentDeviceDescription(imei); OtherUtils.removeDeviceForImei(imei, * devices); */ this.setTitle(getString(R.string.average_results_title)); setContentView(R.layout.page_views); dbHelper = new DBHelper(SamKnowsAggregateStatViewerActivity.this); dbHelperAsync = new DBHelper(SamKnowsAggregateStatViewerActivity.this); adapter = new MyPagerAdapter(this); viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(adapter); // viewPager.setOffscreenPageLimit(3); final TextView tvHeader = (TextView) findViewById(R.id.textViewHeader); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int page) { tvHeader.setText(getString(R.string.page) + " " + (page + 1)); if (page == 0) { on_aggregate_page = true; boolean db_refresh = false; SamKnowsAggregateStatViewerActivity.this.setTitle(getString(R.string.average_results)); TextView timestamp; View v; v = viewPager.findViewWithTag(page); timestamp = (TextView) v.findViewById(R.id.average_results_title); timestamp.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); if (setTotalArchiveRecords()) { adapter = new MyPagerAdapter(SamKnowsAggregateStatViewerActivity.this); viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(adapter); } } else { TextView timestamp; View v; v = viewPager.findViewWithTag(page); timestamp = (TextView) v.findViewById(R.id.timestamp); timestamp.setContentDescription(getString(R.string.archive_result) + " " + timestamp.getText()); timestamp.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); on_aggregate_page = false; SamKnowsAggregateStatViewerActivity.this.setTitle(getString(R.string.archive_result)); } } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_SETTLING) { } } }); Util.initializeFonts(this); Util.overrideFonts(this, findViewById(android.R.id.content)); }
From source file:com.samknows.measurement.activity.SamKnowsTestViewerActivity.java
/** Called when the activity is first created. */ @Override//from w w w .j a v a 2 s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); cxt = this; Bundle b = getIntent().getExtras(); int testID = -1; if (b != null) { testID = b.getInt("testID"); } storage = CachingStorage.getInstance(); config = storage.loadScheduleConfig(); if (config == null) { config = new ScheduleConfig(); } testList = config.manual_tests; array_spinner = new String[testList.size() + 1]; array_spinner_int = new int[testList.size() + 1]; this.setTitle(R.string.running_test); // choose which test to run setContentView(R.layout.individual_stat_test); Util.initializeFonts(this); Util.overrideFonts(this, findViewById(android.R.id.content)); try { handler = new Handler() { @Override public void handleMessage(Message msg) { TextView tv = null; JSONObject message_json; message_json = (JSONObject) msg.obj; String value; int success; int testname; int status_complete; int metric; try { String type = message_json.getString(TestResult.JSON_TYPE_ID); if (type == "completed") { result = 1; SamKnowsTestViewerActivity.this.finish(); overridePendingTransition(0, 0); } if (type == "test") { testname = message_json.getInt(TestResult.JSON_TESTNUMBER); status_complete = message_json.getInt(TestResult.JSON_STATUS_COMPLETE); value = message_json.getString(TestResult.JSON_HRRESULT); if (status_complete == 100 && message_json.has(TestResult.JSON_SUCCESS)) { success = message_json.getInt(TestResult.JSON_SUCCESS); if (success == 0) { value = getString(R.string.failed); } } switch (testname) { // active metrics case TestResult.DOWNLOAD_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel1); tv = (TextView) findViewById(R.id.download_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.download) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.UPLOAD_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel2); tv = (TextView) findViewById(R.id.upload_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.upload) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.PACKETLOSS_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel3); tv = (TextView) findViewById(R.id.packetloss_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.packet_loss) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.LATENCY_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel4); tv = (TextView) findViewById(R.id.latency_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.latency) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.JITTER_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel5); tv = (TextView) findViewById(R.id.jitter_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.jitter) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; } } if (type == "passivemetric") { metric = message_json.getInt("metric"); value = message_json.getString("value"); switch (metric) { // passive metrics case 1: tv = (TextView) findViewById(R.id.passivemetric1); tv.setText(value); break; case 2: tv = (TextView) findViewById(R.id.passivemetric2); tv.setText(value); break; case 3: tv = (TextView) findViewById(R.id.passivemetric3); tv.setText(value); break; case 4: tv = (TextView) findViewById(R.id.passivemetric4); tv.setText(value); break; case 5: tv = (TextView) findViewById(R.id.passivemetric5); tv.setText(value); break; case 6: tv = (TextView) findViewById(R.id.passivemetric6); tv.setText(value); break; case 7: tv = (TextView) findViewById(R.id.passivemetric7); tv.setText(value); break; case 8: tv = (TextView) findViewById(R.id.passivemetric8); tv.setText(value); break; case 9: tv = (TextView) findViewById(R.id.passivemetric9); tv.setText(value); break; case 10: tv = (TextView) findViewById(R.id.passivemetric10); tv.setText(value); break; case 11: tv = (TextView) findViewById(R.id.passivemetric11); tv.setText(value); break; case 12: tv = (TextView) findViewById(R.id.passivemetric12); tv.setText(value); break; case 13: tv = (TextView) findViewById(R.id.passivemetric13); tv.setText(value); break; case 14: tv = (TextView) findViewById(R.id.passivemetric14); tv.setText(value); break; case 15: tv = (TextView) findViewById(R.id.passivemetric15); tv.setText(value); break; case 16: tv = (TextView) findViewById(R.id.passivemetric16); tv.setText(value); break; case 17: tv = (TextView) findViewById(R.id.passivemetric17); tv.setText(value); break; case 18: tv = (TextView) findViewById(R.id.passivemetric18); tv.setText(value); break; case 19: tv = (TextView) findViewById(R.id.passivemetric19); tv.setText(value); break; case 20: tv = (TextView) findViewById(R.id.passivemetric20); tv.setText(value); break; case 21: tv = (TextView) findViewById(R.id.passivemetric21); tv.setText(value); break; case 22: tv = (TextView) findViewById(R.id.passivemetric22); tv.setText(value); break; case 23: tv = (TextView) findViewById(R.id.passivemetric23); tv.setText(value); break; case 24: tv = (TextView) findViewById(R.id.passivemetric24); tv.setText(value); break; case 25: tv = (TextView) findViewById(R.id.passivemetric25); tv.setText(value); break; case 26: tv = (TextView) findViewById(R.id.passivemetric26); tv.setText(value); break; case 27: tv = (TextView) findViewById(R.id.passivemetric27); tv.setText(value); break; case 28: tv = (TextView) findViewById(R.id.passivemetric28); tv.setText(value); break; case 29: tv = (TextView) findViewById(R.id.passivemetric29); tv.setText(value); break; case 30: tv = (TextView) findViewById(R.id.passivemetric30); tv.setText(value); break; case 31: tv = (TextView) findViewById(R.id.passivemetric31); tv.setText(value); break; case 32: tv = (TextView) findViewById(R.id.passivemetric32); tv.setText(value); break; default: // } if (!value.equals("") && tv != null) { TableLayout tl1 = (TableLayout) findViewById(R.id.passive_metrics_status); tl1.setVisibility(View.GONE); TableLayout tl = (TableLayout) tv.getParent().getParent(); tl.setVisibility(View.VISIBLE); } if (value.equals("") && tv != null) { TableLayout tl = (TableLayout) tv.getParent().getParent(); tl.setVisibility(View.GONE); } } } catch (JSONException e) { Logger.e(this, e.getMessage()); } } }; launchTest(testID); } catch (Throwable t) { Logger.e(this, "handler or test failure", t); } }