Java Code Examples for android.widget.ImageView#setOnLongClickListener()

The following examples show how to use android.widget.ImageView#setOnLongClickListener() . 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: Activity_AboutUs.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("");
    TextView toolbarText = (TextView) findViewById(R.id.toolbar_text);
    toolbarText.setText("关于我们");
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    iv_qrcode_download= (ImageView) findViewById(R.id.iv_qrcode_download);

    Glide.with(Activity_AboutUs.this).load(Util.Url+"File/bysj/chaoyoung_qrcode/qr_chaoyoung_wxgzh.jpg").into(iv_qrcode_download);

    iv_qrcode_download.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            showShareDialog();
            return true;
        }
    });
}
 
Example 2
Source File: Activity_ShareUs.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
private void initView() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("");
        TextView toolbarText = (TextView) findViewById(R.id.toolbar_text);
        toolbarText.setText("分享我们");
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        iv_qrcode_download= (ImageView) findViewById(R.id.iv_qrcode_download);
        Glide.with(Activity_ShareUs.this).load(Util.Url+"File/bysj/qr_download_apk/bysj_qr_download_apk.png").into(iv_qrcode_download);

        //食品学院的
//        Glide.with(Activity_ShareUs.this).load(Util.Url+"File/spxy/qr_download_apk/foodordering_apk_download.png").into(iv_qrcode_download);
        iv_qrcode_download.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                showShareDialog();
                return true;
            }
        });
    }
 
Example 3
Source File: Dock.java    From emerald with GNU General Public License v3.0 6 votes vote down vote up
public void update() {
	for (int i=0; i<buttons.size(); i++) {
		ImageView button = buttons.get(i);
		if (i<apps.size()) {
			button.setVisibility(View.VISIBLE);
			IconPackManager.setIcon(contextRef.get(), buttons.get(i), apps.get(i));
			button.setTag(apps.get(i));
			button.setOnClickListener(onAppClickListener);
			button.setOnLongClickListener(onAppLongClickListener);
		} else {
			button.setVisibility(i > 0 ? View.GONE : View.INVISIBLE);
			button.setImageResource(android.R.color.transparent);
			button.setOnClickListener(null);
			button.setOnLongClickListener(null);
		}
	}
	if (apps.size() == 0) {
		hide();
	} else if (apps.size() == 1) {
		unhide();
	}
}
 
Example 4
Source File: Wishlist.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void draw() {
    ImageView wishlistButton = activity.findViewById(R.id.wishlist);
    if (app.isInstalled()) {
        wishlistButton.setVisibility(View.GONE);
        return;
    }
    initWishlistButton(activity, app.getPackageName());
    wishlistButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivity(new Intent(activity, WishlistActivity.class));
            return true;
        }
    });
}
 
Example 5
Source File: WatchMessagePictureActivity.java    From NIM_Android_UIKit with MIT License 6 votes vote down vote up
private void findViews() {
    alertDialog = new CustomAlertDialog(this);
    loadingLayout = findViewById(R.id.loading_layout);

    imageViewPager = (ViewPager) findViewById(R.id.view_pager_image);
    simpleImageView = (ImageView) findViewById(R.id.simple_image_view);

    if (mode == MODE_GIF) {
        simpleImageView.setVisibility(View.VISIBLE);
        simpleImageView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (isOriginImageHasDownloaded(message)) {
                    showWatchPictureAction();
                }
                return true;
            }
        });

        imageViewPager.setVisibility(View.GONE);
    } else if (mode == MODE_NOMARL) {
        simpleImageView.setVisibility(View.GONE);
        imageViewPager.setVisibility(View.VISIBLE);
    }
}
 
Example 6
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView imageView = findViewById(R.id.imageView);
    imageView.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View view) {
            if (mActionMode != null) return false;
            mActionMode = startSupportActionMode(mActionModeCallback);
            mActionMode.setTitle("New Title");
            return true;
        }
    });
}
 
Example 7
Source File: PageIndicatorLineCaret.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
    mAllAppsHandle.setImageDrawable(getCaretDrawable());
    mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
    mAllAppsHandle.setOnClickListener(mLauncher);
    mAllAppsHandle.setOnLongClickListener(mLauncher);
    mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
    mLauncher.setAllAppsButton(mAllAppsHandle);
}
 
Example 8
Source File: AboutAty.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
private void initViews() {
	TextView tvInfo1 = (TextView)findViewById(R.id.info);
	memberLayout = (LinearLayout)findViewById(R.id.about_memberLayout);
	teamLogo = (ImageView)findViewById(R.id.about_teamLogo);
	btnEmail = (Button)findViewById(R.id.email);
	btnEmail.setOnClickListener(this);
	btnQQ = (Button)findViewById(R.id.about_btnQQ);
	btnQQ.setOnClickListener(this);
	llytSinaWeibo = (LinearLayout)findViewById(R.id.about_llytSinaWeiBo);
	llytSinaWeibo.setOnClickListener(this);
	tvSinaWeibo = (TextView)findViewById(R.id.about_sinaWeiBo);
	
	String strInfo1 = "应用版本:V"+MyUtils.getVersionName(this);
	tvInfo1.setText(Html.fromHtml(strInfo1));
	String strEmail = "[email protected]";
	btnEmail.setText(Html.fromHtml("<u>联系邮箱: "+strEmail+"</u>"));
	btnEmail.setTag(strEmail);
	btnQQ.setText(Html.fromHtml("<u>" + strQQ + "</u>"));
	tvSinaWeibo.setText(Html.fromHtml("<u>@"+strSinaWeibo+"</u>"));
	teamLogo.setOnLongClickListener(new View.OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			memberLayout.setVisibility(memberLayout.isShown() ? View.GONE : View.VISIBLE);
			return false;
		}
	});
}
 
Example 9
Source File: BtnFuncFactory.java    From XposedNavigationBar with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 创建按钮并且设置对应功能
 *
 * @param line
 * @param sc
 */
public void createBtnAndSetFunc(LinearLayout line, ShortCut sc) {
    int iconScale = DataHook.iconScale;
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    p.weight = 1;
    p.gravity = Gravity.CENTER;

    Context context = line.getContext();
    ImageView btn = new ImageView(context);

    String iconPath = sc.getIconPath();
    Bitmap iconBitmap = null;
    if (iconPath != null) {
        iconBitmap = ImageUtil.zoomBitmap(iconPath, iconScale);
    }
    if (iconBitmap == null) {
        iconBitmap = ImageUtil.byte2Bitmap(mMapImgRes.get(sc.getCode()));
        iconBitmap = ImageUtil.zommBitmap(iconBitmap, iconScale);
    }
    btn.setImageBitmap(iconBitmap);

    ColorStateList colorStateList = createColorStateList(0xffffffff, 0xffcccccc, 0xff0000ff, 0xffff0000);
    RippleDrawable ripple = new RippleDrawable(colorStateList, null, null);
    btn.setBackground(ripple);
    btn.setScaleType(ImageView.ScaleType.CENTER);
    btn.setOnClickListener(getBtnFuncOfName(sc));
    btn.setOnLongClickListener(getBtnLongFuncOfName(sc.getCode()));

    line.addView(btn, p);
}
 
Example 10
Source File: FirstActivity.java    From MultiWindow with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_activity1);
    setTitle("Frist Activity");
    mTextView = (TextView) findViewById(R.id.textview);
    mScrollView = (ScrollView) findViewById(R.id.scrollview);
    mScrollView.post(new Runnable() {
        @Override
        public void run() {
            mScrollView.fullScroll(View.FOCUS_DOWN);
        }
    });
    mImageView = (ImageView) findViewById(R.id.imageview);
    mImageView.setTag("Drag an ImageView from First Activity");
    mImageView.setOnLongClickListener(new View.OnLongClickListener() {

        public boolean onLongClick(View view) {
            VibratorUtils.vibrate(mActivity, 100);
            Uri uri = getUri(mActivity, R.mipmap.ic_launcher);
            ClipData dragData = ClipData.newPlainText("", (CharSequence) view.getTag());
            ClipData.Item imageItem = new ClipData.Item(uri);
            dragData.addItem(imageItem);
            View.DragShadowBuilder shadow = new View.DragShadowBuilder(view);
            view.startDragAndDrop(dragData, shadow, view, View.DRAG_FLAG_GLOBAL);
            return true;
        }
    });
    print("onCreate", "#ff0000", false);
}
 
Example 11
Source File: ColdAddressFragmentHDMListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    ivType = (ImageView) findViewById(R.id.iv_type);
    ibtnXRandomLabel = (ImageButton) findViewById(R.id.ibtn_xrandom_label);
    ibtnXRandomLabel.setOnLongClickListener(DialogXRandomInfo.InfoLongClick);
    ivType.setOnLongClickListener(typeClick);
    findViewById(R.id.ibtn_seed_option).setOnClickListener(seedOptionClick);
    findViewById(R.id.ibtn_qr_code_option).setOnClickListener(qrCodeOptionClick);
    dp = new DialogProgress(getContext(), R.string.please_wait);
    dp.setCancelable(false);
}
 
Example 12
Source File: ColdAddressFragmentHDMEnterpriseListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    ivType = (ImageView) findViewById(R.id.iv_type);
    ibtnXRandomLabel = (ImageButton) findViewById(R.id.ibtn_xrandom_label);
    ibtnXRandomLabel.setOnLongClickListener(DialogXRandomInfo.InfoLongClick);
    ivType.setOnLongClickListener(typeClick);
    findViewById(R.id.ibtn_seed_option).setOnClickListener(seedOptionClick);
    findViewById(R.id.ibtn_qr_code_option).setOnClickListener(qrCodeOptionClick);
    dp = new DialogProgress(getContext(), R.string.please_wait);
    dp.setCancelable(false);
}
 
Example 13
Source File: ColdAddressFragmentListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    flAddress = (FrameLayout) findViewById(R.id.fl_address);
    ivQr = (QrCodeImageView) findViewById(R.id.iv_qrcode);
    tvAddress = (TextView) findViewById(R.id.tv_address);
    ivType = (ImageView) findViewById(R.id.iv_type);
    btnAlias = (Button) findViewById(R.id.btn_address_alias);
    ibtnXRandomLabel = (ImageButton) findViewById(R.id.ibtn_xrandom_label);
    ibtnXRandomLabel.setOnLongClickListener(DialogXRandomInfo.InfoLongClick);
    flAddress.setOnClickListener(copyClick);
    ivQr.setOnClickListener(qrClick);
    ivType.setOnLongClickListener(typeClick);
    btnAlias.setOnClickListener(aliasClick);
}
 
Example 14
Source File: RefreshActionItem.java    From RefreshActionItem with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public RefreshActionItem(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.rai__action_item, this);
    mRefreshButton = (ImageView) findViewById(R.id.refresh_button);
    mRefreshButton.setOnClickListener(this);
    mRefreshButton.setOnLongClickListener(this);
    mProgressIndicatorIndeterminate = (ProgressBar) findViewById(R.id.indeterminate_progress_indicator);
    mProgressIndicator = (ProgressIndicator) findViewById(R.id.determinate_progress_indicator);
    updateChildrenVisibility();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RefreshActionItem, defStyle, R.style.Widget_RefreshActionItem_Dark);
    int N = a.getIndexCount();
    for (int i = 0; i < N; ++i) {
        int attr = a.getIndex(i);
        switch (attr) {
        case R.styleable.RefreshActionItem_progressIndicatorType:
            mProgressIndicatorType = ProgressIndicatorType.values()[a.getInt(attr, 0)];
            if (mProgressIndicatorType == ProgressIndicatorType.PIE) {
                mProgressIndicator.setPieStyle(true);
            }
            break;
        case R.styleable.RefreshActionItem_refreshActionItemIcon:
            Drawable refreshButtonIcon = a.getDrawable(attr);
            mRefreshButton.setImageDrawable(refreshButtonIcon);
            break;
        case R.styleable.RefreshActionItem_progressIndicatorForegroundColor:
            int color = a.getColor(attr, 0);
            mProgressIndicator.setForegroundColor(color);
            break;
        case R.styleable.RefreshActionItem_progressIndicatorBackgroundColor:
            color = a.getColor(attr, 0);
            mProgressIndicator.setBackgroundColor(color);
            break;
        case R.styleable.RefreshActionItem_refreshActionItemBackground:
            Drawable drawable = a.getDrawable(attr);
            mRefreshButton.setBackgroundDrawable(drawable);
            break;
        case R.styleable.RefreshActionItem_badgeBackgroundColor:
            mBadgeBackgroundColor = a.getColor(attr, -1);
            break;
        case R.styleable.RefreshActionItem_badgeTextStyle:
            mBadgeTextStyle = a.getResourceId(attr, 0);
            break;
        case R.styleable.RefreshActionItem_badgePosition:
            mBadgePosition = a.getInt(attr, 0);
            break;
        }
    }
    a.recycle();
}
 
Example 15
Source File: GalleryAdapter.java    From NClientV2 with Apache License 2.0 4 votes vote down vote up
private void loadPageLayout(ViewHolder holder){
    final int pos=holder.getAdapterPosition();
    final ImageView imgView=holder.master.findViewById(R.id.image);

    imgView.setOnClickListener(v -> startGallery( holder.getAdapterPosition()));
    imgView.setOnLongClickListener(null);
    holder.master.setOnClickListener(v -> startGallery(holder.getAdapterPosition()));
    holder.master.setOnLongClickListener(null);

    holder.pageNumber.setText(String.format(Locale.US,"%d",pos));



    if(policy==Policy.MAX)holder.itemView.post(() -> {//find the max size and apply proportion
        if(maxImageSize !=null)return;
        int cellWidth = holder.itemView.getWidth();// this will give you cell width dynamically
        LogUtility.d(String.format(Locale.US,"Setting: %d,%s",cellWidth, maxSize.toString()));
        if(maxSize.getWidth()>10&&maxSize.getHeight()>10) {
            int hei = (maxSize.getHeight() * cellWidth) / maxSize.getWidth();
            if (hei >= 100)
                setMaxImageSize(new Size(cellWidth, hei));
        }
    });

    if(policy==Policy.MAX&&maxImageSize !=null) {
        ViewGroup.LayoutParams params = imgView.getLayoutParams();
        params.height = maxImageSize.getHeight();
        params.width = maxImageSize.getWidth();
        imgView.setLayoutParams(params);
    }

    if(policy==Policy.FULL){
        PhotoView photoView=(PhotoView)imgView;
        photoView.setZoomable(Global.isZoomOneColumn());
        photoView.setOnMatrixChangeListener(rect -> photoView.setAllowParentInterceptOnEdge(photoView.getScale()<=1f));
        photoView.setOnClickListener(v -> {
            if(photoView.getScale()<=1f)
                startGallery( holder.getAdapterPosition());
        });
        View.OnLongClickListener listener= v -> {
            optionDialog(imgView,pos);
            return true;
        };
        imgView.setOnLongClickListener(listener);
        holder.master.setOnLongClickListener(listener);
    }

    loadImageOnPolicy(imgView, pos);


}
 
Example 16
Source File: RefreshActionItem.java    From RefreshActionItem-Native with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public RefreshActionItem(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.rai__action_item, this);
    mRefreshButton = (ImageView) findViewById(R.id.refresh_button);
    mRefreshButton.setOnClickListener(this);
    mRefreshButton.setOnLongClickListener(this);
    mProgressIndicatorIndeterminate = (ProgressBar) findViewById(R.id.indeterminate_progress_indicator);
    mProgressIndicator = (ProgressIndicator) findViewById(R.id.determinate_progress_indicator);
    updateChildrenVisibility();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RefreshActionItem, defStyle, R.style.Widget_RefreshActionItem_Dark);
    int N = a.getIndexCount();
    for (int i = 0; i < N; ++i) {
        int attr = a.getIndex(i);
        switch (attr) {
        case R.styleable.RefreshActionItem_progressIndicatorType:
            mProgressIndicatorType = ProgressIndicatorType.values()[a.getInt(attr, 0)];
            if (mProgressIndicatorType == ProgressIndicatorType.PIE) {
                mProgressIndicator.setPieStyle(true);
            }
            break;
        case R.styleable.RefreshActionItem_refreshActionItemIcon:
            Drawable refreshButtonIcon = a.getDrawable(attr);
            mRefreshButton.setImageDrawable(refreshButtonIcon);
            break;
        case R.styleable.RefreshActionItem_progressIndicatorForegroundColor:
            int color = a.getColor(attr, 0);
            mProgressIndicator.setForegroundColor(color);
            break;
        case R.styleable.RefreshActionItem_progressIndicatorBackgroundColor:
            color = a.getColor(attr, 0);
            mProgressIndicator.setBackgroundColor(color);
            break;
        case R.styleable.RefreshActionItem_refreshActionItemBackground:
            Drawable drawable = a.getDrawable(attr);
            mRefreshButton.setBackgroundDrawable(drawable);
            break;
        case R.styleable.RefreshActionItem_badgeBackgroundColor:
            mBadgeBackgroundColor = a.getColor(attr, -1);
            break;
        case R.styleable.RefreshActionItem_badgeTextStyle:
            mBadgeTextStyle = a.getResourceId(attr, 0);
            break;
        case R.styleable.RefreshActionItem_badgePosition:
            mBadgePosition = a.getInt(attr, 0);
            break;
        }
    }
    a.recycle();
}
 
Example 17
Source File: ImageViewerActivity.java    From android-wear-gopro-remote with Apache License 2.0 4 votes vote down vote up
@Override
protected Object instantiateItem(ViewGroup viewGroup, int row, int col) {
    View view = null;

    if(col == 0) {
        view = View.inflate(mContext, R.layout.image_viewer, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
        TextView statusText = (TextView) view.findViewById(R.id.textViewStatus);
        if (Logger.DEBUG) imageView.setOnClickListener(ImageViewerActivity.this);
        imageView.setOnLongClickListener(ImageViewerActivity.this);

        File file = null;
        if (mCount > 0) {
            file = mFileList.get(mCount - (row + 1));
        }
        statusText.setText(String.format("%d/%d", row + 1, mCount));
        if (mFirstImage != null && row == mFirstIndex) {
            imageView.setImageBitmap(mFirstImage);
        } else {
            if (file != null) {
                Bitmap thumb = ThumbCache.getThumbFromMemCache(file);
                if (thumb != null) {
                    imageView.setImageBitmap(thumb);
                    Logger.debug(TAG, "Got thumb %s from memcache.", file);
                } else {
                    new LoadThumbTask(imageView, file).execute();
                }
            } else {
                TextView textView = new TextView(mContext);
                textView.setText(R.string.label_no_images);
                textView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
                FrameLayout frame = ((FrameLayout) view);
                frame.addView(textView);
                frame.removeView(imageView);
            }
        }

        if (file != null) {
            ImageView imageViewVideo = (ImageView) view.findViewById(R.id.imageViewVideo);
            String fname = file.getName().toUpperCase();
            if (fname.endsWith("MP4")) {
                imageViewVideo.setImageResource(R.drawable.detail_mode_icon_video);
            } else if (fname.endsWith("JPG")) {
                imageViewVideo.setImageResource(R.drawable.detail_mode_icon_photo);
            } else {
                imageViewVideo.setImageResource(R.drawable.detail_mode_icon_burst);
            }
        }
        viewGroup.addView(view);
    }
    if(Logger.DEBUG) Logger.debug(TAG, "View created: %d/%d", row, col);
    return view;
}
 
Example 18
Source File: RefreshActionItem.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
    public RefreshActionItem(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.rai__action_item, this);
        mRefreshButton = (ImageView) findViewById(R.id.refresh_button);
        mRefreshButton.setOnClickListener(this);
        mRefreshButton.setOnLongClickListener(this);
        mProgressIndicatorIndeterminate = (ProgressBar) findViewById(R.id.indeterminate_progress_indicator);
        mProgressIndicator = (ProgressIndicator) findViewById(R.id.determinate_progress_indicator);
        updateChildrenVisibility();

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RefreshActionItem, defStyle, R.style.Widget_RefreshActionItem_Dark);
        int N = a.getIndexCount();
        for (int i = 0; i < N; ++i) {
            int attr = a.getIndex(i);
            switch (attr) {
//                case R.styleable.RefreshActionItem_progressIndicatorType:
//                    mProgressIndicatorType = ProgressIndicatorType.values()[a.getInt(attr, 0)];
//                    if (mProgressIndicatorType == ProgressIndicatorType.PIE) {
//                        mProgressIndicator.setPieStyle(true);
//                    }
//                    break;
//                case R.styleable.RefreshActionItem_refreshActionItemIcon:
//                    Drawable refreshButtonIcon = a.getDrawable(attr);
//                    mRefreshButton.setImageDrawable(refreshButtonIcon);
//                    break;
//                case R.styleable.RefreshActionItem_progressIndicatorForegroundColor:
//                    int color = a.getColor(attr, 0);
//                    mProgressIndicator.setForegroundColor(color);
//                    break;
//                case R.styleable.RefreshActionItem_progressIndicatorBackgroundColor:
//                    color = a.getColor(attr, 0);
//                    mProgressIndicator.setBackgroundColor(color);
//                    break;
//                case R.styleable.RefreshActionItem_refreshActionItemBackground:
//                    Drawable drawable = a.getDrawable(attr);
//                    mRefreshButton.setBackgroundDrawable(drawable);
//                    break;
//                case R.styleable.RefreshActionItem_badgeBackgroundColor:
//                    mBadgeBackgroundColor = a.getColor(attr, -1);
//                    break;
//                case R.styleable.RefreshActionItem_badgeTextStyle:
//                    mBadgeTextStyle = a.getResourceId(attr, 0);
//                    break;
//                case R.styleable.RefreshActionItem_badgePosition:
//                    mBadgePosition = a.getInt(attr, 0);
//                    break;
            }
        }
        a.recycle();
    }
 
Example 19
Source File: LogInActivity.java    From PracticeCode with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    //动态从域名获取IP
    XSCHelper.getInstance().refreshIPbyHost();

    //初始化
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_log_in);

    //获取组件实例
    icon = (ImageView) findViewById(R.id.iconView);
    nameEdit = (EditText) findViewById(R.id.nameEdit);
    pswEdit = (EditText) findViewById(R.id.pswEdit);
    logIn = (ImageButton) findViewById(R.id.loginButton);
    initAnimation();

    //获取本地化数据,自动填充已有用户名,密码。设置焦点
    final SharedPreferences preferences = this.getPreferences(MODE_PRIVATE);
    nameEdit.setText(preferences.getString("savedAccount", ""));
    if (!nameEdit.getText().toString().equals("")) {
        pswEdit.requestFocus();
    }
    pswEdit.setNextFocusDownId(R.id.loginButton);

    //登陆按钮监听(设置变色,登陆)
    logIn.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN)
                view.setBackgroundResource(R.drawable.enter_button_hover);
            else {
                view.setBackgroundResource(R.drawable.enter_button);

                //获取文本域内容
                String name = nameEdit.getText().toString();
                String psw = pswEdit.getText().toString();

                //本地化存储。优化用户体验
                preferences.edit().putString("savedAccount", name).apply();

                //收起小桌板 - 3 -
                SysUtil.getInstance().hideInputKeyboard(LogInActivity.this, view);

                //如果输入内容不为空,载入动画,登陆
                if (!name.equals("") && !psw.equals("")) {
                    XSCHelper.getInstance().logIn(name, psw, handle);
                    LogInAnimationSet();
                }
            }
            return false;
        }
    });

    //注册按钮监听
    icon.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            icon.setVisibility(View.INVISIBLE);
            nameEdit.setVisibility(View.INVISIBLE);
            pswEdit.setVisibility(View.INVISIBLE);
            logIn.setVisibility(View.INVISIBLE);
            Intent intent = new Intent(LogInActivity.this, RegisterActivity.class);
            startActivity(intent);
            return false;
        }
    });
}