List of usage examples for android.app Dialog getContext
public final @NonNull Context getContext()
From source file:com.frostwire.android.gui.dialogs.HandpickedTorrentDownloadDialog.java
@Override protected void initComponents(Dialog dlg, Bundle savedInstanceState) { byte[] torrentInfoData; Bundle arguments = getArguments();//from w w w.j a v a 2 s . co m if (this.torrentInfo == null && arguments != null && (torrentInfoData = arguments.getByteArray(BUNDLE_KEY_TORRENT_INFO_DATA)) != null) { torrentInfo = TorrentInfo.bdecode(torrentInfoData); magnetUri = arguments.getString(BUNDLE_KEY_MAGNET_URI, null); torrentFetcherDownloadTokenId = arguments.getLong(BUNDLE_KEY_TORRENT_FETCHER_DOWNLOAD_TOKEN_ID); if (torrentFetcherDownloadTokenId != -1) { setOnCancelListener(new OnCancelDownloadsClickListener(this)); } setOnYesListener(new OnStartDownloadsClickListener(dlg.getContext(), this)); } super.initComponents(dlg, savedInstanceState); }
From source file:com.bitants.wally.fragments.MaterialDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (getActivity() != null) { final Dialog dialog = new Dialog(getActivity(), android.support.v7.appcompat.R.style.Base_Theme_AppCompat_Light_Dialog); // android.R.style.Theme_DeviceDefault_Light_Dialog); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setContentView(R.layout.dialog_base_material); textViewTitle = (TextView) dialog.findViewById(R.id.dialog_title); buttonNegative = (Button) dialog.findViewById(R.id.dialog_button_negative); buttonPositive = (Button) dialog.findViewById(R.id.dialog_button_positive); scrollView = (ScrollView) dialog.findViewById(R.id.dialog_scrollview); viewStub = (ViewStub) dialog.findViewById(R.id.dialog_viewstub); setupViews(dialog.getContext()); hideEmptyViews();// w w w. j a v a 2s.com if (!isCancelable()) { buttonNegative.setVisibility(View.GONE); } return dialog; } else { return null; } }
From source file:in.shick.diode.threads.ThreadsListActivity.java
public static void fillThreadClickDialog(Dialog dialog, ThingInfo thingInfo, ThreadClickDialogOnClickListenerFactory threadClickDialogOnClickListenerFactory) { final TextView titleView = (TextView) dialog.findViewById(R.id.title); final TextView urlView = (TextView) dialog.findViewById(R.id.url); final TextView submissionStuffView = (TextView) dialog .findViewById(R.id.submissionTime_submitter_subreddit); final Button loginButton = (Button) dialog.findViewById(R.id.login_button); final Button linkButton = (Button) dialog.findViewById(R.id.thread_link_button); final Button commentsButton = (Button) dialog.findViewById(R.id.thread_comments_button); titleView.setText(thingInfo.getTitle()); urlView.setText(thingInfo.getUrl()); StringBuilder sb = new StringBuilder( Util.getTimeAgo(thingInfo.getCreated_utc(), dialog.getContext().getResources())).append(" by ") .append(thingInfo.getAuthor()).append(" to ").append(thingInfo.getSubreddit()); submissionStuffView.setText(sb);//from ww w. j a v a2 s. c o m // Only show upvote/downvote if user is logged in if (RedditSettings.getInstance().isLoggedIn()) { loginButton.setVisibility(View.GONE); } else { loginButton.setVisibility(View.VISIBLE); loginButton.setOnClickListener(threadClickDialogOnClickListenerFactory.getLoginOnClickListener()); } Util.setStateOfUpvoteDownvoteButtons(dialog, RedditSettings.getInstance().isLoggedIn(), thingInfo, threadClickDialogOnClickListenerFactory.getVoteUpOnCheckedChangeListener(thingInfo), threadClickDialogOnClickListenerFactory.getVoteDownOnCheckedChangeListener(thingInfo)); // "link" button behaves differently for regular links vs. self posts and links to comments pages (e.g., bestof) if (thingInfo.isIs_self()) { // It's a self post. Both buttons do the same thing. linkButton.setEnabled(false); } else { linkButton.setOnClickListener(threadClickDialogOnClickListenerFactory.getLinkOnClickListener(thingInfo, RedditSettings.getInstance().isUseExternalBrowser())); linkButton.setEnabled(true); } // "comments" button is easy: always does the same thing commentsButton .setOnClickListener(threadClickDialogOnClickListenerFactory.getCommentsOnClickListener(thingInfo)); }