Example usage for android.widget LinearLayout setDrawingCacheEnabled

List of usage examples for android.widget LinearLayout setDrawingCacheEnabled

Introduction

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

Prototype

@Deprecated
public void setDrawingCacheEnabled(boolean enabled) 

Source Link

Document

Enables or disables the drawing cache.

Usage

From source file:com.thingsee.tracker.MainActivity.java

public static void refreshTrackerMarker(String serial) {
    TrackerModel trackerModel = trackers.get(serial);
    if (trackerModel != null) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout tv = (LinearLayout) inflater.inflate(R.layout.tracker_map_marker, null, false);
        ImageView image2 = (ImageView) tv.findViewById(R.id.tracker_marker_icon);
        TextView name = (TextView) tv.findViewById(R.id.tracker_name);
        name.setText(trackerModel.getName());
        ImageView trackerBg = (ImageView) trackerModel.getView().findViewById(R.id.tracker_image_bg);
        if (trackerModel.isLocationTimeoutAlarmOn()) {
            image2.setColorFilter(mResources.getColor(R.color.red));
            trackerBg.setColorFilter(mResources.getColor(R.color.red));
            name.setTextColor(mResources.getColor(R.color.white_effect));
        } else {/*from ww  w .  jav  a 2  s  .  c o  m*/
            image2.clearColorFilter();
            trackerBg.setColorFilter(mResources.getColor(R.color.green));
            name.setTextColor(mResources.getColor(R.color.black_effect));
        }
        tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());
        tv.setDrawingCacheEnabled(true);
        tv.buildDrawingCache();
        Bitmap bm = tv.getDrawingCache();
        tv = null;
        if (trackerModel.getMarker() != null) {
            trackerModel.getMarker().setIcon(BitmapDescriptorFactory.fromBitmap(bm));
        }
        if (trackerModelWithMarker != null) {
            if (onChildOnMapView) {
                trackerModelWithMarker.getMarker().showInfoWindow();
            }
        }
    }
}

From source file:com.thingsee.tracker.MainActivity.java

@SuppressLint("InflateParams")
private Marker makeMarkerToMap(LatLng latLng, boolean visible, boolean alarmActive, String name,
        double timeStamp, double accuracy) {
    String snippet;//w  w w  .  ja  v a 2 s.  c  om
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout tv = (LinearLayout) inflater.inflate(R.layout.tracker_map_marker, null, false);
    TextView trackerName = (TextView) tv.findViewById(R.id.tracker_name);
    trackerName.setText(name);
    ImageView image2 = (ImageView) tv.findViewById(R.id.tracker_marker_icon);
    if (alarmActive) {
        image2.setColorFilter(mResources.getColor(R.color.red));
        trackerName.setTextColor(mResources.getColor(R.color.white_effect));
    } else {
        image2.setColorFilter(mResources.getColor(R.color.dark_blue));
        trackerName.setTextColor(mResources.getColor(R.color.white_effect));
    }
    tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
            MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());
    tv.setDrawingCacheEnabled(true);
    tv.buildDrawingCache();
    Bitmap bm = tv.getDrawingCache();
    tv = null;

    if (accuracy != -1) {
        snippet = String.format(mResources.getString(R.string.tracker_accuracy), accuracy);
    } else {
        snippet = String.format(mResources.getString(R.string.tracker_accuracy), 0.0f);
    }
    if (timeStamp != 0) {
        String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, timeStamp);
        snippet = snippet + "\n" + mResources.getString(R.string.tracker_timestamp) + " " + timeStampText;
    } else {
        snippet = snippet + "\n" + mResources.getString(R.string.tracker_timestamp) + " - ";
    }
    return mMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(bm))
            .visible(visible).title(name).snippet(snippet));
}