Android Open Source - Boxee-Thumb-Remote Fragment Alert Dialog Support






From Project

Back to project page Boxee-Thumb-Remote.

License

The source code is released under:

Apache License

If you think the Android project Boxee-Thumb-Remote listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2011 The Android Open Source Project
 *//  w w w  .  ja  v  a  2 s.c  o m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.evendanan.android.thumbremote.ui;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.SeekBar;

import net.evendanan.android.thumbremote.R;

public class FragmentAlertDialogSupport extends DialogFragment {

    public static final int DIALOG_NO_PASSWORD = 1;
    public static final int DIALOG_NO_SERVER = 2;
    public static final int DIALOG_MEDIA_TIME_SEEK = 3;
    public static final int DIALOG_DISCOVERYING = 4;

    public static FragmentAlertDialogSupport newInstance(int dialog_id) {
        FragmentAlertDialogSupport frag = new FragmentAlertDialogSupport();
        Bundle args = new Bundle();
        args.putInt("dialog_id", dialog_id);
        frag.setArguments(args);
        return frag;
    }

    private Dialog createCredentialsRequiredDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder
                .setTitle(R.string.need_creds_title)
                .setMessage(R.string.need_creds_message)
                .setCancelable(true)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        ((RemoteUiActivity) getActivity()).startSetupActivity();
                        dialog.dismiss();
                    }
                })
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

        return builder.create();
    }

    private Dialog createMediaTimeSeekDialog() {
        final Dialog seeker = new Dialog(getActivity(), R.style.Popup);
        seeker.setContentView(R.layout.custom_time_selection);
        seeker.findViewById(R.id.seeker_close_button).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                seeker.dismiss();
            }
        });
        seeker.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                ((RemoteUiActivity) getActivity()).mMediaSeekBar = null;
            }
        });

        SeekBar seekBar = (SeekBar) seeker.findViewById(R.id.time_seek_bar);
        seekBar.setOnSeekBarChangeListener((RemoteUiActivity) getActivity());

        return seeker;
    }

    private Dialog createNoServerDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder
                .setTitle(R.string.no_server_found_title)
                .setMessage(R.string.no_server_found_message)
                .setCancelable(true)
                .setPositiveButton(R.string.no_server_found_action_manual,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                ((RemoteUiActivity) getActivity()).startSetupActivity();
                                dialog.dismiss();
                            }
                        })
                .setNeutralButton(R.string.no_server_found_action_rescan,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                ((RemoteUiActivity) getActivity()).rescanForServers();
                                dialog.dismiss();
                            }
                        })
                .setNegativeButton(R.string.no_server_found_action_neither,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
        return builder.create();
    }

    private Dialog creatDiscoveryProgressDialog() {
        ProgressDialog p = new ProgressDialog(getActivity());
        p.setTitle(R.string.discoverying_dialog_title);
        p.setMessage(getString(R.string.discoverying_dialog_message));
        p.setIndeterminate(true);
        p.setCancelable(false);

        return p;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final int id = getArguments().getInt("dialog_id");

        Dialog dialog = null;
        switch (id)
        {
            case DIALOG_NO_PASSWORD:
                dialog = createCredentialsRequiredDialog();
                break;
            case DIALOG_NO_SERVER:
                dialog = createNoServerDialog();
                break;
            case DIALOG_MEDIA_TIME_SEEK:
                dialog = createMediaTimeSeekDialog();
                break;
            case DIALOG_DISCOVERYING:
                dialog = creatDiscoveryProgressDialog();
                break;
        }

        if (dialog != null)
            dialog.getWindow().setWindowAnimations(R.style.BoxeeInOut);
        
        ((RemoteUiActivity)getActivity()).onFragmentDialogReady(dialog, id);
        
        return dialog;
    }
}




Java Source Code List

.HttpClientBlocking.java
com.example.android.actionbarcompat.ActionBarHelperBase.java
com.example.android.actionbarcompat.ActionBarHelperCompat.java
com.example.android.actionbarcompat.ActionBarHelperHoneycomb.java
com.example.android.actionbarcompat.ActionBarHelperICS.java
com.example.android.actionbarcompat.SimpleMenuItem.java
com.example.android.actionbarcompat.SimpleMenu.java
iharder.base64.Base64.java
net.evendanan.android.thumbremote.MediaStateListener.java
net.evendanan.android.thumbremote.RemoteApplication.java
net.evendanan.android.thumbremote.ServerAddress.java
net.evendanan.android.thumbremote.ServerConnectionListener.java
net.evendanan.android.thumbremote.ServerConnector.java
net.evendanan.android.thumbremote.ServerRemote.java
net.evendanan.android.thumbremote.ServerStatePoller.java
net.evendanan.android.thumbremote.ServerStateUrlsProvider.java
net.evendanan.android.thumbremote.ServerState.java
net.evendanan.android.thumbremote.Settings.java
net.evendanan.android.thumbremote.ShakeListener.java
net.evendanan.android.thumbremote.UiView.java
net.evendanan.android.thumbremote.boxee.BoxeeConnector.java
net.evendanan.android.thumbremote.boxee.BoxeeDiscovererThread.java
net.evendanan.android.thumbremote.network.HttpBlocking.java
net.evendanan.android.thumbremote.network.HttpRequest.java
net.evendanan.android.thumbremote.network.Response.java
net.evendanan.android.thumbremote.network.ReusableHttpClientBlocking.java
net.evendanan.android.thumbremote.service.DoServerRemoteAction.java
net.evendanan.android.thumbremote.service.ServerRemoteService.java
net.evendanan.android.thumbremote.service.State.java
net.evendanan.android.thumbremote.ui.FixedViewFlipper.java
net.evendanan.android.thumbremote.ui.FragmentAlertDialogSupport.java
net.evendanan.android.thumbremote.ui.HelpUiActivity.java
net.evendanan.android.thumbremote.ui.RemoteUiActivity.java
net.evendanan.android.thumbremote.ui.SettingsActivity.java