List of usage examples for android.widget FrameLayout addView
public void addView(View child)
Adds a child view.
From source file:com.github.jvanhie.discogsscrobbler.ReleaseVersionsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //setup list view mList = new ListView(getActivity()); mList.setId(android.R.id.list);/* w w w . ja v a2 s . c o m*/ mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { onListItemClick(view, i, l); } }); //create superframe for adding list and empty view FrameLayout superFrame = new FrameLayout(getActivity()); FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); superFrame.setLayoutParams(layoutparams); View emptyView = inflater.inflate(R.layout.fragment_empty, container, false); ((TextView) emptyView.findViewById(R.id.empty_heading)).setText("No versions found"); ((TextView) emptyView.findViewById(R.id.empty_text)).setText( "No alternative versions of this release were found, this could also mean Discogs did not add a master id to this release"); /*initialize list with local discogs collection*/ if (mDiscogs == null) mDiscogs = Discogs.getInstance(getActivity()); if (mRelease == null) { mDiscogs.getRelease(getArguments().getLong(ARG_ITEM_ID, 0), new Discogs.DiscogsDataWaiter<Release>() { @Override public void onResult(boolean success, Release data) { if (success) { mRelease = data; loadList(); } } }); } else { loadList(); } superFrame.addView(emptyView); mList.setEmptyView(emptyView); superFrame.addView(mList); return superFrame; }
From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java
private View createView() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getActivity()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.argb(136, 0, 0, 0)); mBg.setId(ActionSheet.BG_VIEW_ID);//ww w .java2 s .com mBg.setOnClickListener(this); mPanel = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); if (checkDeviceHasNavigationBar(getActivity())) { parent.setPadding(0, 0, 0, getNavBarHeight(getActivity())); } else { parent.setPadding(0, 0, 0, 0); } parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
private View makeHeader(ViewGroup parent, boolean button, float density) { if (C.API_LOLLIPOP) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); View divider = makeSimpleDivider(); int paddingTop = divider.getPaddingBottom(); divider.setPadding(divider.getPaddingLeft(), divider.getPaddingTop(), divider.getPaddingRight(), 0); linearLayout.addView(divider, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.HORIZONTAL); linearLayout.addView(linearLayout2, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); TextView textView = makeCommonTextView(true); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, (int) (32f * density), 1); layoutParams.setMargins((int) (16f * density), paddingTop, (int) (16f * density), (int) (8f * density)); linearLayout2.addView(textView, layoutParams); ViewHolder holder = new ViewHolder(); holder.text = textView;//from www. ja v a 2 s.c o m if (button) { ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); imageView.setBackgroundResource(ResourceUtils.getResourceId(context, android.R.attr.borderlessButtonStyle, android.R.attr.background, 0)); imageView.setOnClickListener(headerButtonListener); imageView.setImageAlpha(0x5e); int size = (int) (48f * density); layoutParams = new LinearLayout.LayoutParams(size, size); layoutParams.rightMargin = (int) (4f * density); linearLayout2.addView(imageView, layoutParams); holder.extra = imageView; holder.icon = imageView; } linearLayout.setTag(holder); return linearLayout; } else { View view = LayoutInflater.from(context) .inflate(ResourceUtils.getResourceId(context, android.R.attr.preferenceCategoryStyle, android.R.attr.layout, android.R.layout.preference_category), parent, false); ViewHolder holder = new ViewHolder(); holder.text = (TextView) view.findViewById(android.R.id.title); if (button) { int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); view.measure(measureSpec, measureSpec); int size = view.getMeasuredHeight(); if (size == 0) { size = (int) (32f * density); } FrameLayout frameLayout = new FrameLayout(context); frameLayout.addView(view); view = frameLayout; ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); int padding = (int) (4f * density); imageView.setPadding(padding, padding, padding, padding); frameLayout.addView(imageView, new FrameLayout.LayoutParams((int) (48f * density), size, Gravity.END)); View buttonView = new View(context); buttonView.setBackgroundResource( ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0)); buttonView.setOnClickListener(headerButtonListener); frameLayout.addView(buttonView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); holder.extra = buttonView; holder.icon = imageView; } view.setTag(holder); return view; } }
From source file:org.telegram.ui.NotificationsSettingsActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from w w w . j a v a 2s . c o m public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new FrameLayout(context); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); FrameLayout frameLayout = (FrameLayout) fragmentView; listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setAdapter(new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, final View view, final int i, long l) { boolean enabled = false; if (i == messageAlertRow || i == groupAlertRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (i == messageAlertRow) { enabled = preferences.getBoolean("EnableAll", true); editor.putBoolean("EnableAll", !enabled); } else if (i == groupAlertRow) { enabled = preferences.getBoolean("EnableGroup", true); editor.putBoolean("EnableGroup", !enabled); } editor.commit(); updateServerNotificationsSettings(i == groupAlertRow); } else if (i == messagePreviewRow || i == groupPreviewRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (i == messagePreviewRow) { enabled = preferences.getBoolean("EnablePreviewAll", true); editor.putBoolean("EnablePreviewAll", !enabled); } else if (i == groupPreviewRow) { enabled = preferences.getBoolean("EnablePreviewGroup", true); editor.putBoolean("EnablePreviewGroup", !enabled); } editor.commit(); updateServerNotificationsSettings(i == groupPreviewRow); } else if (i == messageSoundRow || i == groupSoundRow) { try { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); Uri currentSound = null; String defaultPath = null; Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI; if (defaultUri != null) { defaultPath = defaultUri.getPath(); } if (i == messageSoundRow) { String path = preferences.getString("GlobalSoundPath", defaultPath); if (path != null && !path.equals("NoSound")) { if (path.equals(defaultPath)) { currentSound = defaultUri; } else { currentSound = Uri.parse(path); } } } else if (i == groupSoundRow) { String path = preferences.getString("GroupSoundPath", defaultPath); if (path != null && !path.equals("NoSound")) { if (path.equals(defaultPath)) { currentSound = defaultUri; } else { currentSound = Uri.parse(path); } } } tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound); startActivityForResult(tmpIntent, i); } catch (Exception e) { FileLog.e("tmessages", e); } } else if (i == resetNotificationsRow) { if (reseting) { return; } reseting = true; TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { MessagesController.getInstance().enableJoined = true; reseting = false; SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear(); editor.commit(); if (listView != null) { listView.invalidateViews(); } if (getParentActivity() != null) { Toast toast = Toast .makeText(getParentActivity(), LocaleController.getString("ResetNotificationsText", R.string.ResetNotificationsText), Toast.LENGTH_SHORT); toast.show(); } } }); } }); } else if (i == inappSoundRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableInAppSounds", true); editor.putBoolean("EnableInAppSounds", !enabled); editor.commit(); } else if (i == inappVibrateRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableInAppVibrate", true); editor.putBoolean("EnableInAppVibrate", !enabled); editor.commit(); } else if (i == inappPreviewRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableInAppPreview", true); editor.putBoolean("EnableInAppPreview", !enabled); editor.commit(); } else if (i == inchatSoundRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableInChatSound", true); editor.putBoolean("EnableInChatSound", !enabled); editor.commit(); NotificationsController.getInstance().setInChatSoundEnabled(!enabled); } else if (i == inappPriorityRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableInAppPriority", false); editor.putBoolean("EnableInAppPriority", !enabled); editor.commit(); } else if (i == contactJoinedRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableContactJoined", true); MessagesController.getInstance().enableJoined = !enabled; editor.putBoolean("EnableContactJoined", !enabled); editor.commit(); } else if (i == pinnedMessageRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("PinnedMessages", true); editor.putBoolean("PinnedMessages", !enabled); editor.commit(); } else if (i == androidAutoAlertRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("EnableAutoNotifications", false); editor.putBoolean("EnableAutoNotifications", !enabled); editor.commit(); } else if (i == badgeNumberRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); enabled = preferences.getBoolean("badgeNumber", true); editor.putBoolean("badgeNumber", !enabled); editor.commit(); NotificationsController.getInstance().setBadgeEnabled(!enabled); } else if (i == notificationsServiceConnectionRow) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); enabled = preferences.getBoolean("pushConnection", true); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("pushConnection", !enabled); editor.commit(); if (!enabled) { ConnectionsManager.getInstance().setPushConnectionEnabled(true); } else { ConnectionsManager.getInstance().setPushConnectionEnabled(false); } } else if (i == notificationsServiceRow) { final SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); enabled = preferences.getBoolean("pushService", true); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("pushService", !enabled); editor.commit(); if (!enabled) { ApplicationLoader.startPushService(); } else { ApplicationLoader.stopPushService(); } /*if (!enabled) { } else { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("pushService", false); editor.commit(); listView.invalidateViews(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ((TextCheckCell) view).setChecked(true); } }); showDialog(builder.create()); }*/ } else if (i == messageLedRow || i == groupLedRow) { if (getParentActivity() == null) { return; } LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final ColorPickerView colorPickerView = new ColorPickerView(getParentActivity()); linearLayout.addView(colorPickerView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); if (i == messageLedRow) { colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00)); } else if (i == groupLedRow) { colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00)); } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { final SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); TextColorCell textCell = (TextColorCell) view; if (i == messageLedRow) { editor.putInt("MessagesLed", colorPickerView.getColor()); textCell.setTextAndColor( LocaleController.getString("LedColor", R.string.LedColor), colorPickerView.getColor(), true); } else if (i == groupLedRow) { editor.putInt("GroupLed", colorPickerView.getColor()); textCell.setTextAndColor( LocaleController.getString("LedColor", R.string.LedColor), colorPickerView.getColor(), true); } editor.commit(); } }); builder.setNeutralButton(LocaleController.getString("LedDisabled", R.string.LedDisabled), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); TextColorCell textCell = (TextColorCell) view; if (i == messageLedRow) { editor.putInt("MessagesLed", 0); textCell.setTextAndColor( LocaleController.getString("LedColor", R.string.LedColor), 0, true); } else if (i == groupLedRow) { editor.putInt("GroupLed", 0); textCell.setTextAndColor( LocaleController.getString("LedColor", R.string.LedColor), 0, true); } editor.commit(); listView.invalidateViews(); } }); showDialog(builder.create()); } else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification)); builder.setItems( new CharSequence[] { LocaleController.getString("NoPopup", R.string.NoPopup), LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn), LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff), LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (i == messagePopupNotificationRow) { editor.putInt("popupAll", which); } else if (i == groupPopupNotificationRow) { editor.putInt("popupGroup", which); } editor.commit(); if (listView != null) { listView.invalidateViews(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i == messageVibrateRow || i == groupVibrateRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate)); builder.setItems( new CharSequence[] { LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), LocaleController.getString("VibrationDefault", R.string.VibrationDefault), LocaleController.getString("Short", R.string.Short), LocaleController.getString("Long", R.string.Long), LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); String param = "vibrate_messages"; if (i == groupVibrateRow) { param = "vibrate_group"; } if (which == 0) { editor.putInt(param, 2); } else if (which == 1) { editor.putInt(param, 0); } else if (which == 2) { editor.putInt(param, 1); } else if (which == 3) { editor.putInt(param, 3); } else if (which == 4) { editor.putInt(param, 4); } editor.commit(); if (listView != null) { listView.invalidateViews(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i == messagePriorityRow || i == groupPriorityRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle( LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority)); builder.setItems(new CharSequence[] { LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); if (i == messagePriorityRow) { preferences.edit().putInt("priority_messages", which).commit(); } else if (i == groupPriorityRow) { preferences.edit().putInt("priority_group", which).commit(); } if (listView != null) { listView.invalidateViews(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i == repeatRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle( LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications)); builder.setItems( new CharSequence[] { LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled), LocaleController.formatPluralString("Minutes", 5), LocaleController.formatPluralString("Minutes", 10), LocaleController.formatPluralString("Minutes", 30), LocaleController.formatPluralString("Hours", 1), LocaleController.formatPluralString("Hours", 2), LocaleController.formatPluralString("Hours", 4) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int minutes = 0; if (which == 1) { minutes = 5; } else if (which == 2) { minutes = 10; } else if (which == 3) { minutes = 30; } else if (which == 4) { minutes = 60; } else if (which == 5) { minutes = 60 * 2; } else if (which == 6) { minutes = 60 * 4; } SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); preferences.edit().putInt("repeat_messages", minutes).commit(); if (listView != null) { listView.invalidateViews(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(!enabled); } } }); return fragmentView; }
From source file:com.github.jvanhie.discogsscrobbler.ReleaseListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //check if the user wants to enable discogs support, if not, stop here if (!PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("enable_discogs", true)) { View emptyView = inflater.inflate(R.layout.fragment_empty, container, false); ((TextView) emptyView.findViewById(R.id.empty_heading)).setText("Discogs not enabled"); ((TextView) emptyView.findViewById(R.id.empty_text)).setText( "Cannot display your collection without Discogs support, enable Discogs in the settings menu if you'd like to use this feature"); mCallbacks.onAdapterSet();/*from w w w . j av a 2s.com*/ return emptyView; } String layout = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("collection_view", ""); if (layout.equals("list")) { //setup list view mList = new ListView(getActivity()); mList.setId(android.R.id.list); } else { mList = new GridView(getActivity()); mList.setId(android.R.id.list); mGrid = true; } mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { onListItemClick(view, i, l); } }); mList.setFastScrollEnabled(true); //create superframe for adding list and empty view FrameLayout superFrame = new FrameLayout(getActivity()); FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); superFrame.setLayoutParams(layoutparams); View emptyView = inflater.inflate(R.layout.fragment_empty, container, false); mEmptyHeading = ((TextView) emptyView.findViewById(R.id.empty_heading)); mEmptyHeading.setText("Empty collection"); mEmptyText = ((TextView) emptyView.findViewById(R.id.empty_text)); mEmptyText.setText( "Your collection appears to be empty, if this isn't an error, start by adding some releases via the search function or online"); /*initialize list with local discogs collection*/ if (mDiscogs == null) mDiscogs = Discogs.getInstance(getActivity()); loadList(); if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("collection_auto_refresh", true)) { //do a background call to update the discogs collection if necessary checkOnlineCollection(); } superFrame.addView(emptyView); mList.setEmptyView(emptyView); superFrame.addView(mList); return superFrame; }
From source file:com.ndn.menurandom.ImageDownloader.java
private void makeFrameLayout(ImageView imageView) { boolean isExist = false; ViewGroup vg = (ViewGroup) imageView.getParent(); if (vg instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) vg; String tag = (String) frameLayout.getTag(); if (tag != null && tag.equals("fl_imagedownloader")) { isExist = true;//w w w . jav a 2s . c o m } } if (!isExist) { int childCount = vg.getChildCount(); int index = 0; while (index < childCount) { if (imageView == vg.getChildAt(index)) { break; } index++; } vg.removeViewAt(index); FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext()); frameLayout.setTag("fl_imagedownloader"); ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams(); frameLayout.setLayoutParams(lpImageView); imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height)); frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(), imageView.getPaddingRight(), imageView.getPaddingBottom()); imageView.setPadding(0, 0, 0, 0); frameLayout.addView(imageView); vg.addView(frameLayout, index); ProgressBar progressBar = new ProgressBar(frameLayout.getContext()); progressBar.setTag("pb_imagedownloader"); int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2; int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2; progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding); frameLayout.addView(progressBar); } }
From source file:com.mci.firstidol.view.ActionSheet.java
@SuppressWarnings("deprecation") private View createView() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getActivity()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.argb(136, 0, 0, 0)); mBg.setId(ActionSheet.BG_VIEW_ID);/*from w w w . j a v a2 s. c o m*/ mBg.setOnClickListener(this); mPanel = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); TextView titleView = new TextView(getActivity()); titleView.setText(TextUtils.isEmpty(getTitle()) ? "" : getTitle()); titleView.setGravity(Gravity.CENTER); titleView.setTextColor(Color.GRAY); titleView.setBackgroundDrawable(mAttrs.actionSheetTitleBackground); mPanel.addView(titleView); parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:com.jgraves.achievementunlocked.AchievementsList_Fragment.java
private void addAchievementToList(Long id, String name, int points) { Log.i(ExploraApp.TAG, "Adding achievement image request of id " + id + " with height, " + imageViewHeight); FrameLayout fl = new FrameLayout(getActivity()); touchMap.put(fl, id);//w w w.j av a 2s.c o m fl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Long id = touchMap.get(v); Log.i(ExploraApp.TAG, "TOUCHED " + id); Intent intent = new Intent(getActivity(), Activity_AchievementInfo.class); intent.putExtra("achievement_id", Long.toString(id)); startActivity(intent); } }); TextView tv_name = new TextView(getActivity()); TextView tv_points = new TextView(getActivity()); ImageView iv = new ImageView(getActivity()); fl.setMinimumHeight(imageViewHeight); fl.setMinimumWidth(ExploraApp.screenWidth); robotoTypeface = Typeface.createFromAsset(getActivity().getAssets(), "Roboto-Thin.ttf"); tv_name.setText(name); tv_name.setTextSize(15f); tv_points.setTextSize(15f); tv_name.setTypeface(robotoTypeface); tv_points.setTypeface(robotoTypeface); tv_points.setText(Integer.toString(points)); tv_points.setGravity(Gravity.RIGHT); tv_points.setTextColor(Color.WHITE); tv_name.setTextColor(Color.WHITE); iv.setMinimumHeight(imageViewHeight); iv.setMinimumWidth(ExploraApp.screenWidth); fl.addView(iv); fl.addView(tv_name); fl.addView(tv_points); ll_images_container.addView(fl); sv_images.bringChildToFront(mQuickReturnView); DefaultImageListener listener = new DefaultImageListener(iv); ImageRequest imageRequest = new ImageRequest( ExploraApp.url_main + "/achievement/" + id + "/photo?y=" + imageViewHeight + "&x=" + ExploraApp.screenWidth, listener, ExploraApp.screenWidth, imageViewHeight, Bitmap.Config.ARGB_8888, listener); ExploraApp.mRequestQueue.add(imageRequest); }
From source file:com.hichinaschool.flashcards.anki.CardEditor.java
private void populateEditFields() { mFieldsLayoutContainer.removeAllViews(); mEditFields = new LinkedList<FieldEditText>(); String[][] fields = mEditorNote.items(); // Use custom font if selected from preferences Typeface mCustomTypeface = null;/* w w w . j av a2 s . co m*/ SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String customFont = preferences.getString("browserEditorFont", ""); if (!customFont.equals("")) { mCustomTypeface = AnkiFont.getTypeface(this, customFont); } for (int i = 0; i < fields.length; i++) { FieldEditText newTextbox = new FieldEditText(this, i, fields[i]); if (mCustomTypeface != null) { newTextbox.setTypeface(mCustomTypeface); } TextView label = newTextbox.getLabel(); label.setTextColor(Color.BLACK); label.setPadding((int) UIUtils.getDensityAdjustedValue(this, 3.4f), 0, 0, 0); mEditFields.add(newTextbox); FrameLayout frame = new FrameLayout(this); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL); params.rightMargin = 10; frame.addView(newTextbox); mFieldsLayoutContainer.addView(label); mFieldsLayoutContainer.addView(frame); } }
From source file:org.telegram.ui.TwoStepVerificationActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//w ww . ja va 2s. co m public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { processDone(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ActionBarMenu menu = actionBar.createMenu(); doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); scrollView = new ScrollView(context); scrollView.setFillViewport(true); frameLayout.addView(scrollView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; scrollView.setLayoutParams(layoutParams); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); scrollView.addView(linearLayout); ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT; linearLayout.setLayoutParams(layoutParams2); titleTextView = new TextView(context); //titleTextView.setTextColor(0xff757575); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); linearLayout.addView(titleTextView); LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = Gravity.CENTER_HORIZONTAL; layoutParams3.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams3); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); //passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); linearLayout.addView(passwordEditText); layoutParams3 = (LinearLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams3.topMargin = AndroidUtilities.dp(32); layoutParams3.height = AndroidUtilities.dp(36); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); layoutParams3.gravity = Gravity.TOP | Gravity.LEFT; layoutParams3.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams3); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) { processDone(); return true; } return false; } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); bottomTextView = new TextView(context); //bottomTextView.setTextColor(0xff757575); bottomTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); bottomTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); bottomTextView.setText(LocaleController.getString("YourEmailInfo", R.string.YourEmailInfo)); linearLayout.addView(bottomTextView); layoutParams3 = (LinearLayout.LayoutParams) bottomTextView.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP; layoutParams3.topMargin = AndroidUtilities.dp(30); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); bottomTextView.setLayoutParams(layoutParams3); LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL); linearLayout.addView(linearLayout2); layoutParams3 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams(); layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = LayoutHelper.MATCH_PARENT; linearLayout2.setLayoutParams(layoutParams3); bottomButton = new TextView(context); bottomButton.setTextColor(0xff4d83b3); bottomButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); bottomButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM); bottomButton.setText(LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip)); bottomButton.setPadding(0, AndroidUtilities.dp(10), 0, 0); linearLayout2.addView(bottomButton); layoutParams3 = (LinearLayout.LayoutParams) bottomButton.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; layoutParams3.bottomMargin = AndroidUtilities.dp(14); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); bottomButton.setLayoutParams(layoutParams3); bottomButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (type == 0) { if (currentPassword.has_recovery) { needShowProgress(); TLRPC.TL_auth_requestPasswordRecovery req = new TLRPC.TL_auth_requestPasswordRecovery(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { needHideProgress(); if (error == null) { final TLRPC.TL_auth_passwordRecovery res = (TLRPC.TL_auth_passwordRecovery) response; AlertDialog.Builder builder = new AlertDialog.Builder( getParentActivity()); builder.setMessage(LocaleController.formatString("RestoreEmailSent", R.string.RestoreEmailSent, res.email_pattern)); builder.setTitle( LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity( 1); fragment.currentPassword = currentPassword; fragment.currentPassword.email_unconfirmed_pattern = res.email_pattern; fragment.passwordSetState = 4; presentFragment(fragment); } }); Dialog dialog = showDialog(builder.create()); if (dialog != null) { dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); } } else { if (error.text.startsWith("FLOOD_WAIT")) { int time = Utilities.parseInt(error.text); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } showAlertWithText( LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); } else { showAlertWithText( LocaleController.getString("AppName", R.string.AppName), error.text); } } } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); } else { showAlertWithText( LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestorePasswordNoEmailText", R.string.RestorePasswordNoEmailText)); } } else { if (passwordSetState == 4) { showAlertWithText( LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestoreEmailTroubleText", R.string.RestoreEmailTroubleText)); } else { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("YourEmailSkipWarningText", R.string.YourEmailSkipWarningText)); builder.setTitle( LocaleController.getString("YourEmailSkipWarning", R.string.YourEmailSkipWarning)); builder.setPositiveButton( LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { email = ""; setNewPassword(false); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } } }); if (type == 0) { progressView = new FrameLayout(context); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); progressView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); listView = new ListView(context); listView.setDivider(null); listView.setEmptyView(progressView); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == setPasswordRow || i == changePasswordRow) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1); fragment.currentPasswordHash = currentPasswordHash; fragment.currentPassword = currentPassword; presentFragment(fragment); } else if (i == setRecoveryEmailRow || i == changeRecoveryEmailRow) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1); fragment.currentPasswordHash = currentPasswordHash; fragment.currentPassword = currentPassword; fragment.emailOnly = true; fragment.passwordSetState = 3; presentFragment(fragment); } else if (i == turnPasswordOffRow || i == abortPasswordRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("TurnPasswordOffQuestion", R.string.TurnPasswordOffQuestion)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { setNewPassword(true); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } }); updateRows(); actionBar.setTitle(LocaleController.getString("TwoStepVerification", R.string.TwoStepVerification)); titleTextView.setText( LocaleController.getString("PleaseEnterCurrentPassword", R.string.PleaseEnterCurrentPassword)); } else if (type == 1) { setPasswordSetState(passwordSetState); } return fragmentView; }