Java Code Examples for android.widget.Spinner#setVisibility()

The following examples show how to use android.widget.Spinner#setVisibility() . 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: SpendingActivity.java    From accountBook with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化spinner
 */
private void initSpinner(){
    month_spinner = (Spinner) findViewById(R.id.month_spinner);
    //将可选内容与ArrayAdapter连接起来
    month_adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, monthList);
    //设置下拉列表的风格
    month_adapter
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //将adapter添加到spinner中
    month_spinner.setAdapter(month_adapter);
    //添加事件Spinner事件监听
    month_spinner
            .setOnItemSelectedListener(new month_spinnerSelectedListener());
    //设置默认值
    month_spinner.setSelection(pubFun.getTime("M"), true);
    month_spinner.setVisibility(View.VISIBLE);
}
 
Example 2
Source File: CountActivity.java    From accountBook with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化spinner
 */
private void initSpinner(){
    month_spinner = (Spinner) findViewById(R.id.month_spinner);
    //将可选内容与ArrayAdapter连接起来
    month_adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, monthList);
    //设置下拉列表的风格
    month_adapter
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //将adapter添加到spinner中
    month_spinner.setAdapter(month_adapter);
    //添加事件Spinner事件监听
    month_spinner
            .setOnItemSelectedListener(new month_spinnerSelectedListener());
    //设置默认值
    month_spinner.setSelection(pubFun.getTime("M"), true);
    month_spinner.setVisibility(View.VISIBLE);
}
 
Example 3
Source File: HistoryFragment.java    From mimi-reader with Apache License 2.0 6 votes vote down vote up
@Override
public void initMenu() {
    super.initMenu();

    MimiActivity activity = null;
    if (getActivity() instanceof MimiActivity) {
        activity = (MimiActivity) getActivity();
        toolbar = activity.getToolbar();
    }

    if (toolbar != null) {

        Spinner toolbarSpinner = toolbar.findViewById(R.id.board_spinner);
        if (toolbarSpinner != null) {
            toolbarSpinner.setVisibility(View.GONE);
        }

        activity.getSupportActionBar().setTitle(getTitle());
        activity.getSupportActionBar().setSubtitle(null);
    }
}
 
Example 4
Source File: OdooActivity.java    From hr with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Actionbar Spinner handler
 */

public void setHasActionBarSpinner(Boolean hasActionBarSpinner) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        Spinner spinner = (Spinner) findViewById(R.id.spinner_nav);
        if (hasActionBarSpinner) {
            if (spinner != null)
                spinner.setVisibility(View.VISIBLE);
            actionBar.setDisplayShowTitleEnabled(false);
        } else {
            if (spinner != null)
                spinner.setVisibility(View.GONE);
            actionBar.setDisplayShowTitleEnabled(true);
        }
        mHasActionBarSpinner = hasActionBarSpinner;
    }
}
 
Example 5
Source File: OdooActivity.java    From framework with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Actionbar Spinner handler
 */

public void setHasActionBarSpinner(Boolean hasActionBarSpinner) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        Spinner spinner = (Spinner) findViewById(R.id.spinner_nav);
        if (hasActionBarSpinner) {
            if (spinner != null)
                spinner.setVisibility(View.VISIBLE);
            actionBar.setDisplayShowTitleEnabled(false);
        } else {
            if (spinner != null)
                spinner.setVisibility(View.GONE);
            actionBar.setDisplayShowTitleEnabled(true);
        }
        mHasActionBarSpinner = hasActionBarSpinner;
    }
}
 
Example 6
Source File: TGHarmonicDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fillData(int type, int selection) {
	TGSelectableItem[] selectableItems = createDataValues(type);
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(getActivity(), android.R.layout.simple_spinner_item, selectableItems);
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	
	Spinner spinner = (Spinner) this.getView().findViewById(R.id.harmonic_dlg_data_value);
	spinner.setAdapter(arrayAdapter);
	spinner.setEnabled(selectableItems.length > 0);
	spinner.setVisibility(selectableItems.length > 0 ? View.VISIBLE : View.GONE);
	if( selectableItems.length > 0 ) {
		spinner.setSelection(arrayAdapter.getPosition(new TGSelectableItem(Integer.valueOf(selection), null)));
	}
}
 
Example 7
Source File: EditorFragment.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_editor, container, false);
    mPostTitle = (TextView) view.findViewById(R.id.post_title);
    mTitleET = (EditText) view.findViewById(R.id.edit_title);
    mTitleET.setText(mTitle);
    mContentET = (EditText) view.findViewById(R.id.edit_content);
    mContentET.setText(mContent);
    mCategoriesSpinner = (Spinner) view.findViewById(R.id.edit_categories_spinner);
    mCategoriesSpinner.setAdapter(mCategoryAdapter);

    setupMarkdownViews(view);
    if (isPrivateMsg()) {
        mCategoriesSpinner.setVisibility(View.GONE);
        mPostTitle.setText(getString(R.string.send_private_msg_title, mUsername));
    } else if (isNewTopic()) {
        mPostTitle.setVisibility(View.GONE);
    } else if (isReplyTopic()) {
        mTitleET.setVisibility(View.GONE);
        mCategoriesSpinner.setVisibility(View.GONE);
        mPostTitle.setText(getString(R.string.reply_topic_title, mTopic.title));
    } else if (isReplyPost()) {
        mTitleET.setVisibility(View.GONE);
        mCategoriesSpinner.setVisibility(View.GONE);
        mPostTitle.setText(getString(R.string.reply_post_title, mPostNum, mUsername));
    } else if (isEditPost()) {
        mTitleET.setVisibility(View.GONE);
        mCategoriesSpinner.setVisibility(View.GONE);
        mPostTitle.setText(getString(R.string.edit_post_title, mPostNum, mUsername));
        mContentET.setText(R.string.loading_post_text);
    }
    return view;
}
 
Example 8
Source File: ShareActivity.java    From Shaarlier with GNU General Public License v3.0 5 votes vote down vote up
private void initAccountSpinner() {
    final Spinner accountSpinner = this.findViewById(R.id.chooseAccount);
    ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.tags_list, accounts);
    accountSpinner.setAdapter(adapter);
    if(accountSpinner.getCount() < 2) {
        accountSpinner.setVisibility(View.GONE);
    }
}
 
Example 9
Source File: ReviewsActivity.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void buildToolBar() {
    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    //disable title on toolbar
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    ImageView homeIcon = (ImageView) findViewById(R.id.activityIcon);
    homeIcon.setBackgroundResource(R.mipmap.livefyreflame);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);

    Spinner mSpinner = (Spinner) findViewById(R.id.activityTitleSpinner);
    String[] items = getResources().getStringArray(R.array.helpful_categories);
    mSpinner.setVisibility(View.VISIBLE);
    activityTitle.setVisibility(View.GONE);
    List<String> spinnerItems = new ArrayList<String>();

    for (int i = 0; i < items.length; i++) {
        spinnerItems.add(items[i]);
    }

    SpinnerAdapter adapter = new SpinnerAdapter(actionBar.getThemedContext(), spinnerItems);
    mSpinner.setAdapter(adapter);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mSpinner.setDropDownVerticalOffset(-116);
    }

}
 
Example 10
Source File: ShareTrackDialogFragment.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
protected Dialog createDialog() {
  FragmentActivity fragmentActivity = getActivity();
  accounts = AccountManager.get(fragmentActivity).getAccountsByType(Constants.ACCOUNT_TYPE);

  if (accounts.length == 0) {
    return new AlertDialog.Builder(fragmentActivity).setMessage(
        R.string.send_google_no_account_message).setTitle(R.string.send_google_no_account_title)
        .setPositiveButton(R.string.generic_ok, null).create();
  }

  // Get all the views
  View view = fragmentActivity.getLayoutInflater().inflate(R.layout.share_track, null);
  publicCheckBox = (CheckBox) view.findViewById(R.id.share_track_public);
  inviteCheckBox = (CheckBox) view.findViewById(R.id.share_track_invite);
  multiAutoCompleteTextView = (MultiAutoCompleteTextView) view.findViewById(
      R.id.share_track_emails);
  accountSpinner = (Spinner) view.findViewById(R.id.share_track_account);
  
  // Setup publicCheckBox
  publicCheckBox.setChecked(PreferencesUtils.getBoolean(
      fragmentActivity, R.string.share_track_public_key,
      PreferencesUtils.SHARE_TRACK_PUBLIC_DEFAULT));

  // Setup inviteCheckBox
  inviteCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      multiAutoCompleteTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
    }
  });
  inviteCheckBox.setChecked(PreferencesUtils.getBoolean(
      fragmentActivity, R.string.share_track_invite_key,
      PreferencesUtils.SHARE_TRACK_INVITE_DEFAULT));

  // Setup multiAutoCompleteTextView
  multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
  SimpleCursorAdapter adapter = new SimpleCursorAdapter(fragmentActivity,
      R.layout.add_emails_item, getAutoCompleteCursor(fragmentActivity, null), new String[] {
          ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email.DATA },
      new int[] { android.R.id.text1, android.R.id.text2 }, 0);
  adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
      @Override
    public CharSequence convertToString(Cursor cursor) {
      int index = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA);
      return cursor.getString(index).trim();
    }
  });
  adapter.setFilterQueryProvider(new FilterQueryProvider() {
      @Override
    public Cursor runQuery(CharSequence constraint) {
      return getAutoCompleteCursor(getActivity(), constraint);
    }
  });
  multiAutoCompleteTextView.setAdapter(adapter);

  // Setup accountSpinner
  accountSpinner.setVisibility(accounts.length > 1 ? View.VISIBLE : View.GONE);
  AccountUtils.setupAccountSpinner(fragmentActivity, accountSpinner, accounts);
  
  return new AlertDialog.Builder(fragmentActivity).setNegativeButton(
      R.string.generic_cancel, null)
      .setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
          @Override
        public void onClick(DialogInterface dialog, int which) {
          FragmentActivity context = getActivity();
          if (!publicCheckBox.isChecked() && !inviteCheckBox.isChecked()) {
            Toast.makeText(context, R.string.share_track_no_selection, Toast.LENGTH_LONG).show();
            return;
          }
          String acl = multiAutoCompleteTextView.getText().toString().trim();
          if (!publicCheckBox.isChecked() && acl.equals("")) {
            Toast.makeText(context, R.string.share_track_no_emails, Toast.LENGTH_LONG).show();
            return;
          }
          PreferencesUtils.setBoolean(
              context, R.string.share_track_public_key, publicCheckBox.isChecked());
          PreferencesUtils.setBoolean(
              context, R.string.share_track_invite_key, inviteCheckBox.isChecked());
          Account account = accounts.length > 1 ? accounts[accountSpinner
              .getSelectedItemPosition()]
              : accounts[0];
          AccountUtils.updateShareTrackAccountPreference(context, account);
          caller.onShareTrackDone(
              getArguments().getLong(KEY_TRACK_ID), publicCheckBox.isChecked(), acl, account);
        }
      }).setTitle(R.string.share_track_title).setView(view).create();
}
 
Example 11
Source File: StatsUtils.java    From mytracks with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the trip statistics values.
 * 
 * @param context the context
 * @param activity the activity for finding views. If null, then view cannot
 *          be null
 * @param view the containing view for finding views. If null, the activity
 *          cannot be null
 * @param tripStatistics the trip statistics
 * @param activityType the activity type
 * @param trackIconValue the track icon value or null to hide the track icon
 *          spinner
 */
public static void setTripStatisticsValues(Context context, Activity activity, View view,
    TripStatistics tripStatistics, ActivityType activityType, String trackIconValue) {
  boolean metricUnits = PreferencesUtils.isMetricUnits(context);
  boolean reportSpeed = PreferencesUtils.isReportSpeed(context);

  // Set total distance
  double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
  setDistanceValue(
      context, getView(activity, view, R.id.stats_distance), totalDistance, metricUnits);

  // Set calorie
  double calorie = tripStatistics == null || activityType == ActivityType.INVALID ? Double.NaN
      : tripStatistics.getCalorie();
  setCalorie(context, getView(activity, view, R.id.stats_calorie), calorie);

  Spinner spinner = (Spinner) getView(activity, view, R.id.stats_activity_type_icon);
  spinner.setVisibility(trackIconValue != null ? View.VISIBLE : View.GONE);
  if (trackIconValue != null) {
    TrackIconUtils.setIconSpinner(spinner, trackIconValue);
  }

  // Set total time
  setTimeValue(context, getView(activity, view, R.id.stats_total_time), R.string.stats_total_time,
      tripStatistics != null ? tripStatistics.getTotalTime() : -1L);

  // Set moving time
  setTimeValue(context, getView(activity, view, R.id.stats_moving_time),
      R.string.stats_moving_time, tripStatistics != null ? tripStatistics.getMovingTime() : -1L);

  // Set average speed/pace
  double averageSpeed = tripStatistics != null ? tripStatistics.getAverageSpeed() : Double.NaN;
  setSpeed(context, getView(activity, view, R.id.stats_average_speed),
      R.string.stats_average_speed, R.string.stats_average_pace, averageSpeed, metricUnits,
      reportSpeed);

  // Set max speed/pace
  double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
  setSpeed(context, getView(activity, view, R.id.stats_max_speed), R.string.stats_max_speed,
      R.string.stats_fastest_pace, maxSpeed, metricUnits, reportSpeed);

  // Set average moving speed/pace
  double averageMovingSpeed = tripStatistics != null ? tripStatistics.getAverageMovingSpeed()
      : Double.NaN;
  setSpeed(context, getView(activity, view, R.id.stats_average_moving_speed),
      R.string.stats_average_moving_speed, R.string.stats_average_moving_pace, averageMovingSpeed,
      metricUnits, reportSpeed);

  // Set grade/elevation
  boolean showGradeElevation = PreferencesUtils.getBoolean(context,
      R.string.stats_show_grade_elevation_key,
      PreferencesUtils.STATS_SHOW_GRADE_ELEVATION_DEFAULT);
  View gradeElevationSeparator = getView(activity, view, R.id.stats_grade_elevation_separator);
  View gradeElevationContainer = getView(activity, view, R.id.stats_grade_elevation_container);

  gradeElevationSeparator.setVisibility(showGradeElevation ? View.VISIBLE : View.GONE);
  gradeElevationContainer.setVisibility(showGradeElevation ? View.VISIBLE : View.GONE);

  if (showGradeElevation) {
    // Set grade
    double minGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMinGrade();
    double maxGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMaxGrade();
    setGradeValue(
        context, getView(activity, view, R.id.stats_grade_min), R.string.stats_min, minGrade);
    setGradeValue(
        context, getView(activity, view, R.id.stats_grade_max), R.string.stats_max, maxGrade);

    // Set elevation
    double elevationGain = tripStatistics == null ? Double.NaN
        : tripStatistics.getTotalElevationGain();
    double minElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMinElevation();
    double maxElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMaxElevation();
    setElevationValue(context, getView(activity, view, R.id.stats_elevation_gain),
        R.string.stats_gain, elevationGain, metricUnits);
    setElevationValue(context, getView(activity, view, R.id.stats_elevation_min),
        R.string.stats_min, minElevation, metricUnits);
    setElevationValue(context, getView(activity, view, R.id.stats_elevation_max),
        R.string.stats_max, maxElevation, metricUnits);
  }
}
 
Example 12
Source File: DrMIPSActivity.java    From drmips with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates/places the tabs in the Tabhost.
 */
private void createTabs() {
	tabHost = (TabHost)findViewById(android.R.id.tabhost);
	tabHost.setup();

	TabSpec tabCode = tabHost.newTabSpec("tabCode");
	tabCode.setIndicator(getString(R.string.code));
	tabCode.setContent(R.id.tabCode);
	tabHost.addTab(tabCode);
	txtCode = (EditText)findViewById(R.id.txtCode);
	lblFilename = (TextView)findViewById(R.id.lblFilename);
	txtCode.addTextChangedListener(new CodeEditorTextWatcher());
	
	TabSpec tabAssembledCode = tabHost.newTabSpec("tabAssembledCode");
	tabAssembledCode.setIndicator(getString(R.string.assembled));
	tabAssembledCode.setContent(R.id.tabAssembledCode);
	tabHost.addTab(tabAssembledCode);
	tblAssembledCode = (TableLayout)findViewById(R.id.tblAssembledCode);
	cmbAssembledCodeFormat = (Spinner)findViewById(R.id.cmbAssembledCodeFormat);
	cmbAssembledCodeFormat.setOnItemSelectedListener(spinnersListener);
	cmbAssembledCodeFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.ASSEMBLED_CODE_FORMAT_PREF, DrMIPS.DEFAULT_ASSEMBLED_CODE_FORMAT));
	
	TabSpec tabDatapath = tabHost.newTabSpec("tabDatapath");
	tabDatapath.setIndicator(getString(R.string.datapath));
	tabDatapath.setContent(R.id.tabDatapath);
	tabHost.addTab(tabDatapath);
	lblCPUFilename = (TextView)findViewById(R.id.lblCPUFilename);
	cmdStep = (ImageButton)findViewById(R.id.cmdStep);
	datapathScroll = (HorizontalScrollView)findViewById(R.id.datapathScroll);
	boolean performanceMode = DrMIPS.getApplication().getPreferences().getBoolean(DrMIPS.PERFORMANCE_MODE_PREF, DrMIPS.DEFAULT_PERFORMANCE_MODE);
	lblDatapathFormat = (TextView)findViewById(R.id.lblDatapathFormat);
	cmbDatapathFormat = (Spinner)findViewById(R.id.cmbDatapathFormat);
	cmbDatapathFormat.setOnItemSelectedListener(spinnersListener);
	cmbDatapathFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATAPATH_DATA_FORMAT_PREF, DrMIPS.DEFAULT_DATAPATH_DATA_FORMAT));
	lblDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE);
	cmbDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE);
	lblDatapathPerformance = (TextView)findViewById(R.id.lblDatapathPerformance);
	cmbDatapathPerformance = (Spinner)findViewById(R.id.cmbDatapathPerformance);
	cmbDatapathPerformance.setOnItemSelectedListener(spinnersListener);
	cmbDatapathPerformance.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.PERFORMANCE_TYPE_PREF, DrMIPS.DEFAULT_PERFORMANCE_TYPE));
	lblDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE);
	cmbDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE);
	tblExec = (TableLayout)findViewById(R.id.tblExec);
	tblExecRow = (TableRow)findViewById(R.id.tblExecRow);
	
	TabSpec tabRegisters = tabHost.newTabSpec("tabRegisters");
	tabRegisters.setIndicator(getString(R.string.registers));
	tabRegisters.setContent(R.id.tabRegisters);
	tabHost.addTab(tabRegisters);
	tblRegisters = (TableLayout)findViewById(R.id.tblRegisters);
	cmbRegistersFormat = (Spinner)findViewById(R.id.cmbRegistersFormat);
	cmbRegistersFormat.setOnItemSelectedListener(spinnersListener);
	cmbRegistersFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.REGISTER_FORMAT_PREF, DrMIPS.DEFAULT_REGISTER_FORMAT));
	
	TabSpec tabDataMemory = tabHost.newTabSpec("tabDataMemory");
	tabDataMemory.setIndicator(getString(R.string.data_memory));
	tabDataMemory.setContent(R.id.tabDataMemory);
	tabHost.addTab(tabDataMemory);
	tblDataMemory = (TableLayout)findViewById(R.id.tblDataMemory);
	cmbDataMemoryFormat = (Spinner)findViewById(R.id.cmbDataMemoryFormat);
	cmbDataMemoryFormat.setOnItemSelectedListener(spinnersListener);
	cmbDataMemoryFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATA_MEMORY_FORMAT_PREF, DrMIPS.DEFAULT_DATA_MEMORY_FORMAT));
}
 
Example 13
Source File: PostFormActivity.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
private void setViews() {
    setContentView(settings.isPinnedMarkup() ? R.layout.postform_layout_pinned_markup : R.layout.postform_layout);
    nameLayout = findViewById(R.id.postform_name_email_layout);
    nameField = (EditText) findViewById(R.id.postform_name_field);
    emailField = (EditText) findViewById(R.id.postform_email_field);
    passwordLayout = findViewById(R.id.postform_password_layout);
    passwordField = (EditText) findViewById(R.id.postform_password_field);
    chkboxLayout = findViewById(R.id.postform_checkbox_layout);
    sageChkbox = (CheckBox) findViewById(R.id.postform_sage_checkbox);
    sageChkbox.setOnClickListener(this);
    custommarkChkbox = (CheckBox) findViewById(R.id.postform_custommark_checkbox);
    attachmentsLayout = (LinearLayout) findViewById(R.id.postform_attachments_layout);
    spinner = (Spinner) findViewById(R.id.postform_spinner);
    subjectField = (EditText) findViewById(R.id.postform_subject_field);
    commentField = (EditText) findViewById(R.id.postform_comment_field);
    markLayout = (LinearLayout) findViewById(R.id.postform_mark_layout);
    for (int i=0, len=markLayout.getChildCount(); i<len; ++i) markLayout.getChildAt(i).setOnClickListener(this);
    captchaLayout = findViewById(R.id.postform_captcha_layout);
    captchaView = (ImageView) findViewById(R.id.postform_captcha_view);
    captchaView.setOnClickListener(this);
    captchaView.setOnCreateContextMenuListener(this);
    captchaLoading = findViewById(R.id.postform_captcha_loading);
    captchaField = (EditText) findViewById(R.id.postform_captcha_field);
    captchaField.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                send();
                return true;
            }
            return false;
        }
    });
    sendButton = (Button) findViewById(R.id.postform_send_button);
    sendButton.setOnClickListener(this);
    
    if (settings.isHidePersonalData()) {
        nameLayout.setVisibility(View.GONE);
        passwordLayout.setVisibility(View.GONE);
    } else {
        nameLayout.setVisibility(boardModel.allowNames || boardModel.allowEmails ? View.VISIBLE : View.GONE);
        nameField.setVisibility(boardModel.allowNames ? View.VISIBLE : View.GONE);
        emailField.setVisibility(boardModel.allowEmails ? View.VISIBLE : View.GONE);
        passwordLayout.setVisibility((boardModel.allowDeletePosts || boardModel.allowDeleteFiles) ? View.VISIBLE : View.GONE);
        
        if (boardModel.allowNames && !boardModel.allowEmails) nameField.setLayoutParams(getWideLayoutParams());
        else if (!boardModel.allowNames && boardModel.allowEmails) emailField.setLayoutParams(getWideLayoutParams());
    }
    
    boolean[] markupEnabled = {
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_QUOTE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_BOLD),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_ITALIC),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_UNDERLINE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_STRIKE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_SPOILER),
    };
    if (markupEnabled[0] || markupEnabled[1] || markupEnabled[2] || markupEnabled[3] || markupEnabled[4] || markupEnabled[5]) {
        markLayout.setVisibility(View.VISIBLE);
        if (!markupEnabled[0]) markLayout.findViewById(R.id.postform_mark_quote).setVisibility(View.GONE);
        if (!markupEnabled[1]) markLayout.findViewById(R.id.postform_mark_bold).setVisibility(View.GONE);
        if (!markupEnabled[2]) markLayout.findViewById(R.id.postform_mark_italic).setVisibility(View.GONE);
        if (!markupEnabled[3]) markLayout.findViewById(R.id.postform_mark_underline).setVisibility(View.GONE);
        if (!markupEnabled[4]) markLayout.findViewById(R.id.postform_mark_strike).setVisibility(View.GONE);
        if (!markupEnabled[5]) markLayout.findViewById(R.id.postform_mark_spoiler).setVisibility(View.GONE);
    } else {
        markLayout.setVisibility(View.GONE);
    }
    
    subjectField.setVisibility(boardModel.allowSubjects ? View.VISIBLE : View.GONE);
    chkboxLayout.setVisibility(boardModel.allowSage || boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    sageChkbox.setVisibility(boardModel.allowSage ? View.VISIBLE : View.GONE);
    custommarkChkbox.setVisibility(boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    if (boardModel.customMarkDescription != null) custommarkChkbox.setText(boardModel.customMarkDescription);
    spinner.setVisibility(boardModel.allowIcons ? View.VISIBLE : View.GONE);
    
    if (boardModel.allowIcons) {
        spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, boardModel.iconDescriptions));
    }
}
 
Example 14
Source File: PopupComposeStatus.java    From Rumble with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_popup_compose_status);

    Bundle args = getIntent().getExtras();
    if(args != null) {
        this.filter_gid = args.getString("GroupID");
        this.filter_hashtag = args.getString("Hashtag");
    }

    imageBitmap = null;
    dismiss = (LinearLayout)(findViewById(R.id.popup_dismiss));
    compose = (EditText)(findViewById(R.id.popup_user_status));
    compose_background = (ImageView)(findViewById(R.id.popup_user_attached_photo));
    takePicture = (ImageButton)(findViewById(R.id.popup_take_picture));
    choosePicture = (ImageButton)(findViewById(R.id.popup_choose_image));
    send = (ImageButton)(findViewById(R.id.popup_button_send));
    spinner = (Spinner)(findViewById(R.id.group_list_spinner));
    groupLock = (ImageView)(findViewById(R.id.group_lock_image));

    groupLock.setBackgroundResource(R.drawable.ic_lock_outline_white_24dp);

    if(filter_gid == null) {
        spinnerArrayAdapter = new GroupSpinnerAdapter();
        spinner.setAdapter(spinnerArrayAdapter);
        spinner.setOnItemSelectedListener(spinnerArrayAdapter);
        getGroupList();
    } else {
        spinner.setVisibility(View.INVISIBLE);
    }

    if(filter_hashtag != null) {
        compose.setText(filter_hashtag);
    }

    dismiss.setOnClickListener(onDiscardClick);
    takePicture.setOnClickListener(onTakePictureClick);
    choosePicture.setOnClickListener(onAttachPictureClick);
    send.setOnClickListener(onClickSend);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
 
Example 15
Source File: MainActivity.java    From AndrOBD with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Activate desired OBD service
 *
 * @param newObdService OBD service ID to be activated
 */
private void setObdService(int newObdService, CharSequence menuTitle)
{
	// remember this as current OBD service
	obdService = newObdService;
	// set list view
	setContentView(mListView);
	getListView().setOnItemLongClickListener(this);
	getListView().setMultiChoiceModeListener(this);
	getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

	// un-filter display
	setFiltered(false);

	// set title
	ActionBar ab = getActionBar();
	if (ab != null)
	{
		// title specified ... show it
		if (menuTitle != null)
		{
			ab.setTitle(menuTitle);
		}
		else
		{
			// no title specified, set to app name if no service set
			if (newObdService == ElmProt.OBD_SVC_NONE)
			{
				ab.setTitle(getString(R.string.app_name));
			}
		}
	}
	// set protocol service
	CommService.elm.setService(newObdService, (getMode() != MODE.FILE));
	// show / hide freeze frame selector */
	Spinner ff_selector = findViewById(R.id.ff_selector);
	ff_selector.setOnItemSelectedListener(ff_selected);
	ff_selector.setAdapter(mDfcAdapter);
	ff_selector.setVisibility(
		newObdService == ObdProt.OBD_SVC_FREEZEFRAME ? View.VISIBLE : View.GONE);
	// set corresponding list adapter
	switch (newObdService)
	{
		case ObdProt.OBD_SVC_DATA:
			getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
			// no break here
		case ObdProt.OBD_SVC_FREEZEFRAME:
			currDataAdapter = mPidAdapter;
			break;

		case ObdProt.OBD_SVC_PENDINGCODES:
		case ObdProt.OBD_SVC_PERMACODES:
		case ObdProt.OBD_SVC_READ_CODES:
			currDataAdapter = mDfcAdapter;
			Toast.makeText(this, getString(R.string.long_press_dfc_hint), Toast.LENGTH_LONG).show();
			break;

		case ObdProt.OBD_SVC_NONE:
			setContentView(R.layout.startup_layout);
			// intentionally no break to initialize adapter
		case ObdProt.OBD_SVC_VEH_INFO:
			currDataAdapter = mVidAdapter;
			break;
	}
	setListAdapter(currDataAdapter);

	// remember this as last selected service
	if (newObdService > ObdProt.OBD_SVC_NONE)
	{ prefs.edit().putInt(PRESELECT.LAST_SERVICE.toString(), newObdService).apply(); }
}
 
Example 16
Source File: ComposerTimeScalingActivity.java    From media-for-mobile with Apache License 2.0 3 votes vote down vote up
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.composer_time_scaling_activity);

    timeScaleSpinner = (Spinner) findViewById(R.id.timescale);
    timeScaleSpinner.setVisibility(View.VISIBLE);

    init();
}