List of usage examples for android.widget LinearLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
public DrawerForm(Context context, Context unstyledContext, Callback callback, WatcherService.Client watcherServiceClient) { this.context = context; this.unstyledContext = unstyledContext; this.callback = callback; this.watcherServiceClient = watcherServiceClient; float density = ResourceUtils.obtainDensity(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT, SortableListView.LayoutParams.WRAP_CONTENT)); LinearLayout editTextContainer = new LinearLayout(context); editTextContainer.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView(editTextContainer); searchEdit = new SafePasteEditText(context); searchEdit.setOnKeyListener((v, keyCode, event) -> { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { v.clearFocus();/*from www . j ava 2 s .c om*/ } return false; }); searchEdit.setHint(context.getString(R.string.text_code_number_address)); searchEdit.setOnEditorActionListener(this); searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI); ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle); searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0)); searchIcon.setScaleType(ImageView.ScaleType.CENTER); searchIcon.setOnClickListener(this); editTextContainer.addView(searchEdit, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density)); if (C.API_LOLLIPOP) { editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0); } else { editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density)); } LinearLayout selectorContainer = new LinearLayout(context); selectorContainer.setBackgroundResource( ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0)); selectorContainer.setOrientation(LinearLayout.HORIZONTAL); selectorContainer.setGravity(Gravity.CENTER_VERTICAL); selectorContainer.setOnClickListener(v -> { hideKeyboard(); setChanSelectMode(!chanSelectMode); }); linearLayout.addView(selectorContainer); selectorContainer.setMinimumHeight((int) (40f * density)); if (C.API_LOLLIPOP) { selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0); ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density); } else { selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0); } chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem); chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f); if (C.API_LOLLIPOP) { chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM); } else { chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() }); } selectorContainer.addView(chanNameView, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); chanSelectorIcon = new ImageView(context); chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0)); selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density)); ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL | Gravity.END; headerView = linearLayout; inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null)); int color = ResourceUtils.getColor(context, R.attr.drawerIconColor); ChanManager manager = ChanManager.getInstance(); Collection<String> availableChans = manager.getAvailableChanNames(); for (String chanName : availableChans) { ChanConfiguration configuration = ChanConfiguration.get(chanName); if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) { watcherSupportSet.add(chanName); } Drawable drawable = manager.getIcon(chanName, color); chanIcons.put(chanName, drawable); chans.add( new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable)); } if (availableChans.size() == 1) { selectorContainer.setVisibility(View.GONE); } }
From source file:com.forrestguice.suntimeswidget.SuntimesActivity.java
/** * initialize the clock ui/* www . j av a2 s.co m*/ * @param context a context used to access resources */ private void initClockViews(Context context) { LinearLayout clockLayout = (LinearLayout) findViewById(R.id.layout_clock); if (clockLayout != null) { clockLayout.setOnClickListener(onClockClick); } txt_time = (TextView) findViewById(R.id.text_time); txt_time_suffix = (TextView) findViewById(R.id.text_time_suffix); txt_timezone = (TextView) findViewById(R.id.text_timezone); }
From source file:edu.berkeley.boinc.attach.SelectionListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView;/*from w ww. j ava2 s . co m*/ LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ProjectListEntry listItem = entries.get(position); v = vi.inflate(R.layout.attach_project_list_layout_listitem, null); TextView name = (TextView) v.findViewById(R.id.name); TextView description = (TextView) v.findViewById(R.id.description); TextView summary = (TextView) v.findViewById(R.id.summary); CheckBox cb = (CheckBox) v.findViewById(R.id.cb); LinearLayout textWrapper = (LinearLayout) v.findViewById(R.id.text_wrapper); if (listItem.am) { // element is account manager name.setText(activity.getString(R.string.attachproject_acctmgr_header)); description.setText(activity.getString(R.string.attachproject_acctmgr_list_desc)); cb.setVisibility(View.GONE); summary.setVisibility(View.GONE); ImageView button = (ImageView) v.findViewById(R.id.am_button_image); button.setVisibility(View.VISIBLE); OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "SelectionListAdapter: account manager clicked."); AcctMgrFragment dialog = new AcctMgrFragment(); dialog.setReturnToMainActivity(); // configure, so dialog returns to main activity when finished dialog.show(activity.getSupportFragmentManager(), activity.getString(R.string.attachproject_acctmgr_header)); } }; v.setOnClickListener(listener); name.setOnClickListener(listener); description.setOnClickListener(listener); button.setOnClickListener(listener); } else { // element is project option name.setText(listItem.info.name); description.setText(listItem.info.generalArea); summary.setText(listItem.info.summary); cb.setChecked(listItem.checked); cb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { listItem.checked = !listItem.checked; } }); textWrapper.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "SelectionListAdapter: onProjectClick open info for: " + listItem.info.name); ProjectInfoFragment dialog = ProjectInfoFragment.newInstance(listItem.info); dialog.show(activity.getSupportFragmentManager(), "ProjectInfoFragment"); } }); } return v; }
From source file:com.ichi2.anki.CardEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(AnkiDroidApp.TAG, "CardEditor: onCreate"); Themes.applyTheme(this); super.onCreate(savedInstanceState); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); Intent intent = getIntent();/* w w w . ja v a2 s .co m*/ if (savedInstanceState != null) { mCaller = savedInstanceState.getInt("caller"); mAddNote = savedInstanceState.getBoolean("addFact"); } else { mCaller = intent.getIntExtra(EXTRA_CALLER, CALLER_NOCALLER); if (mCaller == CALLER_NOCALLER) { String action = intent.getAction(); if (action != null && (ACTION_CREATE_FLASHCARD.equals(action) || ACTION_CREATE_FLASHCARD_SEND.equals(action))) { mCaller = CALLER_INDICLASH; } } } Log.i(AnkiDroidApp.TAG, "CardEditor: caller: " + mCaller); SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); if (mCaller == CALLER_INDICLASH && preferences.getBoolean("intentAdditionInstantAdd", false)) { // save information without showing card editor fetchIntentInformation(intent); MetaDB.saveIntentInformation(CardEditor.this, Utils.joinFields(mSourceText)); Themes.showThemedToast(CardEditor.this, getResources().getString(R.string.app_name) + ": " + getResources().getString(R.string.CardEditorLaterMessage), false); finish(); return; } mCol = AnkiDroidApp.getCol(); if (mCol == null) { reloadCollection(savedInstanceState); return; } registerExternalStorageListener(); View mainView = getLayoutInflater().inflate(R.layout.card_editor, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setContentStyle(mainView, Themes.CALLER_CARD_EDITOR); mFieldsLayoutContainer = (LinearLayout) findViewById(R.id.CardEditorEditFieldsLayout); mSave = (Button) findViewById(R.id.CardEditorSaveButton); mCancel = (Button) findViewById(R.id.CardEditorCancelButton); mLater = (Button) findViewById(R.id.CardEditorLaterButton); mDeckButton = (TextView) findViewById(R.id.CardEditorDeckText); mModelButton = (TextView) findViewById(R.id.CardEditorModelText); mTagsButton = (TextView) findViewById(R.id.CardEditorTagText); mSwapButton = (Button) findViewById(R.id.CardEditorSwapButton); mSwapButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { swapText(false); } }); mAedictIntent = false; switch (mCaller) { case CALLER_NOCALLER: Log.i(AnkiDroidApp.TAG, "CardEditor: no caller could be identified, closing"); finish(); return; case CALLER_REVIEWER: mCurrentEditedCard = Reviewer.getEditorCard(); if (mCurrentEditedCard == null) { finish(); return; } mEditorNote = mCurrentEditedCard.note(); mAddNote = false; break; case CALLER_STUDYOPTIONS: case CALLER_DECKPICKER: mAddNote = true; break; case CALLER_BIGWIDGET_EDIT: // Card widgetCard = AnkiDroidWidgetBig.getCard(); // if (widgetCard == null) { // finish(); // return; // } // mEditorNote = widgetCard.getFact(); // mAddNote = false; break; case CALLER_BIGWIDGET_ADD: mAddNote = true; break; case CALLER_CARDBROWSER_EDIT: mCurrentEditedCard = CardBrowser.sCardBrowserCard; if (mCurrentEditedCard == null) { finish(); return; } mEditorNote = mCurrentEditedCard.note(); mAddNote = false; break; case CALLER_CARDBROWSER_ADD: mAddNote = true; break; case CALLER_CARDEDITOR: mAddNote = true; break; case CALLER_CARDEDITOR_INTENT_ADD: mAddNote = true; break; case CALLER_INDICLASH: fetchIntentInformation(intent); if (mSourceText == null) { finish(); return; } if (mSourceText[0].equals("Aedict Notepad") && addFromAedict(mSourceText[1])) { finish(); return; } mAddNote = true; break; } setNote(mEditorNote); if (mAddNote) { setTitle(R.string.cardeditor_title_add_note); // set information transferred by intent String contents = null; if (mSourceText != null) { if (mAedictIntent && (mEditFields.size() == 3) && mSourceText[1].contains("[")) { contents = mSourceText[1].replaceFirst("\\[", "\u001f"); contents = contents.substring(0, contents.length() - 1); } else { mEditFields.get(0).setText(mSourceText[0]); mEditFields.get(1).setText(mSourceText[1]); } } else { contents = intent.getStringExtra(EXTRA_CONTENTS); } if (contents != null) { setEditFieldTexts(contents); } LinearLayout modelButton = ((LinearLayout) findViewById(R.id.CardEditorModelButton)); modelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(DIALOG_MODEL_SELECT); } }); modelButton.setVisibility(View.VISIBLE); mSave.setText(getResources().getString(R.string.add)); mCancel.setText(getResources().getString(R.string.close)); mLater.setVisibility(View.VISIBLE); mLater.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String content = getFieldsText(); if (content.length() > mEditFields.size() - 1) { MetaDB.saveIntentInformation(CardEditor.this, content); populateEditFields(); mSourceText = null; Themes.showThemedToast(CardEditor.this, getResources().getString(R.string.CardEditorLaterMessage), false); } if (mCaller == CALLER_INDICLASH || mCaller == CALLER_CARDEDITOR_INTENT_ADD) { closeCardEditor(); } } }); } else { setTitle(R.string.cardeditor_title_edit_card); mSwapButton.setVisibility(View.GONE); mSwapButton = (Button) findViewById(R.id.CardEditorLaterButton); mSwapButton.setVisibility(View.VISIBLE); mSwapButton.setText(getResources().getString(R.string.fact_adder_swap)); mSwapButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { swapText(false); } }); } ((LinearLayout) findViewById(R.id.CardEditorDeckButton)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(DIALOG_DECK_SELECT); } }); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); // if Arabic reshaping is enabled, disable the Save button to avoid // saving the reshaped string to the deck if (mPrefFixArabic && !mAddNote) { mSave.setEnabled(false); } ((LinearLayout) findViewById(R.id.CardEditorTagButton)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialog(DIALOG_TAGS_SELECT); } }); mSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (duplicateCheck(true)) { return; } boolean modified = false; for (FieldEditText f : mEditFields) { modified = modified | f.updateField(); } if (mAddNote) { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_ADD_FACT, mSaveFactHandler, new DeckTask.TaskData(mEditorNote)); } else { // added tag? for (String t : mCurrentTags) { modified = modified || !mEditorNote.hasTag(t); } // removed tag? modified = modified || mEditorNote.getTags().size() > mCurrentTags.size(); // changed did? boolean changedDid = mCurrentEditedCard.getDid() != mCurrentDid; modified = modified || changedDid; if (modified) { mEditorNote.setTags(mCurrentTags); // set did for card if (changedDid) { mCurrentEditedCard.setDid(mCurrentDid); } mChanged = true; } closeCardEditor(); // if (mCaller == CALLER_BIGWIDGET_EDIT) { // // DeckTask.launchDeckTask(DeckTask.TASK_TYPE_UPDATE_FACT, // // mSaveFactHandler, new // // DeckTask.TaskData(Reviewer.UPDATE_CARD_SHOW_QUESTION, // // mDeck, AnkiDroidWidgetBig.getCard())); // } else if (!mCardReset) { // // Only send result to save if something was actually // // changed // if (mModified) { // setResult(RESULT_OK); // } else { // setResult(RESULT_CANCELED); // } // closeCardEditor(); // } } } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { closeCardEditor(); } }); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
private void viewAttechmentPopup(View v) { PopupWindow attechmentOptionsPopup = null; View menu_layout = getLayoutInflater().inflate(R.layout.attechmentlayout, null); menu_layout.setVisibility(View.VISIBLE); LinearLayout linLayGallery = (LinearLayout) menu_layout.findViewById(R.id.linLayGallery); LinearLayout linLayPhoto = (LinearLayout) menu_layout.findViewById(R.id.linLayPhoto); LinearLayout linLayVideo = (LinearLayout) menu_layout.findViewById(R.id.linLayVideo); LinearLayout linLayAudio = (LinearLayout) menu_layout.findViewById(R.id.linLayAudio); LinearLayout linLayLocation = (LinearLayout) menu_layout.findViewById(R.id.linLayLocation); LinearLayout linLayContact = (LinearLayout) menu_layout.findViewById(R.id.linLayContact); linLayGallery.setOnClickListener(new View.OnClickListener() { @Override/* w w w .j a v a2 s. c o m*/ public void onClick(View arg0) { // TODO Auto-generated method stub // Toast.makeText(MessageActivity.this,"coming soon",Toast.LENGTH_SHORT).show(); selectWindow.dismiss(); cameraImage(); } }); linLayPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); showFileChooser(); } }); linLayVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); showVideoFileChooser(); } }); linLayAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); showAudioFileChooser(); } }); linLayLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); sendLocationMessage(); } }); linLayContact.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); onBrowseForNumbersButtonClicked(); } }); attechmentOptionsPopup = new PopupWindow(menu_layout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); selectWindow = attechmentOptionsPopup; commonPopupWindowDisplay(attechmentOptionsPopup, v, 0, 15); }
From source file:com.common.widget.pageindicator.C_TabPageIndicator.java
@SuppressLint("NewApi") // private void addTab(int index, CharSequence text, int iconResId) { // final TabView tabView = new TabView(getContext()); // tabView.mIndex = index; // tabView.setFocusable(true); // tabView.setOnClickListener(mTabClickListener); // tabView.setText(text); // if (iconResId != 0) { // // tabView.setCompoundDrawablePadding( // // (int) getResources().getDimension(R.dimen.margin1)); // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0); // // setTabIcon(tabView, iconResId); // }//from w w w .j av a 2s .c o m // if (deviceWeight) { // mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, // MATCH_PARENT, 1)); // } else { // LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( // WRAP_CONTENT, MATCH_PARENT); // lp.leftMargin = 10; // lp.rightMargin = 10; // mTabLayout.addView(tabView, lp); // } // } private void addTab(int index, CharSequence text, int iconResId) { if (deviceWeight) { // tab ? Layout LinearLayout layout = new LinearLayout(getContext()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT, 1); //???GG layout.setBackgroundColor(C_ResUtil.getSrcColor(R.color.full_transparent)); layout.setGravity(Gravity.CENTER); // TextView final TabView tabView = new TabView(getContext()); tabView.mIndex = index; // ?layoutLayout??? tabView.setFocusable(false); tabView.setClickable(false); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (iconResId != 0) { // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, // 0, 0); // tabView.setPaddingRelative(10, 10, 10, 10); // tabView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, // iconResId, 0); tabView.setBackgroundResource(iconResId); } tabView.setPadding(C_ResUtil.getDimens(R.dimen._10dp), 0, C_ResUtil.getDimens(R.dimen._10dp), 0); LinearLayout.LayoutParams tvlp = new LinearLayout.LayoutParams(WRAP_CONTENT, C_ResUtil.getDimens(R.dimen._22dp)); tvlp.rightMargin = C_ResUtil.getDimens(R.dimen._2dp); tvlp.leftMargin = C_ResUtil.getDimens(R.dimen._2dp); layout.addView(tabView, tvlp); layout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tabView.performClick(); } }); // TextView mTabLayout.addView(layout, lp); } else { final TabView tabView = new TabView(getContext()); tabView.mIndex = index; tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (iconResId != 0) { // tabView.setCompoundDrawablePadding( // (int) getResources().getDimension(R.dimen.margin1)); // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, // 0, 0); tabView.setPaddingRelative(10, 10, 10, 10); tabView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, iconResId, 0); // setTabIcon(tabView, iconResId); } tabView.setPadding(C_ResUtil.getDimens(R.dimen._10dp), 0, C_ResUtil.getDimens(R.dimen._10dp), 0); // if (deviceWeight) { // mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, // MATCH_PARENT, 1)); // } else { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WRAP_CONTENT, C_ResUtil.getDimens(R.dimen._22dp)); lp.leftMargin = C_ResUtil.getDimens(R.dimen._2dp); lp.rightMargin = C_ResUtil.getDimens(R.dimen._2dp); // mTabLayout.addView(tabView, lp); // } } }
From source file:com.xbh.tmi.ui.SettingsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from w w w .j a va2 s .com mSettingFramnet = (ImageView) getView().findViewById(R.id.setting_frament_back_iv); mSettingFramnet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ViewUtil.backToOtherActivity(getActivity()); } }); rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification); rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound); rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate); rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker); rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave); rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView() .findViewById(R.id.rl_switch_delete_msg_when_exit_group); rl_switch_auto_accept_group_invitation = (RelativeLayout) getView() .findViewById(R.id.rl_switch_auto_accept_group_invitation); rl_switch_adaptive_video_encode = (RelativeLayout) getView() .findViewById(R.id.rl_switch_adaptive_video_encode); notifiSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification); soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound); vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate); speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker); ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave); switch_delete_msg_when_exit_group = (EaseSwitchButton) getView() .findViewById(R.id.switch_delete_msg_when_exit_group); switch_auto_accept_group_invitation = (EaseSwitchButton) getView() .findViewById(R.id.switch_auto_accept_group_invitation); switch_adaptive_video_encode = (EaseSwitchButton) getView().findViewById(R.id.switch_adaptive_video_encode); LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change); logoutBtn = (Button) getView().findViewById(R.id.btn_logout); if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) { logoutBtn.setText(getString(R.string.button_logout)); } textview1 = (TextView) getView().findViewById(R.id.textview1); textview2 = (TextView) getView().findViewById(R.id.textview2); blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list); userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile); llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose); pushNick = (LinearLayout) getView().findViewById(R.id.ll_set_push_nick); settingsModel = DemoHelper.getInstance().getModel(); chatOptions = EMClient.getInstance().getOptions(); blacklistContainer.setOnClickListener(this); userProfileContainer.setOnClickListener(this); rl_switch_notification.setOnClickListener(this); rl_switch_sound.setOnClickListener(this); rl_switch_vibrate.setOnClickListener(this); rl_switch_speaker.setOnClickListener(this); logoutBtn.setOnClickListener(this); llDiagnose.setOnClickListener(this); pushNick.setOnClickListener(this); rl_switch_chatroom_leave.setOnClickListener(this); rl_switch_delete_msg_when_exit_group.setOnClickListener(this); rl_switch_auto_accept_group_invitation.setOnClickListener(this); rl_switch_adaptive_video_encode.setOnClickListener(this); llChange.setOnClickListener(this); // the vibrate and sound notification are allowed or not? if (settingsModel.getSettingMsgNotification()) { notifiSwitch.openSwitch(); } else { notifiSwitch.closeSwitch(); } // sound notification is switched on or not? if (settingsModel.getSettingMsgSound()) { soundSwitch.openSwitch(); } else { soundSwitch.closeSwitch(); } // vibrate notification is switched on or not? if (settingsModel.getSettingMsgVibrate()) { vibrateSwitch.openSwitch(); } else { vibrateSwitch.closeSwitch(); } // the speaker is switched on or not? Log.e("Lking", "bofang = " + settingsModel.getSettingMsgSpeaker()); if (settingsModel.getSettingMsgSpeaker()) { speakerSwitch.openSwitch(); } else { speakerSwitch.closeSwitch(); } // if allow owner leave if (settingsModel.isChatroomOwnerLeaveAllowed()) { ownerLeaveSwitch.openSwitch(); } else { ownerLeaveSwitch.closeSwitch(); } // delete messages when exit group? if (settingsModel.isDeleteMessagesAsExitGroup()) { switch_delete_msg_when_exit_group.openSwitch(); } else { switch_delete_msg_when_exit_group.closeSwitch(); } if (settingsModel.isAutoAcceptGroupInvitation()) { switch_auto_accept_group_invitation.openSwitch(); } else { switch_auto_accept_group_invitation.closeSwitch(); } if (settingsModel.isAdaptiveVideoEncode()) { switch_adaptive_video_encode.openSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true); } else { switch_adaptive_video_encode.closeSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false); } }
From source file:cn.xcom.helper.chat.ui.SettingsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;// w ww. ja va 2s . c o m rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification); rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound); rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate); rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker); rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave); rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView() .findViewById(R.id.rl_switch_delete_msg_when_exit_group); rl_switch_auto_accept_group_invitation = (RelativeLayout) getView() .findViewById(R.id.rl_switch_auto_accept_group_invitation); rl_switch_adaptive_video_encode = (RelativeLayout) getView() .findViewById(R.id.rl_switch_adaptive_video_encode); notifiSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification); soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound); vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate); speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker); ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave); switch_delete_msg_when_exit_group = (EaseSwitchButton) getView() .findViewById(R.id.switch_delete_msg_when_exit_group); switch_auto_accept_group_invitation = (EaseSwitchButton) getView() .findViewById(R.id.switch_auto_accept_group_invitation); switch_adaptive_video_encode = (EaseSwitchButton) getView().findViewById(R.id.switch_adaptive_video_encode); LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change); logoutBtn = (Button) getView().findViewById(R.id.btn_logout); if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) { logoutBtn.setText( getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")"); } textview1 = (TextView) getView().findViewById(R.id.textview1); textview2 = (TextView) getView().findViewById(R.id.textview2); blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list); userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile); llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose); pushNick = (LinearLayout) getView().findViewById(R.id.ll_set_push_nick); settingsModel = DemoHelper.getInstance().getModel(); chatOptions = EMClient.getInstance().getOptions(); blacklistContainer.setOnClickListener(this); userProfileContainer.setOnClickListener(this); rl_switch_notification.setOnClickListener(this); rl_switch_sound.setOnClickListener(this); rl_switch_vibrate.setOnClickListener(this); rl_switch_speaker.setOnClickListener(this); logoutBtn.setOnClickListener(this); llDiagnose.setOnClickListener(this); pushNick.setOnClickListener(this); rl_switch_chatroom_leave.setOnClickListener(this); rl_switch_delete_msg_when_exit_group.setOnClickListener(this); rl_switch_auto_accept_group_invitation.setOnClickListener(this); rl_switch_adaptive_video_encode.setOnClickListener(this); llChange.setOnClickListener(this); // the vibrate and sound notification are allowed or not? if (settingsModel.getSettingMsgNotification()) { notifiSwitch.openSwitch(); } else { notifiSwitch.closeSwitch(); } // sound notification is switched on or not? if (settingsModel.getSettingMsgSound()) { soundSwitch.openSwitch(); } else { soundSwitch.closeSwitch(); } // vibrate notification is switched on or not? if (settingsModel.getSettingMsgVibrate()) { vibrateSwitch.openSwitch(); } else { vibrateSwitch.closeSwitch(); } // the speaker is switched on or not? if (settingsModel.getSettingMsgSpeaker()) { speakerSwitch.openSwitch(); } else { speakerSwitch.closeSwitch(); } // if allow owner leave if (settingsModel.isChatroomOwnerLeaveAllowed()) { ownerLeaveSwitch.openSwitch(); } else { ownerLeaveSwitch.closeSwitch(); } // delete messages when exit group? if (settingsModel.isDeleteMessagesAsExitGroup()) { switch_delete_msg_when_exit_group.openSwitch(); } else { switch_delete_msg_when_exit_group.closeSwitch(); } if (settingsModel.isAutoAcceptGroupInvitation()) { switch_auto_accept_group_invitation.openSwitch(); } else { switch_auto_accept_group_invitation.closeSwitch(); } if (settingsModel.isAdaptiveVideoEncode()) { switch_adaptive_video_encode.openSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true); } else { switch_adaptive_video_encode.closeSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false); } }
From source file:org.computeforcancer.android.attach.SelectionListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView;/*from w w w .jav a 2 s .c o m*/ LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ProjectListEntry listItem = entries.get(position); v = vi.inflate(R.layout.attach_project_list_layout_listitem, null); TextView name = (TextView) v.findViewById(R.id.name); TextView description = (TextView) v.findViewById(R.id.description); TextView summary = (TextView) v.findViewById(R.id.summary); CheckBox cb = (CheckBox) v.findViewById(R.id.cb); LinearLayout textWrapper = (LinearLayout) v.findViewById(R.id.text_wrapper); if (listItem.am) { // element is account manager name.setText(activity.getString(R.string.attachproject_acctmgr_header)); description.setText(activity.getString(R.string.attachproject_acctmgr_list_desc)); cb.setVisibility(View.GONE); summary.setVisibility(View.GONE); ImageView button = (ImageView) v.findViewById(R.id.am_button_image); button.setVisibility(View.VISIBLE); OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "SelectionListAdapter: account manager clicked."); AcctMgrFragment dialog = new AcctMgrFragment(); dialog.setReturnToMainActivity(); // configure, so dialog returns to main activity when finished dialog.show(activity.getSupportFragmentManager(), activity.getString(R.string.attachproject_acctmgr_header)); } }; v.setOnClickListener(listener); name.setOnClickListener(listener); description.setOnClickListener(listener); button.setOnClickListener(listener); } else { // element is project option name.setText(listItem.info.name); description.setText(listItem.info.generalArea); summary.setText(listItem.info.summary); if ("World Community Grid".equalsIgnoreCase(listItem.info.name)) { cb.setChecked(true); } else { cb.setChecked(listItem.checked); } cb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { listItem.checked = !listItem.checked; } }); textWrapper.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "SelectionListAdapter: onProjectClick open info for: " + listItem.info.name); ProjectInfoFragment dialog = ProjectInfoFragment.newInstance(listItem.info); dialog.show(activity.getSupportFragmentManager(), "ProjectInfoFragment"); } }); } return v; }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
private void buttonSetup() { // button setup Button execute_button;//from w ww . j a va2s . c o m execute_button = (Button) subview.findViewById(R.id.btnRunTest); execute_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(SamKnowsAggregateStatViewerActivity.this, SamKnowsTestViewerActivity.class); startActivityForResult(intent, 1); overridePendingTransition(R.anim.transition_in, R.anim.transition_out); } }); Button run_now_choice_button; run_now_choice_button = (Button) findViewById(R.id.btnRunTestChoice); run_now_choice_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RunChoice(); } }); Button timeperiod_button; timeperiod_button = (Button) findViewById(R.id.btn_timeperiod); timeperiod_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SingleChoice(); } }); LinearLayout timeperiod_button2; timeperiod_button2 = (LinearLayout) findViewById(R.id.timeperiod_header); timeperiod_button2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SingleChoice(); } }); // page turn navigation button ImageView page_right = (ImageView) findViewById(R.id.page_turn_right_agg); page_right.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setCurrentItem(1, true); } }); // grid navigation buttons Button download_grid_right_button; download_grid_right_button = (Button) subview.findViewById(R.id.btn_download_grid_right); download_grid_right_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (download_page_index < total_download_archive_records - ITEMS_PER_PAGE) { download_page_index = download_page_index + ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test1_grid); loadDownloadGrid(TestResult.DOWNLOAD_TEST_ID, R.id.agggregate_test1_grid, download_page_index, ITEMS_PER_PAGE); } }); Button download_grid_left_button; download_grid_left_button = (Button) subview.findViewById(R.id.btn_download_grid_left); download_grid_left_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (download_page_index > 0) { download_page_index = download_page_index - ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test1_grid); loadDownloadGrid(TestResult.DOWNLOAD_TEST_ID, R.id.agggregate_test1_grid, download_page_index, ITEMS_PER_PAGE); } }); Button upload_grid_right_button; upload_grid_right_button = (Button) subview.findViewById(R.id.btn_upload_grid_right); upload_grid_right_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (upload_page_index < total_upload_archive_records - ITEMS_PER_PAGE) { upload_page_index = upload_page_index + ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test2_grid); loadDownloadGrid(TestResult.UPLOAD_TEST_ID, R.id.agggregate_test2_grid, upload_page_index, ITEMS_PER_PAGE); } }); Button upload_grid_left_button; upload_grid_left_button = (Button) subview.findViewById(R.id.btn_upload_grid_left); upload_grid_left_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (upload_page_index > 0) { upload_page_index = upload_page_index - ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test2_grid); loadDownloadGrid(TestResult.UPLOAD_TEST_ID, R.id.agggregate_test2_grid, upload_page_index, ITEMS_PER_PAGE); } }); Button latency_grid_right_button; latency_grid_right_button = (Button) subview.findViewById(R.id.btn_latency_grid_right); latency_grid_right_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (latency_page_index < total_latency_archive_records - ITEMS_PER_PAGE) { latency_page_index = latency_page_index + ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test3_grid); loadDownloadGrid(TestResult.LATENCY_TEST_ID, R.id.agggregate_test3_grid, latency_page_index, ITEMS_PER_PAGE); } }); Button latency_grid_left_button; latency_grid_left_button = (Button) subview.findViewById(R.id.btn_latency_grid_left); latency_grid_left_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (latency_page_index > 0) { latency_page_index = latency_page_index - ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test3_grid); loadDownloadGrid(TestResult.LATENCY_TEST_ID, R.id.agggregate_test3_grid, latency_page_index, ITEMS_PER_PAGE); } }); Button packetloss_grid_right_button; packetloss_grid_right_button = (Button) subview.findViewById(R.id.btn_packetloss_grid_right); packetloss_grid_right_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (packetloss_page_index < total_packetloss_archive_records - ITEMS_PER_PAGE) { packetloss_page_index = packetloss_page_index + ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test4_grid); loadDownloadGrid(TestResult.PACKETLOSS_TEST_ID, R.id.agggregate_test4_grid, packetloss_page_index, ITEMS_PER_PAGE); } }); Button packetloss_grid_left_button; packetloss_grid_left_button = (Button) subview.findViewById(R.id.btn_packetloss_grid_left); packetloss_grid_left_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (packetloss_page_index > 0) { packetloss_page_index = packetloss_page_index - ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test4_grid); loadDownloadGrid(TestResult.PACKETLOSS_TEST_ID, R.id.agggregate_test4_grid, packetloss_page_index, ITEMS_PER_PAGE); } }); Button jitter_grid_right_button; jitter_grid_right_button = (Button) subview.findViewById(R.id.btn_jitter_grid_right); jitter_grid_right_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (jitter_page_index < total_jitter_archive_records - ITEMS_PER_PAGE) { jitter_page_index = jitter_page_index + ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test5_grid); loadDownloadGrid(TestResult.JITTER_TEST_ID, R.id.agggregate_test5_grid, jitter_page_index, ITEMS_PER_PAGE); } }); Button jitter_grid_left_button; jitter_grid_left_button = (Button) subview.findViewById(R.id.btn_jitter_grid_left); jitter_grid_left_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (jitter_page_index > 0) { jitter_page_index = jitter_page_index - ITEMS_PER_PAGE; } clearGrid(R.id.agggregate_test5_grid); loadDownloadGrid(TestResult.JITTER_TEST_ID, R.id.agggregate_test5_grid, jitter_page_index, ITEMS_PER_PAGE); } }); // toggle buttons TableLayout button; button = (TableLayout) findViewById(R.id.download_header); ImageView button_iv = (ImageView) findViewById(R.id.btn_download_toggle); button.setOnClickListener(this); button_iv.setOnClickListener(this); TableLayout button2; button2 = (TableLayout) subview.findViewById(R.id.upload_header); ImageView button2_iv = (ImageView) findViewById(R.id.btn_upload_toggle); button2.setOnClickListener(this); button2_iv.setOnClickListener(this); TableLayout button3; button3 = (TableLayout) subview.findViewById(R.id.latency_header); ImageView button3_iv = (ImageView) findViewById(R.id.btn_latency_toggle); button3.setOnClickListener(this); button3_iv.setOnClickListener(this); TableLayout button4; button4 = (TableLayout) subview.findViewById(R.id.packetloss_header); ImageView button4_iv = (ImageView) findViewById(R.id.btn_packetloss_toggle); button4.setOnClickListener(this); button4_iv.setOnClickListener(this); TableLayout button5; button5 = (TableLayout) subview.findViewById(R.id.jitter_header); ImageView button5_iv = (ImageView) findViewById(R.id.btn_jitter_toggle); button5.setOnClickListener(this); button5_iv.setOnClickListener(this); }