Java Code Examples for android.widget.TextView#setOnClickListener()

The following examples show how to use android.widget.TextView#setOnClickListener() . 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: HomeAdapter.java    From CrazyDaily with Apache License 2.0 6 votes vote down vote up
private void renderGankioHeader(BaseViewHolder holder, CommonHeaderEntity item) {
    final int level = HomeAdapterHelper.LEVEL_GANK_IO;
    holder.setText(R.id.header_title, item.getTitle());
    TextView optionsView = holder.getView(R.id.header_options);
    final String options = item.getOptions();
    optionsView.setText(options);
    optionsView.setTextColor(HomeAdapterHelper.getColor(level));
    optionsView.setOnClickListener(v -> {
        if (mOnHeaderClickListener != null) {
            final int position = holder.getAdapterPosition();
            CommonHeaderEntity headerEntity = (CommonHeaderEntity) mHelper.getItem(position);
            String headerEntityOptions = headerEntity.getOptions();
            mOnHeaderClickListener.onHeaderClick(level,
                    headerEntityOptions);
        }
    });
}
 
Example 2
Source File: UpdateDialog.java    From AppSmartUpdate with Apache License 2.0 6 votes vote down vote up
private void init() {
        View view = View.inflate(getContext(), R.layout.lib_update_dialog, null);
        mProgressBar = (NumberProgressBar) view.findViewById(R.id.progressbar);
        mTitleTV = (TextView) view.findViewById(R.id.title_tv);
        mUpdateInfoTV = (TextView) view.findViewById(R.id.update_info_tv);
        mOKBtn = (Button) view.findViewById(R.id.ok_btn);
        mIgnoreTV = (TextView) view.findViewById(R.id.ignore_tv);
        mCloseIV = (ImageView) view.findViewById(R.id.close_iv);
        mCloseLLT = (LinearLayout) view.findViewById(R.id.close_llt);
        mIgnoreTV.setOnClickListener(this);
        mCloseIV.setOnClickListener(this);
        mOKBtn.setOnClickListener(this);
        setContentView(view);
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.gravity = Gravity.CENTER;

        mIgnoreTV.setOnClickListener(this);

//        WindowManager m = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
//        Display display = m.getDefaultDisplay(); // 获取屏幕宽、高用
//        params.width = (int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.7
        getWindow().setAttributes(params);
//        dialog.setCanceledOnTouchOutside(false);
//        dialog.setCancelable(isCancel);
//        dialog.show();
    }
 
Example 3
Source File: ShowActivity.java    From AppApis with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show);

    final ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);


    data = getIntent().getStringExtra("data");

    System.out.println("data" + data);

    TextView textData = (TextView) findViewById(R.id.textData);
    textData.setText(data);

    textData.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(ShowActivity.this, "已复制", Toast.LENGTH_SHORT).show();
            clipboard.setText(data);
        }
    });
}
 
Example 4
Source File: RxTextViewVertical.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
@Override
public View makeView() {
    TextView t = new TextView(mContext);
    t.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    t.setMaxLines(1);
    t.setPadding(mPadding, mPadding, mPadding, mPadding);
    t.setTextColor(textColor);
    t.setTextSize(mTextSize);

    t.setClickable(true);
    t.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (itemClickListener != null && textList.size() > 0 && currentId != -1) {
                itemClickListener.onItemClick(currentId % textList.size());
            }
        }
    });
    return t;
}
 
Example 5
Source File: SearchActivity.java    From QuickNews with MIT License 6 votes vote down vote up
private void initView(){
    mIvBack= (ImageView) findViewById(R.id.ivBack);
    mEtInput= (EditText) findViewById(R.id.etInput);
    mIvClear= (ImageView) findViewById(R.id.ivClearText);
    mTvSearch= (TextView) findViewById(R.id.tvSearchEnsure);
    mLvSearchResult= (ListView) findViewById(R.id.lvSearchResult);
    mProgressBar= (ProgressBar) findViewById(R.id.pbSearchProgress);

    mTvSearch.setClickable(true);
    mTvSearch.setOnClickListener(this);
    mIvClear.setOnClickListener(this);
    mIvBack.setOnClickListener(this);

    mEtInput.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mEtInput.setFocusable(true);
            mEtInput.setFocusableInTouchMode(true);
            mEtInput.requestFocus();
            return false;
        }
    });
}
 
Example 6
Source File: WatchMessagePictureActivity.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
private void initActionbar() {
    TextView menuBtn = findView(R.id.actionbar_menu);
    if (isShowMenu) {
        menuBtn.setVisibility(View.VISIBLE);
        menuBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WatchPicAndVideoMenuActivity.startActivity(WatchMessagePictureActivity.this, message);
            }
        });
    } else {
        menuBtn.setVisibility(View.GONE);
    }
}
 
Example 7
Source File: MainActivity.java    From wshell with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	ActionBar actionBar = getSupportActionBar();
	actionBar.setDisplayHomeAsUpEnabled(true);

	DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
	ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
			this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
	drawer.setDrawerListener(toggle);
	toggle.syncState();

	NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
	navigationView.setNavigationItemSelectedListener(this);

	FILES_DIR = getApplicationInfo().dataDir;
	extractData();

	TextView tv = (TextView) findViewById(R.id.addressBox);
	tv.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			runURL();
		}
	});
}
 
Example 8
Source File: DeleteObjectsSample.java    From huaweicloud-sdk-java-obs with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(String result)
{
    TextView tv = (TextView)findViewById(R.id.tv);
    tv.setText(result);
    tv.setOnClickListener(null);
    tv.setMovementMethod(ScrollingMovementMethod.getInstance());
}
 
Example 9
Source File: ExpandableListAdapter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public View getChildView(int groupPosition, int childPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.example_list_item2, null);
    }
    LinearLayout l = (LinearLayout) convertView;
    ((TextView) l.getChildAt(0)).setText(datas[groupPosition][childPosition]);
    if (isLastChild) {
        l.getChildAt(1).setVisibility(View.VISIBLE);
    } else {
        l.getChildAt(1).setVisibility(View.INVISIBLE);
    }
    final TextView textView = (TextView) convertView.findViewById(R.id.child_text);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i("introduceFragment", "text is >>>>" + textView.getText());
            ((MainActivity)mContext).quitLongRecordMode();
            String text = textView.getText().toString();
            //隐藏introduce界面
            EventBus.getDefault().post(new IntroduceShowEvent(false));
            //添加到聊天界面
            EventBus.getDefault().post(new ChatMsgEvent(new SpeechMsg(text), null, null, null));
            //2.发送到AssistantService的robot处理
            Intent intent = new Intent(mContext, AssistantService.class);
            intent.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.SEND_TO_ROBOT);
            intent.putExtra(AssistantService.TEXT, text);
            intent.putExtra(AssistantService.INPUT_TYPE, AssistantService.INPUT_VOICE);
            mContext.startService(intent);
        }
    });
    return convertView;
}
 
Example 10
Source File: EditPageLand.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px_1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
	llBottom.addView(v, lp);
}
 
Example 11
Source File: OrdersFragment.java    From bitshares_wallet with MIT License 5 votes vote down vote up
public OrderViewHolder(View itemView) {
    super(itemView);

    txtExpiration = (TextView)itemView.findViewById(R.id.voi_txt_expiration);
    txtCacel = (TextView)itemView.findViewById(R.id.voi_txt_cacel);
    txtOperation = (TextView)itemView.findViewById(R.id.voi_txt_operation);
    txtPrice = (TextView)itemView.findViewById(R.id.voi_txt_price);
    txtSrcCoin = (TextView)itemView.findViewById(R.id.voi_txt_src_coin);
    txtSrcCoinName = (TextView)itemView.findViewById(R.id.voi_txt_src_coin_name);
    txtTargetCoin = (TextView)itemView.findViewById(R.id.voi_txt_target_coin);
    txtTargetCoinName = (TextView)itemView.findViewById(R.id.voi_txt_target_coin_name);

    txtCacel.setOnClickListener(onCancelClickListener);
}
 
Example 12
Source File: BaseConversionActivity.java    From DarkCalculator with MIT License 5 votes vote down vote up
private void initTextOut() {
    textOut = (TextView) findViewById(R.id.text_out);
    AutofitHelper.create(textOut).setMaxLines(5);
    textOut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ClipboardManager cmb = (ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            cmb.setText(textOut.getText());
            Snackbar.make(v, "已复制转换结果", Snackbar.LENGTH_SHORT).show();
        }
    });
}
 
Example 13
Source File: AppListAdapter.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
@Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        convertView = inflater.inflate(R.layout.item_app, parent, false);
        holder = new ViewHolder(convertView);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    final RootAppInfo rootAppInfo = getItem(position);
    ImageView imageView = holder.find(R.id.app_icon);
    TextView appName = holder.find(R.id.app_name);
    TextView appInfo = holder.find(R.id.app_info);
    appName.setText(rootAppInfo.getAppName());
    appInfo.setText(rootAppInfo.getDescription());
    Picasso.with(parent.getContext())
            .load(rootAppInfo.getIconUri())
            .placeholder(R.drawable.ic_image_gray_50dp)
            .into(imageView);

    TextView downloadTv = holder.find(R.id.download_tv);
    downloadTv.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            clickListener.onClick(rootAppInfo);
        }
    });
    return convertView;
}
 
Example 14
Source File: AllDeviceAdapter.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(Context
                .LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.item_device_list, null);
    }

    DeviceInterface deviceInterface = deviceList.get(position);
    if (deviceInterface != null) {
        final Device device = (Device) deviceInterface;
        TextView ipTextView = (TextView) view.findViewById(R.id.device_ip_text_view);
        TextView macTextView = (TextView) view.findViewById(R.id.device_mac_text_view);
        TextView companyTextView = (TextView) view.findViewById(R.id.device_company_text_view);
        TextView reportTextView = (TextView) view.findViewById(R.id.report_camera_button);

        ipTextView.setText(device.getIP());
        macTextView.setText(device.getMAC());
        companyTextView.setText(device.getPublicVendor());

        reportTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CustomedDialog.showReportCameraModelDialog(getContext(), device);
            }
        });
    }

    return view;
}
 
Example 15
Source File: HorizontalTitleBar.java    From customview-samples with Apache License 2.0 5 votes vote down vote up
/**
 * 设置标题栏所有标题
 * @param titleContents
 * @param defSelectdPos:默认选择的标题
 */
public void setTitleContent(String[] titleContents, int defSelectdPos) {
    if(titleContents == null){
        return;
    }

    for(int i=0;i<titleContents.length;i++){
        TextView textView = new TextView(mContext);
        textView.setText(titleContents[i]);
        textView.setTextSize(14);
        textView.setTextColor(Color.parseColor("#212121"));
        textView.setTypeface(Typeface.DEFAULT_BOLD);
        if(i == defSelectdPos){
            textView.setAlpha(1);
        }else{
            textView.setAlpha(0.2f);
        }
        textView.setGravity(Gravity.CENTER);

        LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
        layoutParams.weight = 1;
        textView.setLayoutParams(layoutParams);
        addView(textView);
        mTitleViewList.add(textView);

        final int tempI = i;
        textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mOnClickTitleCallBack!=null){
                    mOnClickTitleCallBack.onClickTitle(tempI);
                }
            }
        });
    }
}
 
Example 16
Source File: EditPageLand.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = R.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_multi_share");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvShare = new TextView(activity);
	tvShare.setTextColor(0xffff6d11);
	tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvShare.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_share");
	if (resId > 0) {
		tvShare.setText(resId);
	}
	tvShare.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvShare, lp);
	tvShare.setOnClickListener(this);
}
 
Example 17
Source File: PlayerFragment.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
private void showSettingsPopup(final Point p) {
    try{
        if(player!=null){
            player.getController().setAutoHide(!getTouchExploreEnabled());
            Activity context = getActivity();

            float popupHeight =  getResources().getDimension(R.dimen.settings_popup_height);
            float popupWidth =  getResources().getDimension(R.dimen.settings_popup_width);

            // Inflate the popup_layout.xml
            LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.setting_popup);
            LayoutInflater layoutInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View layout = layoutInflater.inflate(R.layout.panel_settings_popup, viewGroup);

            // Creating the PopupWindow
            settingPopup = new PopupWindow(context);
            settingPopup.setContentView(layout);
            settingPopup.setWidth((int)popupWidth);
            settingPopup.setHeight((int)popupHeight);
            settingPopup.setFocusable(true);
            settingPopup.setOnDismissListener(new OnDismissListener() {
                @Override
                public void onDismiss() {
                    hideTransparentImage();
                    if(player!=null){
                        player.getController().setSettingsBtnDrawable(false);
                        player.getController().setAutoHide(!getTouchExploreEnabled());
                    }
                }
            });

            // Clear the default translucent background
            settingPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

            // Displaying the popup at the specified location, + offsets.
            settingPopup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x-(int)popupWidth, p.y-(int)popupHeight);

            TextView tv_closedCaption = (TextView) layout.findViewById(R.id.tv_closedcaption);
            if ((langList != null) && (langList.size() > 0))
            {
                tv_closedCaption.setBackgroundResource(R.drawable.white_rounded_selector);
                tv_closedCaption.setOnClickListener(new View.OnClickListener(){
                    public void onClick(View paramAnonymousView) {
                        showCCFragmentPopup();
                    }
                });
            }else{
                tv_closedCaption.setBackgroundResource(R.drawable.grey_roundedbg);
                tv_closedCaption.setOnClickListener(null);
            }

            layout.findViewById(R.id.tv_video_speed).setOnClickListener(v -> showVideoSpeedFragmentPopup());
        }
    }catch(Exception e){
        logger.error(e);
    }
}
 
Example 18
Source File: ScrollSlidingTextTabStrip.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void addTextTab(final int id, CharSequence text) {
    int position = tabCount++;
    if (position == 0 && selectedTabId == -1) {
        selectedTabId = id;
    }
    positionToId.put(position, id);
    idToPosition.put(id, position);
    if (selectedTabId != -1 && selectedTabId == id) {
        currentPosition = position;
        prevLayoutWidth = 0;
    }
    TextView tab = new TextView(getContext());
    tab.setWillNotDraw(false);
    tab.setGravity(Gravity.CENTER);
    tab.setText(text);
    tab.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(selectorColorKey), 3));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    tab.setSingleLine(true);
    tab.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    tab.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    tab.setOnClickListener(v -> {
        int position1 = tabsContainer.indexOfChild(v);
        if (position1 < 0) {
            return;
        }
        if (position1 == currentPosition && delegate != null) {
            delegate.onSamePageSelected();
            return;
        }
        boolean scrollingForward = currentPosition < position1;
        scrollingToChild = -1;
        previousPosition = currentPosition;
        currentPosition = position1;
        selectedTabId = id;

        if (animatingIndicator) {
            AndroidUtilities.cancelRunOnUIThread(animationRunnable);
            animatingIndicator = false;
        }

        animationTime = 0;
        animatingIndicator = true;
        animateIndicatorStartX = indicatorX;
        animateIndicatorStartWidth = indicatorWidth;

        TextView nextChild = (TextView) v;
        animateIndicatorToWidth = getChildWidth(nextChild);
        animateIndicatorToX = nextChild.getLeft() + (nextChild.getMeasuredWidth() - animateIndicatorToWidth) / 2;
        setEnabled(false);

        AndroidUtilities.runOnUIThread(animationRunnable, 16);

        if (delegate != null) {
            delegate.onPageSelected(id, scrollingForward);
        }
        scrollToChild(position1);
    });
    int tabWidth = (int) Math.ceil(tab.getPaint().measureText(text, 0, text.length())) + tab.getPaddingLeft() + tab.getPaddingRight();
    allTextWidth += tabWidth;
    positionToWidth.put(position, tabWidth);
    tabsContainer.addView(tab, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT));
}
 
Example 19
Source File: FieldSelector.java    From android-places-demos with Apache License 2.0 4 votes vote down vote up
public FieldSelector(
        CheckBox enableView,
        TextView outputView,
        List<Field> validFields,
        @Nullable Bundle savedState) {
  fieldStates = new HashMap<>();
  for (Field field : validFields) {
    fieldStates.put(field, new State(field));
  }

  if (savedState != null) {
    List<Integer> selectedFields = savedState.getIntegerArrayList(SELECTED_PLACE_FIELDS_KEY);
    if (selectedFields != null) {
      restoreState(selectedFields);
    }
    outputView.setText(getSelectedString());
  }

  outputView.setOnClickListener(
      v -> {
        if (v.isEnabled()) {
          showDialog(v.getContext());
        }
      });

  enableView.setOnClickListener(
          view -> {
            boolean isChecked = enableView.isChecked();
            outputView.setEnabled(isChecked);
            if (isChecked) {
              showDialog(view.getContext());
            } else {
              outputView.setText("");
              for (State state : fieldStates.values()) {
                state.checked = false;
          }
        }
      });

  this.outputView = outputView;
}
 
Example 20
Source File: MainFragment.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         final Bundle savedInstanceState) {

    Log.d(TAG, "onCreateView -> " + TAG);
    if (isZombieNoView())
        return null;

    final GaService service = getGAService();
    popupWaitDialog(R.string.loading_transactions);

    if (savedInstanceState != null)
        mIsExchanger = savedInstanceState.getBoolean("isExchanger", false);

    if (mIsExchanger)
        mView = inflater.inflate(R.layout.fragment_exchanger_txs, container, false);
    else
        mView = inflater.inflate(R.layout.fragment_main, container, false);
    final RecyclerView txView = UI.find(mView, R.id.mainTransactionList);
    txView.setHasFixedSize(true);
    txView.addItemDecoration(new DividerItem(getActivity()));

    final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    txView.setLayoutManager(layoutManager);

    mSubaccount = service.getCurrentSubAccount();

    if (!mIsExchanger) {
        final TextView firstP = UI.find(mView, R.id.mainFirstParagraphText);
        final TextView secondP = UI.find(mView, R.id.mainSecondParagraphText);
        final TextView thirdP = UI.find(mView, R.id.mainThirdParagraphText);

        if (service.isElements())
            UI.hide(firstP); // Don't show a Bitcoin message for elements
        else
            firstP.setMovementMethod(LinkMovementMethod.getInstance());
        secondP.setMovementMethod(LinkMovementMethod.getInstance());
        thirdP.setMovementMethod(LinkMovementMethod.getInstance());
    }

    final TextView balanceText = UI.find(mView, R.id.mainBalanceText);
    final TextView balanceQuestionMark = UI.find(mView, R.id.mainBalanceQuestionMark);
    final View.OnClickListener unconfirmedClickListener = new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (mUnconfirmedDialog == null && balanceQuestionMark.getVisibility() == View.VISIBLE) {
                // Question mark is visible and dialog not shown, so show it
                mUnconfirmedDialog = UI.popup(getActivity(), R.string.unconfirmedBalanceTitle, 0)
                                       .content(R.string.unconfirmedBalanceText).build();
                UI.setDialogCloseHandler(mUnconfirmedDialog, mDialogCB);
                mUnconfirmedDialog.show();
            }
        }
    };
    balanceText.setOnClickListener(unconfirmedClickListener);
    balanceQuestionMark.setOnClickListener(unconfirmedClickListener);

    makeBalanceObserver(mSubaccount);
    if (isPageSelected() && service.getCoinBalance(mSubaccount) != null) {
        updateBalance();
        reloadTransactions(true);
    }

    if (!mIsExchanger) {
        mSwipeRefreshLayout = UI.find(mView, R.id.mainTransactionListSwipe);
        mSwipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getContext(), R.color.accent));
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                Log.d(TAG, "onRefresh -> " + TAG);
                // user action to force reload balance and tx list
                onBalanceUpdated();
            }
        });
    }

    registerReceiver();
    return mView;
}