Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

In this page you can find the example usage for android.widget LinearLayout findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:project.pamela.slambench.fragments.FrequencyPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }/*from  w w w .j a  v a  2s . co  m*/

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setBackgroundColor(Color.WHITE);
    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.frequency_domain));
    plot.setBackgroundColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    //Remove legend
    //plot.getLayoutManager().remove(plot.getLegendWidget());
    //plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    //plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    for (int i = 0; i < value.getCPUCount(); i++) {

        int strokecolor = Color.rgb(i * (255 / value.getCPUCount()), 137, 192);
        int fillcolor = Color.rgb(i * (255 / value.getCPUCount()), 229, 255);

        Double frequencyNumbers[] = value.getfrequencyList(i);
        XYSeries series = new SimpleXYSeries(Arrays.asList(frequencyNumbers),
                SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
                this.getResources().getString(R.string.frequency_legend, i));
        LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null);

        seriesFormat.setPointLabeler(new PointLabeler() {
            @Override
            public String getLabel(XYSeries series, int index) {
                return "o";
            }
        });

        Paint lineFill = new Paint();
        lineFill.setAlpha(150);
        DisplayMetrics metrics = new DisplayMetrics();
        super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
        lineFill.setShader(new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor,
                Shader.TileMode.MIRROR));
        seriesFormat.setFillPaint(lineFill);

        plot.addSeries(series, seriesFormat);
    }

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(Math.min(0, minXY.y), maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:com.saulcintero.moveon.fragments.Summary1.java

private void populatesMap(LinearLayout fragmentView) {
    mapView = (MapView) fragmentView.findViewById(R.id.summary_mapview);
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);

    getTileSource(Integer.valueOf(prefs.getString("map_tile_type", "0")));

    draw_practice_in_map(true);//from   w  ww.  j  av  a  2 s  .  c o m
}

From source file:project.pamela.slambench.fragments.AccuracyPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }//w ww. ja  va2  s  .  c o m

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_ate));
    plot.setBackgroundColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    int fillcolor = Color.rgb(255, 213, 226);
    int strokecolor = Color.rgb(225, 99, 70);

    Double accuracyNumbers[] = value.getATEList();
    XYSeries series = new SimpleXYSeries(Arrays.asList(accuracyNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
            this.getResources().getString(R.string.legend_ate));
    LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null);

    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    DisplayMetrics metrics = new DisplayMetrics();
    super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    lineFill.setShader(
            new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR));
    seriesFormat.setPointLabeler(new PointLabeler() {
        @Override
        public String getLabel(XYSeries series, int index) {
            return "o";
        }
    });
    seriesFormat.setFillPaint(lineFill);
    plot.addSeries(series, seriesFormat);

    // same as above
    LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null);
    //change the line width
    Paint paint = lineFormat.getLinePaint();
    paint.setStrokeWidth(5);
    lineFormat.setLinePaint(paint);

    if (SLAMBenchApplication.getBenchmark() != null) {
        Number[] line = { 0, SLAMBenchApplication.getBenchmark().getMaxAccuracyError(),
                value.test.dataset.getFrameCount() - 1,
                SLAMBenchApplication.getBenchmark().getMaxAccuracyError() };
        XYSeries expected = new SimpleXYSeries(Arrays.asList(line),
                SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,
                getResources().getString(R.string.legend_error_limit));
        plot.addSeries(expected, lineFormat);
    }

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(0, maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * Returns active command for controls selected in view .
 * Returns null for wrong command//w w w . j  a va  2s . c  o  m
 * 
 * @param v
 * @return
 */
private IFeedbackCubeCommnads getCommnand(View v) {

    LinearLayout llButtons = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llButtons.getParent();

    String sTag = v.getTag().toString();
    if (sTag.compareTo(getString(R.string.tab_vi)) == 0) {

        TextView tvRed = (TextView) llRoot.findViewById(R.id.textViewRedValue);
        TextView tvGreen = (TextView) llRoot.findViewById(R.id.textViewGreenValue);
        TextView tvBlue = (TextView) llRoot.findViewById(R.id.textViewBlueValue);

        RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFullColor);
        RadioButton rbP = (RadioButton) llRoot.findViewById(R.id.rbPartColor);

        if (rbP.isChecked()) {

            NumberPicker npStart = (NumberPicker) llRoot.findViewById(R.id.npLedStart);
            NumberPicker npStop = (NumberPicker) llRoot.findViewById(R.id.npLedStop);

            FCPieChart c = new FCPieChart(FeedbackCubeConfig.getSingleInstance().getIp(),
                    npStart.getValue() + "", npStop.getValue() + "", tvRed.getText().toString(),
                    tvGreen.getText().toString(), tvBlue.getText().toString());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else {
            FCColor c = new FCColor(FeedbackCubeConfig.getSingleInstance().getIp(), tvRed.getText().toString(),
                    tvGreen.getText().toString(), tvBlue.getText().toString());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        }

    } else if (sTag.compareTo(getString(R.string.tab_au)) == 0) {

        //         CheckBox cb = (CheckBox) llRoot.findViewById(R.id.cbBeep);
        //         if (cb.isChecked()) {
        //            FCBeep c = new FCBeep(FeedbackCubeConfig.getSingleInstance()
        //                  .getIp());
        ////            Toast.makeText(this, "Launch cube " + c.toString(),
        ////                  Toast.LENGTH_SHORT).show();
        //
        //            return c;
        //         } else {
        //            Toast.makeText(this,
        //                  "Check off the Beep! to launch the action.",
        //                  Toast.LENGTH_SHORT).show();
        //         }

        RadioButton rbBeep = (RadioButton) llRoot.findViewById(R.id.rbBeep);
        RadioButton rbMelody = (RadioButton) llRoot.findViewById(R.id.rbMelody1);

        if (rbBeep.isChecked()) {

            FCBeep c = new FCBeep(FeedbackCubeConfig.getSingleInstance().getIp());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbMelody.isChecked()) {

            FCMelody1 c = new FCMelody1(FeedbackCubeConfig.getSingleInstance().getIp());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        }

    } else if (sTag.compareTo(getString(R.string.tab_ef)) == 0) {

        RadioButton rbRainbow = (RadioButton) llRoot.findViewById(R.id.rbRainbow);
        RadioButton rbRainbowC = (RadioButton) llRoot.findViewById(R.id.rbRainbowCircle);
        RadioButton rbFade = (RadioButton) llRoot.findViewById(R.id.rbFade);

        if (rbRainbow.isChecked()) {

            FCRainbow c = new FCRainbow(FeedbackCubeConfig.getSingleInstance().getIp());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbRainbowC.isChecked()) {

            FCRainbowCircle c = new FCRainbowCircle(FeedbackCubeConfig.getSingleInstance().getIp());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbFade.isChecked()) {

            NumberPicker npD = (NumberPicker) llRoot.findViewById(R.id.npDelay);
            NumberPicker npN = (NumberPicker) llRoot.findViewById(R.id.npNumber);

            FCFade c = new FCFade(FeedbackCubeConfig.getSingleInstance().getIp(), "" + npN.getValue(),
                    "" + npD.getValue());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;
        }

    }
    return null;

}

From source file:fr.jbteam.jabboid.core.ContactDetailFragment.java

/**
 * Builds an address LinearLayout based on address information from the Contacts Provider.
 * Each address for the contact gets its own LinearLayout object; for example, if the contact
 * has three postal addresses, then 3 LinearLayouts are generated.
 *
 * @param addressType From/*from   w  w  w .j  a  va2  s  .c o  m*/
 * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#TYPE}
 * @param addressTypeLabel From
 * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#LABEL}
 * @param address From
 * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#FORMATTED_ADDRESS}
 * @return A LinearLayout to add to the contact details layout,
 *         populated with the provided address details.
 */
private LinearLayout buildAddressLayout(final String contactID, int contactPresence, int protocol,
        String imLabel) {

    // Inflates the address layout
    final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.contact_detail_item, mDetailsLayout, false);

    // Gets handles to the view objects in the layout
    final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header);
    final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item);
    final ImageButton viewAddressButton = (ImageButton) addressLayout.findViewById(R.id.button_view_address);

    // If there's no addresses for the contact, shows the empty view and message, and hides the
    // header and button.
    if (protocol != PROTOCOL_JABBER || contactID == null) {
        headerTextView.setVisibility(View.GONE);
        viewAddressButton.setVisibility(View.GONE);
        addressTextView.setText(R.string.no_address);
    } else {
        // Gets postal address label type
        CharSequence label = Im.getProtocolLabel(getResources(), protocol, imLabel);

        // Sets TextView objects in the layout
        headerTextView.setText(label);
        addressTextView.setText(contactID);

        // Defines an onClickListener object for the address button
        viewAddressButton.setOnClickListener(new View.OnClickListener() {
            // Defines what to do when users click the address button
            //@Override
            public void onClick(View view) {
                final Intent viewIntent = new Intent(getActivity(), ChatClient.class);
                viewIntent.putExtra("contactID", contactID);
                startActivity(viewIntent);
            }
        });

    }
    return addressLayout;
}

From source file:project.pamela.slambench.fragments.PowerPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }//  w w w .j  av a2  s  .co m

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_power));
    plot.setBackgroundColor(Color.WHITE);
    plot.getBorderPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    //Remove legend
    //plot.getLayoutManager().remove(plot.getLegendWidget());
    //plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    //plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    int strokecolor = Color.rgb(91, 255, 159);
    int fillcolor = Color.rgb(91, 255, 184);

    Double powerNumbers[] = value.getPowerList();
    for (int i = 0; i < value.test.dataset.getFrameCount(); i++) {
        powerNumbers[i] = powerNumbers[i] / -1000;
    }
    XYSeries series = new SimpleXYSeries(Arrays.asList(powerNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
            this.getResources().getString(R.string.legend_power));
    LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null);

    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    DisplayMetrics metrics = new DisplayMetrics();
    super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    lineFill.setShader(
            new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR));
    seriesFormat.setPointLabeler(new PointLabeler() {
        @Override
        public String getLabel(XYSeries series, int index) {
            return "o";
        }
    });
    seriesFormat.setFillPaint(lineFill);
    plot.addSeries(series, seriesFormat);

    // same as above
    LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null);
    //change the line width
    Paint paint = lineFormat.getLinePaint();
    paint.setStrokeWidth(5);
    lineFormat.setLinePaint(paint);

    Number[] line = { 0, 3, value.test.dataset.getFrameCount() - 1, 3 };
    XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,
            getResources().getString(R.string.legend_power_limit));
    plot.addSeries(expected, lineFormat);

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(Math.min(0, minXY.y), maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:com.push.app.HomeActivity.java

private void initViews() {

    LinearLayout firstItemView = (LinearLayout) getLayoutInflater().inflate(R.layout.first_item_view, null);
    firstItemHeadline = (TextView) firstItemView.findViewById(R.id.firstPostHeadline);
    firstItemDescription = (TextView) firstItemView.findViewById(R.id.postDescription);
    firstItemDateandAuthor = (TextView) firstItemView.findViewById(R.id.first_post_Date);
    firstPostImage = (ImageView) firstItemView.findViewById(R.id.firstPostImage);
    // This is required to disable header's list selector effect
    mListView.addHeaderView(firstItemView);
    firstItemView.setClickable(false);//from w  w w .j av  a 2s  . c om

}

From source file:com.dm.material.dashboard.candybar.activities.CandyBarMainActivity.java

@Override
public void onWallpapersChecked(@Nullable Intent intent) {
    if (intent != null) {
        String packageName = intent.getStringExtra("packageName");
        LogUtil.d("Broadcast received from service with packageName: " + packageName);

        if (packageName == null)
            return;

        if (!packageName.equals(getPackageName())) {
            LogUtil.d("Received broadcast from different packageName, expected: " + getPackageName());
            return;
        }// www .  j a v a 2s . c o m

        int size = intent.getIntExtra("size", 0);
        Database database = new Database(this);
        int offlineSize = database.getWallpapersCount();
        Preferences.getPreferences(this).setAvailableWallpapersCount(size);

        if (size > offlineSize) {
            if (mFragmentTag.equals(TAG_HOME)) {
                HomeFragment fragment = (HomeFragment) mFragManager.findFragmentByTag(TAG_HOME);
                if (fragment != null)
                    fragment.resetWallpapersCount();
            }

            int accent = ColorHelper.getAttributeColor(this, R.attr.colorAccent);
            LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(4).getActionView();
            if (container != null) {
                TextView counter = (TextView) container.findViewById(R.id.counter);
                if (counter == null)
                    return;

                ViewCompat.setBackground(counter,
                        DrawableHelper.getTintedDrawable(this, R.drawable.ic_toolbar_circle, accent));
                counter.setTextColor(ColorHelper.getTitleTextColor(accent));
                int newItem = (size - offlineSize);
                counter.setText(String.valueOf(newItem > 99 ? "99+" : newItem));
                container.setVisibility(View.VISIBLE);
                return;
            }
        }
    }

    LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(4).getActionView();
    if (container != null)
        container.setVisibility(View.GONE);
}

From source file:project.pamela.slambench.fragments.DurationPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }//  www  . jav  a 2 s . co m

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_duration));
    plot.setBackgroundColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    //Remove legend
    //plot.getLayoutManager().remove(plot.getLegendWidget());
    //plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    //plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    // Prepare Data (fill stack and add lines)

    KFusion.FieldIndex[] stackIndex = new KFusion.FieldIndex[] { (KFusion.FieldIndex.AQUISITION_DURATION),
            (KFusion.FieldIndex.PREPROCESSING_DURATION), (KFusion.FieldIndex.TRACKING_DURATION),
            (KFusion.FieldIndex.INTEGRATION_DURATION), (KFusion.FieldIndex.RAYCASTING_DURATION),
            (KFusion.FieldIndex.RENDERING_DURATION), (KFusion.FieldIndex.TOTAL_DURATION) };

    Double[][] stackNumbers = new Double[][] { value.getField(stackIndex[0]), value.getField(stackIndex[1]),
            value.getField(stackIndex[2]), value.getField(stackIndex[3]), value.getField(stackIndex[4]),
            value.getField(stackIndex[5]) };

    Double[][] stack = new Double[stackNumbers.length + 1][stackNumbers[0].length];

    int[] stackColor = new int[] { Color.rgb(240, 0, 0), Color.rgb(255, 155, 0), Color.rgb(255, 255, 0),
            Color.rgb(155, 255, 98), Color.rgb(0, 212, 255), Color.rgb(0, 155, 255), Color.rgb(0, 0, 127) };

    stack[0] = stackNumbers[0];

    for (int i = 0; i < stackNumbers[0].length; ++i) {
        for (int j = 1; j < stackNumbers.length; ++j) {
            stack[j][i] = stack[j - 1][i] + stackNumbers[j][i];
        }
    }
    stack[stackNumbers.length] = value.getField(KFusion.FieldIndex.TOTAL_DURATION);

    for (int i = stack.length - 1; i >= 0; --i) {
        // Turn the above arrays into XYSeries':
        XYSeries series = new SimpleXYSeries(Arrays.asList(stack[i]), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
                stackIndex[i].getName());

        LineAndPointFormatter seriesFormat = new LineAndPointFormatter(Color.rgb(73, 73, 73), null,
                stackColor[i], null);
        Paint paint = seriesFormat.getLinePaint();
        paint.setStrokeWidth(1.0f);
        seriesFormat.setLinePaint(paint);

        // setup our line fill paint to be a slightly transparent gradient:
        //Paint lineFill = new Paint();
        // lineFill.setAlpha(200);
        //lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, stackColor[i], Shader.TileMode.MIRROR));
        //seriesFormat.setFillPaint(lineFill);

        plot.addSeries(series, seriesFormat);

    }

    // same as above
    LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null);
    //change the line width
    Paint paint = lineFormat.getLinePaint();
    paint.setStrokeWidth(5);
    lineFormat.setLinePaint(paint);

    Number[] line = { 0, 0.033, stack[0].length - 1, 0.033 };
    XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,
            getResources().getString(R.string.legend_realtime_limit));
    plot.addSeries(expected, lineFormat);

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(0, maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:android.com.example.contactslist.ui.ContactDetailFragment.java

/**
 * Builds an address LinearLayout based on address information from the Contacts Provider.
 * Each address for the contact gets its own LinearLayout object; for example, if the contact
 * has three postal addresses, then 3 LinearLayouts are generated.
 *
 * @param addressType From//from w w  w .j a v  a2  s .  co  m
 * {@link StructuredPostal#TYPE}
 * @param addressTypeLabel From
 * {@link StructuredPostal#LABEL}
 * @param address From
 * {@link StructuredPostal#FORMATTED_ADDRESS}
 * @return A LinearLayout to add to the contact details layout,
 *         populated with the provided address details.
 */
private LinearLayout buildAddressLayout(int addressType, String addressTypeLabel, final String address) {

    // Inflates the address layout
    final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.contact_detail_item, mDetailsLayout, false);

    // Gets handles to the view objects in the layout
    final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header);
    final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item);
    final ImageButton viewAddressButton = (ImageButton) addressLayout.findViewById(R.id.button_view_address);

    // If there's no addresses for the contact, shows the empty view and message, and hides the
    // header and button.
    if (addressTypeLabel == null && addressType == 0) {
        headerTextView.setVisibility(View.GONE);
        viewAddressButton.setVisibility(View.GONE);
        addressTextView.setText(R.string.no_address);
    } else {
        // Gets postal address label type
        CharSequence label = StructuredPostal.getTypeLabel(getResources(), addressType, addressTypeLabel);

        // Sets TextView objects in the layout
        headerTextView.setText(label);
        addressTextView.setText(address);

        // Defines an onClickListener object for the address button
        viewAddressButton.setOnClickListener(new View.OnClickListener() {
            // Defines what to do when users click the address button
            @Override
            public void onClick(View view) {

                final Intent viewIntent = new Intent(Intent.ACTION_VIEW, constructGeoUri(address));

                // A PackageManager instance is needed to verify that there's a default app
                // that handles ACTION_VIEW and a geo Uri.
                final PackageManager packageManager = getActivity().getPackageManager();

                // Checks for an activity that can handle this intent. Preferred in this
                // case over Intent.createChooser() as it will still let the user choose
                // a default (or use a previously set default) for geo Uris.
                if (packageManager.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
                    startActivity(viewIntent);
                } else {
                    // If no default is found, displays a message that no activity can handle
                    // the view button.
                    Toast.makeText(getActivity(), R.string.no_intent_found, Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
    return addressLayout;
}