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