Search in sources :

Example 51 with Window

use of android.view.Window in project remusic by aa112901.

the class AddNetPlaylistDialog method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    //设置无标题
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (getArguments() != null) {
        musics = getArguments().getParcelableArrayList("songs");
        author = getArguments().getString("author");
    }
    playlistInfo = PlaylistInfo.getInstance(mContext);
    playlistsManager = PlaylistsManager.getInstance(mContext);
    View view = inflater.inflate(R.layout.fragment_add_playlist, container);
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.create_new_playlist);
    recyclerView = (RecyclerView) view.findViewById(R.id.add_playlist_recyclerview);
    linearLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
            alertDialog.setView((mContext.getLayoutInflater().inflate(R.layout.dialog, null)));
            alertDialog.show();
            Window window = alertDialog.getWindow();
            window.setContentView(R.layout.dialog);
            final EditText editText = (EditText) (window.findViewById(R.id.message));
            editText.requestFocus();
            (window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    alertDialog.dismiss();
                }
            });
            (window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    dismiss();
                    new Thread(new Runnable() {

                        @Override
                        public void run() {
                            Log.e("addplay", "here");
                            String albumart = null;
                            for (MusicInfo info : musics) {
                                albumart = info.albumData;
                                if (info.islocal) {
                                    if (albumart.equals(MusicUtils.getAlbumdata(MainApplication.context, info.songId)))
                                        break;
                                } else if (!TextUtils.isEmpty(albumart)) {
                                    break;
                                }
                            }
                            long playlistid = editText.getText().hashCode();
                            playlistInfo.addPlaylist(playlistid, editText.getText().toString(), musics.size(), albumart, author);
                            playlistsManager.insertLists(mContext, playlistid, musics);
                            Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
                            MainApplication.context.sendBroadcast(intent);
                        }
                    }).start();
                    alertDialog.dismiss();
                }
            });
        }
    });
    ArrayList<Playlist> playlists = playlistInfo.getPlaylist();
    recyclerView.setLayoutManager(layoutManager);
    AddPlaylistAdapter adapter = new AddPlaylistAdapter(playlists);
    recyclerView.setAdapter(adapter);
    //setItemDecoration();
    return view;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) EditText(android.widget.EditText) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Playlist(com.wm.remusic.info.Playlist) MusicInfo(com.wm.remusic.info.MusicInfo) LinearLayout(android.widget.LinearLayout)

Example 52 with Window

use of android.view.Window in project remusic by aa112901.

the class FirstScreen method show.

/**
     * 显示。
     *
     * @param imageResource 图片资源
     * @param millis        停留时间,以毫秒为单位。
     * @param animation     消失时的动画效果,取值可以是:FirstScreen.SLIDE_LEFT, FirstScreen.SLIDE_UP, FirstScreen.FADE
     */
public void show(final int imageResource, final int animation) {
    Runnable runnable = new Runnable() {

        public void run() {
            // Get reference to display
            DisplayMetrics metrics = new DisplayMetrics();
            //                Display display = activity.getWindowManager().getDefaultDisplay();
            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(activity);
            root.setMinimumHeight(metrics.heightPixels);
            root.setMinimumWidth(metrics.widthPixels);
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(Color.BLACK);
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(imageResource);
            // Create and show the dialog
            splashDialog = new Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            Window window = splashDialog.getWindow();
            switch(animation) {
                case SLIDE_LEFT:
                    window.setWindowAnimations(R.style.dialog_anim_slide_left);
                    break;
                case SLIDE_UP:
                    window.setWindowAnimations(R.style.dialog_anim_slide_up);
                    break;
                case FADE_OUT:
                    window.setWindowAnimations(R.style.dialog_anim_fade_out);
                    break;
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();
        // Set Runnable to remove splash screen just in case
        /*final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                        removeSplashScreen();
                    }
                }, millis);*/
        }
    };
    activity.runOnUiThread(runnable);
}
Also used : Window(android.view.Window) Dialog(android.app.Dialog) DisplayMetrics(android.util.DisplayMetrics) LinearLayout(android.widget.LinearLayout)

Example 53 with Window

use of android.view.Window in project remusic by aa112901.

the class SplashScreen method show.

/**
     * 显示。
     *
     * @param imageResource 图片资源
     * @param millis        停留时间,以毫秒为单位。
     * @param animation     消失时的动画效果,取值可以是:SplashScreen.SLIDE_LEFT, SplashScreen.SLIDE_UP, SplashScreen.FADE
     */
public void show(final int imageResource, final int animation) {
    Runnable runnable = new Runnable() {

        public void run() {
            // Get reference to display
            DisplayMetrics metrics = new DisplayMetrics();
            //                Display display = activity.getWindowManager().getDefaultDisplay();
            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(activity);
            root.setMinimumHeight(metrics.heightPixels);
            root.setMinimumWidth(metrics.widthPixels);
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(Color.BLACK);
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(imageResource);
            // Create and show the dialog
            splashDialog = new Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            Window window = splashDialog.getWindow();
            switch(animation) {
                case SLIDE_LEFT:
                    window.setWindowAnimations(R.style.dialog_anim_slide_left);
                    break;
                case SLIDE_UP:
                    window.setWindowAnimations(R.style.dialog_anim_slide_up);
                    break;
                case FADE_OUT:
                    window.setWindowAnimations(R.style.dialog_anim_fade_out);
                    break;
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();
        // Set Runnable to remove splash screen just in case
        /*final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                        removeSplashScreen();
                    }
                }, millis);*/
        }
    };
    activity.runOnUiThread(runnable);
}
Also used : Window(android.view.Window) Dialog(android.app.Dialog) DisplayMetrics(android.util.DisplayMetrics) LinearLayout(android.widget.LinearLayout)

Example 54 with Window

use of android.view.Window in project material-intro-screen by TangoAgency.

the class MaterialIntroActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    setContentView(R.layout.activity_material_intro);
    overScrollLayout = (OverScrollViewPager) findViewById(R.id.view_pager_slides);
    viewPager = overScrollLayout.getOverScrollView();
    pageIndicator = (InkPageIndicator) findViewById(R.id.indicator);
    backButton = (ImageButton) findViewById(R.id.button_back);
    nextButton = (ImageButton) findViewById(R.id.button_next);
    skipButton = (ImageButton) findViewById(R.id.button_skip);
    messageButton = (Button) findViewById(R.id.button_message);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout_slide);
    navigationView = (LinearLayout) findViewById(R.id.navigation_view);
    adapter = new SlidesAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(2);
    pageIndicator.setViewPager(viewPager);
    nextButtonTranslationWrapper = new NextButtonTranslationWrapper(nextButton);
    initOnPageChangeListeners();
    permissionNotGrantedClickListener = new PermissionNotGrantedClickListener(this, nextButtonTranslationWrapper);
    finishScreenClickListener = new FinishScreenClickListener();
    setBackButtonVisible();
    viewPager.post(new Runnable() {

        @Override
        public void run() {
            if (adapter.getCount() == 0) {
                finish();
            } else {
                int currentItem = viewPager.getCurrentItem();
                messageButtonBehaviourOnPageSelected.pageSelected(currentItem);
                nextButtonBehaviour(currentItem, adapter.getItem(currentItem));
            }
        }
    });
}
Also used : Window(android.view.Window) NextButtonTranslationWrapper(agency.tango.materialintroscreen.animations.wrappers.NextButtonTranslationWrapper) PermissionNotGrantedClickListener(agency.tango.materialintroscreen.listeners.clickListeners.PermissionNotGrantedClickListener) SlidesAdapter(agency.tango.materialintroscreen.adapter.SlidesAdapter)

Example 55 with Window

use of android.view.Window in project android-extendedactionbar by Takhion.

the class ExtendedActionBarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    final Resources res = getResources();
    final boolean isKitkat = Build.VERSION.SDK_INT >= 19;
    // replace window background to reduce overdraw
    final Window window = getWindow();
    final ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content);
    final View content = contentView.getChildAt(0);
    final Drawable extendedWindowBackground = window.getDecorView().getBackground();
    final Drawable windowBackground = !isKitkat ? extendedWindowBackground : getWindowBackgroundLayer(extendedWindowBackground, R.id.window_background, "window_background");
    window.setBackgroundDrawable(null);
    setBackground(content, windowBackground);
    // add statusbar background
    if (isKitkat) {
        // check if translucent bars are enabled
        final int config_enableTranslucentDecor_id = res.getIdentifier("config_enableTranslucentDecor", "bool", "android");
        if (config_enableTranslucentDecor_id > 0 && res.getBoolean(config_enableTranslucentDecor_id)) {
            // get ActionBar container
            final View actionBarContainer = findViewById("action_bar_container", "android");
            if (actionBarContainer != null) {
                // add layout listener (can't get margin before layout)
                //noinspection ConstantConditions
                actionBarContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

                    @SuppressWarnings("ConstantConditions")
                    @Override
                    public void onGlobalLayout() {
                        // remove layout listener
                        final ViewTreeObserver vto = actionBarContainer.getViewTreeObserver();
                        if (Build.VERSION.SDK_INT < 16)
                            vto.removeGlobalOnLayoutListener(this);
                        else
                            vto.removeOnGlobalLayoutListener(this);
                        // create and add statusbar background view
                        final Drawable statusBarBackground = getWindowBackgroundLayer(extendedWindowBackground, R.id.statusbar_background, "statusbar_background");
                        final int statusBarHeight = ((ViewGroup.MarginLayoutParams) actionBarContainer.getLayoutParams()).topMargin;
                        final View statusBarView = new View(ExtendedActionBarActivity.this);
                        setBackground(statusBarView, statusBarBackground);
                        final FrameLayout.LayoutParams statusBarBackground_lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusBarHeight, Gravity.TOP | Gravity.FILL_HORIZONTAL);
                        contentView.addView(statusBarView, 0, statusBarBackground_lp);
                        // shift content under actionbar
                        final ViewGroup.MarginLayoutParams content_lp = (ViewGroup.MarginLayoutParams) content.getLayoutParams();
                        content_lp.topMargin = getActionBar().getHeight() + statusBarHeight;
                        content.setLayoutParams(content_lp);
                    }
                });
            }
        }
    }
}
Also used : Window(android.view.Window) ViewGroup(android.view.ViewGroup) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) View(android.view.View) FrameLayout(android.widget.FrameLayout) Resources(android.content.res.Resources) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

Window (android.view.Window)322 View (android.view.View)72 WindowManager (android.view.WindowManager)58 TextView (android.widget.TextView)34 TargetApi (android.annotation.TargetApi)29 ImageView (android.widget.ImageView)25 ViewGroup (android.view.ViewGroup)22 Activity (android.app.Activity)17 Dialog (android.app.Dialog)17 ColorDrawable (android.graphics.drawable.ColorDrawable)16 AdapterView (android.widget.AdapterView)16 PhoneWindow (com.android.internal.policy.PhoneWindow)15 Intent (android.content.Intent)11 Context (android.content.Context)10 LayoutInflater (android.view.LayoutInflater)10 WindowDecorActionBar (com.android.internal.app.WindowDecorActionBar)10 RemoteException (android.os.RemoteException)9 DisplayMetrics (android.util.DisplayMetrics)9 LinearLayout (android.widget.LinearLayout)9 PopupWindow (android.widget.PopupWindow)8