private MonthView addMonth(int index, CalendarDays days, int height, boolean first) { layout = new RelativeLayout(getContext()); layout.setLayoutParams( new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); layout.setClickable(true); layout.setOnClickListener(clickListener); mv[index] = new MonthView(getContext()); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); mv[index].setMonthIndex(index); mv[index].setLayoutParams(lp); mv[index].setDays(days, height); mv[index].setFocusable(false); mv[index].setOnDayClickListener(this); layout.addView(mv[index]); if (first) { addView(layout, 0); } else { addView(layout); } return mv[index]; }
/** init drop down style, only init once */ private void initDropDownStyle() { if (headerLayout != null) { if (isDropDownStyle) { addHeaderView(headerLayout); } else { removeHeaderView(headerLayout); } return; } if (!isDropDownStyle) { return; } headerReleaseMinDistance = context .getResources() .getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance); flipAnimation = new RotateAnimation( 0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); flipAnimation.setInterpolator(new LinearInterpolator()); flipAnimation.setDuration(250); flipAnimation.setFillAfter(true); reverseFlipAnimation = new RotateAnimation( -180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); reverseFlipAnimation.setInterpolator(new LinearInterpolator()); reverseFlipAnimation.setDuration(250); reverseFlipAnimation.setFillAfter(true); headerDefaultText = context.getString(R.string.drop_down_list_header_default_text); headerPullText = context.getString(R.string.drop_down_list_header_pull_text); headerReleaseText = context.getString(R.string.drop_down_list_header_release_text); headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false); headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text); headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image); headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar); headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text); headerLayout.setClickable(true); headerLayout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { onDropDown(); } }); headerText.setText(headerDefaultText); addHeaderView(headerLayout); measureHeaderLayout(headerLayout); headerOriginalHeight = headerLayout.getMeasuredHeight(); headerOriginalTopPadding = headerLayout.getPaddingTop(); currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.about_fragment, container, false); RelativeLayout parent = (RelativeLayout) rootView.findViewById(R.id.abt_parent); parent.setClickable(true); Utils.setUpActionBar(getActivity(), getResources().getString(R.string.title_about)); return rootView; }
@SuppressWarnings("unchecked") private void FillGroupList() { LinearLayout groupLayout = (LinearLayout) findViewById(R.id.LinkViewGroupsLayout); RelativeLayout entry; Iterator<String> i = m_group_links.keys(); while (i.hasNext()) { entry = (RelativeLayout) View.inflate(this, R.layout.pools_list_item, null); ((TextView) entry.findViewById(R.id.PoolTitle)).setText(i.next()); ((TextView) entry.findViewById(R.id.PoolNPhotos)).setText(""); entry.setClickable(true); entry.setOnClickListener(this); groupLayout.addView(entry); } }
@Override public void populateView(Displayable displayable) { HeaderRow row = (HeaderRow) displayable; title.setText(row.getLabel()); if (row.isHasMore()) { more.setVisibility(View.VISIBLE); if (storeName == null || TextUtils.isEmpty(storeName)) { if (storeId == 0) { more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme)); moreLayout.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme)); } else { more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme, storeId)); moreLayout.setOnClickListener( new BaseAdapter.IHasMoreOnClickListener(row, theme, storeId)); } } else { if (storeId == 0) { more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName)); moreLayout.setOnClickListener( new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName)); } else { more.setOnClickListener( new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName, storeId)); moreLayout.setOnClickListener( new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName, storeId)); } } } else { more.setVisibility(View.GONE); moreLayout.setClickable(false); moreLayout.setFocusable(false); } if (theme != null) { @ColorInt int color = itemView.getContext().getResources().getColor(theme.getStoreHeader()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { more.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN); } else { // put this in Utils when you need to tint a Button background Drawable wrapDrawable = DrawableCompat.wrap(more.getBackground()); DrawableCompat.setTint( wrapDrawable, itemView.getContext().getResources().getColor(theme.getStoreHeader())); more.setBackgroundDrawable(DrawableCompat.unwrap(wrapDrawable)); } } }
/** 布局加载完成回调 做一些初始化的操作 */ @Override protected void onFinishInflate() { super.onFinishInflate(); if (isShowShadow) { iv_shadow = new ImageView(context); iv_shadow.setImageResource(R.mipmap.shadow); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); addView(iv_shadow, 1, lp); } // 左侧界面 vg_left = (RelativeLayout) getChildAt(0); // 右侧(主)界面 vg_main = (CustomRelativeLayout) getChildAt(isShowShadow ? 2 : 1); vg_main.setDragLayout(this); vg_left.setClickable(true); vg_main.setClickable(true); }
public void enableGlobalExit() { rootView.setClickable(true); rootView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { resetToggles_1 = true; resetToggles_2 = true; springLevel1[0].setEndValue(CLOSED); if (global_latest_springLevel2_enabled != null) { global_latest_springLevel2_enabled.setEndValue(CLOSED); } if (global_latest_springLevel2_disabled != null) { global_latest_springLevel2_disabled.setEndValue(CLOSED); } boundOnLeaveListener.onLeave(); } }); }
public void disableGlobalExit() { rootView.setClickable(false); rootView.setOnClickListener(null); }
private void Initialization(View viewToLoad) { try { TypeFaceClass typeface = new TypeFaceClass(mContext); DashBoardTitle = (TextView) viewToLoad.findViewById(R.id.DashBoardTitle); logolayout = (LinearLayout) viewToLoad.findViewById(R.id.logolayout); refresh = (ImageView) viewToLoad.findViewById(R.id.refresh); businesslistview = (ImageView) viewToLoad.findViewById(R.id.businesslistview); loginname = (TextView) findViewById(R.id.loginname); loginname.setTypeface(typeface.RobotoCondensed()); loginname.setText("Hi " + AppConfigManager.getContactname(mContext) + "!"); support = (TextView) findViewById(R.id.Support); support.setTypeface(typeface.RobotoCondensed()); dashboardlink = (TextView) findViewById(R.id.Dashboardlink); dashboardlink.setTypeface(typeface.RobotoCondensed()); dashboardlink.setEnabled(false); logout = (TextView) findViewById(R.id.Logout); logout.setTypeface(typeface.RobotoCondensed()); cpaedit = (TextView) findViewById(R.id.cpaedit); cpaedit.setTypeface(typeface.RobotoCondensed()); EmailAddressText = (TextView) findViewById(R.id.EmailAddressText); EmailAddressText.setText(AppConfigManager.getUserName(mContext)); EmailAddressText.setTypeface(typeface.RobotoCondensed()); listfilter = (EditText) findViewById(R.id.listfilter); businesslistlayout = (LinearLayout) findViewById(R.id.businesslistlayout); rootlayout = (FrameLayout) findViewById(R.id.rootlayout); menulayout = (RelativeLayout) findViewById(R.id.menulayout); menulayout.setClickable(true); myAccount_Layout = (LinearLayout) findViewById(R.id.myAccount_Layout); menu = (ImageView) viewToLoad.findViewById(R.id.menu); businesslist = (ListView) findViewById(R.id.businesslist); addnewbusinessdashboard = (Button) findViewById(R.id.addnewbusinessdashboard); } catch (Exception e) { e.printStackTrace(); new SendException(mContext, e); } }
public CameraLayout(final Activity activity, EvercamCamera camera, boolean showThumbnails) { super(activity.getApplicationContext()); this.context = activity.getApplicationContext(); try { evercamCamera = camera; this.setOrientation(LinearLayout.VERTICAL); this.setGravity(Gravity.START); this.setBackgroundColor(getResources().getColor(R.color.custom_light_gray)); cameraRelativeLayout = new RelativeLayout(context); RelativeLayout.LayoutParams ivParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); cameraRelativeLayout.setLayoutParams(ivParams); this.addView(cameraRelativeLayout); snapshotImageView = new ImageView(context); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); snapshotImageView.setLayoutParams(imageViewParams); snapshotImageView.setBackgroundColor(Color.TRANSPARENT); snapshotImageView.setScaleType(ImageView.ScaleType.FIT_XY); cameraRelativeLayout.addView(snapshotImageView); offlineImage = new ImageView(context); RelativeLayout.LayoutParams offlineImageParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); offlineImageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); offlineImageParams.addRule(RelativeLayout.CENTER_VERTICAL); offlineImage.setLayoutParams(offlineImageParams); cameraRelativeLayout.addView(offlineImage); offlineImage.setImageResource(R.drawable.cam_unavailable); offlineImage.setVisibility(View.INVISIBLE); gradientLayout = new GradientTitleLayout(activity); gradientLayout.setTitle(evercamCamera.getName()); cameraRelativeLayout.addView(gradientLayout); cameraRelativeLayout.setClickable(true); // Show thumbnail returned from Evercam if (showThumbnails) { showThumbnail(); } cameraRelativeLayout.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { VideoActivity.startPlayingVideoForCamera(activity, evercamCamera.getCameraId()); } }); } catch (OutOfMemoryError e) { Log.e(TAG, e.toString() + "-::OOM::-" + Log.getStackTraceString(e)); } }
/** 解析用户信息 */ private void getUserInfo() { relationship = user.getNew_relationship(); if ("myself".equals(relationship)) { rl_level_coin.setClickable(true); rl_add_friend.setVisibility(View.GONE); modify_user_info.setVisibility(View.VISIBLE); UserInfoUtils.setUserInfo(getApplicationContext(), Constants.LEVEL, user.level); UserInfoUtils.setUserInfo(getApplicationContext(), Constants.COINS, user.coins); UserInfoUtils.setUserInfo(getApplicationContext(), Constants.POINTS, user.points); } else if ("stranger".equals(relationship)) { rl_add_friend.setVisibility(View.VISIBLE); user_addfriend.setVisibility(View.VISIBLE); modify_user_info.setVisibility(View.GONE); Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tv_coin.setCompoundDrawables(drawable, null, null, null); rl_level_coin.setClickable(false); } else if ("pending".equals(relationship)) { rl_add_friend.setVisibility(View.VISIBLE); user_invalidation.setVisibility(View.VISIBLE); Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tv_coin.setCompoundDrawables(drawable, null, null, null); rl_level_coin.setClickable(false); } else if ("friend".equals(relationship)) { modify_user_info.setVisibility(View.VISIBLE); Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tv_coin.setCompoundDrawables(drawable, null, null, null); rl_level_coin.setClickable(false); // 1 代表小乐助手 则不显示好友和团队 if ("1".equals(userId)) { user_friend_group.setVisibility(View.GONE); modify_user_info.setVisibility(View.GONE); // 不是自己时修改右上角按钮的样式 } else if (!((String) UserInfoUtils.getUserInfo(getApplicationContext(), Constants.USERID, "")) .equals(userId)) { modify_user_info.setImageResource(R.drawable.icon_eventdetail_rankmore); modify_user_info.setVisibility(View.VISIBLE); } else { modify_user_info.setVisibility(View.VISIBLE); } } else if ("tbc".equals(relationship)) { // 别人请求添加我为好友 等待我确认 rl_add_friend.setVisibility(View.VISIBLE); accept_addfriend.setVisibility(View.VISIBLE); Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tv_coin.setCompoundDrawables(drawable, null, null, null); rl_level_coin.setClickable(false); } headImgUrl = user.getHeadimgurl(); nickname = user.getNickname(); sex = user.getSex() + ""; age = user.getAge() + ""; intro = user.getIntro(); sport = user.getSports(); eventCounts = user.getEvent_count(); friendCounts = user.getFriend_count(); groupCounts = user.getGroup_count(); calorie = user.getTotal_calorie(); duration = user.getTotal_duration(); setUserInfo(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bt_settings); syncContact = (LinearLayout) findViewById(R.id.sync_contact); // 蓝牙名称 btName = (EditText) findViewById(R.id.bt_name); btName.setText(Config.BT_NAME); btName.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub String name = btName.getText().toString(); if (name == null || name.length() == 0) { name = Config.BT_NAME; btName.setText(name); } if (!Config.BT_NAME.equals(name)) { Log.d("goc", "input finish " + Config.BT_NAME + " " + name); Config.BT_NAME = name; if (isBTConnected()) { sendBroadcast(new Intent(GocMessage.DISCONNECT_PHONE)); } sendBroadcast(new Intent(GocMessage.SET_BT_NAME)); } return false; } }); // 蓝牙密钥 btPinCode = (EditText) findViewById(R.id.bt_pin_code); btPinCode.setText(Config.BT_PIN_CODE); btPinCode.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub Log.d("goc", "input finish"); String pin = btPinCode.getText().toString(); if (pin == null || pin.length() == 0) { pin = Config.BT_PIN_CODE; btPinCode.setText(pin); } Config.BT_PIN_CODE = pin; sendBroadcast(new Intent(GocMessage.SET_BT_PIN_CODE)); return false; } }); // 蓝牙连接 btPair = (RelativeLayout) findViewById(R.id.bt_pair); btConnectOperate = (TextView) findViewById(R.id.bt_connect_operate); btConnectStatus = (TextView) findViewById(R.id.bt_connect_status); btConnectOperate.setText(isBTConnected() ? "断开连接" : "开始配对"); btConnectStatus.setText(Config.BT_PARI_NAME); // 蓝牙开关 switchButton = (SwitchButton) findViewById(R.id.switchBT); String btStatus = Settings.System.getString(getContentResolver(), "bt_enable"); if (BTFileOperater.getAccStatus()) { switchButton.setChecked(btStatus.equals("1")); switchButton.setEnabled(true); } else { switchButton.setEnabled(false); btName.setEnabled(false); btPinCode.setEnabled(false); btPair.setEnabled(false); btPair.setClickable(false); } switchButton.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub String status = isChecked ? "1" : "0"; Settings.System.putString(getContentResolver(), "bt_enable", status); if (!isChecked) { btPair.setClickable(false); syncContact.setClickable(false); Settings.System.putString(getContentResolver(), "bt_connect", "0"); startGocsdkService(OperateCommand.BT_UNFOUND_UNCONNECT); } else { btPair.setClickable(true); syncContact.setClickable(true); btConnectOperate.setText(isBTConnected() ? "断开连接" : "开始配对"); startGocsdkService(OperateCommand.BT_FOUND_CONNECT); } // BTFileOperater.writeBTFile(status); // startGocsdkService(isChecked ? OperateCommand.OPEN_BT : OperateCommand.CLOSE_BT); switchButton.setEnabled(false); new Handler() .postDelayed( new Runnable() { @Override public void run() { // TODO Auto-generated method stub switchButton.setEnabled(true); } }, 2000); } }); initGocReceiver(); }