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

The following examples show how to use android.widget.Button#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: CommonAlertDialog.java    From Awesome-WanAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Show alertDialog
 *
 * @param mActivity activity instance
 * @param content show content
 * @param btnContent btn content
 * @param onClickListener btn onClickListener
 */
public void showDialog(Activity mActivity, String content, String btnContent, final View.OnClickListener onClickListener) {
    if (mActivity == null) {
        return;
    }
    if (alertDialog == null) {
        alertDialog = new AlertDialog.Builder(mActivity, R.style.myCorDialog).create();
    }
    if (!alertDialog.isShowing()) {
        alertDialog.show();
    }
    alertDialog.setCanceledOnTouchOutside(false);
    Window window = alertDialog.getWindow();
    if (window != null) {
        window.setContentView(R.layout.common_alert_dialog);
        TextView contentTv = (TextView) window.findViewById(R.id.dialog_content);
        contentTv.setText(content);
        Button mOkBtn = (Button) window.findViewById(R.id.dialog_btn);
        mOkBtn.setText(btnContent);
        mOkBtn.setOnClickListener(onClickListener);
        View btnDivider = window.findViewById(R.id.dialog_btn_divider);
        btnDivider.setVisibility(View.GONE);
        Button mNeBtn = (Button) window.findViewById(R.id.dialog_negative_btn);
        mNeBtn.setVisibility(View.GONE);
    }
}
 
Example 2
Source File: ConfirmView.java    From confirmdialog with Apache License 2.0 6 votes vote down vote up
private View getVwContent() {
  View contentView = LayoutInflater.from(context).inflate(R.layout.view_confirm, this, false);
  ViewGroup cntViewGroup = (ViewGroup) contentView.findViewById(R.id.alert_content);
  FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(WRAP_CONTENT,
      WRAP_CONTENT);
  layoutParams.gravity = Gravity.CENTER;
  cntViewGroup.addView(vwContent, layoutParams);
  btnPositive = (Button) contentView.findViewById(R.id.btn_confirm);
  btnNegative = (Button) contentView.findViewById(R.id.btn_cancel);
  btnPositive.setText(positive);
  btnNegative.setText(negative);
  btnPositive.setOnClickListener(this);
  btnNegative.setOnClickListener(this);

  if (TextUtils.isEmpty(positive)) {
    btnPositive.setVisibility(View.GONE);
  }
  if (TextUtils.isEmpty(negative)) {
    btnNegative.setVisibility(View.GONE);
  }
  return contentView;
}
 
Example 3
Source File: GraphicActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void resetView() {
	setContentView(R.layout.activity_graphic);

	playBtn = (Button)findViewById(R.id.playButton);
	downloadBtn = (Button)findViewById(R.id.downloadButton);
	try{
		super.resetView();
		
	}catch(Exception e){
		MainActivity.showMessage(e.getMessage(), this);
	}
	
	
	if (instance.isExternal) {
		findViewById(R.id.playButton).setVisibility(View.GONE);
		findViewById(R.id.downloadButton).setVisibility(View.GONE);
	}
	
	if(gInstance.isVideo() || gInstance.isAudio()){
		downloadBtn.setVisibility(View.VISIBLE);
		playBtn.setText(R.string.play);
	}else {
		downloadBtn.setVisibility(View.VISIBLE);
		playBtn.setText(R.string.view);
	}
	
}
 
Example 4
Source File: MainActivity.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
public void newData(View view) {
    EditText edit = (EditText) findViewById(R.id.EditS);
    TextView newName = (TextView) findViewById(R.id.bestName);
    TextView newScore = (TextView) findViewById(R.id.bestScore);
    TextView currScore = (TextView) findViewById(R.id.nowScore);
    newName.setText(edit.getText());
    newScore.setText(currScore.getText());
    saved.edit().putString("Name", edit.getText() + "").apply();
    saved.edit().putInt("Score", Integer.parseInt(currScore.getText() + "")).apply();
    TextView high2 = (TextView) findViewById(R.id.newHighS2);
    Button btn = (Button) findViewById(R.id.button);
    edit.setVisibility(View.INVISIBLE);
    high2.setVisibility(View.INVISIBLE);
    btn.setVisibility(View.INVISIBLE);
}
 
Example 5
Source File: SolveActivity.java    From DebugRank with Apache License 2.0 5 votes vote down vote up
private void showShowcase(ViewTarget viewTarget, @StringRes int titleResId, @StringRes int descriptionResId)
{
    Button button = new Button(this);
    button.setVisibility(View.GONE);

    compileShowcaseView = new ShowcaseView.Builder(this)
            .withNewStyleShowcase()
            .setStyle(R.style.CustomShowcaseTheme2)
            .setTarget(viewTarget)
            .setContentTitle(titleResId)
            .setContentText(descriptionResId)
            .replaceEndButton(button)
            .build();
}
 
Example 6
Source File: CommonAlertDialog.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Show alertDialog
 *
 * @param mActivity activity instance
 * @param content show content
 * @param btnContent btn content
 */
public void showDialog(Activity mActivity, String content, String btnContent) {
    if (mActivity == null) {
        return;
    }
    if (alertDialog == null) {
        alertDialog = new AlertDialog.Builder(mActivity, R.style.myCorDialog).create();
    }
    if (!alertDialog.isShowing()) {
        alertDialog.show();
    }
    alertDialog.setCanceledOnTouchOutside(false);
    Window window = alertDialog.getWindow();
    if (window != null) {
        window.setContentView(R.layout.common_alert_dialog);
        TextView contentTv = (TextView) window.findViewById(R.id.dialog_content);
        contentTv.setText(content);
        Button mOkBtn = (Button) window.findViewById(R.id.dialog_btn);
        mOkBtn.setText(btnContent);
        mOkBtn.setOnClickListener(v -> {
            if (alertDialog != null) {
                alertDialog.cancel();
                alertDialog = null;
            }
        });
        View btnDivider = window.findViewById(R.id.dialog_btn_divider);
        btnDivider.setVisibility(View.GONE);
        Button mNeBtn = (Button) window.findViewById(R.id.dialog_negative_btn);
        mNeBtn.setVisibility(View.GONE);
    }
}
 
Example 7
Source File: HotStatusesActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
private void bindEvent() {
	Button btnBack = (Button)this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnOperate = (Button) this.findViewById(R.id.btnOperate);
	btnOperate.setVisibility(View.VISIBLE);
	btnOperate.setText(R.string.btn_home);
	btnOperate.setOnClickListener(new GoHomeClickListener());
	
	ListView  lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
	lvMicroBlog.setOnItemClickListener(new MicroBlogItemClickListener(this));
	MicroBlogContextMenuListener contextMenuListener =
		new MicroBlogContextMenuListener(lvMicroBlog);
	lvMicroBlog.setOnCreateContextMenuListener(contextMenuListener);
}
 
Example 8
Source File: SettingsActivity.java    From echo with GNU General Public License v3.0 5 votes vote down vote up
private void initSampleRateButton(ViewGroup layout, int buttonId, int primarySampleRate, int secondarySampleRate) {
    Button button = (Button) layout.findViewById(buttonId);
    button.setOnClickListener(qualityClickListener);
    if(testSampleRateValid(primarySampleRate)) {
        button.setText(String.format("%d kHz", primarySampleRate / 1000));
        button.setTag(primarySampleRate);
    } else if(testSampleRateValid(secondarySampleRate)) {
        button.setText(String.format("%d kHz", secondarySampleRate / 1000));
        button.setTag(secondarySampleRate);
    } else {
        button.setVisibility(View.GONE);
    }
}
 
Example 9
Source File: SelectOneWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private void addClearButton(Context context, boolean show) {
    clearButton = (Button) LayoutInflater.from(context).inflate(R.layout.blue_outlined_button, this, false);
    clearButton.setText(Localization.get("button.clear.title"));
    clearButton.setVisibility(show ? VISIBLE : GONE);
    clearButton.setOnClickListener(view -> {
        clearAnswer();
        widgetEntryChanged();
    });
    addView(clearButton);
}
 
Example 10
Source File: SendScreen.java    From smartcoins-wallet with MIT License 5 votes vote down vote up
private void showDialogPin(final Boolean fundTransfer) {
    final ArrayList<AccountDetails> accountDetails = tinyDB.getListObject(getString(R.string.pref_wallet_accounts), AccountDetails.class);
    final Dialog dialog = new Dialog(SendScreen.this);
    dialog.setTitle(R.string.title_prompt_pin);
    dialog.setContentView(R.layout.activity_alert_pin_dialog);
    Button btnDone = (Button) dialog.findViewById(R.id.btnDone);
    btnDone.setVisibility(View.VISIBLE);
    final EditText etPin = (EditText) dialog.findViewById(R.id.etPin);
    btnDone.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < accountDetails.size(); i++) {
                if (accountDetails.get(i).isSelected) {
                    if (etPin.getText().toString().equals(accountDetails.get(i).pinCode)) {
                        dialog.cancel();
                        if (fundTransfer) {
                            String transferFunds = getString(R.string.transfer_funds) + "...";
                            showDialog("", transferFunds);
                            tradeAsset();
                        } else {
                            sendFunds(false);
                        }
                        break;
                    }
                }
            }

        }
    });
    dialog.setCancelable(true);

    dialog.show();
}
 
Example 11
Source File: ECAlertDialog.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置按钮
 * @param id 按钮号
 * @param text 按钮显示文本
 * @param listener
 * @return
 */
public final Button setButton(int id , CharSequence text , OnClickListener listener) {
    Button button = mButtons.get(id);
    button.setText(text);
    button.setVisibility(View.VISIBLE);
    setButtonTag(id, listener);
    mLayoutButton.setVisibility(View.VISIBLE);
    return button;
}
 
Example 12
Source File: CustomDialog.java    From qingyang with Apache License 2.0 5 votes vote down vote up
/**
 * 设置dialog的确定按钮
 */
public void setPositiveButton(String text, OnClickListener onClickListener) {
	final Button buttonOk = (Button) mRootLayout
			.findViewById(R.id.custom_dialog_btn_ok);
	buttonOk.setText(text);
	buttonOk.setOnClickListener(onClickListener);
	buttonOk.setVisibility(View.VISIBLE);
}
 
Example 13
Source File: ImportTokenActivity.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
private void displayImportAction()
{
    Token token = viewModel.getImportToken();
    Button importTickets = findViewById(R.id.import_ticket);
    importTickets.setVisibility(View.VISIBLE);
    importTickets.setAlpha(1.0f);

    MagicLinkData data = viewModel.getSalesOrder();
    //Customise button text
    View baseView = findViewById(android.R.id.content);

    switch (data.contractType)
    {
        case spawnable:
            importTickets.setText(R.string.action_import);
            if (token != null) 
                tokenView.displayTicketHolder(token, ticketRange, viewModel.getAssetDefinitionService());
            break;
        case currencyLink:
            importTickets.setText(R.string.action_import);
            break;
        default:
            importTxt.setText(R.string.ticket_import_valid);
            if (token != null) 
                tokenView.displayTicketHolder(token, ticketRange, viewModel.getAssetDefinitionService());
            break;
    }
}
 
Example 14
Source File: CanDialog.java    From CanDialog with Apache License 2.0 4 votes vote down vote up
/**
 * button的点击事件可返回点击item的position,text,单选中的position,多选的选择状态等。
 *
 * @param button   Button
 * @param text     CharSequence
 * @param dismiss  boolean
 * @param listener CanDialogInterface
 */
private void setButton(Button button, CharSequence text, final boolean dismiss, final CanDialogInterface.OnClickListener listener) {
    mButtonPanel.setVisibility(View.VISIBLE);
    button.setVisibility(View.VISIBLE);
    button.setText(text);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {

            hideSoftInput();

            if (listener != null) {

                switch (mType) {
                    case DIALOG_EDIT:
                        final EditText etPwd = (EditText) findViewById(R.id.et_pwd);
                        listener.onClick(mDialog, 0, etPwd.getText().toString(), null);
                        break;

                    case DIALOG_SINGLE_CHOICE:
                        listener.onClick(mDialog, checkedItem, null, null);
                        break;

                    case DIALOG_MULTI_CHOICE:
                        listener.onClick(mDialog, 0, null, checkedItems);
                        break;
                    default:
                        listener.onClick(mDialog, 0, null, null);
                        break;
                }

            }


            if (dismiss) {
                dismiss();
            }


        }
    });


}
 
Example 15
Source File: DynamicAlertController.java    From dynamic-support with Apache License 2.0 4 votes vote down vote up
private void setupButtons(ViewGroup buttonPanel) {
    int BIT_BUTTON_POSITIVE = 1;
    int BIT_BUTTON_NEGATIVE = 2;
    int BIT_BUTTON_NEUTRAL = 4;
    int whichButtons = 0;
    mButtonPositive = (Button) buttonPanel.findViewById(android.R.id.button1);
    mButtonPositive.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonPositiveText) && mButtonPositiveIcon == null) {
        mButtonPositive.setVisibility(View.GONE);
    } else {
        mButtonPositive.setText(mButtonPositiveText);
        if (mButtonPositiveIcon != null) {
            mButtonPositiveIcon.setBounds(0, 0, mButtonIconDimen, mButtonIconDimen);
            mButtonPositive.setCompoundDrawables(mButtonPositiveIcon, null, null, null);
        }
        mButtonPositive.setVisibility(View.VISIBLE);
        whichButtons = whichButtons | BIT_BUTTON_POSITIVE;
    }

    mButtonNegative = buttonPanel.findViewById(android.R.id.button2);
    mButtonNegative.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNegativeText) && mButtonNegativeIcon == null) {
        mButtonNegative.setVisibility(View.GONE);
    } else {
        mButtonNegative.setText(mButtonNegativeText);
        if (mButtonNegativeIcon != null) {
            mButtonNegativeIcon.setBounds(0, 0, mButtonIconDimen, mButtonIconDimen);
            mButtonNegative.setCompoundDrawables(mButtonNegativeIcon, null, null, null);
        }
        mButtonNegative.setVisibility(View.VISIBLE);
        whichButtons = whichButtons | BIT_BUTTON_NEGATIVE;
    }

    mButtonNeutral = (Button) buttonPanel.findViewById(android.R.id.button3);
    mButtonNeutral.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNeutralText) && mButtonNeutralIcon == null) {
        mButtonNeutral.setVisibility(View.GONE);
    } else {
        mButtonNeutral.setText(mButtonNeutralText);
        if (mButtonPositiveIcon != null) {
            mButtonPositiveIcon.setBounds(0, 0, mButtonIconDimen, mButtonIconDimen);
            mButtonPositive.setCompoundDrawables(mButtonPositiveIcon, null, null, null);
        }
        mButtonNeutral.setVisibility(View.VISIBLE);
        whichButtons = whichButtons | BIT_BUTTON_NEUTRAL;
    }

    if (shouldCenterSingleButton(mContext)) {
        /*
         * If we only have 1 button it should be centered on the layout and
         * expand to fill 50% of the available space.
         */
        if (whichButtons == BIT_BUTTON_POSITIVE) {
            centerButton(mButtonPositive);
        } else if (whichButtons == BIT_BUTTON_NEGATIVE) {
            centerButton(mButtonNegative);
        } else if (whichButtons == BIT_BUTTON_NEUTRAL) {
            centerButton(mButtonNeutral);
        }
    }

    final boolean hasButtons = whichButtons != 0;
    if (!hasButtons) {
        buttonPanel.setVisibility(View.GONE);
    }
}
 
Example 16
Source File: OnboardingFragment.java    From Onboarder with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_onboarding, container, false);

    // Inflate the layout for this fragment
    Bundle bundle = getArguments();

    /* The title which is displayed at the top of the fragment */
    String title = bundle.getString(TITLE, null);
    /* The body text which is displayed in the middle of the fragment */
    String bodyText = bundle.getString(BODY_TEXT, null);
    /* The image resource which is displayed in the middle of the fragment, above the text */
    int imageResId = bundle.getInt(IMAGE_RESOURCE_ID, -1);
    /* The position that the fragment is in adapter */
    final int position = bundle.getInt(POSITION, 0);
    /* The button text (if the user set any) */
    String buttonText = bundle.getString(BUTTON_TEXT, null);
    /* Max height for the image (if not, it just scales it up) */
    int maxImageHeight = bundle.getInt(MAX_IMAGE_HEIGHT,-1);

    @ColorRes int titleTextColor = bundle.getInt(TITLE_TEXT_COLOR, -1);
    @ColorRes int bodyTextColor = bundle.getInt(BODY_TEXT_COLOR,-1);

    TextView titleTextView = (TextView) view.findViewById(R.id.onboarding_fragment_title);
    TextView bodyTextView = (TextView) view.findViewById(R.id.onboarding_fragment_body_text);
    ImageView imageView = (ImageView) view.findViewById(R.id.onboarding_fragment_image);
    Button button = (Button) view.findViewById(R.id.onboarding_fragment_button);

    //Set the title
    if (title !=null) {
        titleTextView.setText(title);
        //Set the body text color
        if (titleTextColor!=-1) {
            titleTextView.setTextColor(getResources().getColor(titleTextColor));
        }
    } else {
        titleTextView.setVisibility(View.GONE);
    }

    //Set the body text
    if (bodyText !=null) {
        bodyTextView.setText(bodyText);
        //Set the body text color
        if (bodyTextColor!=-1) {
            bodyTextView.setTextColor(getResources().getColor(bodyTextColor));
        }
    } else {
        bodyTextView.setVisibility(View.GONE);
    }

    //Set the image
    if (imageResId !=-1) {
        imageView.setImageResource(imageResId);
        //Set the max image height (if it was set)
        if (maxImageHeight !=-1) {
            imageView.setMaxHeight(maxImageHeight);
        }
    } else {
        imageView.setVisibility(View.GONE);
    }

    //Set the button text and link it to the method
    if (buttonText!=null) {
        button.setText(buttonText);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clickOnboardingButton(position);
            }
        });
    } else {
        button.setVisibility(View.GONE);
    }

    return view;
}
 
Example 17
Source File: UserInfoShowActivity.java    From WeCenterMobile-Android with GNU General Public License v2.0 4 votes vote down vote up
private void init() {
	// TODO Auto-generated method stub
	iv_avatar = (SmartImageView) findViewById(R.id.iv_avatar);
	tv_username = (TextView) findViewById(R.id.tv_username);
	lv_topics = (LinearLayout) findViewById(R.id.lv_topics);
	lv_topics.setOnClickListener(this);
	tv_topic = (TextView) findViewById(R.id.tv_topic);
	lv_ifocus_person = (LinearLayout) findViewById(R.id.lv_ifocus_person);
	lv_ifocus_person.setOnClickListener(this);
	tv_ifocus_person = (TextView) findViewById(R.id.tv_ifocus_person);
	lv_focusi_person = (LinearLayout) findViewById(R.id.lv_focusi_person);
	lv_focusi_person.setOnClickListener(this);
	tv_focusi_person = (TextView) findViewById(R.id.tv_focusi_person);

	tv_thanks = (TextView) findViewById(R.id.tv_thanks);
	tv_votes = (TextView) findViewById(R.id.tv_votes);
	tv_collect = (TextView) findViewById(R.id.tv_collect);

	lv_replys = (LinearLayout) findViewById(R.id.lv_replys);
	lv_replys.setOnClickListener(this);
	tv_replys = (TextView) findViewById(R.id.tv_replys);
	lv_asks = (LinearLayout) findViewById(R.id.lv_asks);
	lv_asks.setOnClickListener(this);
	tv_asks = (TextView) findViewById(R.id.tv_asks);
	lv_articles = (LinearLayout) findViewById(R.id.lv_articles);
	lv_articles.setOnClickListener(this);

	lv_news = (LinearLayout) findViewById(R.id.lv_news);
	lv_news.setOnClickListener(this);

	lv_search_friens = (LinearLayout) findViewById(R.id.lv_search_friens);
	lv_search_friens.setOnClickListener(this);

	bt_focus = (Button) findViewById(R.id.bt_focus);
	bt_focus.setOnClickListener(this);
	tv_focusi_person_comment = (TextView) findViewById(R.id.tv_focusi_person_comment);
	tv_ifocus_person_comment = (TextView) findViewById(R.id.tv_ifocus_person_comment);
	tv_topic_comment = (TextView) findViewById(R.id.tv_topic_comment);
	tvSignature = (TextView) findViewById(R.id.tvSignature);
	pb_change_follow = (ProgressBar) findViewById(R.id.pb_change_follow);
	ll_logout = (LinearLayout) findViewById(R.id.ll_logout);
	ll_logout.setOnClickListener(this);
	// �жϱ������ѵ�¼�û�������ǿ��Ա༭�����ع�ע��ť���������ر༭��ť��ʾ��ע��ť��
	if (status == GlobalVariables.AVAILABLE_EDIT) {
		bt_focus.setVisibility(View.INVISIBLE);
		ll_logout.setVisibility(View.VISIBLE);
	} else {
		ll_logout.setVisibility(View.GONE);
		tv_focusi_person_comment.setText("��ע������");
		tv_ifocus_person_comment.setText("����ע����");
		tv_topic_comment.setText("����ע�Ļ���");
	}
	if (haveFrocus == YES) {
		bt_focus.setBackgroundResource(R.drawable.btn_silver_normal);
		bt_focus.setTextColor(android.graphics.Color.BLACK);
		bt_focus.setText("ȡ����ע");
	}
}
 
Example 18
Source File: CustomDialog.java    From Android with Apache License 2.0 4 votes vote down vote up
public void setNegativeButton(String text,OnClickListener listener ) {
    final Button buttonCancel = (Button)mRootLayout.findViewById(R.id.CustomDlgButtonCancel);
    buttonCancel.setText(text);
    buttonCancel.setOnClickListener(listener);
    buttonCancel.setVisibility(View.VISIBLE);
}
 
Example 19
Source File: ImageGridActivity.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_grid);

        imagePicker = ImagePicker.getInstance();
        imagePicker.clear();
        imagePicker.addOnImageSelectedListener(this);


        // 新增可直接拍照
        if (getIntent() != null && getIntent().getExtras() != null){
            directPhoto = getIntent().getBooleanExtra(EXTRAS_TAKE_PICKERS,false); // 默认不是直接打开相机
            if (directPhoto){
                if (!(checkPermission(Manifest.permission.CAMERA))) {
                    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, ImageGridActivity.REQUEST_PERMISSION_CAMERA);
                } else {
                    imagePicker.takePicture(this, ImagePicker.REQUEST_CODE_TAKE);
                }
            }
        }


        mRecyclerView = (RecyclerView) findViewById(R.id.recycler);


        findViewById(R.id.btn_back).setOnClickListener(this);
        mBtnOk = (Button) findViewById(R.id.btn_ok);
        mBtnOk.setOnClickListener(this);
        mBtnDir = (Button) findViewById(R.id.btn_dir);
        mBtnDir.setOnClickListener(this);
        mBtnPre = (Button) findViewById(R.id.btn_preview);
        mBtnPre.setOnClickListener(this);
        mGridView = (GridView) findViewById(R.id.gridview);
        mFooterBar = findViewById(R.id.footer_bar);
        if (imagePicker.isMultiMode()) {
            mBtnOk.setVisibility(View.VISIBLE);
            mBtnPre.setVisibility(View.VISIBLE);
        } else {
            mBtnOk.setVisibility(View.GONE);
            mBtnPre.setVisibility(View.GONE);
        }

//        mImageGridAdapter = new ImageGridAdapter(this, null);
        mImageFolderAdapter = new ImageFolderAdapter(this, null);
        mRecyclerAdapter = new ImageRecyclerAdapter(this,null);

        onImageSelected(0, null, false);

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            if (checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                new ImageDataSource(this, null, this);
            } else {
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_PERMISSION_STORAGE);
            }
        }
    }
 
Example 20
Source File: OnboardingActivity.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setContentView(R.layout.rss_activity_onboarding);

    ImageView logoView = (ImageView) findViewById(R.id.layout_studyoverview_landing_logo);
    TextView titleView = (TextView) findViewById(R.id.layout_studyoverview_landing_title);
    TextView subtitleView = (TextView) findViewById(R.id.layout_studyoverview_landing_subtitle);

    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.layout_studyoverview_main);
    StudyOverviewModel model = parseStudyOverviewModel();

    // The first item is used for the main activity and not the tabbed dialog
    StudyOverviewModel.Question welcomeQuestion = model.getQuestions().remove(0);

    titleView.setText(welcomeQuestion.getTitle());

    if (!TextUtils.isEmpty(welcomeQuestion.getDetails())) {
        subtitleView.setText(welcomeQuestion.getDetails());
    } else {
        subtitleView.setVisibility(View.GONE);
    }

    // add Read Consent option to list and tabbed dialog
    if ("yes".equals(welcomeQuestion.getShowConsent())) {
        StudyOverviewModel.Question consent = new StudyOverviewModel.Question();
        consent.setTitle(getString(R.string.rss_read_consent_doc));
        consent.setDetails(ResourceManager.getInstance().getConsentHtml().getName());
        model.getQuestions().add(0, consent);
    }

    for (int i = 0; i < model.getQuestions().size(); i++) {
        AppCompatButton button = (AppCompatButton) LayoutInflater.from(this)
                .inflate(R.layout.rss_button_study_overview, linearLayout, false);
        button.setText(model.getQuestions().get(i).getTitle());
        // set the index for opening the viewpager to the correct page on click
        button.setTag(i);
        linearLayout.addView(button);
        button.setOnClickListener(this);
    }

    signUp = (Button) findViewById(R.id.intro_sign_up);
    signIn = (TextView) findViewById(R.id.intro_sign_in);

    skip = (Button) findViewById(R.id.intro_skip);
    skip.setVisibility(UiManager.getInstance().isConsentSkippable() ? View.VISIBLE : View.GONE);

    int resId = ResUtils.getDrawableResourceId(this, model.getLogoName());
    logoView.setImageResource(resId);

    pagerContainer = findViewById(R.id.pager_container);
    pagerContainer.setTranslationY(48);
    pagerContainer.setAlpha(0);
    pagerContainer.setScaleX(.9f);
    pagerContainer.setScaleY(.9f);

    pagerFrame = findViewById(R.id.pager_frame);
    pagerFrame.setAlpha(0);
    pagerFrame.setOnClickListener(v -> hidePager());

    OnboardingPagerAdapter adapter = new OnboardingPagerAdapter(this, model.getQuestions());
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setOffscreenPageLimit(2);
    pager.setAdapter(adapter);
    tabStrip = (TabLayout) findViewById(R.id.pager_title_strip);
    tabStrip.setupWithViewPager(pager);
}