Java Code Examples for android.widget.FrameLayout#getLayoutParams()

The following examples show how to use android.widget.FrameLayout#getLayoutParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogCropPhotoTransit.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private DialogCropPhotoTransit(Context context) {
    super(context, R.style.dialogCropPhotoTransit);
    toShowAnimation = true;
    this.setCancelable(false);
    this.mContext = context;
    this.mWindow = this.getWindow();
    this.mWindowLp = mWindow.getAttributes();
    mWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mWindowLp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    mWindowLp.windowAnimations = R.style.dialogCropPhotoTransit;
    mWindow.setAttributes(mWindowLp);
    this.setContentView(R.layout.dialog_crop_image_transit);
    this.mIv = (ImageView) findViewById(R.id.iv_photo);
    ivLp = (LayoutParams) mIv.getLayoutParams();
    mFl = (FrameLayout) findViewById(R.id.fl_container);
    mFl.getLayoutParams().height = mContext.getResources()
            .getDisplayMetrics().heightPixels;
    mFl.getLayoutParams().width = mContext.getResources()
            .getDisplayMetrics().widthPixels;
}
 
Example 2
Source File: TwitterCoverListView.java    From TwitterCover-Android with MIT License 6 votes vote down vote up
private void init(Context context) {
    mContext = context;
    setOverScrollMode(OVER_SCROLL_NEVER);
    View header = LayoutInflater.from(mContext).inflate(R.layout.listview_header, null);

    mCoverContainer = (FrameLayout) header.findViewById(R.id.layout_header_container);

    mCoverView = (ImageView) header.findViewById(R.id.layout_header_image);
    mCoverView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    mCoverMaskView = (ImageView) header.findViewById(R.id.layout_header_mask);
    mCoverMaskView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    mCoverImageViewHeight = context.getResources().getDimensionPixelSize(R.dimen.size_default_height);
    mCoverImageViewMaxHeight = mCoverImageViewHeight * 2;
    mCoverContainer.getLayoutParams().height = mCoverImageViewHeight;
    addHeaderView(header);

}
 
Example 3
Source File: ActionBarLayer.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
public ActionBarLayer(Context context, ActionBar actionBar) {
    super(context);
    parentActionBar = actionBar;
    backButtonFrameLayout = new FrameLayout(context);
    addView(backButtonFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backButtonFrameLayout.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.FILL_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    backButtonFrameLayout.setLayoutParams(layoutParams);
    backButtonFrameLayout.setPadding(0, 0, OSUtilities.dp(4), 0);
    backButtonFrameLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (isSearchFieldVisible) {
                closeSearchField();
                return;
            }
            if (actionBarMenuOnItemClick != null) {
                actionBarMenuOnItemClick.onItemClick(-1);
            }
        }
    });
    backButtonFrameLayout.setEnabled(false);
}
 
Example 4
Source File: ShowFullScreenQrView.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void initView() {
	removeAllViews();
	LayoutInflater.from(getContext()).inflate(
			R.layout.layout_show_full_screen_qr, this);
	vMask = findViewById(R.id.v_mask);
	iv = (ImageView) findViewById(R.id.iv_large_photo);
	ivPlaceHolder = (ImageView) findViewById(R.id.iv_place_holder);
	flImages = (FrameLayout) findViewById(R.id.fl_images);
	flImages.getLayoutParams().width = screenWidth;
	flImages.getLayoutParams().height = screenWidth;
	setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			hideToFromView();
		}
	});
}
 
Example 5
Source File: QrCodeFinderView.java    From QrCodeScanner with GNU General Public License v3.0 6 votes vote down vote up
private void init(Context context) {
    if (isInEditMode()) {
        return;
    }
    // 需要调用下面的方法才会执行onDraw方法
    setWillNotDraw(false);
    LayoutInflater inflater = LayoutInflater.from(context);
    RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(R.layout.layout_qr_code_scanner, this);
    FrameLayout frameLayout = (FrameLayout) relativeLayout.findViewById(R.id.qr_code_fl_scanner);
    mFrameRect = new Rect();
    RelativeLayout.LayoutParams layoutParams = (LayoutParams) frameLayout.getLayoutParams();
    mFrameRect.left = (ScreenUtils.getScreenWidth() - layoutParams.width) / 2;
    mFrameRect.top = layoutParams.topMargin;
    mFrameRect.right = mFrameRect.left + layoutParams.width;
    mFrameRect.bottom = mFrameRect.top + layoutParams.height;
}
 
Example 6
Source File: FoldingTextView.java    From Bailan with Apache License 2.0 6 votes vote down vote up
public void initView(Context context) {
    setOrientation(LinearLayout.VERTICAL);
    View view = View.inflate(context, R.layout.appdetail_item_desc, null);
    titleTextView = (TextView) view.findViewById(R.id.detail_desc_title_textview);
    contentTextView = (TextView) view.findViewById(R.id.detail_desc_content_textview);
    foldImage = (ImageView) view.findViewById(R.id.detail_desc_folding_imageview);
    flContent = (FrameLayout) view.findViewById(R.id.fl_content);

    flContent.getLayoutParams().height = getTileHeight() + getShortHeight();


    contentTextView.setOnClickListener(this);
    foldImage.setOnClickListener(this);

    contentTextView.setTag(false);
    foldImage.setTag(false);

    addView(view);
}
 
Example 7
Source File: FoldingTextView.java    From Bailan with Apache License 2.0 6 votes vote down vote up
public void initView(Context context) {
    setOrientation(LinearLayout.VERTICAL);
    View view = View.inflate(context, R.layout.appdetail_item_desc, null);
    titleTextView = (TextView) view.findViewById(R.id.detail_desc_title_textview);
    contentTextView = (TextView) view.findViewById(R.id.detail_desc_content_textview);
    foldImage = (ImageView) view.findViewById(R.id.detail_desc_folding_imageview);
    flContent = (FrameLayout) view.findViewById(R.id.fl_content);

    flContent.getLayoutParams().height = getTileHeight() + getShortHeight();


    contentTextView.setOnClickListener(this);
    foldImage.setOnClickListener(this);

    contentTextView.setTag(false);
    foldImage.setTag(false);

    addView(view);
}
 
Example 8
Source File: StaticLabelTextInputLayout.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
public void setForceShowHint(boolean enabled, CharSequence hint) {
    CharSequence oldHint = mForceHint;
    mForceHint = hint;
    if (enabled == mForceShowHint)
        return;
    mWasHintEnabled = isHintEnabled();
    if (enabled)
        setHintEnabled(false);
    mForceShowHint = enabled;

    FrameLayout inputFrame = (FrameLayout) getChildAt(0);

    LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) inputFrame.getLayoutParams();
    int newTopMargin = 0;
    if (enabled) {
        newTopMargin = (int) -mTextPaint.ascent();
    }

    if(newTopMargin != lp.topMargin) {
        lp.topMargin = newTopMargin;
        inputFrame.requestLayout();
    }

    if (!enabled) {
        setHintEnabled(mWasHintEnabled);
        setHint(oldHint);
    }
}
 
Example 9
Source File: CurtainViewController.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
public static final CurtainViewController.SlidingStatus getSlidingStatus(
        CurtainViewController mCurtainViewController) {

    FrameLayout slidingParent = mCurtainViewController.getSlidingParent();
    FrameLayout.LayoutParams slidingLayoutParams = (FrameLayout.LayoutParams) slidingParent
            .getLayoutParams();

    if (mCurtainViewController.getSlidingItem().getSlidingType() == SlidingType.SIZE) {

        int currentSlidingHeight = slidingParent.getHeight();

        if (currentSlidingHeight == 0) {
            return CurtainViewController.SlidingStatus.COLLAPSED;

        } else if (currentSlidingHeight >= mCurtainViewController
                .getSlidingHeight()) {
            return CurtainViewController.SlidingStatus.EXPANDED;

        } else {
            return CurtainViewController.SlidingStatus.ANIMATING;
        }

    } else if (mCurtainViewController.getSlidingItem().getSlidingType() == SlidingType.MOVE) {

        int currentSlidingTop = slidingLayoutParams.topMargin;

        if (currentSlidingTop <= -mCurtainViewController.getSlidingHeight()) {
            return CurtainViewController.SlidingStatus.COLLAPSED;

        } else if (currentSlidingTop >= 0) {
            return CurtainViewController.SlidingStatus.EXPANDED;

        } else {
            return CurtainViewController.SlidingStatus.ANIMATING;
        }

    } else {
        return CurtainViewController.SlidingStatus.ANIMATING;
    }
}
 
Example 10
Source File: VideoDetailActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 5 votes vote down vote up
private void goLargeLandscape() {
	isFullscreen = false;
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
	
	VideoController videoControls = (VideoController) findViewById(R.id.controller);
	if (videoControls != null) {
		videoControls.setFullscreen(false);
	}
	
	ThumbnailWrapper videoContainer = (ThumbnailWrapper) findViewById(R.id.video_fragment_container);
	videoContainer.setMaintainAspectRatio(true);
	
	FrameLayout headerContainer = (FrameLayout) findViewById(R.id.detail_header_container);
	LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) headerContainer.getLayoutParams();
	p.weight = 1;
	headerContainer.setLayoutParams(p);
	headerContainer.setVisibility(View.VISIBLE);
	
	FrameLayout emptyContainer = (FrameLayout) findViewById(R.id.detail_bottom_container);
	p = (LinearLayout.LayoutParams) emptyContainer.getLayoutParams();
	p.weight = 0;
	emptyContainer.setLayoutParams(p);
	emptyContainer.setVisibility(View.GONE);
	
	findViewById(R.id.detail_right_container).setVisibility(View.VISIBLE);
	createAndAttachCaptionFragment(R.id.detail_right_caption_container);
	createAndAttachHeader();
	
	findViewById(R.id.detail_center_divider).setVisibility(View.VISIBLE);
	
	getDecorViewTreeObserver().addOnGlobalLayoutListener(layoutFixer);
}
 
Example 11
Source File: DrawerFragment.java    From AndroidNavigation with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.nav_fragment_drawer, container, false);
    drawerLayout = root.findViewById(R.id.drawer);
    drawerLayout.addDrawerListener(this);

    if (savedInstanceState != null) {
        minDrawerMargin = savedInstanceState.getInt(MIN_DRAWER_MARGIN_KEY, 64);
        maxDrawerWidth = savedInstanceState.getInt(MAX_DRAWER_WIDTH_KEY);
    }

    FrameLayout menuLayout = drawerLayout.findViewById(R.id.drawer_menu);
    ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) menuLayout.getLayoutParams();
    int screenWidth = AppUtils.getScreenWidth(requireContext());
    int margin1 = AppUtils.dp2px(requireContext(), minDrawerMargin);
    if (margin1 > screenWidth) {
        margin1 = screenWidth;
    } else if (margin1 < 0) {
        margin1 = 0;
    }
    if (maxDrawerWidth <= 0 || maxDrawerWidth > screenWidth) {
        maxDrawerWidth = screenWidth;
    }
    int margin2 = screenWidth - AppUtils.dp2px(requireContext(), maxDrawerWidth);
    int margin = Math.max(margin1, margin2);
    layoutParams.rightMargin = margin - AppUtils.dp2px(requireContext(), 64);

    return root;
}
 
Example 12
Source File: AddAddressHotHDMFragment.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView(View v) {
    flParent = (FrameLayout) v.findViewById(R.id.fl_parent);
    flContainer = (FrameLayout) v.findViewById(R.id.fl_container);
    vBg = (HDMTriangleBgView) v.findViewById(R.id.v_bg);
    llHot = (LinearLayout) v.findViewById(R.id.ll_hot);
    llCold = (LinearLayout) v.findViewById(R.id.ll_cold);
    llServer = (LinearLayout) v.findViewById(R.id.ll_server);
    ivHotLight = (ImageView) v.findViewById(R.id.iv_hot_light);
    ivColdLight = (ImageView) v.findViewById(R.id.iv_cold_light);
    ivServerLight = (ImageView) v.findViewById(R.id.iv_server_light);
    tvHot = (TextView) v.findViewById(R.id.tv_hot);
    tvCold = (TextView) v.findViewById(R.id.tv_cold);
    tvServer = (TextView) v.findViewById(R.id.tv_server);
    llSingular = (LinearLayout) v.findViewById(R.id.ll_singular);
    cbxSingular = (CheckBox) v.findViewById(R.id.cbx_singular);
    llSingularRunning = v.findViewById(R.id.ll_singular_running);
    v.findViewById(R.id.ibtn_info).setOnClickListener(DialogHDMInfo.ShowClick);
    v.findViewById(R.id.ibtn_singular_info).setOnClickListener(singularInfoClick);
    ViewGroup.LayoutParams lpContainer = flContainer.getLayoutParams();
    lpContainer.width = UIUtil.getScreenWidth();
    lpContainer.height = lpContainer.width - flContainer.getPaddingLeft() - flContainer
            .getPaddingRight() + flContainer.getPaddingTop() + flContainer.getPaddingBottom();
    flParent.getLayoutParams().width = lpContainer.width;
    flParent.getLayoutParams().height = lpContainer.height;

    llHot.setOnClickListener(hotClick);
    llCold.setOnClickListener(coldClick);
    llServer.setOnClickListener(serverClick);
    hdmHotAddWithAndroid = new HDMHotAddAndroid(getActivity(), this, this);

}
 
Example 13
Source File: MainLayout.java    From emerald with GNU General Public License v3.0 4 votes vote down vote up
public static RelativeLayout get(Context context, SharedPreferences options) {
	RelativeLayout mainLayout = new RelativeLayout(context);
	LayoutInflater layoutInflater = (LayoutInflater) 
		context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

	addDockBar(mainLayout, layoutInflater, options);

	boolean kitkatNoImmersiveMode = (Build.VERSION.SDK_INT == 19 && !options.getBoolean(Keys.FULLSCREEN, false));
	FrameLayout mainBar = (FrameLayout) layoutInflater.inflate(R.layout.main_bar, mainLayout, false);
	RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(mainBar.getLayoutParams());
	
	GridView grid = (GridView) layoutInflater.inflate(R.layout.apps_grid, mainLayout, false);
	initAppsGrid(grid, options);
	
	if (options.getBoolean(Keys.BOTTOM_MAIN_BAR, true)) {
		layoutParams.addRule(RelativeLayout.ABOVE, R.id.dock_bar);
		mainBar.setLayoutParams(layoutParams);
		mainLayout.addView(mainBar);
		
		if (kitkatNoImmersiveMode) {
			mainLayout.addView(getFakeStatusBar(mainLayout, layoutInflater, options));
		}
		layoutParams = new RelativeLayout.LayoutParams(grid.getLayoutParams());
		if (kitkatNoImmersiveMode) {
			layoutParams.addRule(RelativeLayout.BELOW, R.id.kitkat_status_bar);
		} else {
			layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		}
		layoutParams.addRule(RelativeLayout.ABOVE, R.id.main_bar);
		grid.setLayoutParams(layoutParams);
		mainLayout.addView(grid);
	} else {
		if (!kitkatNoImmersiveMode) {
			layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		} else {
			mainLayout.addView(getFakeStatusBar(mainLayout, layoutInflater, options));
			layoutParams.addRule(RelativeLayout.BELOW, R.id.kitkat_status_bar);
		}
		
		mainBar.setLayoutParams(layoutParams);
		mainLayout.addView(mainBar);
		
		layoutParams = new RelativeLayout.LayoutParams(grid.getLayoutParams());
		layoutParams.addRule(RelativeLayout.ABOVE, R.id.dock_bar);
		layoutParams.addRule(RelativeLayout.BELOW, R.id.main_bar);
		grid.setLayoutParams(layoutParams);
		mainLayout.addView(grid);
	}
	if (options.getBoolean(Keys.HIDE_MAIN_BAR, false)) {
		mainBar.setVisibility(View.GONE);
	}
	mainBar.setBackgroundColor(options.getInt(Keys.BAR_BACKGROUND, 0x22000000));
	
	return mainLayout;
}
 
Example 14
Source File: PhotoAlbumPickerActivity.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    // actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
 
Example 15
Source File: ActionBarActivity.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    try {
        openAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_in);
        closeAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_out);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }

    setTheme(R.style.Theme_TMessages);
    getWindow().setBackgroundDrawableResource(R.drawable.transparent);

    contentView = new FrameLayoutTouch(this);
    setContentView(contentView, new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));

    containerViewBack = new FrameLayout(this);
    contentView.addView(containerViewBack);

    containerView = new FrameLayout(this);
    contentView.addView(containerView);

    shadowView = new FrameLayout(this);
    contentView.addView(shadowView);
    shadowView.setBackgroundResource(R.drawable.shadow);
    ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams();
    layoutParams.width = OSUtilities.dp(2);
    layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
    shadowView.setLayoutParams(layoutParams);
    shadowView.setVisibility(View.INVISIBLE);

    actionBar = new ActionBar(this);
    contentView.addView(actionBar);
    layoutParams = actionBar.getLayoutParams();
    layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
    actionBar.setLayoutParams(layoutParams);

    for (BaseFragment fragment : fragmentsStack) {
        fragment.setParentActivity(this);
    }

    needLayout();
}
 
Example 16
Source File: OneKeyWifi.java    From zhangshangwuda with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle bundle) {
	super.onCreate(bundle);
	setContentView(R.layout.wifi_onekey);
	final Intent intent = getIntent();
	SharedPreferences localSharedPreferences = OneKeyWifi.this
			.getSharedPreferences("User_Data", 0);
	String str1 = localSharedPreferences.getString("wifi_Account", "");
	String str2 = localSharedPreferences.getString("wifi_Password", "");
	try {
		Account = BosCrypto.decrypt(BosCrypto.Excalibur, str1);
		Password = BosCrypto.decrypt(BosCrypto.Excalibur, str2);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	wifiManager = (WifiManager) OneKeyWifi.this
			.getSystemService(Context.WIFI_SERVICE);
	bg = (FrameLayout) findViewById(R.id.anim_layout);
	Rect rect = intent.getSourceBounds();
	if (rect != null) {
		// int i = getResources().getDimensionPixelSize(0x7f0b001d);
		int i = 5;
		int j = rect.left + rect.width() / 2;
		int k = i + rect.top;
		android.widget.RelativeLayout.LayoutParams layoutparams = (android.widget.RelativeLayout.LayoutParams) bg
				.getLayoutParams();
		layoutparams.leftMargin = j - layoutparams.width / 2;
		layoutparams.topMargin = k - layoutparams.height / 2;
		bg.setLayoutParams(layoutparams);
	}
	final ImageView iv = (ImageView) findViewById(R.id.anim_image);
	iv.setScaleType(ScaleType.CENTER);

	final InputStream is = getResources().openRawResource(
			R.drawable.wifi_onekey_cat);
	final GifFrame[] frames = CommonUtil.getGif(is);
	// System.out.println("delay:" + frames[1].delay + ",size:"
	// + frames.length);
	if (GetWifiStatus())
		new Thread(new OnlineThread()).start();
	else
		CheckNetwork();
	// new Thread(new OnlineThread()).start();
	mGifTask = new PlayGifTask(iv, frames);
	mGifTask.start();
}
 
Example 17
Source File: BottomSheetMenuDialog.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    final FrameLayout sheet = findViewById(R.id.design_bottom_sheet);

    if (sheet != null) {
        mBehavior = BottomSheetBehavior.from(sheet);
        mBehavior.setBottomSheetCallback(mBottomSheetCallback);

        if (getContext().getResources().getBoolean(R.bool.tablet_landscape)) {
            CoordinatorLayout.LayoutParams layoutParams
                    = (CoordinatorLayout.LayoutParams) sheet.getLayoutParams();
            layoutParams.width = getContext().getResources()
                    .getDimensionPixelSize(R.dimen.bottomsheet_width);
            sheet.setLayoutParams(layoutParams);
        }

        // Make sure the sheet doesn't overlap the appbar
        if (mAppBarLayout != null) {
            if (mAppBarLayout.getHeight() == 0) {
                mAppBarLayout.getViewTreeObserver()
                        .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                            @Override
                            public void onGlobalLayout() {
                                applyAppbarMargin(sheet);
                            }
                        });
            } else {
                applyAppbarMargin(sheet);
            }
        }


        if (mExpandOnStart) {
            sheet.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                    if (mBehavior.getState() == BottomSheetBehavior.STATE_SETTLING
                            && mRequestedExpand) {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                            sheet.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                        } else {
                            //noinspection deprecation
                            sheet.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                        }
                    }
                    mRequestedExpand = true;
                }
            });
        } else if (getContext().getResources().getBoolean(R.bool.landscape)) {
            fixLandscapePeekHeight(sheet);
        }
    }
}
 
Example 18
Source File: BottomSheetMenuDialog.java    From BottomSheetBuilder with Apache License 2.0 4 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    final FrameLayout sheet = findViewById(R.id.design_bottom_sheet);

    if (sheet != null) {
        mBehavior = BottomSheetBehavior.from(sheet);
        mBehavior.setBottomSheetCallback(mBottomSheetCallback);

        if (getContext().getResources().getBoolean(R.bool.tablet_landscape)) {
            CoordinatorLayout.LayoutParams layoutParams
                    = (CoordinatorLayout.LayoutParams) sheet.getLayoutParams();
            layoutParams.width = getContext().getResources()
                    .getDimensionPixelSize(R.dimen.bottomsheet_width);
            sheet.setLayoutParams(layoutParams);
        }

        // Make sure the sheet doesn't overlap the appbar
        if (mAppBarLayout != null) {
            if (mAppBarLayout.getHeight() == 0) {
                mAppBarLayout.getViewTreeObserver()
                        .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                            @Override
                            public void onGlobalLayout() {
                                applyAppbarMargin(sheet);
                            }
                        });
            } else {
                applyAppbarMargin(sheet);
            }
        }


        if (mExpandOnStart) {
            sheet.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                    if (mBehavior.getState() == BottomSheetBehavior.STATE_SETTLING
                            && mRequestedExpand) {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                            sheet.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                        } else {
                            //noinspection deprecation
                            sheet.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                        }
                    }
                    mRequestedExpand = true;
                }
            });
        } else if (getContext().getResources().getBoolean(R.bool.landscape)) {
            fixLandscapePeekHeight(sheet);
        }
    }
}
 
Example 19
Source File: AlertController.java    From ticdesign with Apache License 2.0 4 votes vote down vote up
private void setupView() {
        final ViewGroup contentPanel = (ViewGroup) mWindow.findViewById(R.id.contentPanel);
        setupContent(contentPanel);
        final boolean hasButtons = setupButtons();

        final ViewGroup topPanel = (ViewGroup) mWindow.findViewById(R.id.topPanel);
        final TypedArray a = mContext.obtainStyledAttributes(
                null, R.styleable.AlertDialog, android.R.attr.alertDialogStyle, 0);
        final boolean hasTitle = setupTitle(topPanel);

        if (!hasButtons) {
            final View spacer = mWindow.findViewById(R.id.textSpacerNoButtons);
            if (spacer != null) {
                spacer.setVisibility(View.VISIBLE);
            }
//            mWindow.setCloseOnTouchOutsideIfNotSet(true);
        }

        final FrameLayout customPanel = (FrameLayout) mWindow.findViewById(R.id.customPanel);
        final View customView;
        if (mView != null) {
            customView = mView;
        } else if (mViewLayoutResId != 0) {
            final LayoutInflater inflater = LayoutInflater.from(mContext);
            customView = inflater.inflate(mViewLayoutResId, customPanel, false);
        } else {
            customView = null;
        }

        final boolean hasCustomView = customView != null;
        if (!hasCustomView || !canTextInput(customView)) {
            mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                    WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        }

        if (hasCustomView) {
            final FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
            custom.addView(customView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

            if (mViewSpacingSpecified) {
                custom.setPadding(
                        mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
            }

            if (mListView != null) {
                ((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
            }
        } else {
            customPanel.setVisibility(View.GONE);
        }

        a.recycle();

        final TicklableRecyclerView listView = mListView;
        if (listView != null && mAdapter != null) {
            listView.setAdapter(mAdapter);
        }
    }
 
Example 20
Source File: ImaPlayer.java    From google-media-framework-android with Apache License 2.0 4 votes vote down vote up
/**
 * @param activity The activity that will contain the video player.
 * @param container The {@link FrameLayout} which will contain the video player.
 * @param video The video that should be played.
 * @param videoTitle The title of the video (displayed on the left of the top chrome).
 * @param sdkSettings The settings that should be used to configure the IMA SDK.
 * @param adTagUrl The URL containing the VAST document of the ad.
 * @param fullscreenCallback The callback that should be triggered when the player enters or
 *                           leaves fullscreen.
 */
public ImaPlayer(Activity activity,
                 FrameLayout container,
                 Video video,
                 String videoTitle,
                 ImaSdkSettings sdkSettings,
                 String adTagUrl,
                 PlaybackControlLayer.FullscreenCallback fullscreenCallback) {
  this.activity = activity;
  this.container = container;

  if (adTagUrl != null) {
    this.adTagUrl = Uri.parse(adTagUrl);
  }

  sdkSettings.setPlayerType(PLAYER_TYPE);
  sdkSettings.setPlayerVersion(PLAYER_VERSION);
  adsLoader = ImaSdkFactory.getInstance().createAdsLoader(activity, sdkSettings);
  adListener = new AdListener();
  adsLoader.addAdErrorListener(adListener);
  adsLoader.addAdsLoadedListener(adListener);

  callbacks = new ArrayList<VideoAdPlayer.VideoAdPlayerCallback>();

  boolean autoplay = false;
  contentPlayer = new SimpleVideoPlayer(activity,
      container,
      video,
      videoTitle,
      autoplay);

  contentPlayer.addPlaybackListener(contentPlaybackListener);

  // Move the content player's surface layer to the background so that the ad player's surface
  // layer can be overlaid on top of it during ad playback.
  contentPlayer.moveSurfaceToBackground();
  contentPlayer.hide();

  // Create the ad adDisplayContainer UI which will be used by the IMA SDK to overlay ad controls.
  adUiContainer = new FrameLayout(activity);
  container.addView(adUiContainer);
  adUiContainer.setLayoutParams(Util.getLayoutParamsBasedOnParent(
      adUiContainer,
      ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT));


  this.originalContainerLayoutParams = container.getLayoutParams();

  setFullscreenCallback(fullscreenCallback);
}