コード例 #1
0
  public static View getAddMultiMediaView() {
    if (_root.getParent() != null) {
      ViewParent parentView = _root.getParent();
      ((ViewGroup) parentView).removeView(_root);
    }

    return _root;
  }
コード例 #2
0
  private void initTitle() {
    if (mTitleLayout == null) {
      LayoutInflater inflater = LayoutInflater.from(getContext());
      inflater.inflate(R.layout.abc_action_bar_title_item, this);
      mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
      mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
      mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
      if (mTitleStyleRes != 0) {
        mTitleView.setTextAppearance(getContext(), mTitleStyleRes);
      }
      if (mSubtitleStyleRes != 0) {
        mSubtitleView.setTextAppearance(getContext(), mSubtitleStyleRes);
      }
    }

    mTitleView.setText(mTitle);
    mSubtitleView.setText(mSubtitle);

    final boolean hasTitle = !TextUtils.isEmpty(mTitle);
    final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle);
    mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE);
    mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE);
    if (mTitleLayout.getParent() == null) {
      addView(mTitleLayout);
    }
  }
コード例 #3
0
ファイル: CustomVideoPlayer.java プロジェクト: kj0604/CarAvn
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.menuButton:
       if (((ScrollView) mVideoList.getParent()).getVisibility() == View.INVISIBLE) {
         ((ScrollView) mVideoList.getParent()).setVisibility(View.VISIBLE);
         ((ScrollView) mVideoList.getParent()).bringToFront();
         controller.show();
       } else ((ScrollView) mVideoList.getParent()).setVisibility(View.INVISIBLE);
       Log.e("TAG", "menu Button");
       break;
     case R.id.videoList:
       break;
     default:
       break;
   }
 }
コード例 #4
0
  /**
   * 具体的转屏执行函数--使用父窗口方式
   *
   * @param container
   * @param isFullScreen
   */
  private void setIsFullModeUsingContainer(ViewGroup container, boolean isFullScreen) {
    if (container == null) {
      VDLog.e(VDVideoFullModeController.TAG, "videoview---setIsFullMode---container--return null");
      throw new IllegalArgumentException("container is null");
    }
    if (mVideoViewParams == null) {
      VDLog.e(
          VDVideoFullModeController.TAG,
          "videoview---setIsFullMode---mVideoViewParams--return null");
      mVideoViewParams = getLayoutParams();
    }
    mVideoView.beginChangeParentView();

    if (mVideoFullScreenContainer != null) {
      mVideoFullScreenContainer.removeAllViews();
    }

    if (mVideoFullScreenContainer.getParent() == null) {
      changeToRoot(mVideoFullScreenContainer);
    }
    VDVideoViewController controller = VDVideoViewController.getInstance(mContext);
    if (controller != null) {
      controller.notifyScreenOrientationSwitch(isFullScreen);
      if (mVideoView.isPlaying()) {
        controller.notifyOnShowHideADContainer(true);
      }
    }
    if (isFullScreen) {
      if (mExternalFullScreenContainer != null) {
        mExternalFullScreenContainer.setVisibility(VISIBLE);
      }
      // 横屏
      VDVideoScreenOrientation.setStatusBarVisible(mContext, true);
      mVideoFullScreenContainer.setVisibility(View.VISIBLE);

      container.removeView(this);
      mVideoFullScreenContainer.addView(
          this, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    } else {
      if (mExternalFullScreenContainer != null) {
        mExternalFullScreenContainer.setVisibility(GONE);
      }
      VDVideoScreenOrientation.setStatusBarVisible(mContext, false);
      mVideoFullScreenContainer.setVisibility(View.GONE);
      // 竖屏
      if (getParent() == null) {
        container.addView(this, mVideoViewParams);
      }
    }
    for (VDVideoViewLayerContext item : mVDVideoViewLayerData.getLayerList()) {
      if (item.mIsComplexLayerType) {
        // 有复杂模式才进行横竖屏转换
        if (controller != null) item.setFullMode(isFullScreen, controller.isInsertAD());
      }
    }
    mVideoView.endChangeParentView();
    mVideoView.requestVideoLayout();
  }
コード例 #5
0
 private String getFileName(View v, boolean plusExtension) {
   LinearLayout horizontalButtons = (LinearLayout) v.getParent();
   LinearLayout linearLayout = (LinearLayout) horizontalButtons.getParent();
   TextView name = (TextView) linearLayout.findViewById(R.id.filename_editText);
   String filename = name.getText().toString();
   if (plusExtension) {
     filename += Utility.FILE_EXT;
   }
   return filename;
 }
コード例 #6
0
ファイル: Forecast.java プロジェクト: Maxislav/WeatherRadar
  Forecast(Activity activity, LinearLayout fr) {
    db = new DataBaseHelper(activity);

    this.activity = activity;
    toast = (ToastShow) activity;
    this.fr = fr;
    parent = (FrameLayout) fr.getParent().getParent();
    loader = new Loader(activity, parent);
    context = activity.getApplicationContext();

    _onStart();

    //  onInflate();
  }
コード例 #7
0
 public void show(boolean animate) {
   menuSize = dpToPx(250, act);
   content = ((LinearLayout) act.findViewById(android.R.id.content).getParent());
   FrameLayout.LayoutParams parm = (FrameLayout.LayoutParams) content.getLayoutParams();
   parm.gravity = Gravity.TOP;
   statusHeight = 0;
   parm.setMargins(menuSize, 0, -menuSize, 0);
   content.setLayoutParams(parm);
   // animation for smooth slide-out
   TranslateAnimation ta = new TranslateAnimation(-menuSize, 0, 0, 0);
   ta.setDuration(500);
   if (animate) content.startAnimation(ta);
   parent = (FrameLayout) content.getParent();
   LayoutInflater inflater =
       (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   menu = inflater.inflate(R.layout.menu, null);
   FrameLayout.LayoutParams lays = new FrameLayout.LayoutParams(-1, -1, 3);
   lays.setMargins(0, statusHeight, 0, 0);
   menu.setLayoutParams(lays);
   parent.addView(menu);
   ListView list = (ListView) act.findViewById(R.id.menu_listview);
   list.setBackgroundResource(R.drawable.shadow);
   list.setOnItemClickListener(
       new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           // handle your menu-click
         }
       });
   if (animate) menu.startAnimation(ta);
   menu.findViewById(R.id.overlay)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               NewsgroupListMenu.this.hide();
             }
           });
   enableDisableViewGroup(
       (LinearLayout) parent.findViewById(android.R.id.content).getParent(), false);
   // ((ExtendedViewPager) act.findViewById(R.id.viewpager)).setPagingEnabled(false);
   // ((ExtendedPagerTabStrip) act.findViewById(R.id.viewpager_tabs)).setNavEnabled(false);
   menuShown = true;
   this.fill();
 }
コード例 #8
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mFragmentView == null) {
      mFragmentView = (LinearLayout) inflater.inflate(R.layout.fragment_webview, container, false);
      wb = (WebView) mFragmentView.findViewById(R.id.webView);
      // 获得索引值
      Bundle bundle = getArguments();
      if (bundle != null) {
        mCurIndex = bundle.getInt(FRAGMENT_INDEX);
        url = bundle.getString("URL");
      }
      isPrepared = true;
      lazyLoad();
    }

    // 因为共用一个Fragment视图,所以当前这个视图已被加载到Activity中,必须先清除后再加入Activity
    ViewGroup parent = (ViewGroup) mFragmentView.getParent();
    if (parent != null) {
      parent.removeView(mFragmentView);
    }
    return mFragmentView;
  }
コード例 #9
0
ファイル: ActionBarView.java プロジェクト: kairon007/UpMobile
  /*
   * Must be public so we can dispatch pre-2.2 via ActionBarImpl.
   */
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    mTitleView = null;
    mSubtitleView = null;
    mTitleUpView = null;
    if (mTitleLayout != null && mTitleLayout.getParent() == this) {
      removeView(mTitleLayout);
    }
    mTitleLayout = null;
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
      initTitle();
    }

    if (mTabScrollView != null && mIncludeTabs) {
      ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
      if (lp != null) {
        lp.width = LayoutParams.WRAP_CONTENT;
        lp.height = LayoutParams.MATCH_PARENT;
      }
      mTabScrollView.setAllowCollapse(true);
    }
  }
コード例 #10
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.context_add:
        {
          Intent addContextIntent =
              new Intent(Intent.ACTION_INSERT, ContextProvider.Contexts.CONTENT_URI);
          startActivityForResult(addContextIntent, cNewContextCode);
          break;
        }

      case R.id.project_add:
        {
          Intent addProjectIntent =
              new Intent(Intent.ACTION_INSERT, ProjectProvider.Projects.CONTENT_URI);
          startActivityForResult(addProjectIntent, cNewProjectCode);
          break;
        }

      case R.id.scheduling_entry:
        {
          toggleSchedulingSection();
          break;
        }

      case R.id.completed_entry:
        {
          mCompletedCheckBox.toggle();
          break;
        }

      case R.id.deleted_entry:
        {
          mDeletedCheckBox.toggle();
          break;
        }

      case R.id.gcal_entry:
        {
          CheckBox checkBox = (CheckBox) v.findViewById(R.id.update_calendar_checkbox);
          checkBox.toggle();
          break;
        }

      case R.id.clear_dates:
        {
          mAllDayCheckBox.setChecked(false);
          mStartTime = new Time();
          mDueTime = new Time();
          setWhenDefaults();
          populateWhen();
          updateCalendarPanel();
          break;
        }

      case R.id.reminder_remove:
        {
          LinearLayout reminderItem = (LinearLayout) v.getParent();
          LinearLayout parent = (LinearLayout) reminderItem.getParent();
          parent.removeView(reminderItem);
          mReminderItems.remove(reminderItem);
          updateRemindersVisibility();
          break;
        }

      default:
        super.onClick(v);
        break;
    }
  }
 /**
  * Returns how big this panel's view should be. This method should only be called when the view
  * has not been attached to a parent.
  *
  * @throws IllegalStateException
  */
 public Size measure() {
   Preconditions.checkState(mContentView.getParent() == null);
   mContentView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
   return new Size(mContentView.getMeasuredWidth(), mContentView.getMeasuredHeight());
 }
コード例 #12
0
  private void createNewContactObject(String type, View my_contact_view) {
    if (my_contact_view == null) {
      my_contact_view = fragment_mycontact.getView();
    }

    if (my_contact_view == null) return;

    LinearLayout ll_data;
    List<String> list = new ArrayList<String>();
    int it = android.text.InputType.TYPE_CLASS_TEXT;
    int hint = 0;

    // Typen setzen:
    List<Integer> list_number = new ArrayList<Integer>();

    for (int i = 0; i < array_en_type.length; i++) {
      if (array_en_type[i].equals(type)) {
        list_number.add(i);
      }
    }

    for (int i = 0; i < list_number.size(); i++) {
      list.add((array_en_name[list_number.get(i)]));
    }

    final String[] spinnerArray = list.toArray(new String[list.size()]);

    // -----------

    LinearLayout ll_telephone =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_telephone);
    LinearLayout ll_email =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_email);
    LinearLayout ll_other =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_other);

    // new row
    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);

    DisplayMetrics tmp_metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(tmp_metrics);
    int resolution_width = tmp_metrics.widthPixels;

    final boolean large_screen = (resolution_width >= 720);

    final EditText et = new EditText(this);
    LayoutParams lp_et;
    lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);

    if (type.equals("number")) {
      ll_data = ll_telephone;

      it = InputType.TYPE_CLASS_PHONE;

      hint = R.string.telephone;

    } else if (type.equals("email")) {
      ll_data = ll_email;

      it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;

      hint = R.string.email;

    } else {
      ll_data = ll_other;

      if (type.equals("address")) {

        et.setMinLines(1);
        et.setMaxLines(3);
        et.setLines(2);

        hint = R.string.address;
        it =
            InputType.TYPE_CLASS_TEXT
                | InputType
                    .TYPE_TEXT_FLAG_MULTI_LINE; // android.text.InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS;
        lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, large_screen ? 130 : 90, 1);

        row.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT, (large_screen ? 130 : 90) + 20));

        et.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
        // et.setGravity(Gravity.LEFT | Gravity.TOP );

      } else if (type.equals("website")) {
        hint = R.string.website;
        it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      }
    }

    ((LinearLayout) ll_data.getParent()).setVisibility(LinearLayout.VISIBLE);

    et.setTextSize(large_screen ? 16 : 14); // EditText-Textgr��e
    et.setEms(10);
    et.setHint(hint);

    et.setInputType(it);

    lp_et.setMargins(0, 3, 0, 0);
    et.setLayoutParams(lp_et);

    Spinner spinner = new Spinner(this);
    LayoutParams lp_spinner =
        new LayoutParams(
            large_screen ? Functions.dpsToPx(this, 100) : Functions.dpsToPx(this, 80), /*300 : 200*/
            LayoutParams.MATCH_PARENT);

    lp_spinner.setMargins(0, 3, 0, 0);

    MySpinnerArrayAdapter dataAdapter = new MySpinnerArrayAdapter(this, list, large_screen);

    dataAdapter.setDropDownViewResource(
        android.support.v7.appcompat.R.layout.support_simple_spinner_dropdown_item);

    spinner.setAdapter(dataAdapter);
    spinner.setLayoutParams(lp_spinner);

    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(
              final AdapterView<?> adapterView, final View view, int arg2, long arg3) {
            final Spinner spinner = (Spinner) adapterView;
            MySpinnerArrayAdapter adapter = (MySpinnerArrayAdapter) spinner.getAdapter();
            if (adapter
                .getItem(arg2)
                .toLowerCase(new Locale("en"))
                .equals(getString(R.string.en_custom).toLowerCase(new Locale("en")))) {

              LinearLayout ll = new LinearLayout(MainActivity.this);
              final EditText et = new EditText(MainActivity.this);

              LinearLayout.LayoutParams layoutParams =
                  new LinearLayout.LayoutParams(
                      LinearLayout.LayoutParams.MATCH_PARENT,
                      LinearLayout.LayoutParams.WRAP_CONTENT);
              layoutParams.setMargins(0, 20, 0, 0);

              et.setTextColor(Color.BLACK);
              et.requestFocus();

              // et.setHint(R.string.place);

              ll.addView(et, layoutParams);

              AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
              builder
                  .setView(ll)
                  .setTitle(R.string.message_custom_en)
                  .setPositiveButton(
                      android.R.string.ok,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                          String[] newItems = new String[spinnerArray.length + 1];
                          System.arraycopy(spinnerArray, 0, newItems, 0, spinnerArray.length);
                          newItems[newItems.length - 1] = et.getText().toString();

                          MySpinnerArrayAdapter adapter =
                              new MySpinnerArrayAdapter(
                                  getApplicationContext(),
                                  newItems,
                                  ((MySpinnerArrayAdapter) spinner.getAdapter()).getLargeScreen());
                          spinner.setAdapter(adapter);
                          spinner.setSelection(newItems.length - 1);
                        }
                      })
                  .setNegativeButton(
                      android.R.string.cancel,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {}
                      })
                  .create()
                  .show();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    Button btn = new Button(this);
    btn.setText("x");
    LayoutParams lp_btn = new LayoutParams(Functions.dpsToPx(this, 32), LayoutParams.WRAP_CONTENT);
    lp_btn.setMargins(-10, 0, -10, 0);
    btn.setLayoutParams(lp_btn);
    btn.setBackgroundColor(Color.TRANSPARENT);

    btn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (((LinearLayout) v.getParent().getParent()).getChildCount() == 1) {
              ((LinearLayout) v.getParent().getParent().getParent()).setVisibility(View.GONE);
            }
            ((LinearLayout) v.getParent().getParent()).removeView((LinearLayout) v.getParent());
          }
        });

    row.addView(et);
    row.addView(spinner);
    row.addView(btn);

    row.setTag(type);

    ll_data.addView(row);
  }
コード例 #13
0
  @Override
  /*
   * TODO: Ensure that player does not play twice in same team.
   * 		 Now not yet working: Disabled checkboxes can be reenabled.
   * TODO: Take care of critical game process here (Disable choice when needed)
   * (non-Javadoc)
   * @see android.widget.CompoundButton.OnCheckedChangeListener#onCheckedChanged(android.widget.CompoundButton, boolean)
   */
  public void onCheckedChanged(CompoundButton checkBox, boolean newChecked) {
    LinearLayout boxParent = (LinearLayout) checkBox.getParent();
    LinearLayout horzLayout = (LinearLayout) boxParent.getParent();

    int leftOrRight = ((ViewGroup) horzLayout).indexOfChild(boxParent);

    LinearLayout otherParent = (LinearLayout) horzLayout.getChildAt(1 - leftOrRight);

    boolean ownChecked[] = new boolean[boxParent.getChildCount()];
    boolean otherChecked[] = new boolean[otherParent.getChildCount()];

    Log.d(
        "Dialog",
        "Created ownChecked (" + ownChecked.length + "), other (" + otherChecked.length + ")");
    // get an overview of current situation:
    int alreadyChecked = 0;
    int otherCheckedNo = 0;
    CheckBox currentBox, currentOtherBox;
    for (int i = 0; i < boxParent.getChildCount(); i++) {
      currentBox = (CheckBox) boxParent.getChildAt(i);
      if (currentBox.isChecked()) {
        alreadyChecked++;
        ownChecked[i] = true;
      } else {
        ownChecked[i] = false;
      }
    }
    Log.d("Dialog", "Checked " + alreadyChecked + " Boxes in this column");
    for (int i = 0; i < otherParent.getChildCount(); i++) {
      currentBox = (CheckBox) otherParent.getChildAt(i);
      if (currentBox.isChecked()) {
        otherCheckedNo++;
        otherChecked[i] = true;
      } else {
        otherChecked[i] = false;
      }
    }
    Log.d("Dialog", "Checked " + otherCheckedNo + " Boxes in other column");

    for (int i = 0; i < boxParent.getChildCount(); i++) {
      currentBox = (CheckBox) boxParent.getChildAt(i);
      currentOtherBox = (CheckBox) otherParent.getChildAt(i);
      // first, handle own team
      if (alreadyChecked == 2) {
        // this team is complete. Disable all other unconditionally
        if (!ownChecked[i]) {
          Log.d("Dialog", "Disabling own box " + i + "(" + players.get(i) + ")");
          currentBox.setEnabled(false);
        }
      } else {
        // this team is not complete. Disable those who can't be partner
        if (!ownChecked[i] && !otherChecked[i]) {
          // This one is not yet in a team => first enable
          Log.d("Dialog", "Enabling own box " + i + "(" + players.get(i) + ")");
          currentBox.setEnabled(true);
          // if he already played with another team member
          for (int j = 0; j < ownChecked.length; j++) {
            if (players.get(i).hasPlayedWith(players.get(j)) && ownChecked[j]) {
              // => disable again
              Log.d("Dialog", players.get(i) + " has played with " + players.get(j));
              Log.d("Dialog", "Disabling own box " + i + "(" + players.get(i) + ")");
              currentBox.setEnabled(false);
              break;
            }
            if (players.get(i).nGamesAgainst(players.get(j)) == 2
                && otherChecked[j]
                && criticalGame) {
              Log.d(
                  "Dialog",
                  players.get(i) + " has already playes 2 times against " + players.get(j));
              Log.d("Dialog", "Disabling own box " + i + "(" + players.get(i) + ")");
              currentBox.setEnabled(false);
              break;
            }
          }

        } else if (otherChecked[i]) {
          // he plays in the other team => disable
          Log.d("Dialog", players.get(i) + " is in the other team!");
          currentBox.setEnabled(false);
        } else {
          // he plays in this team => enable for unchecking
          currentBox.setEnabled(true);
        }
      }
      // Now handle this player in  the other team:
      if (otherCheckedNo == 2) {
        // Disable all unchecked players
        // other team is complete. Disable all other unconditionally
        if (!otherChecked[i]) {
          Log.d("Dialog", "Disabling other box " + i + "(" + players.get(i) + ")");
          currentOtherBox.setEnabled(false);
        }
      } else if (ownChecked[i]) {
        // Disable if he is in the team of invoked box
        Log.d("Dialog", players.get(i) + " is in this team! Disabling other.");
        currentOtherBox.setEnabled(false);
      } else {
        // probably he is available
        Log.d("Dialog", "Enabling other box " + i + "(" + players.get(i) + ")");
        currentOtherBox.setEnabled(true);
        // unless he already played with other activated player of that team
        for (int j = 0; j < otherChecked.length; j++) {
          //        			Log.d("Dialog", "i = " + i + ", other j = " + j);
          if (players.get(i).hasPlayedWith(players.get(j)) && otherChecked[j]) {
            Log.d("Dialog", players.get(i) + " has played with " + players.get(j));
            Log.d("Dialog", "Disabling other box " + i + "(" + players.get(i) + ")");
            currentOtherBox.setEnabled(false);
            break;
          }
          if (players.get(i).nGamesAgainst(players.get(j)) == 2 && ownChecked[j] && criticalGame) {
            Log.d(
                "Dialog", players.get(i) + " has already playes 2 times against " + players.get(j));
            Log.d("Dialog", "Disabling other box " + i + "(" + players.get(i) + ")");
            currentOtherBox.setEnabled(false);
            break;
          }
        }
      }
    }

    //        // make sure that not more than 2 players get in one team:
    //        if (alreadyChecked == 2) {
    //            for (int i = 0; i < boxParent.getChildCount(); i++) {
    //                currentBox = (CheckBox) boxParent.getChildAt(i);
    //                if (!ownChecked[i]) {
    //                    Log.d("Dialog", "Disabling Box " + i);
    //                    currentBox.setEnabled(false);
    //                }
    //            }
    //        } else {
    //            for (int i = 0; i < boxParent.getChildCount(); i++) {
    //            	// this team is not complete. See who can be my partner
    //                currentBox = (CheckBox) boxParent.getChildAt(i);
    //                if (!ownChecked[i] && !otherChecked[i]) {
    //                	// This one is not yet in a team
    //                    Log.d("Dialog", "Enabling Box " + i);
    //                    currentBox.setEnabled(true);
    //                    // did he play with the just selected player?
    //                    if(this.players.get(i).hasPlayedWith(this.players.get(index)) &&
    // newChecked){
    //                    	// he did => disable!
    //                    	Log.d("Dialog", players.get(i) + " has played with " +
    // players.get(index));
    //                        currentBox.setEnabled(false);
    //                    }
    //                }
    //            }
    //        }
    //
    //        // Male sure that one player is not in two teams at same time:
    //        CheckBox otherCheckBox = (CheckBox) otherParent.getChildAt(index);
    //        if (newChecked && otherCheckBox.isEnabled()) {
    //            // This player was selectable. Disable!
    //            otherCheckBox.setEnabled(false);
    //            Log.d("Dialog", (leftOrRight == 1 ? "Left" : "Right")
    //                    + " column disabled");
    //        } else if (!newChecked && (otherCheckedNo != 2)) {
    //            // This player was not selectable but the other team is not complete
    //            // => Enable!
    //        	otherCheckBox.setEnabled(true);
    //            Log.d("Dialog", (leftOrRight == 1 ? "Left" : "Right")
    //                    + " column enabled");
    //        }

  }
コード例 #14
0
  /** Formats message as a View suitable for a conversation list */
  private View oneMessageToView(ConversationOneMessage oMsg) {
    final String method = "oneMessageToView";
    if (MyLog.isLoggable(this, MyLog.VERBOSE)) {
      MyLog.v(
          this,
          method
              + ": msgId="
              + oMsg.msgId
              + (oMsg.avatarDrawable != null
                  ? ", avatar=" + oMsg.avatarDrawable.getFileName()
                  : ""));
    }
    LayoutInflater inflater = LayoutInflater.from(context);
    int layoutResource = R.layout.message_conversation;
    if (!Activity.class.isAssignableFrom(context.getClass())) {
      MyLog.w(this, "Context should be from an Activity");
    }
    View messageView = inflater.inflate(layoutResource, null);
    messageView.setOnCreateContextMenuListener(contextMenu);

    float displayDensity = context.getResources().getDisplayMetrics().density;
    // See
    // http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-code
    int indent0 = (int) (10 * displayDensity);
    int indentPixels = indent0 * oMsg.indentLevel;

    LinearLayout messageIndented = (LinearLayout) messageView.findViewById(R.id.message_indented);
    if (oMsg.msgId == selectedMessageId && oMsgs.size() > 1) {
      messageIndented.setBackgroundDrawable(
          context.getResources().getDrawable(R.drawable.message_current_background));
    }

    int viewToTheLeftId = 0;
    if (oMsg.indentLevel > 0) {
      View divider = messageView.findViewById(R.id.divider);
      RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
      layoutParams.leftMargin = indentPixels - 4;
      divider.setLayoutParams(layoutParams);

      if (MyLog.isLoggable(this, MyLog.VERBOSE)) {
        MyLog.v(this, "density=" + displayDensity);
      }
      viewToTheLeftId = 2;
      ImageView indentView =
          new ConversationIndentImageView(context, messageIndented, indentPixels);
      indentView.setId(viewToTheLeftId);
      ((ViewGroup) messageIndented.getParent()).addView(indentView);
    }

    if (MyPreferences.showAvatars()) {
      ImageView avatarView = new ImageView(context);
      int size = Math.round(AvatarDrawable.AVATAR_SIZE_DIP * displayDensity);
      avatarView.setScaleType(ScaleType.FIT_CENTER);
      RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(size, size);
      layoutParams.topMargin = 3;
      if (oMsg.indentLevel > 0) {
        layoutParams.leftMargin = 1;
      }
      if (viewToTheLeftId == 0) {
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
      } else {
        layoutParams.addRule(RelativeLayout.RIGHT_OF, viewToTheLeftId);
      }
      avatarView.setLayoutParams(layoutParams);
      avatarView.setImageDrawable(oMsg.avatarDrawable.getDrawable());
      indentPixels += size;
      ((ViewGroup) messageIndented.getParent()).addView(avatarView);
    }
    messageIndented.setPadding(indentPixels + 6, 2, 6, 2);

    TextView id = (TextView) messageView.findViewById(R.id.id);
    id.setText(Long.toString(oMsg.msgId));
    TextView linkedUserId = (TextView) messageView.findViewById(R.id.linked_user_id);
    linkedUserId.setText(Long.toString(oMsg.linkedUserId));

    TextView author = (TextView) messageView.findViewById(R.id.message_author);
    TextView body = (TextView) messageView.findViewById(R.id.message_body);
    TextView details = (TextView) messageView.findViewById(R.id.message_details);

    author.setText(oMsg.author);

    TextView number = (TextView) messageView.findViewById(R.id.message_number);
    number.setText(Integer.toString(oMsg.historyOrder));

    if (!TextUtils.isEmpty(oMsg.body)) {
      body.setLinksClickable(true);
      body.setMovementMethod(LinkMovementMethod.getInstance());
      body.setFocusable(true);
      body.setFocusableInTouchMode(true);
      Spanned spanned = Html.fromHtml(oMsg.body);
      body.setText(spanned);
      if (!MbMessage.hasUrlSpans(spanned)) {
        Linkify.addLinks(body, Linkify.ALL);
      }
    }

    // Everything else goes to messageDetails
    String messageDetails = RelativeTime.getDifference(context, oMsg.createdDate);
    if (!SharedPreferencesUtil.isEmpty(oMsg.via)) {
      messageDetails +=
          " "
              + String.format(
                  MyContextHolder.get().getLocale(),
                  context.getText(R.string.message_source_from).toString(),
                  oMsg.via);
    }
    if (oMsg.inReplyToMsgId != 0) {
      String inReplyToName = oMsg.inReplyToName;
      if (SharedPreferencesUtil.isEmpty(inReplyToName)) {
        inReplyToName = "...";
      }
      messageDetails +=
          " "
              + String.format(
                  MyContextHolder.get().getLocale(),
                  context.getText(R.string.message_source_in_reply_to).toString(),
                  oMsg.inReplyToName)
              + " ("
              + msgIdToHistoryOrder(oMsg.inReplyToMsgId)
              + ")";
    }
    if (!SharedPreferencesUtil.isEmpty(oMsg.rebloggersString)
        && !oMsg.rebloggersString.equals(oMsg.author)) {
      if (!SharedPreferencesUtil.isEmpty(oMsg.inReplyToName)) {
        messageDetails += ";";
      }
      messageDetails +=
          " "
              + String.format(
                  MyContextHolder.get().getLocale(),
                  context
                      .getText(ma.alternativeTermForResourceId(R.string.reblogged_by))
                      .toString(),
                  oMsg.rebloggersString);
    }
    if (!SharedPreferencesUtil.isEmpty(oMsg.recipientName)) {
      messageDetails +=
          " "
              + String.format(
                  MyContextHolder.get().getLocale(),
                  context.getText(R.string.message_source_to).toString(),
                  oMsg.recipientName);
    }
    if (MyLog.isLoggable(this, MyLog.VERBOSE)) {
      messageDetails = messageDetails + " (i" + oMsg.indentLevel + ",r" + oMsg.replyLevel + ")";
    }
    details.setText(messageDetails);
    ImageView favorited = (ImageView) messageView.findViewById(R.id.message_favorited);
    favorited.setImageResource(
        oMsg.favorited ? android.R.drawable.star_on : android.R.drawable.star_off);
    return messageView;
  }