Search in sources :

Example 21 with Window

use of android.view.Window in project CoCoin by Nightonke.

the class MainActivity method changeColor.

private void changeColor() {
    boolean shouldChange = SettingManager.getInstance().getIsMonthLimit() && SettingManager.getInstance().getIsColorRemind() && RecordManager.getCurrentMonthExpense() >= SettingManager.getInstance().getMonthWarning();
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
        // Do something for lollipop and above versions
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        if (shouldChange) {
            window.setStatusBarColor(CoCoinUtil.getInstance().getDeeperColor(SettingManager.getInstance().getRemindColor()));
        } else {
            window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
        }
    } else {
    // do something for phones running an SDK before lollipop
    }
    if (shouldChange) {
        root.setBackgroundColor(SettingManager.getInstance().getRemindColor());
        toolbar.setBackgroundColor(SettingManager.getInstance().getRemindColor());
        guillotineBackground.setBackgroundColor(SettingManager.getInstance().getRemindColor());
        guillotineColorLy.setBackgroundColor(SettingManager.getInstance().getRemindColor());
        guillotineToolBar.setBackgroundColor(SettingManager.getInstance().getRemindColor());
    } else {
        root.setBackgroundColor(CoCoinUtil.getInstance().MY_BLUE);
        toolbar.setBackgroundColor(CoCoinUtil.getInstance().MY_BLUE);
        guillotineBackground.setBackgroundColor(CoCoinUtil.getInstance().MY_BLUE);
        guillotineColorLy.setBackgroundColor(CoCoinUtil.getInstance().MY_BLUE);
        guillotineToolBar.setBackgroundColor(CoCoinUtil.getInstance().MY_BLUE);
    }
    if (CoCoinFragmentManager.mainActivityEditMoneyFragment != null)
        CoCoinFragmentManager.mainActivityEditMoneyFragment.setEditColor(shouldChange);
    if (CoCoinFragmentManager.mainActivityEditRemarkFragment != null)
        CoCoinFragmentManager.mainActivityEditRemarkFragment.setEditColor(shouldChange);
    myGridViewAdapter.notifyDataSetInvalidated();
}
Also used : Window(android.view.Window)

Example 22 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 23 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 24 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 25 with Window

use of android.view.Window in project material-dialogs by afollestad.

the class MaterialEditTextPreference method requestInputMethod.

/**
   * Copied from DialogPreference.java
   */
private void requestInputMethod(Dialog dialog) {
    Window window = dialog.getWindow();
    if (window == null) {
        return;
    }
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
Also used : Window(android.view.Window)

Aggregations

Window (android.view.Window)310 View (android.view.View)69 WindowManager (android.view.WindowManager)56 TextView (android.widget.TextView)34 TargetApi (android.annotation.TargetApi)26 ImageView (android.widget.ImageView)25 Activity (android.app.Activity)17 Dialog (android.app.Dialog)17 ViewGroup (android.view.ViewGroup)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