本文整理汇总了Java中android.app.DialogFragment类的典型用法代码示例。如果您正苦于以下问题:Java DialogFragment类的具体用法?Java DialogFragment怎么用?Java DialogFragment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DialogFragment类属于android.app包,在下文中一共展示了DialogFragment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDialogFragment
import android.app.DialogFragment; //导入依赖的package包/类
private void showDialogFragment(int dialogId, String customMessage) {
if (mDestroyed) {
return;
}
mProgressBar.setIndeterminate(false);
DialogFragment fragment;
switch (dialogId) {
case R.id.dialog_account_setup_error: {
fragment = ConfirmationDialogFragment.newInstance(dialogId,
getString(R.string.account_setup_failed_dlg_title),
customMessage,
getString(R.string.account_setup_failed_dlg_edit_details_action),
getString(R.string.account_setup_failed_dlg_continue_action)
);
break;
}
default: {
throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
}
}
FragmentTransaction ta = getFragmentManager().beginTransaction();
ta.add(fragment, getDialogTag(dialogId));
ta.commitAllowingStateLoss();
// TODO: commitAllowingStateLoss() is used to prevent https://code.google.com/p/android/issues/detail?id=23761
// but is a bad...
//fragment.show(ta, getDialogTag(dialogId));
}
示例2: onCreate
import android.app.DialogFragment; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mNum = getArguments().getInt("num");
// Pick a style based on the num.
int style = DialogFragment.STYLE_NORMAL, theme = 0;
switch ((mNum-1)%6) {
case 1: style = DialogFragment.STYLE_NO_TITLE; break;
case 2: style = DialogFragment.STYLE_NO_FRAME; break;
case 3: style = DialogFragment.STYLE_NO_INPUT; break;
case 4: style = DialogFragment.STYLE_NORMAL; break;
case 5: style = DialogFragment.STYLE_NORMAL; break;
case 6: style = DialogFragment.STYLE_NO_TITLE; break;
case 7: style = DialogFragment.STYLE_NO_FRAME; break;
case 8: style = DialogFragment.STYLE_NORMAL; break;
}
switch ((mNum-1)%6) {
case 4: theme = android.R.style.Theme_Holo; break;
case 5: theme = android.R.style.Theme_Holo_Light_Dialog; break;
case 6: theme = android.R.style.Theme_Holo_Light; break;
case 7: theme = android.R.style.Theme_Holo_Light_Panel; break;
case 8: theme = android.R.style.Theme_Holo_Light; break;
}
setStyle(style, theme);
}
示例3: getPickImageClickListener
import android.app.DialogFragment; //导入依赖的package包/类
public static View.OnClickListener getPickImageClickListener(final FragmentActivity activity,final DialogFragment fragment, final int requestCode){
return new View.OnClickListener() {
@Override
public void onClick(View v) {
pickIntent();
}
private void pickIntent(){
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
activity.startActivityFromFragment(fragment, Intent.createChooser(intent,
"Complete action using"), requestCode);
}
};
}
示例4: onLocButtonClick
import android.app.DialogFragment; //导入依赖的package包/类
/**
* Location button clicked, record location.
* @param dialog
* @return currentLoc
*/
@Override
public Location onLocButtonClick(DialogFragment dialog) {
if (checkLocationPermission()){
mFusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
if (location != null) {
currentLoc = location;
}
}
});
}else{requestPermission();}
return currentLoc;
}
示例5: onDatePicked
import android.app.DialogFragment; //导入依赖的package包/类
/**
* Handles the call back from the date picker
* @param dialog DatePicker
* @param date Habit Date
*/
@Override
public void onDatePicked(DialogFragment dialog, Date date) {
boolean allowed=true;
ArrayList<HabitEvent> events = habit.getEvents();
if (events!=null){
for (HabitEvent event : events){
if (Util.isDateAfter(event.getDate(),date)){
allowed=false;
break;
}
}
}
if (allowed) {
TextView habitDate = (TextView) findViewById(R.id.textHabitDate);
habitDate.setText(dateFormat.format(date));
habit.setStartDate(date);
}else{
Toast.makeText(ViewHabitActivity.this,"An event already exists prior to " + dateFormat.format(date) + "!",Toast.LENGTH_LONG).show();
}
}
示例6: onDialogPositiveClick
import android.app.DialogFragment; //导入依赖的package包/类
/**
* User clicked the request dialog's positive option
* @param dialog Send Request Dialog Fragment
* @param userName Username of profile to follow
*/
public void onDialogPositiveClick(DialogFragment dialog, String userName) {
Log.i("Info", "requested to follow "+userName);
ElasticSearchController.GetProfilesTask sendARequest = new ElasticSearchController.GetProfilesTask();
sendARequest.execute(userName);
try {
matches = sendARequest.get();
}catch (Exception e){
Log.i("Error", "Failed to get profiles from async object");
}
followee = matches.get(0);
if (followee.getFollowRequests()==null) {
followee.setFollowRequests(new ArrayList<Profile>());
}
followee.addFollowReq(me);
if (!followee.getFollowRequests().isEmpty()) {
Log.i("Info", "Added " + me.getUsername() + " to " + followee.getUsername());
}
saveData();
}
示例7: onDialogPositiveClick
import android.app.DialogFragment; //导入依赖的package包/类
/**
* User clicked the Accept Follower Dialog's positive option. The follow request is deleted, and
* the follower adds the user to their users follower.
* @param dialog Accept Follower Dialog Fragment
* @param followerName Username of new follower profile
*/
@Override
public void onDialogPositiveClick(DialogFragment dialog, String followerName) {
Log.i("Info", "accepted follow from "+followerName);
ElasticSearchController.GetProfilesTask acceptFollow = new ElasticSearchController.GetProfilesTask();
acceptFollow.execute(followerName);
try {
followers = acceptFollow.get();
}catch (Exception e){
Log.i("Error", "Failed to get profiles from async object");
}
follower = followers.get(0);
if (follower.getUsersFollowed()==null) {
follower.setUsersFollowed(new ArrayList<Profile>());
}
follower.addFollowee(me);
if (follower.getUsersFollowed().get(follower.getUsersFollowed().size()-1).getUsername().equals(me.getUsername())) {
Log.i("Info", "Added " + me.getUsername() + " as user followed to " + follower.getUsername());
}
saveData();
me.removeFollowReq(pos);
saveProfile();
usersArrayAdapter.notifyDataSetChanged();
}
示例8: onOptionsItemSelected
import android.app.DialogFragment; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(R.id.add_photo == id) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.add_photo)), PICK_IMAGE);
} else if(R.id.clear == id) {
List<Drawable> drawables = imageViewPagerAdapter.drawables;
drawables.clear();
addDefaultImages(drawables);
imageViewPagerAdapter.notifyDataSetChanged();
} else if(R.id.info == id) {
DialogFragment infoDialogFragment = new InfoDialogFragment();
infoDialogFragment.show(getFragmentManager(), "info");
}
return super.onOptionsItemSelected(item);
}
示例9: updateSummary
import android.app.DialogFragment; //导入依赖的package包/类
private void updateSummary(String key, boolean changing) {
switch (key) {
case Constants.PREF_APP_LANGUAGE:
entrySummary(key);
if (changing) {
DialogFragment dialogFragment = new SettingsAlertDialog().newInstance(R.string.restart_dialog_message);
dialogFragment.show(getActivity().getFragmentManager(), "restartApp");
}
break;
case Constants.PREF_MOVIES_LANGUAGE:
entrySummary(key);
break;
case Constants.PREF_IMAGES_CACHE:
File cacheDir = getActivity().getCacheDir();
File picassoCacheDir = new File(cacheDir, "picasso-cache");
double size = AppUtils.getDirSize(picassoCacheDir);
preferenceSummary(key, getString(R.string.pref_summary_cache_size, size));
break;
}
}
示例10: alertDialog
import android.app.DialogFragment; //导入依赖的package包/类
/**
* For working with pre-Android M security permissions
* @param gpsEnabled If the cacheManifest and system allow gps
* @param networkLocationEnabled If the cacheManifest and system allow network location access
* @param cellularEnabled If the cacheManifest and system allow cellular data access
*/
private void alertDialog(boolean gpsEnabled, boolean networkLocationEnabled, boolean cellularEnabled){
if(!gpsEnabled || !networkLocationEnabled){
sendCallback(PluginResult.Status.ERROR,
JSONHelper.errorJSON(PROVIDER_PRIMARY, ErrorMessages.LOCATION_SERVICES_UNAVAILABLE()));
final DialogFragment gpsFragment = new GPSAlertDialogFragment();
gpsFragment.show(_cordovaActivity.getFragmentManager(), "GPSAlert");
}
if(!cellularEnabled){
sendCallback(PluginResult.Status.ERROR,
JSONHelper.errorJSON(PROVIDER_PRIMARY, ErrorMessages.CELL_DATA_NOT_AVAILABLE()));
final DialogFragment networkUnavailableFragment = new NetworkUnavailableDialogFragment();
networkUnavailableFragment.show(_cordovaActivity.getFragmentManager(), "NetworkUnavailableAlert");
}
}
示例11: showDialog
import android.app.DialogFragment; //导入依赖的package包/类
private static void showDialog(Activity activity, Class clazz, String tag) {
FragmentManager fm = activity.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(tag);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
try {
((DialogFragment) clazz.newInstance()).show(ft, tag);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例12: onDialogPositiveClick
import android.app.DialogFragment; //导入依赖的package包/类
@Override
public void onDialogPositiveClick(DialogFragment dialog) {
Dialog dialogView = dialog.getDialog();
EditText txt_seed = (EditText) dialogView.findViewById(R.id.txt_seed);
seed = txt_seed.getText().toString();
generate_potd_list();
}
示例13: onCreate
import android.app.DialogFragment; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Do not create a new Fragment when the Activity is re-created such as orientation changes.
setRetainInstance(true);
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog);
}
开发者ID:hiteshsahu,项目名称:FingerPrint-Authentication-With-React-Native-Android,代码行数:8,代码来源:FingerprintAuthenticationDialogFragment.java
示例14: onPreferenceTreeClick
import android.app.DialogFragment; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (preference.equals(findPreference(Constants.PREF_IMAGES_CACHE))) {
File cacheDir = getActivity().getCacheDir();
File picassoCacheDir = new File(cacheDir, "picasso-cache");
int messageId = AppUtils.deleteDir(picassoCacheDir) ? R.string.clear_cache_message_ok : R.string.clear_cache_message_fail;
DialogFragment dialogFragment = new SettingsAlertDialog().newInstance(messageId);
dialogFragment.show(getActivity().getFragmentManager(), "clearCache");
updateSummary(Constants.PREF_IMAGES_CACHE, false);
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
示例15: onViewCreated
import android.app.DialogFragment; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);
}