use of edu.berkeley.cs.amplab.carat.android.ui.DrawView in project carat by amplab.
the class BugsOrHogsFragment method initEnergyDetails.
private void initEnergyDetails(View root, ViewGroup container) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
detailPage = inflater.inflate(R.layout.graph, container);
w = new DrawView(getActivity());
OnClickListener detailViewer = new OnClickListener() {
@Override
public void onClick(View arg0) {
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
if (p != null) {
String uuId = p.getString(CaratApplication.getRegisteredUuid(), "UNKNOWN");
HashMap<String, String> options = new HashMap<String, String>();
options.put("status", getActivity().getTitle().toString());
options.put("type", isBugs ? "Bugs" : "Hogs");
options.put("app", ((TextView) detailPage.findViewById(R.id.name)).getText() + "");
options.put("benefit", ((TextView) detailPage.findViewById(R.id.benefit)).getText().toString().replace('±', '+'));
ClickTracking.track(uuId, "whatnumbers", options, getActivity());
}
}
};
View moreinfo = detailPage.findViewById(R.id.jscore_info);
moreinfo.setOnClickListener(detailViewer);
View item = detailPage.findViewById(R.id.benefit);
item.setClickable(true);
item.setOnClickListener(detailViewer);
item = detailPage.findViewById(R.id.benefit);
item.setClickable(true);
item.setOnClickListener(detailViewer);
item = detailPage.findViewById(R.id.name);
item.setClickable(true);
item.setOnClickListener(detailViewer);
item = detailPage.findViewById(R.id.appIcon);
item.setClickable(true);
item.setOnClickListener(detailViewer);
final ListView lv = (ListView) root.findViewById(android.R.id.list);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv.getItemAtPosition(position);
SimpleHogBug fullObject = (SimpleHogBug) o;
AppDetailsFragment fragment = AppDetailsFragment.getInstance(Constants.Type.BUG, fullObject, isBugs);
CaratApplication.getMainActivity().replaceFragment(fragment, fullObject.getAppName(), false);
}
});
}
use of edu.berkeley.cs.amplab.carat.android.ui.DrawView in project carat by amplab.
the class AppDetailsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View detailsPage = inflater.inflate(R.layout.graph, container, false);
DrawView drawView = new DrawView(getActivity());
if (isApp) {
drawView.setParams(fullObject, detailsPage);
setBenefitTextView(detailsPage, fullObject.getBenefitText());
} else {
// isOS or isModel
Reports reports = CaratApplication.storage.getReports();
if (reports != null) {
Tracker tracker = Tracker.getInstance();
if (isOs) {
setOsWidgets(detailsPage, drawView, reports, tracker);
} else {
// isModel
setModelWidgets(detailsPage, drawView, reports, tracker);
}
// common piece of code for both OS and Model
setBenefitWidget(detailsPage);
}
Log.d("NullReports", "Reports are null!!!");
}
// common piece of code for App, OS, and Model
setDescriptionWidgets(detailsPage);
// layout file
return detailsPage;
}
use of edu.berkeley.cs.amplab.carat.android.ui.DrawView in project carat by amplab.
the class BugsOrHogsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = null;
if (isBugs && CaratApplication.storage.getBugReport().length == 0) {
root = inflater.inflate(R.layout.emptybugsonly, container, false);
return root;
} else {
root = inflater.inflate(R.layout.hogs, container, false);
initEnergyDetails(root, container);
initDetailView(root);
if (savedInstanceState != null) {
Object o = savedInstanceState.get("savedInstance");
if (o != null) {
BugsOrHogsFragment previous = (BugsOrHogsFragment) o;
TextView pn = (TextView) previous.detailPage.findViewById(R.id.name);
ImageView pi = (ImageView) previous.detailPage.findViewById(R.id.appIcon);
TextView pp = (TextView) previous.detailPage.findViewById(R.id.benefit);
DrawView w = previous.w;
((TextView) detailPage.findViewById(R.id.name)).setText(pn.getText());
((ImageView) detailPage.findViewById(R.id.appIcon)).setImageDrawable(pi.getDrawable());
((TextView) detailPage.findViewById(R.id.benefit)).setText(pp.getText());
String appName = w.getAppName();
w.setParams(isBugs ? Constants.Type.BUG : Constants.Type.HOG, appName, w.getEv(), w.getEvWithout(), w.getSampleCount(), w.getSampleCountWithout(), w.getError(), w.getErrorWithout(), (ViewGroup) detailPage);
// w.postInvalidate();
}
}
return root;
}
}
Aggregations