use of android.app.Dialog in project platform_frameworks_base by android.
the class PreferenceScreen method showDialog.
private void showDialog(Bundle state) {
Context context = getContext();
if (mListView != null) {
mListView.setAdapter(null);
}
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View childPrefScreen = inflater.inflate(mLayoutResId, null);
View titleView = childPrefScreen.findViewById(android.R.id.title);
mListView = (ListView) childPrefScreen.findViewById(android.R.id.list);
if (mDividerSpecified) {
mListView.setDivider(mDividerDrawable);
}
bind(mListView);
// Set the title bar if title is available, else no title bar
final CharSequence title = getTitle();
Dialog dialog = mDialog = new Dialog(context, context.getThemeResId());
if (TextUtils.isEmpty(title)) {
if (titleView != null) {
titleView.setVisibility(View.GONE);
}
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
} else {
if (titleView instanceof TextView) {
((TextView) titleView).setText(title);
titleView.setVisibility(View.VISIBLE);
} else {
dialog.setTitle(title);
}
}
dialog.setContentView(childPrefScreen);
dialog.setOnDismissListener(this);
if (state != null) {
dialog.onRestoreInstanceState(state);
}
// Add the screen to the list of preferences screens opened as dialogs
getPreferenceManager().addPreferencesScreen(dialog);
dialog.show();
}
use of android.app.Dialog in project JamsMusicPlayer by psaravan.
the class AsyncGoogleMusicAuthenticationTask method onPostExecute.
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (mFirstRun) {
pd.dismiss();
}
//Perform an action based on the operation's result code.
if (result.equals("GOOGLE_PLAY_SERVICES_AVAILABILITY_EXCEPTION")) {
Dialog d = GooglePlayServicesUtil.getErrorDialog(availabilityExceptionStatusCode, mActivity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR);
d.show();
} else if (result.equals("USER_RECOVERABLE_AUTH_EXCEPTION")) {
//45 is an arbitrary value that identifies this activity's result.
LauncherActivity.mAccountName = mAccountName;
SettingsActivity____.mAccountName = mAccountName;
if (mActivity != null) {
mActivity.startActivityForResult(userRecoverableExceptionIntent, 45);
}
} else if (result.equals("GOOGLE_AUTH_EXCEPTION") || result.equals("GENERIC_EXCEPTION")) {
Toast.makeText(mContext, R.string.unknown_error_google_music, Toast.LENGTH_LONG).show();
} else if (result.equals("AUTHENTICATED")) {
if (mFirstRun) {
String text = mContext.getResources().getString(R.string.signed_in_as) + " " + mAccountName;
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
} else if (mFirstRunFromSettings) {
//Start scanning the library to add GMusic songs.
String text = mContext.getResources().getString(R.string.signed_in_as) + " " + mAccountName;
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
//Seting the "REBUILD_LIBRARY" flag to true will force MainActivity to rescan the folders.
mApp.getSharedPreferences().edit().putBoolean("REBUILD_LIBRARY", true).commit();
//Restart the app.
final Intent i = mActivity.getBaseContext().getPackageManager().getLaunchIntentForPackage(mActivity.getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mActivity.finish();
mActivity.startActivity(i);
}
mApp.getSharedPreferences().edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", true).commit();
} else {
Toast.makeText(mContext, R.string.unknown_error_google_music, Toast.LENGTH_LONG).show();
}
}
use of android.app.Dialog in project JamsMusicPlayer by psaravan.
the class LicensesDialog method create.
public Dialog create() {
//Get resources
final WebView webView = new WebView(mContext);
webView.loadDataWithBaseURL(null, mLicensesText, "text/html", "utf-8", null);
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext).setTitle(mTitleText).setView(webView).setPositiveButton(mCloseText, new Dialog.OnClickListener() {
public void onClick(final DialogInterface dialogInterface, final int i) {
dialogInterface.dismiss();
}
});
final AlertDialog dialog = builder.create();
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(final DialogInterface dialog) {
if (mOnDismissListener != null) {
mOnDismissListener.onDismiss(dialog);
}
}
});
return dialog;
}
use of android.app.Dialog in project weiciyuan by qii.
the class UserAvatarDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String path = getArguments().getString("path");
final Rect ori = getArguments().getParcelable("rect");
Bitmap bitmap = BitmapFactory.decodeFile(path);
final View content = getActivity().getLayoutInflater().inflate(R.layout.useravatardialog_layout, null);
final ImageView avatar = ((ImageView) content.findViewById(R.id.imageview));
avatar.setImageBitmap(bitmap);
avatar.setClickable(true);
content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animateClose(avatar, ori);
}
});
Dialog dialog = new Dialog(getActivity(), R.style.UserAvatarDialog) {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
animateClose(avatar, ori);
return true;
}
return super.onKeyDown(keyCode, event);
}
};
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(content);
content.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
content.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (ori == null) {
return;
}
int[] avatarLocation = new int[2];
avatar.getLocationOnScreen(avatarLocation);
final int transX = ori.left - avatarLocation[0];
final int transY = ori.top - avatarLocation[1];
final float scaleX = (float) ori.width() / (float) avatar.getWidth();
final float scaleY = (float) ori.height() / (float) avatar.getHeight();
avatar.setTranslationX(transX);
avatar.setTranslationY(transY);
avatar.setPivotX(0);
avatar.setPivotY(0);
avatar.setScaleX(scaleX);
avatar.setScaleY(scaleY);
avatar.animate().translationX(0).translationY(0).scaleY(1).scaleX(1).alpha(1.0f).setDuration(300).withEndAction(new Runnable() {
@Override
public void run() {
}
});
}
});
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return dialog;
}
use of android.app.Dialog in project weiciyuan by qii.
the class AboutFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(false);
addPreferencesFromResource(R.xml.about_pref);
findPreference(SettingActivity.SUGGEST).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getActivity(), WriteWeiboActivity.class);
intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
intent.putExtra("account", GlobalContext.getInstance().getAccountBean());
intent.putExtra("content", buildContent());
startActivity(intent);
return true;
}
});
findPreference(SettingActivity.VERSION).setSummary(buildVersionInfo());
findPreference(SettingActivity.VERSION).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
ChangeLogDialog changeLogDialog = new ChangeLogDialog(getActivity());
changeLogDialog.show();
return true;
}
});
findPreference(SettingActivity.DONATE).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Dialog dialog = new Dialog(getActivity(), R.style.UserAvatarDialog);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
ImageView imageView = new ImageView(getActivity());
imageView.setImageResource(R.drawable.alipay);
dialog.setContentView(imageView);
dialog.show();
return true;
}
});
detectDebugPreference();
findPreference(SettingActivity.AUTHOR).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
blackMagicCount++;
if (blackMagicCount > 3) {
SettingUtility.setBlackMagicEnabled();
}
if (mp != null && mp.isPlaying()) {
mp.stop();
playing = false;
return true;
}
if (mp == null || !playing) {
mp = MediaPlayer.create(getActivity(), R.raw.star);
}
mp.start();
playing = true;
Toast.makeText(getActivity(), "♩♪♫♬♭", Toast.LENGTH_SHORT).show();
return true;
}
});
buildCacheSummary();
buildLogSummary();
findPreference(SettingActivity.SAVED_PIC_PATH).setSummary(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
}
Aggregations