Search in sources :

Example 1 with DrawView

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);
        }
    });
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) SharedPreferences(android.content.SharedPreferences) HashMap(java.util.HashMap) LocalizedWebView(edu.berkeley.cs.amplab.carat.android.ui.LocalizedWebView) ImageView(android.widget.ImageView) DrawView(edu.berkeley.cs.amplab.carat.android.ui.DrawView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) DrawView(edu.berkeley.cs.amplab.carat.android.ui.DrawView) OnClickListener(android.view.View.OnClickListener) AppDetailsFragment(edu.berkeley.cs.amplab.carat.android.subscreens.AppDetailsFragment) TextView(android.widget.TextView) SimpleHogBug(edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug)

Example 2 with DrawView

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;
}
Also used : Tracker(edu.berkeley.cs.amplab.carat.android.utils.Tracker) DrawView(edu.berkeley.cs.amplab.carat.android.ui.DrawView) Reports(edu.berkeley.cs.amplab.carat.thrift.Reports) DrawView(edu.berkeley.cs.amplab.carat.android.ui.DrawView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with DrawView

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;
    }
}
Also used : DrawView(edu.berkeley.cs.amplab.carat.android.ui.DrawView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LocalizedWebView(edu.berkeley.cs.amplab.carat.android.ui.LocalizedWebView) ImageView(android.widget.ImageView) DrawView(edu.berkeley.cs.amplab.carat.android.ui.DrawView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

View (android.view.View)3 TextView (android.widget.TextView)3 DrawView (edu.berkeley.cs.amplab.carat.android.ui.DrawView)3 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 LocalizedWebView (edu.berkeley.cs.amplab.carat.android.ui.LocalizedWebView)2 SharedPreferences (android.content.SharedPreferences)1 LayoutInflater (android.view.LayoutInflater)1 OnClickListener (android.view.View.OnClickListener)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 SimpleHogBug (edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug)1 AppDetailsFragment (edu.berkeley.cs.amplab.carat.android.subscreens.AppDetailsFragment)1 Tracker (edu.berkeley.cs.amplab.carat.android.utils.Tracker)1 Reports (edu.berkeley.cs.amplab.carat.thrift.Reports)1 HashMap (java.util.HashMap)1