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();
}
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;
}
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);
}
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);
}
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);
}
Aggregations