android.widget.LinearLayout#setVisibility ( )源码实例Demo

下面列出了android.widget.LinearLayout#setVisibility ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FimiX8-RE   文件: CustomVideoView.java
private void showBar(boolean isShow) {
    int i;
    int i2 = 0;
    LinearLayout linearLayout = this.mTopBarLl;
    if (isShow) {
        i = 0;
    } else {
        i = 8;
    }
    linearLayout.setVisibility(i);
    RelativeLayout relativeLayout = this.mBottomPlayRl;
    if (!isShow) {
        i2 = 8;
    }
    relativeLayout.setVisibility(i2);
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String identityName = IdentityDBHelper.getInstance(this).getIdentityName(SqrlApplication.getCurrentId(this));
    TextView instructions = rootView.findViewById(R.id.txtLoginDescription);
    instructions.setText(getString(R.string.quickpass_enable_prompt, identityName));

    TextView domainPrompt = rootView.findViewById(R.id.txtLoginHeadline);
    domainPrompt.setText("");

    TextView domainText = rootView.findViewById(R.id.txtSite);
    domainText.setText("");
    domainText.setVisibility(GONE);

    LinearLayout toggleAdvancedFunctionsLayout = rootView.findViewById(R.id.toggleAdvancedFunctionsLayout);
    toggleAdvancedFunctionsLayout.setVisibility(GONE);

    Button buttonLogin = rootView.findViewById(R.id.btnLogin);
    buttonLogin.setText(R.string.enable_text);
}
 
源代码3 项目: AndroidTreeView   文件: TreeNodeWrapperView.java
private void init() {
    setOrientation(LinearLayout.VERTICAL);

    nodeContainer = new RelativeLayout(getContext());
    nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeContainer.setId(R.id.node_header);

    ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
    nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
    nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeItemsContainer.setId(R.id.node_items);
    nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
    nodeItemsContainer.setVisibility(View.GONE);

    addView(nodeContainer);
    addView(nodeItemsContainer);
}
 
private FragmentCharacteristicDetail initFragmentCharacteristicDetail(BluetoothGattCharacteristic bluetoothGattCharacteristic, int expansionId, BluetoothGattService service, LinearLayout characteristicExpansion, boolean displayWriteDialog) {
    FragmentManager fragmentManager = getFragmentManager();

    FragmentCharacteristicDetail characteristicDetail = new FragmentCharacteristicDetail();
    characteristicDetail.address = bluetoothGatt.getDevice().getAddress();
    characteristicDetail.setmService(service);
    characteristicDetail.setmBluetoothCharact(bluetoothGattCharacteristic);
    characteristicDetail.displayWriteDialog = displayWriteDialog;

    characteristicExpansion.setVisibility(View.VISIBLE);

    // show characteristic's expansion and add the fragment to view/edit characteristic detail
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(expansionId, characteristicDetail, CHARACTERISTIC_ADD_FRAGMENT_TRANSACTION_ID);
    fragmentTransaction.commit();

    return characteristicDetail;
}
 
源代码5 项目: FimiX8-RE   文件: X8RightIconForMapController.java
public void showLocation() {
    boolean isShow;
    int i;
    int i2 = 8;
    if (this.activity.getmMapVideoController().isFullVideo()) {
        isShow = false;
    } else {
        isShow = true;
    }
    ImageButton imageButton = this.imbLocation;
    if (isShow) {
        i = 0;
    } else {
        i = 8;
    }
    imageButton.setVisibility(i);
    LinearLayout linearLayout = this.vSetHomePoint;
    if (isShow) {
        i2 = 0;
    }
    linearLayout.setVisibility(i2);
}
 
源代码6 项目: LyricHere   文件: ColorPickerPreference.java
private void setPreviewColor() {
    if (mView == null) return;
    ImageView iView = new ImageView(getContext());
    LinearLayout widgetFrameView = ((LinearLayout) mView.findViewById(android.R.id.widget_frame));
    if (widgetFrameView == null) return;
    widgetFrameView.setVisibility(View.VISIBLE);
    widgetFrameView.setPadding(
            widgetFrameView.getPaddingLeft(),
            widgetFrameView.getPaddingTop(),
            (int) (mDensity * 8),
            widgetFrameView.getPaddingBottom()
    );
    // remove already create preview image
    int count = widgetFrameView.getChildCount();
    if (count > 0) {
        widgetFrameView.removeViews(0, count);
    }
    widgetFrameView.addView(iView);
    widgetFrameView.setMinimumWidth(0);
    iView.setBackgroundDrawable(new AlphaPatternDrawable((int) (5 * mDensity)));
    iView.setImageBitmap(getPreviewBitmap());
}
 
源代码7 项目: WifiChat   文件: BaseDialog.java
private void initViews() {
    mLayoutRoot = (LinearLayout) findViewById(R.id.dialog_generic_layout_root);
    mLayoutTop = (LinearLayout) findViewById(R.id.dialog_generic_layout_top);
    mLayoutTitle = (LinearLayout) findViewById(R.id.dialog_generic_layout_title);
    mHtvTitle = (TextView) findViewById(R.id.dialog_generic_htv_title);
    mViewTitleLine = findViewById(R.id.dialog_generic_view_titleline);
    mLayoutContent = (LinearLayout) findViewById(R.id.dialog_generic_layout_content);
    mHtvMessage = (TextView) findViewById(R.id.dialog_generic_htv_message);
    mLayoutBottom = (LinearLayout) findViewById(R.id.dialog_generic_layout_bottom);
    mBtnButton1 = (Button) findViewById(R.id.dialog_generic_btn_button1);
    mBtnButton2 = (Button) findViewById(R.id.dialog_generic_btn_button2);
    mBtnButton3 = (Button) findViewById(R.id.dialog_generic_btn_button3);
    mLayoutRoot.setVisibility(View.VISIBLE);
    setTitleLineVisibility(View.VISIBLE);

}
 
源代码8 项目: YTPlayer   文件: YTutils.java
public static void addADView(Activity activity, LinearLayout l) {
    l.setVisibility(View.VISIBLE);
    int number = ThreadLocalRandom.current().nextInt(1, 4);
    l.removeAllViews();
    int layout;// = R.layout.ad_banner;
    if (number==1) {
        layout = R.layout.ad_banner;
        link = "https://androdevkit.github.io";
    }else if (number==2) {
        layout = R.layout.ad_banner_2;
        link = "https://github.com/KaustubhPatange/Kling";
    }else {
        layout = R.layout.ad_banner_3;
        link = "https://kaustubhpatange.github.io/Iso2Usb";
    }
    View v = LayoutInflater.from(activity).inflate(layout,null);
    v.findViewById(R.id.ad_banner_click).setOnClickListener(view ->
            YTutils.StartURL(link,activity));
    l.addView(v);
}
 
源代码9 项目: Mupdf   文件: DocActivityView.java
protected void hidePages()
{
	LinearLayout pages = (LinearLayout) findViewById(R.id.pages_container);
	if (null == pages)
		return;

	if (pages.getVisibility() == View.GONE)
		return;

	pages.setVisibility(View.GONE);
	ViewTreeObserver observer = mDocView.getViewTreeObserver();
	observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
	{
		@Override
		public void onGlobalLayout()
		{
			mDocView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
			mDocView.onHidePages();
		}
	});
}
 
源代码10 项目: PowerFileExplorer   文件: CloudSheetFragment.java
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);

    rootView = getActivity().getLayoutInflater().inflate(R.layout.fragment_sheet_cloud, null);

    if (((ExplorerActivity) getActivity()).getAppTheme().equals(AppTheme.DARK)) {
        rootView.setBackgroundColor(Utils.getColor(getContext(), R.color.holo_dark_background));
    } else {
        rootView.setBackgroundColor(Utils.getColor(getContext(), android.R.color.white));
    }

    mSmbLayout = (LinearLayout) rootView.findViewById(R.id.linear_layout_smb);
    mBoxLayout = (LinearLayout) rootView.findViewById(R.id.linear_layout_box);
    mDropboxLayout = (LinearLayout) rootView.findViewById(R.id.linear_layout_dropbox);
    mGoogleDriveLayout = (LinearLayout) rootView.findViewById(R.id.linear_layout_google_drive);
    mOnedriveLayout = (LinearLayout) rootView.findViewById(R.id.linear_layout_onedrive);
    mGetCloudLayout = (LinearLayout) rootView.findViewById(R.id.linear_layout_get_cloud);

    if (isCloudProviderAvailable(getContext())) {

        mBoxLayout.setVisibility(View.VISIBLE);
        mDropboxLayout.setVisibility(View.VISIBLE);
        mGoogleDriveLayout.setVisibility(View.VISIBLE);
        mOnedriveLayout.setVisibility(View.VISIBLE);
        mGetCloudLayout.setVisibility(View.GONE);
    }

    mSmbLayout.setOnClickListener(this);
    mBoxLayout.setOnClickListener(this);
    mDropboxLayout.setOnClickListener(this);
    mGoogleDriveLayout.setOnClickListener(this);
    mOnedriveLayout.setOnClickListener(this);
    mGetCloudLayout.setOnClickListener(this);

    dialog.setContentView(rootView);
}
 
源代码11 项目: android-chromium   文件: CertificateViewer.java
private void showCertificateChain(byte[][] derData) {
    for (int i = 0; i < derData.length; i++) {
        addCertificate(derData[i]);
    }
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item,
            mTitles);
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    Spinner spinner = new Spinner(mContext);
    spinner.setAdapter(arrayAdapter);
    spinner.setOnItemSelectedListener(this);

    LinearLayout container = new LinearLayout(mContext);
    container.setOrientation(LinearLayout.VERTICAL);
    container.addView(spinner);

    for (int i = 0; i < mViews.size(); ++i) {
        LinearLayout certificateView = mViews.get(i);
        if (i != 0) {
            certificateView.setVisibility(LinearLayout.GONE);
        }
        container.addView(certificateView);
    }

    showDialogForView(container);
}
 
源代码12 项目: Chorus-RF-Laptimer   文件: RaceSetupFragment.java
private void updateLiPoMonitorCheckbox(View rootView) {
    boolean isEnabled = AppState.getInstance().isLiPoMonitorEnabled;
    CheckBox chkLiPoMonitor = (CheckBox) rootView.findViewById(R.id.chkLiPoMonitor);
    chkLiPoMonitor.setChecked(isEnabled);
    LinearLayout layoutVoltage = (LinearLayout) rootView.findViewById(R.id.layoutVoltage);
    layoutVoltage.setVisibility(isEnabled ? View.VISIBLE : View.GONE);
    LinearLayout layoutAdjustment = (LinearLayout) rootView.findViewById(R.id.adjustmentLayout);
    layoutAdjustment.setVisibility(View.GONE);
}
 
源代码13 项目: whiteboard   文件: Painter.java
/**
 * 
 * @description: ��ʼ��������ͼ
 * @date: 2015-3-16 ����1:42:09
 * @author�� yems
 */
private void setView()
{
	mCanvas = (PainterCanvasControl) findViewById(R.id.canvas);
	mBrushSize = (SeekBar) findViewById(R.id.brush_size);
	mPropertiesBar = (LinearLayout) findViewById(R.id.properties_bar);
	mSettingsLayout = (RelativeLayout) findViewById(R.id.settings_layout);
	changeBrushColor = (ImageButton) findViewById(R.id.bt_change_brush_color);
	mPropertiesBar.setVisibility(View.INVISIBLE);
}
 
源代码14 项目: Primary   文件: MainActivity.java
private void showNewUserArea(boolean show, boolean edit) {
    LinearLayout new_user_area = findViewById(R.id.login_new_user_area);
    TextView nametxt = findViewById(R.id.username_input);
    Spinner avatarspinner = findViewById(R.id.user_avatar_spinner);
    Button user_change_button = findViewById(R.id.user_change_button);
    Button user_added_button = findViewById(R.id.user_added_button);


    nametxt.setEnabled(!edit);
    if (edit) {
        user_added_button.setVisibility(View.GONE);
        user_change_button.setVisibility(View.VISIBLE);
        UserData user = appdata.getUser(userlist.getSelected());
        if (user != null) {
            populateAvatarSpinner(user.getAvatar());
            nametxt.setText(user.getUsername());
            int aindex = avatarlist.indexOf(user.getAvatar());
            avatarspinner.setSelection(aindex);
        }

    } else {
        avatarspinner.setSelection((int) (Math.random() * avatarlist.size()));
        nametxt.setText("");
        user_added_button.setVisibility(View.VISIBLE);
        user_change_button.setVisibility(View.GONE);

    }

    if (show) {
        new_user_area.setVisibility(View.VISIBLE);
        new_user_shown = true;
        selectUser(null);
    } else {
        new_user_area.setVisibility(View.GONE);
        new_user_shown = false;
    }
    showSteps2and3(false);
}
 
private void setupDataEntryButton(View root) {
    dataEntryButton = (LinearLayout) root.findViewById(R.id.user_data_entry);
    formTextView = (TextView) root.findViewById(R.id.choosen_form);
    formDescriptionTextView = (TextView) root.findViewById(R.id.form_description);
    organisationUnitTextView = (TextView) root.findViewById(R.id.choosen_unit);
    offlineSavedIcon = (ImageView) root.findViewById(R.id.offline_saved_icon);

    dataEntryButton.setVisibility(View.GONE);
}
 
源代码16 项目: emoji-keyboard   文件: EmojiKeyboardLayout.java
private void init(Context context, AttributeSet attrs) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.rsc_emoji_keyboard, this, true);
    this.findViewById(R.id.emoji_keyboard).setVisibility(RelativeLayout.VISIBLE);
    LinearLayout curtain = (LinearLayout) this.findViewById(R.id.curtain);
    curtain.setVisibility(LinearLayout.INVISIBLE);
}
 
源代码17 项目: Effects-Pro   文件: PhotoActivity.java
private void displayEffectHolder() {
	hideEffectsBox(true);
	hideLoading();

	if (selected_effect.equals("hue")) {

		hue_value.setProgress(180);
		modifyHueHolder();
		hue_value.setOnSeekBarChangeListener(onHueChange);

	} else if (selected_effect.equals("brightness")) {

		bright_value.setProgress(200);
		modifyBrightnessHolder();
		bright_value.setOnSeekBarChangeListener(onBrightChange);

	} else if (selected_effect.equals("contrast")) {

		cont_value.setProgress(50);
		modifyContrastHolder();
		cont_value.setOnSeekBarChangeListener(onContChange);

	} else if (selected_effect.equals("flip")) {

		flip_h = false;
		flip_v = false;
		rotate_value.setProgress(0);
		modifyRotateHolder();
		rotate_value.setOnSeekBarChangeListener(onRotateChange);

	} else if (selected_effect.equals("gamma")) {

		gRed_value.setProgress(24);
		gGreen_value.setProgress(24);
		gBlue_value.setProgress(24);
		modifyGammaHolder();
		gRed_value.setOnSeekBarChangeListener(onGRedChange);
		gGreen_value.setOnSeekBarChangeListener(onGGreenChange);
		gBlue_value.setOnSeekBarChangeListener(onGBlueChange);

	} else if (selected_effect.equals("cdepth")) {

		cdepth_value.setProgress(1);
		modifyCDepthHolder();
		cdepth_value.setOnSeekBarChangeListener(onCDepthChange);

	} else if (selected_effect.equals("cbalance")) {

		bRed_value.setProgress(100);
		bGreen_value.setProgress(100);
		bBlue_value.setProgress(100);
		modifyBalanceHolder();
		bRed_value.setOnSeekBarChangeListener(onBRedChange);
		bGreen_value.setOnSeekBarChangeListener(onBGreenChange);
		bBlue_value.setOnSeekBarChangeListener(onBBlueChange);

	} else if (selected_effect.equals("boost")) {

		boost_type = 1;
		boost_value.setProgress(100);
		modifyBoostHolder();
		boost_value.setOnSeekBarChangeListener(onBoostChange);

	} else if (selected_effect.equals("saturation")) {

		sat_value.setProgress(100);
		modifySaturationHolder();
		sat_value.setOnSeekBarChangeListener(onSatChange);

	}

	holder_target = (LinearLayout) findViewById(getResources().getIdentifier("holder_" + selected_effect, "id", getPackageName()));

	/*
	// SET MAX SIZE FOR TOOL BOX OF FILTER
	DisplayMetrics metrics = getResources().getDisplayMetrics();
	holder_target.getLayoutParams().width = Math.min(700, metrics.widthPixels);
	holder_target.requestLayout();
	 */

	holder_target.setVisibility(View.VISIBLE);
	apply_set.setVisibility(View.VISIBLE);

	animation = AnimationUtils.loadAnimation(this, R.anim.holder_bottom_fast);
	holder_target.startAnimation(animation);

	animation = AnimationUtils.loadAnimation(this, R.anim.holder_top_fast);
	apply_set.startAnimation(animation);
}
 
源代码18 项目: adt-leanback-support   文件: ListFragment.java
/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 * 
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

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

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null,
            android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

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

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    return root;
}
 
源代码19 项目: NetGuard   文件: AdapterAccess.java
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    // Get values
    final int version = cursor.getInt(colVersion);
    final int protocol = cursor.getInt(colProtocol);
    final String daddr = cursor.getString(colDaddr);
    final int dport = cursor.getInt(colDPort);
    long time = cursor.getLong(colTime);
    int allowed = cursor.getInt(colAllowed);
    int block = cursor.getInt(colBlock);
    int count = cursor.getInt(colCount);
    long sent = cursor.isNull(colSent) ? -1 : cursor.getLong(colSent);
    long received = cursor.isNull(colReceived) ? -1 : cursor.getLong(colReceived);
    int connections = cursor.isNull(colConnections) ? -1 : cursor.getInt(colConnections);

    // Get views
    TextView tvTime = view.findViewById(R.id.tvTime);
    ImageView ivBlock = view.findViewById(R.id.ivBlock);
    final TextView tvDest = view.findViewById(R.id.tvDest);
    LinearLayout llTraffic = view.findViewById(R.id.llTraffic);
    TextView tvConnections = view.findViewById(R.id.tvConnections);
    TextView tvTraffic = view.findViewById(R.id.tvTraffic);

    // Set values
    tvTime.setText(new SimpleDateFormat("dd HH:mm").format(time));
    if (block < 0)
        ivBlock.setImageDrawable(null);
    else {
        ivBlock.setImageResource(block > 0 ? R.drawable.host_blocked : R.drawable.host_allowed);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            Drawable wrap = DrawableCompat.wrap(ivBlock.getDrawable());
            DrawableCompat.setTint(wrap, block > 0 ? colorOff : colorOn);
        }
    }

    String dest = Util.getProtocolName(protocol, version, true) +
            " " + daddr + (dport > 0 ? "/" + dport : "") + (count > 1 ? " ?" + count : "");
    SpannableString span = new SpannableString(dest);
    span.setSpan(new UnderlineSpan(), 0, dest.length(), 0);
    tvDest.setText(span);

    if (Util.isNumericAddress(daddr))
        new AsyncTask<String, Object, String>() {
            @Override
            protected void onPreExecute() {
                ViewCompat.setHasTransientState(tvDest, true);
            }

            @Override
            protected String doInBackground(String... args) {
                try {
                    return InetAddress.getByName(args[0]).getHostName();
                } catch (UnknownHostException ignored) {
                    return args[0];
                }
            }

            @Override
            protected void onPostExecute(String addr) {
                tvDest.setText(
                        Util.getProtocolName(protocol, version, true) +
                                " >" + addr + (dport > 0 ? "/" + dport : ""));
                ViewCompat.setHasTransientState(tvDest, false);
            }
        }.execute(daddr);

    if (allowed < 0)
        tvDest.setTextColor(colorText);
    else if (allowed > 0)
        tvDest.setTextColor(colorOn);
    else
        tvDest.setTextColor(colorOff);

    llTraffic.setVisibility(connections > 0 || sent > 0 || received > 0 ? View.VISIBLE : View.GONE);
    if (connections > 0)
        tvConnections.setText(context.getString(R.string.msg_count, connections));

    if (sent > 1024 * 1204 * 1024L || received > 1024 * 1024 * 1024L)
        tvTraffic.setText(context.getString(R.string.msg_gb,
                (sent > 0 ? sent / (1024 * 1024 * 1024f) : 0),
                (received > 0 ? received / (1024 * 1024 * 1024f) : 0)));
    else if (sent > 1204 * 1024L || received > 1024 * 1024L)
        tvTraffic.setText(context.getString(R.string.msg_mb,
                (sent > 0 ? sent / (1024 * 1024f) : 0),
                (received > 0 ? received / (1024 * 1024f) : 0)));
    else
        tvTraffic.setText(context.getString(R.string.msg_kb,
                (sent > 0 ? sent / 1024f : 0),
                (received > 0 ? received / 1024f : 0)));
}
 
源代码20 项目: framework   文件: OdooActivity.java
private void setupAccountBox() {
    mDrawerAccountContainer = (LinearLayout) findViewById(R.id.accountList);
    View chosenAccountView = findViewById(R.id.drawerAccountView);
    OUser currentUser = OUser.current(this);
    if (currentUser == null) {
        chosenAccountView.setVisibility(View.GONE);
        mDrawerAccountContainer.setVisibility(View.GONE);
        return;
    } else {
        chosenAccountView.setVisibility(View.VISIBLE);
        mDrawerAccountContainer.setVisibility(View.INVISIBLE);
    }

    ImageView avatar = (ImageView) chosenAccountView.findViewById(R.id.profile_image);
    TextView name = (TextView) chosenAccountView.findViewById(R.id.profile_name_text);
    TextView url = (TextView) chosenAccountView.findViewById(R.id.profile_url_text);

    name.setText(currentUser.getName());
    url.setText(currentUser.getHost());

    if (!currentUser.getAvatar().equals("false")) {
        Bitmap bitmap = BitmapUtils.getBitmapImage(this, currentUser.getAvatar());
        if (bitmap != null)
            avatar.setImageBitmap(bitmap);
    }

    // Setting Accounts
    List<OUser> accounts = OdooAccountManager.getAllAccounts(this);
    if (accounts.size() > 0) {
        chosenAccountView.setEnabled(true);
        ImageView boxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator);
        boxIndicator.setVisibility(View.VISIBLE);
        chosenAccountView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAccountBoxExpanded = !mAccountBoxExpanded;
                accountBoxToggle();
            }
        });
        populateAccountList(currentUser, accounts);
    }
}