List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:com.money.manager.ex.home.DashboardFragment.java
private View showTableLayoutTopWithdrawals(Cursor cursor) { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null); CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext()); // Textview Title TextView title = (TextView) layout.findViewById(R.id.textViewTitle); title.setText(R.string.top_withdrawals_last_30_days); // Table// ww w . ja va2 s . c o m TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary); // Create Title tableLayout.addView(createTableRow( new String[] { "<small><b>" + getString(R.string.category) + "</b></small>", "<small><b>" + getString(R.string.quantity) + "</b></small>", "<small><b>" + getString(R.string.summary) + "</b></small>" }, new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null })); // add rows while (cursor.moveToNext()) { // load values String category = "<b>" + cursor.getString(cursor.getColumnIndex(ViewMobileData.Category)) + "</b>"; if (!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)))) { category += " : " + cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)); } double total = cursor.getDouble(cursor.getColumnIndex("TOTAL")); int num = cursor.getInt(cursor.getColumnIndex("NUM")); // Add Row tableLayout.addView(createTableRow( new String[] { "<small>" + category + "</small>", "<small><i>" + Integer.toString(num) + "</i></small>", "<small>" + currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(total)) + "</small>" }, new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null })); } // return Layout return layout; }
From source file:com.granita.tasks.EditTaskFragment.java
private void updateView() { /*//from w w w . j ava2s. c o m * If the model loads very slowly then this function may be called after onDetach. In this case check if Activity is <code>null</code> and return if * <code>true</code>. Also return if we don't have values or the values are still loading. */ Activity activity = getActivity(); if (activity == null || mValues == null || mValues.isLoading()) { return; } final LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (mEditor != null) { // remove values, to ensure all listeners get released mEditor.setValues(null); } mContent.removeAllViews(); mEditor = (TaskEdit) inflater.inflate(R.layout.task_edit, mContent, false); mEditor.setModel(mModel); mEditor.setValues(mValues); mContent.addView(mEditor); // update focus to title String title = mValues.getAsString(Tasks.TITLE); // set focus to first element of the editor if (mEditor != null) { mEditor.requestFocus(); if (title == null || title.length() == 0) { // open soft input as there is no title InputMethodManager imm = (InputMethodManager) this.getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); } } } updateColor((float) mRootView.getScrollY() / mTaskListBar.getMeasuredHeight()); }
From source file:com.fastbootmobile.encore.app.adapters.SearchAdapter.java
/** * {@inheritDoc}// w ww. ja v a 2 s . c om */ @Override public View getGroupView(int i, boolean b, View view, ViewGroup parent) { final Context ctx = parent.getContext(); assert ctx != null; GroupViewHolder holder; if (view == null) { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.item_group_separator, parent, false); holder = new GroupViewHolder(); holder.tvSearchSeparator = (TextView) view.findViewById(R.id.tv_search_separator); view.setTag(holder); } else { holder = (GroupViewHolder) view.getTag(); } int title; switch (i) { case ARTIST: title = R.string.tab_artists; break; case ALBUM: title = R.string.albums; break; case SONG: title = R.string.songs; break; case PLAYLIST: title = R.string.tab_playlists; break; default: throw new RuntimeException("Unknown group index: " + i); } holder.tvSearchSeparator.setText(title); if (getChildrenCount(i) == 0) { view.setVisibility(View.GONE); } else { view.setVisibility(View.VISIBLE); } return view; }
From source file:com.bill.metrobus.FriendsList.java
public FriendListAdapter(Context context) { super(context, android.R.layout.simple_list_item_2); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); }
From source file:com.mobileman.moments.android.frontend.fragments.StreamListFragment.java
private void doIt() { // View v = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.overlay_thumbnail, null, false); /* Bitmap overlayBitmap = Bitmap.createBitmap(getResources().getDimensionPixelOffset(R.dimen.thumbnailWidth), getResources().getDimensionPixelOffset(R.dimen.thumbnailHeight),Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(overlayBitmap); Drawable bgDrawable = overlayView.getBackground(); if (bgDrawable!=null)/*from w w w . java2s . c o m*/ bgDrawable.draw(canvas); else canvas.drawColor(Color.WHITE); overlayView.draw(canvas); */ LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); //Inflate the layout into a view and configure it the way you like RelativeLayout view = new RelativeLayout(getActivity()); mInflater.inflate(R.layout.overlay_thumbnail, view, true); // TextView tv = (TextView) findViewById(R.id.my_text); // tv.setText("Beat It!!"); //Provide it with a layout params. It should necessarily be wrapping the //content as we not really going to have a parent for it. view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); //Pre-measure the view so that height and width don't remain null. view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); //Assign a size and position to the view and all of its descendants view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); //Create the bitmap Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888); //Create a canvas with the specified bitmap to draw into Canvas c = new Canvas(bitmap); //Render this view (and all of its children) to the given Canvas view.draw(c); String path = Environment.getExternalStorageDirectory().toString(); OutputStream fOut = null; File file = new File(path, "testing.jpg"); // the File to save to try { fOut = new FileOutputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); } bitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate try { fOut.flush(); } catch (IOException e) { e.printStackTrace(); } finally { try { fOut.close(); // do not forget to close the stream } catch (IOException e) { e.printStackTrace(); } } }
From source file:ar.rulosoft.mimanganu.PreferencesFragment.java
@Override public void onCreatePreferences(Bundle bundle, String s) { addPreferencesFromResource(R.xml.fragment_preferences); ColorListDialogPref primaryColor = (ColorListDialogPref) getPreferenceManager().findPreference("primario"); primaryColor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override/* w w w. j ava2 s . c om*/ public boolean onPreferenceChange(Preference preference, Object o) { ((MainActivity) getActivity()).setColorToBars(); return false; } }); PreferenceGroup preferenceGroup = (PreferenceGroup) findPreference("account"); ServerBase[] servers = ServerBase.getServers(getContext()); for (final ServerBase sb : servers) { if (sb.needLogin()) { SwitchPreferenceCompat preference = new SwitchPreferenceCompat(getContext()); preference.setTitle(sb.getServerName()); preference.setSelectable(true); preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { new LoginDialog(getContext(), sb).show(); return false; } }); preferenceGroup.addPreference(preference); } } /** Once, create necessary Data */ prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); final String current_filepath = prefs.getString("directorio", Environment.getExternalStorageDirectory().getAbsolutePath()) + "/MiMangaNu/"; /** This enables to hide downloaded images from gallery, just a toggle */ final SwitchPreferenceCompat cBoxPref = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("mostrar_en_galeria"); cBoxPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean have_noMedia = (Boolean) newValue; if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { File mimaFolder = new File(current_filepath, ".nomedia"); if (have_noMedia) { try { mimaFolder.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } else { if (mimaFolder.exists()) { mimaFolder.delete(); } } } return true; } }); /** Set summary for Reader preference + seamless chapter transitions summary **/ // true: Paged Reader; false: Continuous Reader Boolean readType = prefs.getBoolean("reader_type", false); Preference reader_type = getPreferenceManager().findPreference("reader_type"); Preference seamlessChapterTransitionsPref = getPreferenceManager() .findPreference("seamless_chapter_transitions"); if (readType) { reader_type.setTitle(getString(R.string.paged_reader)); seamlessChapterTransitionsPref .setSummary(getString(R.string.seamless_chapter_transitions_paged_reader_subtitle)); } else { reader_type.setTitle(getString(R.string.continuous_reader)); seamlessChapterTransitionsPref .setSummary(getString(R.string.seamless_chapter_transitions_continuous_reader_subtitle)); } final SwitchPreferenceCompat readerTypePref = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("reader_type"); readerTypePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); Boolean readType = prefs.getBoolean("reader_type", false); Preference reader_type = getPreferenceManager().findPreference("reader_type"); Preference seamlessChapterTransitions = getPreferenceManager() .findPreference("seamless_chapter_transitions"); if (!readType) { reader_type.setTitle(getString(R.string.paged_reader)); seamlessChapterTransitions .setSummary(getString(R.string.seamless_chapter_transitions_paged_reader_subtitle)); } else { reader_type.setTitle(getString(R.string.continuous_reader)); seamlessChapterTransitions.setSummary( getString(R.string.seamless_chapter_transitions_continuous_reader_subtitle)); } return true; } }); /** enable / disable seamless_chapter_transitions_delete_read depending on the state of seamless_chapter_transitions **/ Preference seamlessChapterTransitionsDeleteReadPreference = getPreferenceManager() .findPreference("seamless_chapter_transitions_delete_read"); if (prefs.getBoolean("seamless_chapter_transitions", false)) { seamlessChapterTransitionsDeleteReadPreference.setEnabled(true); } else { seamlessChapterTransitionsDeleteReadPreference.setEnabled(false); } final SwitchPreferenceCompat seamlessChapterTransitionsSPC = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("seamless_chapter_transitions"); seamlessChapterTransitionsSPC.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); Preference seamlessChapterTransitionsDeleteReadPreference = getPreferenceManager() .findPreference("seamless_chapter_transitions_delete_read"); if (!prefs.getBoolean("seamless_chapter_transitions", false)) { seamlessChapterTransitionsDeleteReadPreference.setEnabled(true); } else { seamlessChapterTransitionsDeleteReadPreference.setEnabled(false); SharedPreferences.Editor prefEdit = prefs.edit(); prefEdit.putBoolean("seamless_chapter_transitions_delete_read", false); prefEdit.apply(); } return true; } }); Preference autoImportPath = getPreferenceManager().findPreference("auto_import_path"); /** enable / disable auto_import_path depending on the state of auto_import **/ if (prefs.getBoolean("auto_import", false)) { autoImportPath.setEnabled(true); } else { autoImportPath.setEnabled(false); } final SwitchPreferenceCompat autoImportSPC = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("auto_import"); autoImportSPC.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); Preference autoImportPath = getPreferenceManager().findPreference("auto_import_path"); if (!prefs.getBoolean("auto_import", false)) { autoImportPath.setEnabled(true); } else { autoImportPath.setEnabled(false); } return true; } }); /** This sets the download threads (parallel downloads) */ final SeekBarCustomPreference listPreferenceDT = (SeekBarCustomPreference) getPreferenceManager() .findPreference("download_threads"); listPreferenceDT.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int threads = (int) newValue; int antes = DownloadPoolService.SLOTS; DownloadPoolService.SLOTS = threads; if (DownloadPoolService.actual != null) DownloadPoolService.actual.slots += (threads - antes); return true; } }); /** This sets the maximum number of errors to tolerate */ final SeekBarCustomPreference listPrefET = (SeekBarCustomPreference) getPreferenceManager() .findPreference("error_tolerancia"); listPrefET.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { ChapterDownload.MAX_ERRORS = (int) newValue; return true; } }); /** This sets the number of retries to fetch images */ SeekBarCustomPreference listPrefRT = (SeekBarCustomPreference) getPreferenceManager() .findPreference("reintentos"); listPrefRT.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { SingleDownload.RETRY = (int) newValue; return true; } }); /** This sets the Update Interval of the mangas (i.e. once per week) */ final ListPreference listPrefCU = (ListPreference) getPreferenceManager().findPreference("update_interval"); listPrefCU.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { long time = Long.parseLong((String) newValue); if (time > 0) { AlarmReceiver.setAlarms(getActivity().getApplicationContext(), System.currentTimeMillis() + time, time); } else { AlarmReceiver.stopAlarms(getActivity().getApplicationContext()); } if (time < 0) MainActivity.coldStart = false; return true; } }); /** This is for Custom language selection */ final ListPreference listPrefBatotoLang = (ListPreference) getPreferenceManager() .findPreference("batoto_lang_selection"); listPrefBatotoLang.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.equals("Custom")) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rootView = inflater.inflate(R.layout.batoto_custom_lang_dialog, null); final EditText CustomLang = (EditText) rootView.findViewById(R.id.txtCustomLang); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()); dialogBuilder.setTitle("Custom language"); dialogBuilder.setView(rootView); dialogBuilder.setPositiveButton("Ok", null); dialogBuilder.setNegativeButton("Cancel", null); AlertDialog dialog = dialogBuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button accept = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); accept.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { prefs.edit().putString("batoto_custom_lang", CustomLang.getText().toString()) .apply(); Util.getInstance().toast(getContext(), "Custom Language: " + CustomLang.getText().toString()); dialog.dismiss(); } }); Button cancel = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); } }); dialog.show(); } return true; } }); /** This sets the Version Number, that's all */ final Preference prefAbout = getPreferenceManager().findPreference("about_text"); prefAbout.setSummary("v" + BuildConfig.VERSION_NAME); /** This will check how much storage is taken by the mangas */ new calcStorage().execute(current_filepath); final Preference prefLicense = getPreferenceManager().findPreference("license_view"); prefLicense.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { ((MainActivity) getActivity()).replaceFragment(new LicenseFragment(), "licence_fragment"); return false; } }); final SwitchPreferenceCompat onlyWifiUpdateSwitch = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("update_only_wifi"); SwitchPreferenceCompat onlyWifiSwitch = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("only_wifi"); onlyWifiSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object o) { NetworkUtilsAndReceiver.ONLY_WIFI = (Boolean) o; NetworkUtilsAndReceiver.connectionStatus = NetworkUtilsAndReceiver.ConnectionStatus.UNCHECKED; onlyWifiUpdateSwitch.setEnabled(!(Boolean) o); return true; } }); if (onlyWifiSwitch.isChecked()) { onlyWifiUpdateSwitch.setEnabled(false); } else { onlyWifiUpdateSwitch.setEnabled(true); } final SeekBarCustomPreference seekBarConnectionTimeout = (SeekBarCustomPreference) getPreferenceManager() .findPreference("connection_timeout"); seekBarConnectionTimeout.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Navigator.connectionTimeout = Integer.parseInt(prefs.getString("connection_timeout", "10")); return true; } }); final SeekBarCustomPreference seekBarWriteTimeout = (SeekBarCustomPreference) getPreferenceManager() .findPreference("write_timeout"); seekBarWriteTimeout.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Navigator.writeTimeout = Integer.parseInt(prefs.getString("write_timeout", "10")); return true; } }); final SeekBarCustomPreference seekBarReadTimeout = (SeekBarCustomPreference) getPreferenceManager() .findPreference("read_timeout"); seekBarReadTimeout.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Navigator.readTimeout = Integer.parseInt(prefs.getString("read_timeout", "30")); return true; } }); Preference gridColumnsPref = getPreferenceManager().findPreference("grid_columns"); if (prefs.getBoolean("grid_columns_automatic_detection", true)) { gridColumnsPref.setEnabled(false); } else { gridColumnsPref.setEnabled(true); } final SwitchPreferenceCompat gridColumnsAutomaticDetectionSPC = (SwitchPreferenceCompat) getPreferenceManager() .findPreference("grid_columns_automatic_detection"); gridColumnsAutomaticDetectionSPC.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); Preference gridColumns = getPreferenceManager().findPreference("grid_columns"); if (prefs.getBoolean("grid_columns_automatic_detection", true)) { gridColumns.setEnabled(true); } else { gridColumns.setEnabled(false); } return true; } }); final Preference prefClearCache = getPreferenceManager().findPreference("clear_cache"); prefClearCache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Preference clearCache = getPreferenceManager().findPreference("clear_cache"); clearCache.setEnabled(false); Thread t0 = new Thread(new Runnable() { @Override public void run() { new FileCache(getActivity()).clearCache(); } }); Thread t1 = new Thread(new Runnable() { @Override public void run() { Util.getInstance().createNotificationWithProgressbar(getContext(), 69, getString(R.string.deleting_empty_directories), ""); Util.getInstance().deleteEmptyDirectoriesRecursive(new File(current_filepath)); Util.getInstance().cancelNotification(69); } }); t0.start(); t1.start(); return true; } }); final Preference prefResetServersToDefaults = getPreferenceManager() .findPreference("reset_server_list_to_defaults"); prefResetServersToDefaults.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Preference resetServerListToDefaults = getPreferenceManager() .findPreference("reset_server_list_to_defaults"); resetServerListToDefaults.setEnabled(false); prefs.edit().putString("unused_servers", "").apply(); return true; } }); final Preference prefVacuumDatabase = getPreferenceManager().findPreference("vacuum_database"); prefVacuumDatabase.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Preference vacuumDatabase = getPreferenceManager().findPreference("vacuum_database"); vacuumDatabase.setEnabled(false); Thread t0 = new Thread(new Runnable() { @Override public void run() { Util.getInstance().createNotificationWithProgressbar(getContext(), 70, getString(R.string.vacuum_database_notification_text), ""); Database.vacuumDatabase(getContext()); Util.getInstance().cancelNotification(70); } }); t0.start(); return true; } }); setFirstRunDefaults(); }
From source file:com.luseen.spacenavigation.SpaceNavigationView.java
/** * Adding given space items to content/*from w w w . j ava 2s .c om*/ * * @param leftContent to left content * @param rightContent and right content */ private void addSpaceItems(LinearLayout leftContent, LinearLayout rightContent) { /** * Removing all views for not being duplicated */ if (leftContent.getChildCount() > 0 || rightContent.getChildCount() > 0) { leftContent.removeAllViews(); rightContent.removeAllViews(); } /** * Clear spaceItemList and badgeList for not being duplicated */ spaceItemList.clear(); badgeList.clear(); /** * Getting LayoutInflater to inflate space item view from XML */ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < spaceItems.size(); i++) { final int index = i; int targetWidth; if (spaceItems.size() > 2) targetWidth = contentWidth / 2; else targetWidth = contentWidth; RelativeLayout.LayoutParams textAndIconContainerParams = new RelativeLayout.LayoutParams(targetWidth, mainContentHeight); RelativeLayout textAndIconContainer = (RelativeLayout) inflater.inflate(R.layout.space_item_view, this, false); textAndIconContainer.setLayoutParams(textAndIconContainerParams); ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon); TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text); RelativeLayout badgeContainer = (RelativeLayout) textAndIconContainer .findViewById(R.id.badge_container); spaceItemIcon.setImageResource(spaceItems.get(i).getItemIcon()); spaceItemText.setText(spaceItems.get(i).getItemName()); spaceItemText.setTextSize(TypedValue.COMPLEX_UNIT_PX, spaceItemTextSize); /** * Set custom font to space item textView */ if (isCustomFont) spaceItemText.setTypeface(customFont); /** * Hide item icon and show only text */ if (textOnly) Utils.changeViewVisibilityGone(spaceItemIcon); /** * Hide item text and change icon size */ ViewGroup.LayoutParams iconParams = spaceItemIcon.getLayoutParams(); if (iconOnly) { iconParams.height = spaceItemIconOnlySize; iconParams.width = spaceItemIconOnlySize; spaceItemIcon.setLayoutParams(iconParams); Utils.changeViewVisibilityGone(spaceItemText); } else { iconParams.height = spaceItemIconSize; iconParams.width = spaceItemIconSize; spaceItemIcon.setLayoutParams(iconParams); } /** * Adding space items to item list for future */ spaceItemList.add(textAndIconContainer); /** * Adding badge items to badge list for future */ badgeList.add(badgeContainer); /** * Adding sub views to left and right sides */ if (spaceItems.size() == 2 && leftContent.getChildCount() == 1) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else if (spaceItems.size() > 2 && leftContent.getChildCount() == 2) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else { leftContent.addView(textAndIconContainer, textAndIconContainerParams); } /** * Changing current selected item tint */ if (i == currentSelectedItem) { spaceItemText.setTextColor(activeSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, activeSpaceItemColor); } else { spaceItemText.setTextColor(inActiveSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, inActiveSpaceItemColor); } textAndIconContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { updateSpaceItems(index); } }); } /** * Restore available badges from saveInstance */ restoreBadges(); }
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
private void initLayout() { /* get size of screen */ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w w w . java2s . c om*/ //size of screen screenWidth = size.x; screenHeight = size.y; FrameLayout.LayoutParams layoutParam = null; LayoutInflater myInflate = null; myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); topLayout = new FrameLayout(this); setContentView(topLayout); mGLView = overlay.getGLView(); // OpenGLview int display_width_d = (int) (1.0 * screenWidth); int display_height_d = (int) (1.0 * screenHeight); int button_width = 0; int button_height = 0; int prev_rw, prev_rh; if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) { prev_rh = display_height_d; button_height = display_height_d; prev_rw = (int) (1.0 * display_height_d * live_width / live_height); button_width = display_width_d - prev_rw; } else { prev_rw = display_width_d; prev_rh = (int) (1.0 * display_width_d * live_height / live_width); } layoutParam = new FrameLayout.LayoutParams(1, 1, Gravity.BOTTOM); Log.d("LAYOUT", "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:" + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:" + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height); Log.d("CameraDebug", "InitLayout acquired camera"); if (CAMERA_PREVIEW) { cameraDevice = openCamera(); cameraView = new CameraView(this, cameraDevice); topLayout.addView(cameraView, layoutParam); } layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER); topLayout.addView(mGLView, layoutParam); FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null); layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight); topLayout.addView(preViewLayout, layoutParam); Log.i(LOG_TAG, "cameara preview start: OK"); }
From source file:com.android.settings.Settings.java
@Override protected void onCreate(Bundle savedInstanceState) { mVoiceCapable = getResources().getBoolean(com.android.internal.R.bool.config_voice_capable); if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) { getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0)); }/* w ww . j av a 2 s . c om*/ mAuthenticatorHelper = new AuthenticatorHelper(); mAuthenticatorHelper.updateAuthDescriptions(this); mAuthenticatorHelper.onAccountsUpdated(this, null); mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE); getMetaData(); mInLocalHeaderSwitch = true; super.onCreate(savedInstanceState); mInLocalHeaderSwitch = false; /** * SPRD:Optimization to erase the animation on click. @{ */ ListView list = getListView(); list.setSelector(R.drawable.list_selector_holo_dark); //revo lyq 2014 for advan settings if (FeatureOption.PRJ_FEATURE_MULTI_PRJ_CUSTOMER_ADVAN_BASE) { list.is_no_padding = true; } /** @} */ if (!onIsHidingHeaders() && onIsMultiPane()) { highlightHeader(mTopLevelHeaderId); // Force the title so that it doesn't get overridden by a direct launch of // a specific settings screen. setTitle(R.string.settings_label); } // Retrieve any saved state if (savedInstanceState != null) { mCurrentHeader = savedInstanceState.getParcelable(SAVE_KEY_CURRENT_HEADER); mParentHeader = savedInstanceState.getParcelable(SAVE_KEY_PARENT_HEADER); } // If the current header was saved, switch to it if (savedInstanceState != null && mCurrentHeader != null) { //switchToHeaderLocal(mCurrentHeader); showBreadCrumbs(mCurrentHeader.title, null); } if (mParentHeader != null) { setParentTitle(mParentHeader.title, null, new OnClickListener() { @Override public void onClick(View v) { switchToParent(mParentHeader.fragment); } }); } // Override up navigation for multi-pane, since we handle it in the fragment breadcrumbs if (onIsMultiPane()) { getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setHomeButtonEnabled(false); } /* SPRD: add for tab style @{ */ mInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (UNIVERSEUI_SUPPORT) { if (this.getClass().equals(Settings.class)) { int index = getIntent().getIntExtra("tab_index", mCurrentTabIndex); setupTab(); chooseTab(index); } } if (FeatureOption.PRJ_FEATURE_MULTI_PRJ_TIANRUIXIANG_BASE || FeatureOption.PRJ_FEATURE_SHOW_MENU_FOR_DEVOLOPMENT_SETTINGS) { getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE).edit() .putBoolean(DevelopmentSettings.PREF_SHOW, true).apply(); } /* @} */ }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void init(AttributeSet attrs) { mHostActivity = Util.getHostActivity(getContext()); LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mMainLayout = inflate(getContext(), R.layout.floating_search_layout, this); mBackgroundDrawable = new ColorDrawable(Color.BLACK); mQuerySection = (CardView) findViewById(R.id.search_query_section); mClearButton = (ImageView) findViewById(R.id.clear_btn); mSearchInput = (SearchInputView) findViewById(R.id.search_bar_text); mSearchInputParent = findViewById(R.id.search_input_parent); mLeftAction = (ImageView) findViewById(R.id.left_action); mSearchProgress = (ProgressBar) findViewById(R.id.search_bar_search_progress); initDrawables();/*from w w w.j a va2s. co m*/ mClearButton.setImageDrawable(mIconClear); mMenuView = (MenuView) findViewById(R.id.menu_view); mDivider = findViewById(R.id.divider); mSuggestionsSection = (RelativeLayout) findViewById(R.id.search_suggestions_section); mSuggestionListContainer = findViewById(R.id.suggestions_list_container); mSuggestionsList = (RecyclerView) findViewById(R.id.suggestions_list); setupViews(attrs); }