List of usage examples for android.widget FrameLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.jaredrummler.android.colorpicker.ColorPickerDialog.java
void createColorShades(@ColorInt final int color) { final int[] colorShades = getColorShades(color); if (shadesLayout.getChildCount() != 0) { for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); final ColorPanelView cpv = (ColorPanelView) layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = (ImageView) layout.findViewById(R.id.cpv_color_image_view); cpv.setColor(colorShades[i]); cpv.setTag(false);/*from ww w . j a va 2s. co m*/ iv.setImageDrawable(null); } return; } final int horizontalPadding = getResources().getDimensionPixelSize(R.dimen.cpv_item_horizontal_padding); for (final int colorShade : colorShades) { int layoutResId; if (colorShape == ColorShape.SQUARE) { layoutResId = R.layout.cpv_color_item_square; } else { layoutResId = R.layout.cpv_color_item_circle; } final View view = View.inflate(getActivity(), layoutResId, null); final ColorPanelView colorPanelView = (ColorPanelView) view.findViewById(R.id.cpv_color_panel_view); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) colorPanelView.getLayoutParams(); params.leftMargin = params.rightMargin = horizontalPadding; colorPanelView.setLayoutParams(params); colorPanelView.setColor(colorShade); shadesLayout.addView(view); colorPanelView.post(new Runnable() { @Override public void run() { // The color is black when rotating the dialog. This is a dirty fix. WTF!? colorPanelView.setColor(colorShade); } }); colorPanelView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v.getTag() instanceof Boolean && (Boolean) v.getTag()) { colorPickerDialogListener.onColorSelected(dialogId, ColorPickerDialog.this.color); dismiss(); return; // already selected } ColorPickerDialog.this.color = colorPanelView.getColor(); adapter.selectNone(); for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); ColorPanelView cpv = (ColorPanelView) layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = (ImageView) layout.findViewById(R.id.cpv_color_image_view); iv.setImageResource(cpv == v ? R.drawable.cpv_preset_checked : 0); if (cpv == v && ColorUtils.calculateLuminance(cpv.getColor()) >= 0.65 || Color.alpha(cpv.getColor()) <= ALPHA_THRESHOLD) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { iv.setColorFilter(null); } cpv.setTag(cpv == v); } } }); colorPanelView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { colorPanelView.showHint(); return true; } }); } }
From source file:com.nice295.scratchgames.fragment.MygamesFragment.java
@Nullable @Override/*from w ww . j a v a2 s .c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout ll = (FrameLayout) inflater.inflate(R.layout.fragment_mygames, container, false); //mMyItemArray = new ArrayList<ShowRoomItem>(); mMyItemArray = Paper.book().read("_showroom", new ArrayList<ShowRoomItem>()); mMyItemExtHash = Paper.book().read("_showroom-ext", new HashMap<String, ShowRoomExtItem>()); mListLikes = Paper.book().read("likes", new LinkedList<String>()); Log.d(TAG, "mMyItemArray count: " + mMyItemArray.size()); mTvNoGames = (TextView) ll.findViewById(R.id.tvNoGames); mLvMyItems = (ListView) ll.findViewById(R.id.lvShowroom); mAdapter = new ListViewAdapter(getActivity(), R.layout.layout_item_list_item, mMyItemArray); mLvMyItems.setAdapter(mAdapter); EventBus.getDefault().post(new EventMygames(mListLikes.size())); /* 170620 final View header = getActivity().getLayoutInflater().inflate(R.layout.layout_showroom_header, null, false); mLvMyItems.addHeaderView(header); */ final View footer = getActivity().getLayoutInflater().inflate(R.layout.layout_item_list_item_ad, null, false); mLvMyItems.addFooterView(footer, null, false); NativeExpressAdView adView = (NativeExpressAdView) footer.findViewById(R.id.adView); AdRequest request = new AdRequest.Builder().build(); adView.loadAd(request); // Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity()); mDatabase = FirebaseDatabase.getInstance().getReference(); Query showroomExtQuery = mDatabase.child("showroom-ext"); showroomExtQuery.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { mMyItemExtHash.clear(); if (dataSnapshot.getChildrenCount() != 0) { for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) { ShowRoomExtItem item = postSnapshot.getValue(ShowRoomExtItem.class); Log.d(TAG, "postSnapshot.getKey(): " + postSnapshot.getKey()); Log.d(TAG, "viewCount: " + item.getViewCount()); mMyItemExtHash.put(postSnapshot.getKey(), item); } mAdapter.notifyDataSetChanged(); EventBus.getDefault().post(new EventMygames(mAdapter.getCount())); Paper.book().write("_showroom-ext", mMyItemExtHash); } } @Override public void onCancelled(DatabaseError databaseError) { Log.w(TAG, "showroom-ext:onCancelled", databaseError.toException()); } }); Query myTopPostsQuery = mDatabase.child("showroom").orderByChild("name"); myTopPostsQuery.addValueEventListener( //mDatabase.child("my-items").addValueEventListener( new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { mMyItemArray.clear(); if (dataSnapshot.getChildrenCount() != 0) { for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) { ShowRoomItem item = postSnapshot.getValue(ShowRoomItem.class); if (mListLikes.contains(item.getId())) { mMyItemArray.add(item); } } mAdapter.notifyDataSetChanged(); EventBus.getDefault().post(new EventMygames(mAdapter.getCount())); Paper.book().write("_showroom", mMyItemArray); } mLastdataSnapshot = dataSnapshot; } @Override public void onCancelled(DatabaseError databaseError) { Log.w(TAG, "my-items:onCancelled", databaseError.toException()); } }); mLvMyItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Intent intent = new Intent(getActivity(), ShowWebView.class); ShowRoomItem item = mAdapter.getItem().get(i); intent.putExtra("id", item.getId()); intent.putExtra("user", item.getUser()); intent.putExtra("name", item.getName()); // Add view count ShowRoomExtItem showRoomExtItem = mMyItemExtHash.get(item.getId()); if (showRoomExtItem != null) { increaseViewCount(item.getId(), showRoomExtItem.getViewCount()); } startActivity(intent); } }); mAndroidId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID); Log.d(TAG, "ANDROID_ID: " + mAndroidId); /* Later mLvMyItems.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long id) { ShowRoomItem item = mAdapter.getItem().get(position); ShowRoomExtItem showRoomExtItem = mMyItemExtHash.get(item.getId()); if (mAndroidId != null && ( mAndroidId.equals("3aebba2c123546da") || mAndroidId.equals(showRoomExtItem.getReserved1()) )) { showRemoveDialog(item.getId()); return true; } return false; } }); */ return ll; }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mapView = super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.fragment_map, container, false); FrameLayout layout = (FrameLayout) v.findViewById(R.id.map_container); layout.addView(mapView, 0);//from ww w .j ava2s. co m mFloorControls = layout.findViewById(R.id.map_floorcontrol); // setup floor button handlers mFloorButtons[0] = (Button) v.findViewById(R.id.map_floor1); mFloorButtons[1] = (Button) v.findViewById(R.id.map_floor2); mFloorButtons[2] = (Button) v.findViewById(R.id.map_floor3); mFloorButtons[0].setVisibility(View.GONE); mFloorButtons[1].setVisibility(View.GONE); mFloorButtons[2].setVisibility(View.GONE); mFloorControls.setVisibility(View.GONE); for (int i = 0; i < mFloorButtons.length; i++) { final int j = i; mFloorButtons[i].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showFloor(j); } }); } // get the height and width of the view mapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onGlobalLayout() { final View v = getView(); mHeight = v.getHeight(); mWidth = v.getWidth(); // also requires width and height enableFloors(); if (v.getViewTreeObserver().isAlive()) { // remove this layout listener if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { v.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { v.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } } }); if (mMap == null) { setupMap(true); } // load all markers LoaderManager lm = getActivity().getSupportLoaderManager(); lm.initLoader(MarkerQuery._TOKEN, null, this); // load the tile overlays lm.initLoader(OverlayQuery._TOKEN, null, this); // load tracks data lm.initLoader(TracksQuery._TOKEN, null, this); return v; }
From source file:com.sabaibrowser.UI.java
public UI(Activity browser, UiController controller) { mActivity = browser;/*from w ww. j a va 2 s.com*/ mUiController = controller; mTabControl = controller.getTabControl(); Resources res = mActivity.getResources(); mInputManager = (InputMethodManager) browser.getSystemService(Activity.INPUT_METHOD_SERVICE); FrameLayout frameLayout = (FrameLayout) mActivity.getWindow().getDecorView() .findViewById(android.R.id.content); LayoutInflater.from(mActivity).inflate(R.layout.custom_screen, frameLayout); mFixedTitlebarContainer = (FrameLayout) frameLayout.findViewById(R.id.fixed_titlebar_container); mContentView = (FrameLayout) frameLayout.findViewById(R.id.main_content); mCustomViewContainer = (FrameLayout) frameLayout.findViewById(R.id.fullscreen_custom_content); mBlockedElementsContainer = (FrameLayout) frameLayout.findViewById(R.id.blocked_dialog_container); mBubbleMenu = (BubbleMenu) frameLayout.findViewById(R.id.bubble_menu); setImmersiveFullscreen(false); mTitleBar = new TitleBar(mActivity, mUiController, this, mContentView); mTitleBar.setProgress(100); mNavigationBar = mTitleBar.getNavigationBar(); mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); mSwipeContainer = (SwipeRefreshLayout) frameLayout.findViewById(R.id.swipe_container); mSwipeContainer.setColorSchemeColors(browser.getResources().getColor(R.color.primary)); mSwipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mUiController.getCurrentTopWebView().reload(); mSwipeContainer.setRefreshing(false); } }); mSwipeContainer.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (getWebView() == null) return; int scrollY = getWebView().getScrollY(); // workaround for swipetorefresh not "stealing" the scrolling if (scrollY == 0) { mSwipeContainer.setEnabled(true); } else { mSwipeContainer.setEnabled(false); } if (mLastWebViewScrollY < scrollY && mLastWebViewScrollY != 0 && !mTitleBar.isShrank()) { mTitleBar.shrink(); } else if (mLastWebViewScrollY > scrollY && scrollY != 0 && mTitleBar.isShrank()) { mTitleBar.unShrink(); } mLastWebViewScrollY = scrollY; } }); mNavigationBar = mTitleBar.getNavigationBar(); mNavigationBar.setFabMenu(mBubbleMenu); initBubbleMenu(); TypedValue heightValue = new TypedValue(); browser.getTheme().resolveAttribute(android.R.attr.actionBarSize, heightValue, true); mActionBarHeight = TypedValue.complexToDimensionPixelSize(heightValue.data, browser.getResources().getDisplayMetrics()); MainThreadBus.get().register(this); }
From source file:android.support.v7.internal.widget.ActivityChooserView.java
/** * Create a new instance.//from w w w . j a v a2s.c o m * * @param context The application environment. * @param attrs A collection of attributes. * @param defStyle The default style to apply to this view. */ public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView, defStyle, 0); mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); Drawable expandActivityOverflowButtonDrawable = attributesArray .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable); attributesArray.recycle(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.abc_activity_chooser_view, this, true); mCallbacks = new Callbacks(); mActivityChooserContent = (LinearLayoutCompat) findViewById(R.id.activity_chooser_view_content); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image); final FrameLayout expandButton = (FrameLayout) findViewById(R.id.expand_activities_button); expandButton.setOnClickListener(mCallbacks); expandButton.setOnTouchListener(new ListPopupWindow.ForwardingListener(expandButton) { @Override public ListPopupWindow getPopup() { return getListPopupWindow(); } @Override protected boolean onForwardingStarted() { showPopup(); return true; } @Override protected boolean onForwardingStopped() { dismissPopup(); return true; } }); mExpandActivityOverflowButton = expandButton; mExpandActivityOverflowButtonImage = (ImageView) expandButton.findViewById(R.id.image); mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); mAdapter = new ActivityChooserViewAdapter(); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); updateAppearance(); } }); Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); }
From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w w w.j av a2 s . c o m public void onCreate(Bundle savedInstanceState) { currentPreferences = Preferences.getCurrent(); if (C.API_LOLLIPOP) { requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY); } ResourceUtils.applyPreferredTheme(this); expandedScreen = new ExpandedScreen(this, Preferences.isExpandedScreen()); super.onCreate(savedInstanceState); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); float density = ResourceUtils.obtainDensity(this); setContentView(R.layout.activity_main); ClickableToast.register(clickableToastHolder); FavoritesStorage.getInstance().getObservable().register(this); watcherServiceClient.bind(this); pageManager = new PageManager(); actionIconSet = new ActionIconSet(this); progressView = findViewById(R.id.progress); errorView = findViewById(R.id.error); errorText = (TextView) findViewById(R.id.error_text); listView = (PullableListView) findViewById(android.R.id.list); registerForContextMenu(listView); drawerCommon = (ViewGroup) findViewById(R.id.drawer_common); drawerWide = (ViewGroup) findViewById(R.id.drawer_wide); TypedArray typedArray = obtainStyledAttributes(new int[] { R.attr.styleDrawerSpecial }); int drawerResId = typedArray.getResourceId(0, 0); typedArray.recycle(); ContextThemeWrapper styledContext = drawerResId != 0 ? new ContextThemeWrapper(this, drawerResId) : this; int drawerBackground = ResourceUtils.getColor(styledContext, R.attr.backgroundDrawer); drawerCommon.setBackgroundColor(drawerBackground); drawerWide.setBackgroundColor(drawerBackground); drawerListView = new SortableListView(styledContext, this); drawerListView.setId(android.R.id.tabcontent); drawerListView.setOnSortingStateChangedListener(this); drawerForm = new DrawerForm(styledContext, this, this, watcherServiceClient); drawerForm.bind(drawerListView); drawerParent = new FrameLayout(this); drawerParent.addView(drawerListView); drawerCommon.addView(drawerParent); uiManager = new UiManager(this, this, expandedScreen); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (C.API_LOLLIPOP) { FrameLayout foreground = new FrameLayout(this); drawerLayout.addView(foreground, drawerLayout.indexOfChild(drawerCommon), new DrawerLayout.LayoutParams( DrawerLayout.LayoutParams.MATCH_PARENT, DrawerLayout.LayoutParams.MATCH_PARENT)); getLayoutInflater().inflate(R.layout.widget_toolbar, foreground); Toolbar toolbar = (Toolbar) foreground.findViewById(R.id.toolbar); setActionBar(toolbar); toolbarView = toolbar; expandedScreen.setToolbar(toolbar, foreground); } else { getActionBar().setIcon(R.drawable.ic_logo); // Show white logo on search } drawerToggle = new DrawerToggle(this, drawerLayout); if (C.API_LOLLIPOP) { drawerCommon.setElevation(6f * density); drawerWide.setElevation(4f * density); } else { drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); } drawerLayout.addDrawerListener(drawerToggle); drawerLayout.addDrawerListener(drawerForm); if (toolbarView == null) { drawerLayout.addDrawerListener(new ExpandedScreenDrawerLocker()); } ViewUtils.applyToolbarStyle(this, toolbarView); if (Preferences.isActiveScrollbar()) { listView.setFastScrollEnabled(true); if (!C.API_LOLLIPOP) { ListViewUtils.colorizeListThumb4(listView); } } listView.setOnItemClickListener(this); listView.setOnItemLongClickListener(this); listView.getWrapper().setOnPullListener(this); listView.getWrapper().setPullStateListener(this); listView.setClipToPadding(false); ScrollListenerComposite scrollListenerComposite = new ScrollListenerComposite(); listView.setOnScrollListener(scrollListenerComposite); scrollListenerComposite.add(new BusyScrollListener(this)); updateWideConfiguration(true); expandedScreen.setDrawerOverToolbarEnabled(!wideMode); expandedScreen.setContentListView(listView, scrollListenerComposite); expandedScreen.setDrawerListView(drawerParent, drawerListView, drawerForm.getHeaderView()); expandedScreen.addAdditionalView(progressView, true); expandedScreen.addAdditionalView(errorView, true); expandedScreen.finishInitialization(); LocalBroadcastManager.getInstance(this).registerReceiver(newPostReceiver, new IntentFilter(C.ACTION_POST_SENT)); if (savedInstanceState == null) { savedInstanceState = pageManager.readFromStorage(); } PageHolder savedCurrentPageHolder = pageManager.restore(savedInstanceState); if (savedCurrentPageHolder != null) { navigatePageHolder(savedCurrentPageHolder, false); } else { navigateIntent(getIntent(), false); } if (savedInstanceState == null) { startUpdateTask(); int drawerInitialPosition = Preferences.getDrawerInitialPosition(); if (drawerInitialPosition != Preferences.DRAWER_INITIAL_POSITION_CLOSED) { if (!wideMode) { drawerLayout.post(() -> drawerLayout.openDrawer(Gravity.START)); } if (drawerInitialPosition == Preferences.DRAWER_INITIAL_POSITION_FORUMS) { drawerForm.setChanSelectMode(true); } } } }
From source file:com.nbplus.vbroadlauncher.fragment.LauncherFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_launcher, container, false); mMainViewLayout = (LinearLayout) v.findViewById(R.id.main_view_layout); // push agent ??. mPushServiceStatus = (ImageView) v.findViewById(R.id.ic_nav_wifi); if (((BaseActivity) getActivity()).isPushServiceConnected()) { mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_on); } else {/*from www. ja va 2 s . c o m*/ mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_off); } mVillageName = (TextView) v.findViewById(R.id.launcher_village_name); mVillageName.setText(LauncherSettings.getInstance(getActivity()).getVillageName()); mApplicationsView = (LinearLayout) v.findViewById(R.id.ic_nav_apps); mApplicationsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), ShowApplicationActivity.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } }); mServiceTreeMap = (LinearLayout) v.findViewById(R.id.ic_nav_show_map); mServiceTreeMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!NetworkUtils.isConnected(getActivity())) { ((BaseActivity) getActivity()).showNetworkConnectionAlertDialog(); return; } Intent intent = new Intent(getActivity(), BroadcastWebViewActivity.class); ShortcutData data = new ShortcutData(Constants.SHORTCUT_TYPE_WEB_DOCUMENT_SERVER, R.string.btn_show_map, getActivity().getResources().getString(R.string.addr_show_map), R.drawable.ic_menu_04, R.drawable.ic_menu_shortcut_02_selector, 0, null); VBroadcastServer serverInfo = LauncherSettings.getInstance(getActivity()).getServerInformation(); data.setDomain(serverInfo.getDocServer()); intent.putExtra(Constants.EXTRA_NAME_SHORTCUT_DATA, data); startActivity(intent); } }); mOutdoorMode = (LinearLayout) v.findViewById(R.id.ic_nav_outdoor); mOutdoorText = (TextView) v.findViewById(R.id.tv_outdoor); if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) { mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on)); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0); } else { mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off)); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0); } mOutdoorMode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast toast; boolean mode = false; if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) { LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(false); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0); mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off)); toast = Toast.makeText(getActivity(), R.string.outdoor_mode_off, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.show(); } else { mode = true; LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(true); mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on)); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0); toast = Toast.makeText(getActivity(), R.string.outdoor_mode_on, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.show(); } HomeLauncherApplication application = (HomeLauncherApplication) getActivity() .getApplicationContext(); if (application != null) { application.outdoorModeChanged(mode); } } }); // ?? ? mIoTDataSync = (LinearLayout) v.findViewById(R.id.ic_iot_data_sync); mIoTDataSyncText = (TextView) v.findViewById(R.id.tv_iot_data_sync); mIoTDataSync.setOnClickListener(mIoTSyncClickListener); mIoTDataSync.setClickable(true); mIoTDataSync.setEnabled(true); mTextClock = (TextClock) v.findViewById(R.id.text_clock); if (mTextClock != null) { mTextClock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_APP_CALENDAR); startActivity(intent); getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } catch (ActivityNotFoundException e) { e.printStackTrace(); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent i = new Intent( android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); startActivity(i); } }); alert.setMessage(R.string.alert_calendar_not_found); alert.show(); } } }); } mWeatherView = (WeatherView) v.findViewById(R.id.weather_view); mMainViewLeftPanel = (LinearLayout) v.findViewById(R.id.main_view_left_panel); mMainViewRightPanel = (LinearLayout) v.findViewById(R.id.main_view_right_panel); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // add main shortcut. ArrayList<ShortcutData> mainShortcutDatas = LauncherSettings.getInstance(getActivity()) .getLauncherMainShortcuts(); mMainShortcutGridLayout = (GridLayout) v.findViewById(R.id.main_shortcut_grid); float dp;// = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_width); // float widthPx = DisplayUtils.pxFromDp(getActivity(), dp); // // dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_height); // float heightPx = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_font_size); float mainShortcutFontPx = DisplayUtils.pxFromDp(getActivity(), dp); for (int i = 0; i < mMainShortcutGridLayout.getColumnCount(); i++) { /** * right shortcut panel */ ShortcutData data = mainShortcutDatas.get(i); FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_top_item, mMainShortcutGridLayout, false);//new Button(getActivity()); mMainShortcutGridLayout.addView(btnLayout); if (data.getPushType() != null && data.getPushType().length > 0) { data.setLauncherButton(btnLayout); mPushNotifiableShorcuts.add(data); } btnLayout.setBackgroundResource(data.getIconBackResId()); // GridLayout.LayoutParams lp = (GridLayout.LayoutParams)btnLayout.getLayoutParams(); // lp.width = (int)widthPx; // lp.height = (int)heightPx; // btnLayout.setLayoutParams(lp); TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label); label.setText(data.getName()); label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mainShortcutFontPx); label.setTextColor(getResources().getColor(R.color.white)); label.setTypeface(null, Typeface.BOLD); label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image); icon.setImageResource(data.getIconResId()); btnLayout.setTag(data); btnLayout.setOnClickListener(this); } // add other shortcuts. mShorcutGridLayout = (GridLayout) v.findViewById(R.id.shortcut_grid); ArrayList<ShortcutData> shortcutDatas = LauncherSettings.getInstance(getActivity()).getLauncherShortcuts(); int columnNum = mShorcutGridLayout.getColumnCount(); final int MAX_ROW_NUM = 3; int shortcutNum = shortcutDatas.size() > (columnNum * MAX_ROW_NUM) ? (columnNum * MAX_ROW_NUM) : shortcutDatas.size(); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_font_size); float btnFontPx = DisplayUtils.pxFromDp(getActivity(), dp); for (int i = 0; i < shortcutNum; i++) { /** * right shortcut panel */ ShortcutData data = shortcutDatas.get(i); FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_item, mShorcutGridLayout, false);//new Button(getActivity()); mShorcutGridLayout.addView(btnLayout); if (data.getPushType() != null && data.getPushType().length > 0) { data.setLauncherButton(btnLayout); mPushNotifiableShorcuts.add(data); } btnLayout.setBackgroundResource(data.getIconBackResId()); TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label); label.setText(data.getName()); label.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnFontPx); label.setTextColor(getResources().getColor(R.color.white)); label.setTypeface(null, Typeface.BOLD); label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image); icon.setImageResource(data.getIconResId()); btnLayout.setTag(data); btnLayout.setOnClickListener(this); } setContentViewByOrientation(); return v; }