public ResultItem<T>[] getMergedResult() { Insertion[] insertedByA = new Insertion[base.length + 1]; boolean[] deletedByA = new boolean[base.length]; Insertion[] insertedByB = new Insertion[base.length + 1]; boolean[] deletedByB = new boolean[base.length]; Diff aDiff = new Diff(base, a); Diff.change aChanges = aDiff.diff_2(false); recordChanges(insertedByA, deletedByA, aChanges); Diff bDiff = new Diff(base, b); Diff.change bChanges = bDiff.diff_2(false); recordChanges(insertedByB, deletedByB, bChanges); List<ResultItem> result = new ArrayList<ResultItem>(); InsertedItemFactory<T> aFactory = new InsertedItemFactoryA(); InsertedItemFactory<T> bFactory = new InsertedItemFactoryB(); int aPos = 0; int bPos = 0; for (int i = 0; i <= base.length; i++) { if (insertedByA[i] != null) aPos = addInsertions(result, insertedByA[i], aFactory); if (insertedByB[i] != null) bPos = addInsertions(result, insertedByB[i], bFactory); if (i < base.length) { ResultItem<T> item = new ResultItem<T>(base[i], i, -1, -1); if (deletedByA[i] == false) item.aPos = aPos++; if (deletedByB[i] == false) item.bPos = bPos++; result.add(item); } } return (ResultItem<T>[]) result.toArray(new ResultItem[result.size()]); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; ResultHolder holder = null; final LinearLayout container = (LinearLayout) row; if (row == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new ResultHolder(); holder.pricePerTest = (TextView) row.findViewById(R.id.pricePerTest); holder.infoIcon = (TextView) row.findViewById(R.id.labInfoIcon); Typeface font = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf"); holder.infoIcon.setTypeface(font); holder.lab_add = (TextView) row.findViewById(R.id.lab_add); holder.lab_address = (TextView) row.findViewById(R.id.lab_address); holder.tvhcharges = (TextView) row.findViewById(R.id.tvhcharges); if (frag.equals("toprated")) { holder.lab_add.setVisibility(View.GONE); holder.lab_address.setVisibility(View.GONE); holder.tvhcharges.setVisibility(View.VISIBLE); } holder.lab_name = (TextView) row.findViewById(R.id.lab_name); holder.mrp = (TextView) row.findViewById(R.id.mrp); holder.cost = (TextView) row.findViewById(R.id.cost); holder.saving = (TextView) row.findViewById(R.id.saving); holder.rating = (TextView) row.findViewById(R.id.rating); holder.circle = (LinearLayout) row.findViewById(R.id.rating_circle); holder.select = (Button) row.findViewById(R.id.selectlab); holder.nabl = (TextView) row.findViewById(R.id.nabl); holder.homeCollectionPrice = (TextView) row.findViewById(R.id.homeCollectionPrice); // holder.expand=(ImageView)row.findViewById(R.id.expand_newfeatures); // holder.num_rating=(TextView)row.findViewById(R.id.number_rating); holder.tvhcharges = (TextView) row.findViewById(R.id.tvhcharges); holder.ac = (ImageView) row.findViewById(R.id.ac_boolean_icon); holder.ambulance = (ImageView) row.findViewById(R.id.ambulance_boolean_icon); holder.homecollection = (ImageView) row.findViewById(R.id.homecollection_boolean_icon); holder.cc_accept = (ImageView) row.findViewById(R.id.cc_accept_boolean_icon); holder.ac_tv = (TextView) row.findViewById(R.id.airconditioning); holder.ambulance_tv = (TextView) row.findViewById(R.id.ambulance); // holder.homecollection_tv=(TextView)row.findViewById(R.id.homecollection); holder.cc_accept_tv = (TextView) row.findViewById(R.id.creditcardsaccepted); // holder.homecollectionava=(TextView)row.findViewById(R.id.homecollectionava); // holder.direction=(ImageButton)row.findViewById(R.id.direction_list); /* holder.ambulance.setVisibility(container.GONE); holder.ac.setVisibility(container.GONE); holder.homecollection.setVisibility(container.GONE); holder.cc_accept.setVisibility(container.GONE); holder.ambulance_tv.setVisibility(container.GONE); holder.ac_tv.setVisibility(container.GONE); holder.homecollection_tv.setVisibility(container.GONE); holder.cc_accept_tv.setVisibility(container.GONE); */ row.setTag(holder); } else { holder = (ResultHolder) row.getTag(); } final ResultItem currentResultItem = resultItemArrayList.get(position); double a = currentResultItem.getPriceMrp(); double b = currentResultItem.getPriceUser(); double disc = (a - b) / a * 100; int dis = (int) disc; holder.pricePerTest.setText(currentResultItem.getPricePerTest()); // TestResultItem tmp=data.get(position); holder.lab_name.setText(currentResultItem.getLabName()); holder.lab_address.setText(currentResultItem.getLabAdd()); holder.tvhcharges.setText( "Home Collection Charge:" + context.getString(R.string.Rs) + currentResultItem.getPriceHome()); // holder.tvhcharges.setText("Extra home collection charges may apply"); holder.cost.setText( context.getString(R.string.Rs) + String.valueOf(currentResultItem.getPriceUser())); holder.saving.setText(dis + "% OFF"); holder.mrp.setText( context.getString(R.string.Rs) + String.valueOf(currentResultItem.getPriceMrp())); holder.mrp.setPaintFlags(holder.mrp.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); if (currentResultItem.isHomeCollectionAvailable()) { Log.d("shreyDebug", "home collection price is - " + currentResultItem.getPriceHome()); if (currentResultItem.getPriceHome() == "0") { holder.homeCollectionPrice.setVisibility(View.VISIBLE); } else { holder.homeCollectionPrice.setVisibility(View.VISIBLE); holder.homeCollectionPrice.setText( "Home collection price: " + currentResultItem.getPriceHome()); } } else { holder.homeCollectionPrice.setVisibility(View.GONE); } if (currentResultItem.isHomecollection()) { AppControllerSearchTests.setHomecollection(true); // holder.homecollectionava.setText("Home collection available"); } else { AppControllerSearchTests.setHomecollection(false); // holder.homecollectionava.setText("Home collection not available"); } if (currentResultItem.isNabl()) { holder.nabl.setText("NABL Accredited"); } else { holder.nabl.setVisibility(View.GONE); } final ResultHolder finalHolder = holder; if (currentResultItem.getRating() > -1) holder.rating.setText(String.valueOf(currentResultItem.getRating())); else holder.circle.setVisibility(View.INVISIBLE); final String lab_id = currentResultItem.getLabID(); String phone = currentResultItem.getLabPhone(); final ResultHolder finalHolder1 = holder; final ResultHolder finalHolder2 = holder; holder.select.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Bundle the lab details Intent i = new Intent(context, PastPatients.class); i.putExtra("goto", "Registration"); AppControllerSearchTests.setSelectedLab(currentResultItem); if (frag.equals("toprated")) { AppControllerSearchTests.setHomecollection(true); AppControllerSearchTests.setPriceHome(currentResultItem.getPriceHome()); } else AppControllerSearchTests.setHomecollection(false); AppControllerSearchTests.setSearchType(AppControllerSearchTests.TYPELAB); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } }); holder.infoIcon.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Log.d("in onItemClick", "yes"); if (AppControllerSearchTests.imageDBhelper.isOpen()) AppControllerSearchTests.imageDBhelper.close(); ResultItem tmp = currentResultItem; Intent intent = new Intent(context, Detailed_result.class); AppControllerSearchTests.setSearchType(AppControllerSearchTests.TYPELAB); AppControllerSearchTests.setHomecollection(tmp.isHomecollection()); AppControllerSearchTests.setSelectedLab(tmp); context.startActivity(intent); } }); return row; }
/** {@inheritDoc} */ @Override public void testStopped(final Result result) { LOGGER.info("result is : ---- " + result.getAssert() + " ----"); long cost = System.currentTimeMillis() - currentTestStartTime; ResultItem item = new ResultItem(); item.id = currentTestCase.getId(); item.res = result.getAssert(); item.notes = result.getReason(); item.costInMS = cost; item.spec = currentTestCase.getSpecSection(); item.desc = currentTestCase.getDescription(); String prefix = "" + currentTestCase.getId() + "."; if (result.getAssert() != TestResult.SKIP) { final PatternLayout layout = new PatternLayout(); layout.setConversionPattern("%6r [%-20.20t] %-5p %30.30c (%6L) %x %m%n"); final File remoteFile = new File(reportDir, prefix + "remote.log"); final File localFile = new File(reportDir, prefix + "local.log"); final File resourceFile = new File(reportDir, prefix + "resource.log"); try { remoteAppender.writeToFile(layout, remoteFile); item.remoteLogURI = "file:" + remoteFile.getName(); boolean hasError = remoteAppender.hasErrorLevelEvent(); item.hasErrorLevelLog = Boolean.toString(hasError); localAppender.writeToFile(layout, localFile); item.localLogURI = "file:" + localFile.getName(); resourceAppender.writeToFile(layout, resourceFile); item.resourceLog = filterReturn(resourceAppender); } catch (IOException e) { LOGGER.error(e.getMessage(), e); return; } } reportDoc.add(item); currentTestCase = null; // write to file. final File report = new File(reportDir, reportName); try { LOGGER.info("writing report to: '" + report.getCanonicalPath() + "'"); writeReport(report); } catch (IOException e) { LOGGER.error("error writing the report", e); } }