List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP
int COMPLEX_UNIT_DIP
To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.
Click Source Link
From source file:com.androguide.apkreator.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override// w w w . j av a2 s. com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_main); /** * Before anything we need to check if the config files exist to avoid * FC is they don't * * @see #checkIfConfigExists() */ checkIfConfigExists(); /** * Now it's all good because if no configuration was found we have * copied a default one over. * * @see #checkIfConfigExists() */ setAppConfigInPrefs(); headers = getPluginTabs(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); /* * set a custom shadow that overlays the main content when the drawer * opens */ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); /* set up the drawer's list view with items and click listener */ ArrayAdapter<String> pimpAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item, mDrawerHeaders); mDrawerList.setAdapter(pimpAdapter); Log.e("FIRST POS", mDrawerList.getFirstVisiblePosition() + ""); Log.e("LAST POS", mDrawerList.getLastVisiblePosition() + ""); View child = mDrawerList.getChildAt(mDrawerList.getFirstVisiblePosition()); if (child != null && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) child.setBackground(getColouredTouchFeedback()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); /** Set the user-defined ActionBar icon */ File file = new File(getFilesDir() + "/.APKreator/icon.png"); if (file.exists()) { try { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); Uri iconUri = Uri.fromFile(new File(getFilesDir() + "/.APKreator/icon.png")); Bitmap icon = BitmapFactory.decodeFile(iconUri.getPath()); Drawable ic = new BitmapDrawable(icon); getSupportActionBar().setIcon(ic); } catch (NullPointerException e) { Log.e("NPE", e.getMessage()); } } /* * ActionBarDrawerToggle ties together the proper interactions between * the sliding drawer and the action bar app icon */ mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.app_name, /* "open drawer" description for accessibility */ R.string.app_name /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); /* * creates call to * onPrepareOptionsMenu() */ } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); /* * creates call to * onPrepareOptionsMenu() */ } }; mDrawerLayout.setDrawerListener(mDrawerToggle); /** Tabs adapter using the PagerSlidingStrip library */ tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); ViewPager pager = (ViewPager) findViewById(R.id.pager); MyPagerAdapter adapter = new MyPagerAdapter(this.getSupportFragmentManager()); pager.setAdapter(adapter); pager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); tabs.setOnPageChangeListener(this); changeColor(Color.parseColor(getPluginColor())); pager.setOffscreenPageLimit(5); }
From source file:com.donsen.svg.ui.common.AnimatedSvgView.java
private void rebuildGlyphData() { SvgPathParser parser = new SvgPathParser() { @Override/*from w w w . j av a 2s . c o m*/ protected float transformX(float x) { return x * mWidth / mViewport.x; } @Override protected float transformY(float y) { return y * mHeight / mViewport.y; } }; mGlyphData = new GlyphData[mGlyphStrings.length]; for (int i = 0; i < mGlyphStrings.length; i++) { mGlyphData[i] = new GlyphData(); try { mGlyphData[i].path = parser.parsePath(mGlyphStrings[i]); } catch (ParseException e) { mGlyphData[i].path = new Path(); Log.e(TAG, "Couldn't parse path", e); } PathMeasure pm = new PathMeasure(mGlyphData[i].path, true); while (true) { mGlyphData[i].length = Math.max(mGlyphData[i].length, pm.getLength()); if (!pm.nextContour()) { break; } } mGlyphData[i].paint = new Paint(); mGlyphData[i].paint.setStyle(Paint.Style.STROKE); mGlyphData[i].paint.setAntiAlias(true); mGlyphData[i].paint.setColor(Color.WHITE); mGlyphData[i].paint.setStrokeWidth( TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics())); } }
From source file:com.amitupadhyay.aboutexample.ui.widget.CollapsingTitleLayout.java
private void recalculate(int width) { // reset stateful objects that might change over measure passes paint.setTextSize(collapsedTextSize); displayText = new SpannableStringBuilder(title); // Calculate line height; ensure it' a multiple of 4dp to sit on the grid final float fourDip = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); Paint.FontMetricsInt fm = paint.getFontMetricsInt(); int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading; final int baselineAlignedLineHeight = (int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip)); lineSpacingAdd = Math.max(0, baselineAlignedLineHeight - fontHeight); // now create the layout with our desired insets & line height createLayout(width, lineSpacingAdd); // adjust the title top inset to vertically center text with the toolbar collapsedHeight = (int) Math.max(ViewUtils.getActionBarSize(getContext()), (fourDip + baselineAlignedLineHeight + fourDip)); titleInsetTop = (collapsedHeight - baselineAlignedLineHeight) / 2f; if (lineCount == 1) { // single line mode layout = null;//from w w w .jav a2 s. c om collapsingText = new CollapsingTextHelper(this); collapsingText.setText(title); collapsingText.setCollapsedBounds(titleInsetStart, 0, width - titleInsetEnd, (int) collapsedHeight); collapsingText.setExpandedBounds(titleInsetStart, (int) titleInsetTop, width - titleInsetEnd, getMinimumHeight() - titleInsetBottom); collapsingText.setCollapsedTextColor(paint.getColor()); collapsingText.setExpandedTextColor(paint.getColor()); collapsingText.setCollapsedTextSize(collapsedTextSize); int expandedTitleTextSize = (int) Math.max(collapsedTextSize, ViewUtils.getSingleLineTextSize(displayText.toString(), paint, width - titleInsetStart - titleInsetEnd, collapsedTextSize, maxExpandedTextSize, 0.5f, getResources().getDisplayMetrics())); collapsingText.setExpandedTextSize(expandedTitleTextSize); collapsingText.setExpandedTextGravity(GravityCompat.START | Gravity.BOTTOM); collapsingText.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL); collapsingText.setTypeface(paint.getTypeface()); textTop = getHeight() - titleInsetBottom - fontHeight; scrollRange = getMinimumHeight() - (int) collapsedHeight; } else { // multi-line mode // bottom align the text textTop = getDesiredHeight() - titleInsetBottom - layout.getHeight(); // pre-calculate at what scroll offsets lines should disappear scrollRange = (int) (textTop - titleInsetTop); final int fadeDistance = layout.getLineBottom(0) - layout.getLineBaseline(0); lines = new Line[lineCount]; for (int i = 1; i < lineCount; i++) { int lineBottomScrollOffset = scrollRange + ((lineCount - i - 1) * baselineAlignedLineHeight); lines[i] = new Line(layout.getLineStart(i), layout.getLineEnd(i), new TextColorSpan(paint.getColor()), lineBottomScrollOffset, lineBottomScrollOffset + fadeDistance); } } calculatedWithWidth = width; }
From source file:com.cnblogs.app.ui.viewpagerindicator.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from w w w .j a v a 2 s . co m mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final TabView child = (TabView) mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } // ? if (dynamicTabFontSize) { if (isSelected) { child.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); } else { child.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); } } } }
From source file:babbq.com.searchplace.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();//from w ww . j ava 2s .c om auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API) .addApi(Places.GEO_DATA_API).addConnectionCallbacks(this).addOnConnectionFailedListener(this) .build(); mAdapter = new TestAdapter(null, v -> { int position = results.getChildLayoutPosition(v); //Toast.makeText(getActivity(), "#" + position, Toast.LENGTH_SHORT).show(); PendingResult result = Places.GeoDataApi.getPlaceById(mGoogleApiClient, String.valueOf(mAdapter.getElementAt(position).placeId)); result.setResultCallback(mCoordinatePlaceDetailsCallback); }, mGoogleApiClient); dataManager = new SearchDataManager(mGoogleApiClient, mCoordinatePlaceDetailsCallback) { @Override public void onDataLoaded(List<? extends PlaceAutocomplete> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); // fab.setVisibility(View.VISIBLE); fab.setAlpha(0.6f); fab.setScaleX(0f); fab.setScaleY(0f); fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); } // mAdapter.addAndResort(data); mAdapter.setList(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; // mAdapter = new FeedAdapter(this, dataManager, columns); results.setAdapter(mAdapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); // layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { // // @Override // public int getSpanSize(int position) { // return mAdapter.getItemColumnSpan(position); // } // }); results.setLayoutManager(layoutManager); results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadMore(); } }); results.setHasFixedSize(true); results.addOnScrollListener(gridScroll); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }
From source file:com.example.mapsv2.ClustersAreListsActivity.java
private int getClusterTolerance() { // Compute the maximum distance (in screen space pixels) between two // items on the map that will be displayed with one combined icon final float f = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, clusterToleranceDIP, getResources().getDisplayMetrics()); return (int) (f + 0.5); // round up }
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * /*from ww w . j a v a 2 s.c o m*/ * @param url * The url to load. * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... // Makes the text // NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(cordova.getActivity()); webview.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setPluginsEnabled(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container // layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java
/*** * Hide the searchbox using the circle animation. Can be called regardless of result list length * @param activity Activity/*from w w w . j a v a2s . c om*/ */ public void hideCircularly(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView() .findViewById(android.R.id.content); RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root); display.getSize(size); Resources r = getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics()); int cx = layout.getLeft() + layout.getRight(); int cy = layout.getTop(); int finalRadius = (int) Math.max(layout.getWidth() * 1.5, px); SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, cx, cy, 0, finalRadius); animator.setInterpolator(new ReverseInterpolator()); animator.setDuration(500); animator.start(); animator.addListener(new SupportAnimator.AnimatorListener() { @Override public void onAnimationStart() { } @Override public void onAnimationEnd() { setVisibility(View.GONE); } @Override public void onAnimationCancel() { } @Override public void onAnimationRepeat() { } }); }
From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (position == 2) { final View vv = inflater.inflate(R.layout.benchmark_lay, null); Button run = (Button) vv.findViewById(R.id.runAlgor); Button reset = (Button) vv.findViewById(R.id.cleardata); run.setOnClickListener(new View.OnClickListener() { @Override/* www . j a v a 2 s . com*/ public void onClick(View v) { EditText thrd; EditText points; EditText canvasY; EditText canvasX; thrd = (EditText) vv.findViewById(R.id.numberTreadstxt); points = (EditText) vv.findViewById(R.id.numberpoints); canvasX = (EditText) vv.findViewById(R.id.canvasWidth); canvasY = (EditText) vv.findViewById(R.id.canvasHeight); int threads = Integer.valueOf(thrd.getText().toString()); int ponts = Integer.valueOf(points.getText().toString()); int canvY = Integer.valueOf(canvasY.getText().toString()); int canvX = Integer.valueOf(canvasX.getText().toString()); if (threads < 1) threads = 1; if (ponts <= 2) ponts = 3; if (threads > ponts) threads = ponts - 1; if (threads > 25) threads = 25; if (canvX + 100 < ponts) canvX = canvX + 100; if (canvY + 100 < ponts) canvY = canvY + 100; final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */, Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true); int animTime = 10; final int finalThreads = threads; final int finalPonts = ponts; QuickHull qh = new QuickHull(point2DCloud, threads, true, animTime, new DoneListener() { @Override public void jobDone(int id, float time) { mResults.add(new DataHolder(finalThreads, time, finalPonts)); updateChart(mResults); } }); qh.run(); algorithmIndex = 2; } }); reset.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (DataHolder hld : mResults) { mResults.remove(hld); } updateChart(mResults); } }); doHardcore(vv, inflater); return vv; } else if (position == 3) { final View vv = inflater.inflate(R.layout.benchmark_lay, null); ((TextView) vv.findViewById(R.id.nametxt)).setText(" GrahamScan\n Multithreaded Benchmark"); Button run = (Button) vv.findViewById(R.id.runAlgor); Button resetgr = (Button) vv.findViewById(R.id.cleardata); run.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText thrd; EditText points; EditText canvasY; EditText canvasX; thrd = (EditText) vv.findViewById(R.id.numberTreadstxt); points = (EditText) vv.findViewById(R.id.numberpoints); canvasX = (EditText) vv.findViewById(R.id.canvasWidth); canvasY = (EditText) vv.findViewById(R.id.canvasHeight); int threads = Integer.valueOf(thrd.getText().toString()); int ponts = Integer.valueOf(points.getText().toString()); int canvY = Integer.valueOf(canvasY.getText().toString()); int canvX = Integer.valueOf(canvasX.getText().toString()); if (threads < 1) threads = 1; if (ponts <= 2) ponts = 3; if (threads > ponts) threads = ponts - 1; if (threads > 25) threads = 25; if (canvX + 100 < ponts) canvX = canvX + 100; if (canvY + 100 < ponts) canvY = canvY + 100; final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */, Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true); int animTime = 10; final int finalThreads = threads; final int finalPonts = ponts; GrahamScanParallel gh = new GrahamScanParallel(point2DCloud, threads, true, animTime, new DoneListener() { @Override public void jobDone(int id, float time) { mGResults.add(new DataHolder(finalThreads, time, finalPonts)); updateChart(mGResults); } }); gh.run(); algorithmIndex = 3; } }); resetgr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (DataHolder hld : mGResults) { mGResults.remove(hld); } updateChart(mGResults); } }); doHardcore(vv, inflater); return vv; } else { if (position == 0) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); View v = (View) inflater.inflate(R.layout.intro, null); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); //v.setBackgroundResource(R.drawable.background_card); fl.addView(v); //fl.addView(btn); return fl; } else if (position == 1) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); View v = (View) inflater.inflate(R.layout.algo, null); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); //v.setBackgroundResource(R.drawable.background_card); fl.addView(v); return fl; } } return null; }
From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java
private RoundedImageView createAvatar(final String email) { int sizeInDip = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 65, getResources().getDisplayMetrics()); RoundedImageView image = new RoundedImageView(getActivity()); image.setTag(email);/*from w w w .ja v a2s. co m*/ image.setCornerRadius(100f); image.setBorderWidth(0f); image.setPadding(20, 0, 0, 0); image.setLayoutParams(new LinearLayout.LayoutParams(sizeInDip, sizeInDip)); image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MainApplication.emailBeingTracked = email; LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent("LOCATION-UPDATE")); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent("GO-TO-MAP")); } }); return image; }