當前位置: 首頁>>代碼示例>>Java>>正文


Java DialogFragment類代碼示例

本文整理匯總了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));
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:31,代碼來源:AccountSetupCheckSettings.java

示例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);
}
 
開發者ID:atulgpt,項目名稱:TimeTrix,代碼行數:27,代碼來源:DialogAddNewNote.java

示例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);
        }
    };
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:18,代碼來源:ChatSDKIntentClickListener.java

示例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;
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:23,代碼來源:ViewEventActivity.java

示例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();
    }
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:26,代碼來源:ViewHabitActivity.java

示例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();
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:25,代碼來源:SearchResultsActivity.java

示例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();
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:30,代碼來源:FollowerRequestsActivity.java

示例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);
}
 
開發者ID:martinwithaar,項目名稱:PinchToZoom,代碼行數:20,代碼來源:MainActivity.java

示例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;
    }
}
 
開發者ID:ansarisufiyan777,項目名稱:Show_Chat,代碼行數:21,代碼來源:SettingsActivity.java

示例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");
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:25,代碼來源:AdvancedGeolocation.java

示例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();
    }
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:16,代碼來源:DialogHelper.java

示例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();
}
 
開發者ID:borfast,項目名稱:arrispwgen-android,代碼行數:8,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:ansarisufiyan777,項目名稱:Show_Chat,代碼行數:13,代碼來源:SettingsActivity.java

示例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);
}
 
開發者ID:Dentacoin,項目名稱:aftercare-app-android,代碼行數:8,代碼來源:DCDialogFragment.java


注:本文中的android.app.DialogFragment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。