Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

In this page you can find the example usage for android.widget LinearLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:fr.cph.chicago.core.activity.StationActivity.java

/**
 * Draw line//  ww  w .j a v  a 2  s.c o m
 *
 * @param eta the eta
 */
public void drawAllArrivalsTrain(@NonNull final Eta eta) {
    final TrainLine line = eta.getRouteName();
    final Stop stop = eta.getStop();
    final String key = line.toString() + "_" + stop.getDirection().toString();
    // viewId might be not there if CTA API provide wrong data
    if (ids.containsKey(key)) {
        final int viewId = ids.get(key);
        final LinearLayout line3View = (LinearLayout) findViewById(viewId);
        final Integer id = ids
                .get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName());
        if (id == null) {
            final LinearLayout insideLayout = new LinearLayout(this);
            insideLayout.setOrientation(LinearLayout.HORIZONTAL);
            insideLayout.setLayoutParams(paramsStop);
            final int newId = Util.generateViewId();
            insideLayout.setId(newId);
            ids.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId);

            final TextView stopName = new TextView(this);
            final String stopNameData = eta.getDestName() + ": ";
            stopName.setText(stopNameData);
            stopName.setTextColor(grey);
            stopName.setPadding(line3PaddingLeft, line3PaddingTop, 0, 0);
            insideLayout.addView(stopName);

            final TextView timing = new TextView(this);
            final String timingData = eta.getTimeLeftDueDelay() + " ";
            timing.setText(timingData);
            timing.setTextColor(grey);
            timing.setLines(1);
            timing.setEllipsize(TruncateAt.END);
            insideLayout.addView(timing);

            line3View.addView(insideLayout);
        } else {
            final LinearLayout insideLayout = (LinearLayout) findViewById(id);
            final TextView timing = (TextView) insideLayout.getChildAt(1);
            final String timingData = timing.getText() + eta.getTimeLeftDueDelay() + " ";
            timing.setText(timingData);
        }
        line3View.setVisibility(View.VISIBLE);
    }
}

From source file:com.nadmm.airports.afd.AirportDetailsFragment.java

protected void showRemarks(Cursor[] result) {
    int row = 0;/*from   w ww. j a  v  a  2 s . c  om*/
    TextView label = (TextView) findViewById(R.id.detail_remarks_label);
    LinearLayout layout = (LinearLayout) findViewById(R.id.detail_remarks_layout);
    Cursor rmk = result[2];
    if (rmk.moveToFirst()) {
        do {
            String remark = rmk.getString(rmk.getColumnIndex(Remarks.REMARK_TEXT));
            addBulletedRow(layout, remark);
            ++row;
        } while (rmk.moveToNext());
    }

    Cursor twr1 = result[3];
    Cursor twr7 = result[5];
    if (twr1.moveToFirst()) {
        String facilityType = twr1.getString(twr1.getColumnIndex(Tower1.FACILITY_TYPE));
        if (facilityType.equals("NON-ATCT") && twr7.getCount() == 0) {
            // Show remarks, if any, since there are no frequencies listed
            Cursor twr6 = result[6];
            if (twr6.moveToFirst()) {
                do {
                    String remark = twr6.getString(twr6.getColumnIndex(Tower6.REMARK_TEXT));
                    addBulletedRow(layout, remark);
                    ++row;
                } while (twr6.moveToNext());
            }
        }
    }

    if (row == 0) {
        label.setVisibility(View.GONE);
        layout.setVisibility(View.GONE);
    }
}

From source file:com.wit.and.dialog.LoginDialog.java

/**
 * /*from   w  w  w . j  a  va  2  s  . co  m*/
 */
@Override
protected View onCreateBodyView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();

    RelativeLayout layout = new RelativeLayout(context);
    // Apply neutral layout params.
    layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    // Do not allow to apply style to body view.
    // layout.setId(R.id.Dialog_Layout_Body);

    // Create layout for loading view.
    LinearLayout loadingLayout = new LinearLayout(context);
    loadingLayout.setOrientation(LinearLayout.HORIZONTAL);
    loadingLayout.setGravity(Gravity.CENTER_VERTICAL);
    // Allow styling of loading layout as body layout.
    loadingLayout.setId(R.id.And_Dialog_Layout_Body);

    // Create text view for message.
    TextView msgTextView = new TextView(context);
    msgTextView.setId(R.id.And_Dialog_TextView_Message);

    // Create circle progress bar.
    ProgressBar circleProgressBar = new ProgressBar(context);
    circleProgressBar.setId(R.id.And_Dialog_ProgressBar);

    // Build loading view.
    loadingLayout.addView(circleProgressBar, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    loadingLayout.addView(msgTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    loadingLayout.setVisibility(View.GONE);

    // Insert loading layout into main body layout.
    RelativeLayout.LayoutParams loadingLayoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    loadingLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(loadingLayout, loadingLayoutParams);

    // Create layout for edit texts.
    LinearLayout editLayout = new LinearLayout(context);
    editLayout.setOrientation(LinearLayout.VERTICAL);
    editLayout.setId(R.id.And_Dialog_Layout_LoginDialog_EditView);

    // Create edit texts for username and password.
    EditText userEdit = new EditText(context);
    userEdit.setId(R.id.And_Dialog_EditText_Username);
    userEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    EditText passEdit = new EditText(context);
    passEdit.setId(R.id.And_Dialog_EditText_Password);
    passEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

    // Create edit texts divider.
    DialogDivider divider = new DialogDivider(context);
    divider.setId(R.id.And_Dialog_Divider_LoginDialog_EditTexts);

    // Build edit layout.
    editLayout.addView(userEdit, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    editLayout.addView(divider, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    editLayout.addView(passEdit, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    // Add custom layout.
    View customView = onCreateCustomView(inflater, editLayout, savedInstanceState);
    if (customView != null) {
        editLayout.addView(this.mCustomView = customView);
    }

    // Insert edit layout into main body layout.
    RelativeLayout.LayoutParams editLayoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    editLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(editLayout, editLayoutParams);

    return layout;
}

From source file:org.openintents.notepad.NoteEditor.java

private void menuSearch() {
    LinearLayout searchLayout = (LinearLayout) findViewById(R.id.search);
    searchLayout.setVisibility(View.VISIBLE);
    EditText edt = (EditText) findViewById(R.id.edtSearchWord);
    edt.requestFocus();/*from  w  w w  .j  a  va 2  s.  c o m*/
}

From source file:org.openintents.notepad.NoteEditor.java

private void startupSearch() {
    String searchString = getIntent().getStringExtra("SEARCH_STRING");
    if (searchString != null && !searchString.equals("")) {
        LinearLayout searchLayout = (LinearLayout) findViewById(R.id.search);
        searchLayout.setVisibility(View.VISIBLE);
        EditText edt = (EditText) findViewById(R.id.edtSearchWord);
        edt.setText(searchString);/* w w  w. ja  va  2s.  c  o m*/
        mText.setSelection(0, 0);
        searchForward();
    }
}

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();//from   ww  w  .  j a  va  2s.  c  o  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:org.openintents.notepad.NoteEditor.java

private void initSearchPanel() {
    ImageButton mBtnForward = (ImageButton) findViewById(R.id.btnForward);
    mBtnForward.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            searchForward();//from ww w.java  2  s .  c o m
        }
    });
    ImageButton mBtnBackward = (ImageButton) findViewById(R.id.btnBackward);
    mBtnBackward.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            searchBackward();
        }
    });
    ImageButton btnClose = (ImageButton) findViewById(R.id.btnClose);
    btnClose.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LinearLayout searchLayout = (LinearLayout) findViewById(R.id.search);
            searchLayout.setVisibility(View.GONE);
        }
    });
}

From source file:android_network.hetnet.vpn_service.AdapterAccess.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    // Get values
    final long id = cursor.getLong(colID);
    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);
    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//  w  w  w  .ja v a2 s .  co m
    TextView tvTime = (TextView) view.findViewById(R.id.tvTime);
    ImageView ivBlock = (ImageView) view.findViewById(R.id.ivBlock);
    final TextView tvDest = (TextView) view.findViewById(R.id.tvDest);
    LinearLayout llTraffic = (LinearLayout) view.findViewById(R.id.llTraffic);
    TextView tvConnections = (TextView) view.findViewById(R.id.tvConnections);
    TextView tvTraffic = (TextView) 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);
        }
    }

    tvDest.setText(
            Util.getProtocolName(protocol, version, true) + " " + daddr + (dport > 0 ? "/" + dport : ""));

    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)));
}

From source file:eu.faircode.netguard.ActivityPro.java

private void updateState() {
    Button btnLog = findViewById(R.id.btnLog);
    Button btnFilter = findViewById(R.id.btnFilter);
    Button btnNotify = findViewById(R.id.btnNotify);
    Button btnSpeed = findViewById(R.id.btnSpeed);
    Button btnTheme = findViewById(R.id.btnTheme);
    Button btnAll = findViewById(R.id.btnAll);
    Button btnDev1 = findViewById(R.id.btnDev1);
    Button btnDev2 = findViewById(R.id.btnDev2);
    TextView tvLog = findViewById(R.id.tvLog);
    TextView tvFilter = findViewById(R.id.tvFilter);
    TextView tvNotify = findViewById(R.id.tvNotify);
    TextView tvSpeed = findViewById(R.id.tvSpeed);
    TextView tvTheme = findViewById(R.id.tvTheme);
    TextView tvAll = findViewById(R.id.tvAll);
    TextView tvDev1 = findViewById(R.id.tvDev1);
    TextView tvDev2 = findViewById(R.id.tvDev2);
    LinearLayout llChallenge = findViewById(R.id.llChallenge);

    TextView tvLogUnavailable = findViewById(R.id.tvLogUnavailable);
    TextView tvFilterUnavailable = findViewById(R.id.tvFilterUnavailable);

    boolean can = Util.canFilter(this);

    btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) || !can ? View.GONE : View.VISIBLE);
    btnFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) || !can ? View.GONE : View.VISIBLE);
    btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.GONE : View.VISIBLE);
    btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE);
    btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE);
    btnAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.GONE : View.VISIBLE);
    btnDev1.setVisibility(IAB.isPurchased(SKU_SUPPORT1, this) ? View.GONE : View.VISIBLE);
    btnDev2.setVisibility(IAB.isPurchased(SKU_SUPPORT2, this) ? View.GONE : View.VISIBLE);

    tvLog.setVisibility(IAB.isPurchased(SKU_LOG, this) && can ? View.VISIBLE : View.GONE);
    tvFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) && can ? View.VISIBLE : View.GONE);
    tvNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.VISIBLE : View.GONE);
    tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
    tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
    tvAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.VISIBLE : View.GONE);
    tvDev1.setVisibility(IAB.isPurchased(SKU_SUPPORT1, this) ? View.VISIBLE : View.GONE);
    tvDev2.setVisibility(IAB.isPurchased(SKU_SUPPORT2, this) ? View.VISIBLE : View.GONE);

    tvLogUnavailable.setVisibility(can ? View.GONE : View.VISIBLE);
    tvFilterUnavailable.setVisibility(can ? View.GONE : View.VISIBLE);

    llChallenge.setVisibility(
            IAB.isPurchased(SKU_DONATION, this) || Util.isPlayStoreInstall(this) ? View.GONE : View.VISIBLE);
}

From source file:com.xicheng.trid.hx.activity.ChatActivity.java

private void freshAlarmPreview() {
    //??//from w ww  .  java2s.com
    UserDao dao = new UserDao(ChatActivity.this);
    ChatAlarm myAlarm = dao.queryAlarm(toChatUsername);
    addAlarm = (ImageView) findViewById(R.id.add_alarm);
    LinearLayout r1 = (LinearLayout) findViewById(R.id.rl_1);
    LinearLayout r2 = (LinearLayout) findViewById(R.id.rl_2);
    TextView text23 = (TextView) findViewById(R.id.text_23);
    TextView text21 = (TextView) findViewById(R.id.text_21);

    if (myAlarm != null) {
        if (myAlarm.getContentForHe() != null)//
        {
            addAlarm.setVisibility(View.GONE);
            r1.setVisibility(View.VISIBLE);
            long longtime = Long.parseLong(myAlarm.getTimeForHe());
            String stringtime = AlarmUtils.LongToStringTime(longtime);
            String[] time = new String[2];
            time = stringtime.split(" ");
            //
            date1.setText(time[0]);
            time1.setText(time[1]);
            //
            content1.setText("* " + myAlarm.getContentForHe());
            //
            if (myAlarm.isTurnOnForHe == 1) {
                alarm_preview_but1.setChecked(true);
            } else {
                alarm_preview_but1.setChecked(false);
            }
        } else {
            addAlarm.setVisibility(View.VISIBLE);
            r1.setVisibility(View.GONE);
        }
        if (myAlarm.getContentForMe() != null)//
        {

            text21.setVisibility(View.VISIBLE);
            text23.setVisibility(View.GONE);
            r2.setVisibility(View.VISIBLE);

            //
            content2.setText("* " + myAlarm.getContentForMe());
            //
            long longtime = Long.parseLong(myAlarm.getTimeForMe());
            String stringtime = AlarmUtils.LongToStringTime(longtime);
            String[] time = new String[2];
            time = stringtime.split(" ");
            //
            date2.setText(time[0]);
            time2.setText(time[1]);
            //
            if (myAlarm.isTurnOnForMe == 1) {
                alarm_preview_but2.setChecked(true);
            } else {
                alarm_preview_but2.setChecked(false);
            }

        } else {
            text21.setVisibility(View.GONE);
            text23.setVisibility(View.VISIBLE);
            r2.setVisibility(View.GONE);

        }
    } else {
        addAlarm.setVisibility(View.VISIBLE);
        r1.setVisibility(View.GONE);
        text21.setVisibility(View.GONE);
        text23.setVisibility(View.VISIBLE);
        r2.setVisibility(View.GONE);
    }

}