List of usage examples for android.view View LAYER_TYPE_SOFTWARE
int LAYER_TYPE_SOFTWARE
To view the source code for android.view View LAYER_TYPE_SOFTWARE.
Click Source Link
Indicates that the view has a software layer.
From source file:com.cosmicsubspace.nerdyaudio.visuals.PlayControlsView.java
public PlayControlsView(Context context, AttributeSet attrs) { super(context, attrs); pt = new Paint(Paint.ANTI_ALIAS_FLAG); density = getResources().getDisplayMetrics().density; qm = QueueManager.getInstance();/*from w w w.j a v a 2 s . co m*/ ap = AudioPlayer.getInstance(); Resources res = getResources(); menuColor = getResources().getColor(R.color.colorPrimary); buttonColor = Color.WHITE; textPrimary = getResources().getColor(R.color.colorLightPrimaryText); textSecondary = getResources().getColor(R.color.colorLightSecondaryText); playedColor = ColorFiddler.setAlpha(res.getColor(R.color.colorPrimary), 200); //Log2.log(2,this,Color.alpha(playedColor),Color.red(playedColor),Color.blue(playedColor),Color.green(playedColor)); remainingColor = ColorFiddler.setAlpha(res.getColor(R.color.colorPrimary), 100); playedColorEX = ColorFiddler.setAlpha(res.getColor(R.color.colorAccentFallbackDark), 255); remainingColorEX = ColorFiddler.setAlpha(res.getColor(R.color.colorAccent), 255); //We need to disable hardware acceleration for this layer, //since we need to fiddle with blending and shader combining //for the marquee text effect. //It also takes care of a bug with Paths. setLayerType(View.LAYER_TYPE_SOFTWARE, null); prepareLayout(); inst = this; refreshPlaying(); }
From source file:com.ehret.mixit.fragment.PeopleDetailFragment.java
private void addPeopleInfo(Member membre) { Context context = getActivity().getBaseContext(); if (membre != null) { this.membreUserName.setText(membre.getCompleteName()); this.membreEntreprise.setText(membre.getCompany()); this.personDesciptif.setText(Html.fromHtml(Processor.process(membre.getLongDescription().trim())), TextView.BufferType.SPANNABLE); this.personShortDesciptif .setText(Html.fromHtml(Processor.process(membre.getShortDescription().trim()))); } else {//from w w w .j av a 2s. c om this.membreUserName.setText("Inconnu"); this.membreEntreprise.setText("Inconnu"); this.personDesciptif.setText(""); this.personShortDesciptif.setText(""); } Bitmap image = null; //Si on est un sponsor on affiche le logo if (membre != null && membre.isSponsor()) { image = FileUtils.getImageLogo(context, membre); profileImage.setImageBitmap(image); logoImage.setImageBitmap(image); logoImage.setVisibility(View.VISIBLE); } else { logoImage.setVisibility(View.INVISIBLE); } if (image == null) { //Recuperation de l'mage liee au profil image = FileUtils.getImageProfile(context, membre); if (image == null) { profileImage.setImageResource(R.drawable.person_image_empty); } } if (membre.getExtension() != null && membre.getExtension().equals("svg")) { profileImage.setAdjustViewBounds(true); profileImage.setLayerType(View.LAYER_TYPE_SOFTWARE, null); profileImage.setImageDrawable(FileUtils.getImageSvg(context, membre)); } else if (image != null) { profileImage.setImageBitmap(image); } }
From source file:com.moki.touch.fragments.views.WebContent.java
private void configureWebView(Context context) { if (!userAgent.equals("default")) { webView.getSettings().setUserAgentString(userAgent); }//from w ww . j a v a 2s .com webView.getSettings().setJavaScriptEnabled(true); // Set cache size to 32 mb by default. should be more than enough webView.getSettings().setAppCacheMaxSize(1024 * 1024 * 32); webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); String appCachePath = context.getCacheDir().getAbsolutePath(); webView.getSettings().setAppCachePath(appCachePath); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); webView.setWebViewClient(new CustomClient()); if (showProgressBar) { webView.setWebChromeClient(new CustomChromeClient()); } }
From source file:im.vector.adapters.ImagesSliderAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = mLayoutInflater.inflate(R.layout.activity_image_web_view, null, false); // hide the pie chart final PieFractionView pieFractionView = (PieFractionView) view .findViewById(R.id.download_zoomed_image_piechart); pieFractionView.setVisibility(View.GONE); final WebView webView = (WebView) view.findViewById(R.id.image_webview); // black background view.setBackgroundColor(0xFF000000); webView.setBackgroundColor(0xFF000000); final SlidableImageInfo imageInfo = mListImageMessages.get(position); String mediaUrl = imageInfo.mImageUrl; final int rotationAngle = imageInfo.mRotationAngle; final String mimeType = imageInfo.mMimeType; final MXMediasCache mediasCache = Matrix.getInstance(this.context).getMediasCache(); File mediaFile = mediasCache.mediaCacheFile(mediaUrl, mimeType); // is the high picture already downloaded ? if (null != mediaFile) { if (mHighResMediaIndex.indexOf(position) < 0) { mHighResMediaIndex.add(position); }/* www.j a v a 2 s. c om*/ } else { // try to retrieve the thumbnail mediaFile = mediasCache.mediaCacheFile(mediaUrl, mMaxImageWidth, mMaxImageHeight, null); } // the thumbnail is not yet downloaded if (null == mediaFile) { // display nothing container.addView(view, 0); return view; } String mediaUri = "file://" + mediaFile.getPath(); String css = computeCss(mediaUri, mMaxImageWidth, mMaxImageHeight, rotationAngle); final String viewportContent = "width=640"; webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setBuiltInZoomControls(true); loadImage(webView, Uri.parse(mediaUri), viewportContent, css); container.addView(view, 0); return view; }
From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java
@SuppressLint("NewApi") public void setImageBitmap(final Bitmap bitmap, final boolean fitScreen) { //???/*from w w w .j a v a 2 s. c om*/ if (Build.VERSION.SDK_INT >= MIN_SDK_ENABLE_LAYER_TYPE_HARDWARE) { if (bitmap != null && (bitmap.getHeight() > SampleSizeUtil.getTextureSize() || bitmap.getWidth() > SampleSizeUtil.getTextureSize())) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } else { setLayerType(View.LAYER_TYPE_HARDWARE, null); } } final int viewWidth = getWidth(); if (viewWidth <= 0) { mOnLayoutRunnable = new Runnable() { public void run() { setImageBitmap(bitmap, fitScreen); } }; return; } Bitmap oldBitmap = this.mBitmap; if (bitmap != null) { setBaseMatrix(bitmap, mBaseMatrix); this.mBitmap = bitmap; } else { mBaseMatrix.reset(); this.mBitmap = bitmap; } if (oldBitmap != null && oldBitmap != mBitmap && !oldBitmap.isRecycled()) { oldBitmap.recycle(); } mSuppMatrix.reset(); setImageMatrix(getImageViewMatrix()); mMaxZoom = maxZoom(); // Set the image to fit the screen if (fitScreen) { zoomToScreen(); } }
From source file:com.shizhefei.view.coolrefreshview.header.MaterialProgressDrawable.java
private void setUp(final double diameter) { if (mBackgroundColor != Color.TRANSPARENT) { final int shadowYOffset = Utils.dipToPix(mContext, Y_OFFSET); final int shadowXOffset = Utils.dipToPix(mContext, X_OFFSET); int mShadowRadius = Utils.dipToPix(mContext, SHADOW_RADIUS); OvalShape oval = new OvalShadow(mShadowRadius, (int) diameter); mShadow = new ShapeDrawable(oval); if (Build.VERSION.SDK_INT >= 11) { mParent.setLayerType(View.LAYER_TYPE_SOFTWARE, mShadow.getPaint()); }//from w ww . jav a 2 s .c o m mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); } }
From source file:com.miz.mizuu.fragments.ShowDetailsFragment.java
public void onViewCreated(final View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); if (MizLib.isPortrait(getActivity())) { mActionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { 0x00000000, 0xaa000000 }); getActivity().getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable); ObservableScrollView sv = (ObservableScrollView) v.findViewById(R.id.scrollView1); sv.setOnScrollChangedListener(new OnScrollChangedListener() { @Override//w w w. j a v a 2 s . co m public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { final int headerHeight = v.findViewById(R.id.imageBackground).getHeight() - getActivity().getActionBar().getHeight(); final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; final int newAlpha = (int) (ratio * 255); mActionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { Color.parseColor("#" + ((Integer.toHexString(newAlpha).length() == 1) ? ("0" + Integer.toHexString(newAlpha)) : Integer.toHexString(newAlpha)) + "080808"), (newAlpha >= 170) ? Color.parseColor("#" + Integer.toHexString(newAlpha) + "080808") : 0xaa080808 }); getActivity().getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable); } }); } background = (ImageView) v.findViewById(R.id.imageBackground); textTitle = (TextView) v.findViewById(R.id.movieTitle); textPlot = (TextView) v.findViewById(R.id.textView2); textGenre = (TextView) v.findViewById(R.id.textView7); textRuntime = (TextView) v.findViewById(R.id.textView9); textReleaseDate = (TextView) v.findViewById(R.id.textReleaseDate); textRating = (TextView) v.findViewById(R.id.textView12); textTagline = (TextView) v.findViewById(R.id.textView6); textCertification = (TextView) v.findViewById(R.id.textView11); cover = (ImageView) v.findViewById(R.id.traktIcon); // Set the show title textTitle.setVisibility(View.VISIBLE); textTitle.setText(thisShow.getTitle()); textTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); textTitle.setLayerType(View.LAYER_TYPE_SOFTWARE, null); textPlot.setTypeface(mLight); textGenre.setTypeface(mLight); textRuntime.setTypeface(mLight); textReleaseDate.setTypeface(mLight); textRating.setTypeface(mLight); textCertification.setTypeface(mLight); // Set the show plot textPlot.setText(thisShow.getDescription()); textTagline.setVisibility(TextView.GONE); // Set the show genre if (!MizLib.isEmpty(thisShow.getGenres())) { textGenre.setText(thisShow.getGenres()); } else { textGenre.setText(R.string.stringNA); } // Set the show runtime textRuntime.setText(MizLib.getPrettyTime(getActivity(), Integer.parseInt(thisShow.getRuntime()))); // Set the first aired date textReleaseDate.setText(MizLib.getPrettyDate(getActivity(), thisShow.getFirstAirdate())); // Set the show rating if (!thisShow.getRating().equals("0.0/10")) { if (thisShow.getRating().contains("/")) { try { int rating = (int) (Double.parseDouble( thisShow.getRating().substring(0, thisShow.getRating().indexOf("/"))) * 10); textRating.setText(Html.fromHtml(rating + "<small> %</small>")); } catch (NumberFormatException e) { textRating.setText(Html.fromHtml(thisShow.getRating().replace("/", "<small> / ") + "</small>")); } } else { textRating.setText(thisShow.getRating()); } } else { textRating.setText(R.string.stringNA); } // Set the show certification if (!MizLib.isEmpty(thisShow.getCertification())) { textCertification.setText(thisShow.getCertification()); } else { textCertification.setText(R.string.stringNA); } loadImages(); }
From source file:com.jaspersoft.android.jaspermobile.activities.viewer.html.report.fragment.NodeWebViewFragment.java
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) private void prepareWebView() { // disable hardware acceleration if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); }// w w w .jav a 2s .c o m // configure additional settings webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); webView.setWebViewClient(jsWebViewClient); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } }
From source file:at.maui.cheapcast.fragment.DonationsFragment.java
/** * Build view for Flattr. see Flattr API for more information: * http://developers.flattr.net/button//*from ww w .j a v a 2 s .co m*/ */ @SuppressLint("SetJavaScriptEnabled") @TargetApi(11) private void buildFlattrView() { final FrameLayout mLoadingFrame; final WebView mFlattrWebview; mFlattrWebview = (WebView) getActivity().findViewById(R.id.donations__flattr_webview); mLoadingFrame = (FrameLayout) getActivity().findViewById(R.id.donations__loading_frame); // disable hardware acceleration for this webview to get transparent background working if (Build.VERSION.SDK_INT >= 11) { mFlattrWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } // define own webview client to override loading behaviour mFlattrWebview.setWebViewClient(new WebViewClient() { /** * Open all links in browser, not in webview */ @Override public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) { try { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(urlNewString))); } catch (ActivityNotFoundException e) { openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__alert_dialog_title, getString(R.string.donations__alert_dialog_no_browser)); } return false; } /** * Links in the flattr iframe should load in the browser not in the iframe itself, * http:/ * /stackoverflow.com/questions/5641626/how-to-get-webview-iframe-link-to-launch-the * -browser */ @Override public void onLoadResource(WebView view, String url) { if (url.contains("flattr")) { HitTestResult result = view.getHitTestResult(); if (result != null && result.getType() > 0) { try { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } catch (ActivityNotFoundException e) { openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__alert_dialog_title, getString(R.string.donations__alert_dialog_no_browser)); } view.stopLoading(); } } } /** * After loading is done, remove frame with progress circle */ @Override public void onPageFinished(WebView view, String url) { // remove loading frame, show webview if (mLoadingFrame.getVisibility() == View.VISIBLE) { mLoadingFrame.setVisibility(View.GONE); mFlattrWebview.setVisibility(View.VISIBLE); } } }); // get flattr values from xml config String projectUrl = mFlattrProjectUrl; String flattrUrl = this.mFlattrUrl; // make text white and background transparent String htmlStart = "<html> <head><style type='text/css'>*{color: #FFFFFF; background-color: transparent;}</style>"; // https is not working in android 2.1 and 2.2 String flattrScheme; if (Build.VERSION.SDK_INT >= 9) { flattrScheme = "https://"; } else { flattrScheme = "http://"; } // set url of flattr link mFlattrUrlTextView = (TextView) getActivity().findViewById(R.id.donations__flattr_url); mFlattrUrlTextView.setText(flattrScheme + flattrUrl); String flattrJavascript = "<script type='text/javascript'>" + "/* <![CDATA[ */" + "(function() {" + "var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];" + "s.type = 'text/javascript';" + "s.async = true;" + "s.src = '" + flattrScheme + "api.flattr.com/js/0.6/load.js?mode=auto';" + "t.parentNode.insertBefore(s, t);" + "})();" + "/* ]]> */" + "</script>"; String htmlMiddle = "</head> <body> <div align='center'>"; String flattrHtml = "<a class='FlattrButton' style='display:none;' href='" + projectUrl + "' target='_blank'></a> <noscript><a href='" + flattrScheme + flattrUrl + "' target='_blank'> <img src='" + flattrScheme + "api.flattr.com/button/flattr-badge-large.png' alt='Flattr this' title='Flattr this' border='0' /></a></noscript>"; String htmlEnd = "</div> </body> </html>"; String flattrCode = htmlStart + flattrJavascript + htmlMiddle + flattrHtml + htmlEnd; mFlattrWebview.getSettings().setJavaScriptEnabled(true); mFlattrWebview.loadData(flattrCode, "text/html", "utf-8"); // disable scroll on touch mFlattrWebview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { // already handled (returns true) when moving return (motionEvent.getAction() == MotionEvent.ACTION_MOVE); } }); // make background of webview transparent // has to be called AFTER loadData // http://stackoverflow.com/questions/5003156/android-webview-style-background-colortransparent-ignored-on-android-2-2 mFlattrWebview.setBackgroundColor(0x00000000); }
From source file:plugin.google.maps.GoogleMaps.java
@SuppressLint("NewApi") @Override// w w w . jav a 2 s.c o m public void initialize(final CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); activity = cordova.getActivity(); density = Resources.getSystem().getDisplayMetrics().density; root = (ViewGroup) webView.getParent(); // Is this app in debug mode? try { PackageManager manager = activity.getPackageManager(); ApplicationInfo appInfo = manager.getApplicationInfo(activity.getPackageName(), 0); isDebug = (appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; } catch (Exception e) { } Log.i("CordovaLog", "This app uses phonegap-googlemaps-plugin version " + PLUGIN_VERSION); if (isDebug) { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { JSONArray params = new JSONArray(); params.put("get"); params.put("http://plugins.cordova.io/api/plugin.google.maps"); HttpRequest httpReq = new HttpRequest(); httpReq.initialize(cordova, null); httpReq.execute("execute", params, new CallbackContext("version_check", webView) { @Override public void sendPluginResult(PluginResult pluginResult) { if (pluginResult.getStatus() == PluginResult.Status.OK.ordinal()) { try { JSONObject result = new JSONObject(pluginResult.getStrMessage()); JSONObject distTags = result.getJSONObject("dist-tags"); String latestVersion = distTags.getString("latest"); if (latestVersion.equals(PLUGIN_VERSION) == false) { Log.i("CordovaLog", "phonegap-googlemaps-plugin version " + latestVersion + " is available."); } } catch (JSONException e) { } } } }); } catch (Exception e) { } } }); } cordova.getActivity().runOnUiThread(new Runnable() { @SuppressLint("NewApi") public void run() { /* try { Method method = webView.getClass().getMethod("getSettings"); WebSettings settings = (WebSettings)method.invoke(null); settings.setRenderPriority(RenderPriority.HIGH); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); } catch (Exception e) { e.printStackTrace(); } */ if (Build.VERSION.SDK_INT >= 11) { webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } root.setBackgroundColor(Color.WHITE); if (VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } if (VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { Log.d(TAG, "Google Maps Plugin reloads the browser to change the background color as transparent."); webView.setBackgroundColor(0); try { Method method = webView.getClass().getMethod("reload"); method.invoke(webView); } catch (Exception e) { e.printStackTrace(); } } } }); }