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

The following examples show how to use android.widget.ImageView#setClickable() . 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: SubCategoryActivity.java    From wallpaper with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void alreadyBindBaseViewModel() {
	super.alreadyBindBaseViewModel();
	SubCategoryViewModel viewModel = (SubCategoryViewModel) this.baseViewModel;
	cateId = viewModel.cateId;
	boolean issubcategory_screen = viewModel.issubcategory_screen;
	Log.i("kyson", issubcategory_screen + "  第一次");
	subcategoryScreenImage = (ImageView) findViewById(R.id.subcategory_screen_image);
	if (issubcategory_screen) {
		subcategoryScreenImage.setVisibility(View.VISIBLE);
		subcategoryScreenImage.setOnClickListener(this);
	} else {
		subcategoryScreenImage.setVisibility(View.INVISIBLE);
		subcategoryScreenImage.setClickable(false);
	}
	subcategory_title_textview.setText(viewModel.cateShortName);
	this.setCurrentPage(0);
}
 
Example 2
Source File: BlurActionBarDrawerToggle.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * We make a fake ImageView with width and height MATCH_PARENT.
 * This ImageView will host the blurred snapshot/bitmap.
 */
private void init() {
    mBlurredImageView = new ImageView(context);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    mBlurredImageView.setLayoutParams(params);
    mBlurredImageView.setClickable(false);
    mBlurredImageView.setVisibility(View.GONE);
    mBlurredImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            // Add the ImageViewiew not in the last position.
            // Otherwise, it will be shown in NavigationDrawer
            mDrawerLayout.addView(mBlurredImageView, 1);
        }
    });
}
 
Example 3
Source File: LeftFragment.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
private void initView(View view) {
    mReLogin = (RelativeLayout) view.findViewById(R.id.rl_login);
    mTvName = (TextView) view.findViewById(R.id.tv_name);
    mTvName.setClickable(false);
    mBtLogin = (TextView) view.findViewById(R.id.tv_login);
    mBtLogin.setOnClickListener(this);
    mIvTour = (ImageView) view.findViewById(R.id.img_avatar);
    mIvTour.setClickable(false);
    mReLogin.setOnClickListener(this);
    mLiReserve = (LinearLayout) view.findViewById(R.id.my_message);
    mLiReserve.setOnClickListener(this);
    mLiFollow = (LinearLayout) view.findViewById(R.id.my_follow);
    mLiFollow.setOnClickListener(this);
    mLiContact = (LinearLayout) view.findViewById(R.id.my_contact);
    mLiContact.setOnClickListener(this);
    mLiMoney = (LinearLayout) view.findViewById(R.id.my_money);
    mLiMoney.setOnClickListener(this);
    mLiGift = (LinearLayout) view.findViewById(R.id.my_gift);
    mLiGift.setOnClickListener(this);
    mLiWorry = (LinearLayout) view.findViewById(R.id.my_worry);
    mLiWorry.setOnClickListener(this);
    mReSetting = (RelativeLayout) view.findViewById(R.id.re_setting);
    mReSetting.setOnClickListener(this);

}
 
Example 4
Source File: LiteIconActivityV2.java    From NanoIconPackLite with Apache License 2.0 6 votes vote down vote up
private View initIconView() {
    FrameLayout contentView = new FrameLayout(LiteIconActivityV2.this);
    int gridW = (int) (displayMetrics.density * GRID_W_IN_DP);
    int gridH = (int) (displayMetrics.density * GRID_H_IN_DP);
    ViewGroup.LayoutParams lpCv = new ViewGroup.LayoutParams(gridW, gridH);
    contentView.setLayoutParams(lpCv);

    ImageView ivIcon = new ImageView(LiteIconActivityV2.this);
    ivIcon.setTag("iv");
    ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ivIcon.setClickable(true);
    ivIcon.setBackgroundResource(getClickBg());
    int iconSize = (int) (displayMetrics.density * ICON_SIZE_IN_DP);
    FrameLayout.LayoutParams lpIv = new FrameLayout.LayoutParams(iconSize, iconSize);
    lpIv.gravity = Gravity.CENTER;
    ivIcon.setLayoutParams(lpIv);
    contentView.addView(ivIcon);

    return contentView;
}
 
Example 5
Source File: Transition3d.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.animations_main_screen);

    mPhotosList = (ListView) findViewById(android.R.id.list);
    mImageView = (ImageView) findViewById(R.id.picture);
    mContainer = (ViewGroup) findViewById(R.id.container);

    // Prepare the ListView
    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, PHOTOS_NAMES);

    mPhotosList.setAdapter(adapter);
    mPhotosList.setOnItemClickListener(this);

    // Prepare the ImageView
    mImageView.setClickable(true);
    mImageView.setFocusable(true);
    mImageView.setOnClickListener(this);

    // Since we are caching large views, we want to keep their cache
    // between each animation
    mContainer.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
}
 
Example 6
Source File: BlurActionBarDrawerToggle.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * We make a fake ImageView with width and height MATCH_PARENT.
 * This ImageView will host the blurred snapshot/bitmap.
 */
private void init() {
    mBlurredImageView = new ImageView(context);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    mBlurredImageView.setLayoutParams(params);
    mBlurredImageView.setClickable(false);
    mBlurredImageView.setVisibility(View.GONE);
    mBlurredImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            // Add the ImageViewiew not in the last position.
            // Otherwise, it will be shown in NavigationDrawer
            mDrawerLayout.addView(mBlurredImageView, 1);
        }
    });
}
 
Example 7
Source File: SubCategoryActivity.java    From wallpaper with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void alreadyBindBaseViewModel() {
	super.alreadyBindBaseViewModel();
	SubCategoryViewModel viewModel = (SubCategoryViewModel) this.baseViewModel;
	cateId = viewModel.cateId;
	boolean issubcategory_screen = viewModel.issubcategory_screen;
	Log.i("kyson", issubcategory_screen + "  第一次");
	subcategoryScreenImage = (ImageView) findViewById(R.id.subcategory_screen_image);
	if (issubcategory_screen) {
		subcategoryScreenImage.setVisibility(View.VISIBLE);
		subcategoryScreenImage.setOnClickListener(this);
	} else {
		subcategoryScreenImage.setVisibility(View.INVISIBLE);
		subcategoryScreenImage.setClickable(false);
	}
	subcategory_title_textview.setText(viewModel.cateShortName);
	this.setCurrentPage(0);
}
 
Example 8
Source File: ImageFetcher.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
private void setInvisible() {
//            Log.d("COLLAGE", "Setting something invisible...");
            if (imageViewReference != null) {
                final ImageView imageView = imageViewReference.get();
                BitmapFetcherTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);
                if (this == bitmapDownloaderTask) {
                    imageView.setVisibility(View.GONE);
                    imageView.setClickable(false);
                    imageView.setEnabled(false);
                }
            }
        }
 
Example 9
Source File: AbstractTreeViewAdapter.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
public final LinearLayout populateTreeItem(final LinearLayout layout,
        final View childView, final TreeNodeInfo<T> nodeInfo,
        final boolean newChildView) {
    final Drawable individualRowDrawable = getBackgroundDrawable(nodeInfo);
    layout.setBackgroundDrawable(individualRowDrawable == null ? getDrawableOrDefaultBackground(rowBackgroundDrawable)
            : individualRowDrawable);
    final LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(
            calculateIndentation(nodeInfo), LayoutParams.FILL_PARENT);
    final LinearLayout indicatorLayout = (LinearLayout) layout
            .findViewById(R.id.treeview_list_item_image_layout);
    indicatorLayout.setGravity(indicatorGravity);
    indicatorLayout.setLayoutParams(indicatorLayoutParams);
    final ImageView image = (ImageView) layout
            .findViewById(R.id.treeview_list_item_image);
    image.setImageDrawable(getDrawable(nodeInfo));
    image.setScaleType(ScaleType.CENTER);
    image.setTag(nodeInfo.getId());
    image.setOnClickListener(null);
    image.setClickable(false);
    layout.setTag(nodeInfo.getId());
    final FrameLayout frameLayout = (FrameLayout) layout
            .findViewById(R.id.treeview_list_item_frame);
    final FrameLayout.LayoutParams childParams = new FrameLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    if (newChildView) {
        frameLayout.addView(childView, childParams);
    }
    frameLayout.setTag(nodeInfo.getId());
    return layout;
}
 
Example 10
Source File: Transition3d.java    From AnimationApiDemos with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// 布局中就是一个ListView和一个ImageView重叠放在一个FrameLayout中
	setContentView(R.layout.animations_main_screen);

	mPhotosList = (ListView) findViewById(android.R.id.list);
	mImageView = (ImageView) findViewById(R.id.picture);
	mContainer = (ViewGroup) findViewById(R.id.container);

	// Prepare the ListView
	final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
			android.R.layout.simple_list_item_1, PHOTOS_NAMES);

	mPhotosList.setAdapter(adapter);
	mPhotosList.setOnItemClickListener(this);

	// Prepare the ImageView
	mImageView.setClickable(true);
	mImageView.setFocusable(true);
	mImageView.setOnClickListener(this);

	// Since we are caching large views, we want to keep their cache
	// between each animation
	mContainer
			.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
	// 为了使动画效果比较流畅这里还通过persistentDrawingCache设置了控件的绘制缓存策略,一共有4种策略:
	// PERSISTENT_NO_CACHE 说明不在内存中保存绘图缓存;
	// PERSISTENT_ANIMATION_CACHE 说明只保存动画绘图缓存;
	// PERSISTENT_SCROLLING_CACHE 说明只保存滚动效果绘图缓存
	// PERSISTENT_ALL_CACHES 说明所有的绘图缓存都应该保存在内存中。

}
 
Example 11
Source File: BGABannerUtil.java    From KUtils with Apache License 2.0 5 votes vote down vote up
public static ImageView getItemImageView(Context context, @DrawableRes int placeholderResId, ImageView.ScaleType scaleType) {
    ImageView imageView = new ImageView(context);
    imageView.setImageResource(placeholderResId);
    imageView.setClickable(true);
    imageView.setScaleType(scaleType);
    return imageView;
}
 
Example 12
Source File: ColorPickerView.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
	if (colorPreview == null)
		return;
	this.colorPreview = colorPreview;
	if (selectedColor == null)
		selectedColor = 0;
	int children = colorPreview.getChildCount();
	if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
		return;

	for (int i = 0; i < children; i++) {
		View childView = colorPreview.getChildAt(i);
		if (!(childView instanceof LinearLayout))
			continue;
		LinearLayout childLayout = (LinearLayout) childView;
		if (i == selectedColor) {
			childLayout.setBackgroundColor(Color.WHITE);
		}
		ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
		childImage.setClickable(true);
		childImage.setTag(i);
		childImage.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (v == null)
					return;
				Object tag = v.getTag();
				if (tag == null || !(tag instanceof Integer))
					return;
				setSelectedColor((int) tag);
			}
		});
	}
}
 
Example 13
Source File: BGABannerUtil.java    From KUtils-master with Apache License 2.0 5 votes vote down vote up
public static ImageView getItemImageView(Context context, @DrawableRes int placeholderResId, ImageView.ScaleType scaleType) {
    ImageView imageView = new ImageView(context);
    imageView.setImageResource(placeholderResId);
    imageView.setClickable(true);
    imageView.setScaleType(scaleType);
    return imageView;
}
 
Example 14
Source File: AboutActivity.java    From Contacts with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_about);
	

	setTitle(R.string.about_activity_title);
	getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient));
	getActionBar().setDisplayHomeAsUpEnabled(true);

	ImageView companyLogo = (ImageView) findViewById(R.id.company_logo);

	companyLogo.setClickable(true);
	companyLogo.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v)
		{
			PhoneUtil.openURL(AboutActivity.this, getString(R.string.company_url));
		}
	});

	TextView version = (TextView) findViewById(R.id.version);
	TextView copyright = (TextView) findViewById(R.id.copyright);

	version.setText(getString(R.string.about_version, ApplicationUtil.getAppVersion(this)));
	
	int year = new GregorianCalendar().get(Calendar.YEAR);
	copyright.setText(getString(R.string.about_copyright, year));
}
 
Example 15
Source File: ToolbarPhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void inflateTabSwitchingResources() {
    mToggleTabStackButton = (ImageView) findViewById(R.id.tab_switcher_button);
    mNewTabButton = (NewTabButton) findViewById(R.id.new_tab_button);

    mToggleTabStackButton.setClickable(false);
    Resources resources = getResources();
    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(resources, false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(resources, true);
    mToggleTabStackButton.setImageDrawable(mTabSwitcherButtonDrawable);
    mTabSwitcherModeViews.add(mNewTabButton);

    // Ensure that the new tab button will not draw over the toolbar buttons if the
    // translated string is long.  Set a margin to the size of the toolbar button container
    // for the new tab button.
    WindowManager wm = (WindowManager) getContext().getSystemService(
            Context.WINDOW_SERVICE);
    Point screenSize = new Point();
    wm.getDefaultDisplay().getSize(screenSize);

    mToolbarButtonsContainer.measure(
            MeasureSpec.makeMeasureSpec(screenSize.x, MeasureSpec.AT_MOST),
            MeasureSpec.makeMeasureSpec(screenSize.y, MeasureSpec.AT_MOST));

    ApiCompatibilityUtils.setMarginEnd(getFrameLayoutParams(mNewTabButton),
            mToolbarButtonsContainer.getMeasuredWidth());
}
 
Example 16
Source File: SimpleGridMenu.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    View view;
    if (convertView == null) {
        view = mInflater.inflate(R.layout.item_grid_menu, parent, false);
    } else {
        view = convertView;
    }
    final String actionKey = mActionKeys.get(position);
    view.setTag(actionKey);

    final MenuItem menuItem = mMenuItems.get(actionKey);
    TextView textView = (TextView) view.findViewById(R.id.action_text);
    textView.setText(mMenuItems.get(actionKey).actionName);

    ImageView imageView = (ImageView) view.findViewById(R.id.action_image);
    if (menuItem.icon != null) {
        imageView.setVisibility(View.VISIBLE);
        int pading = Utils.dpToPx(16);
        imageView.setPadding(pading, pading, pading, pading);
        imageView.setClickable(true);
        imageView.setImageDrawable(new IconicsDrawable(mContext, menuItem.icon)
                .sizeDp(24).color(ContextCompat.getColor(mContext, R.color.background_grey)));
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (menuItem.iconListener != null)
                    menuItem.iconListener.onClick(v);
                dismiss();
            }
        });

    } else {
        imageView.setVisibility(View.GONE);
    }
    return view;
}
 
Example 17
Source File: FiltersSetupActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public FilterCell(Context context) {
    super(context);
    setWillNotDraw(false);

    moveImageView = new ImageView(context);
    moveImageView.setFocusable(false);
    moveImageView.setScaleType(ImageView.ScaleType.CENTER);
    moveImageView.setImageResource(R.drawable.list_reorder);
    moveImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
    moveImageView.setClickable(true);
    addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : 64, 14, LocaleController.isRTL ? 64 : 80, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setPadding(0, 0, 0, 0);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : 64, 35, LocaleController.isRTL ? 64 : 80, 0));
    valueTextView.setVisibility(GONE);

    optionsImageView = new ImageView(context);
    optionsImageView.setFocusable(false);
    optionsImageView.setScaleType(ImageView.ScaleType.CENTER);
    optionsImageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
    optionsImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
    optionsImageView.setImageResource(R.drawable.msg_actions);
    addView(optionsImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
}
 
Example 18
Source File: SuggestionView.java    From pearl with Apache License 2.0 4 votes vote down vote up
private void case0(Context context,Bitmap bitmp){
        suggestionTempDBHandler = new SuggestionTempDBHandler(context);
        rootView = inflate(context, R.layout.sapphireview, this);
        valueTextView = (TextView) rootView.findViewById(R.id.header);
        footer = (TextView) rootView.findViewById(R.id.footer);
        RelativeLayout.LayoutParams paramsT = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        paramsT.addRule(RelativeLayout.CENTER_HORIZONTAL, valueTextView.getId());
        paramsT.setMargins(21,22,22,22);
        valueTextView.setLayoutParams(paramsT);
        valueTextView.setText(TEXT);
        valueTextView.setGravity(Gravity.CENTER);
        valueTextView.setTextSize(headerTextSize);
        valueTextView.setTextColor(Color.parseColor(defaultheaderTextColor));
        valueTextView.setClickable(false);
        minusButton = (ImageView) rootView.findViewById(R.id.imageBack);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_HORIZONTAL, minusButton.getId());
        params.addRule(RelativeLayout.BELOW, valueTextView.getId());
        minusButton.setLayoutParams(params);
        minusButton.setClickable(false);
        if(bitmp!= null){
            minusButton.setImageBitmap(bitmp);
        }else{
            //Try to fetch image from the backend. Try the internet connection . Use internet for thart.

          /*  String urlpic = "https://api.backendless.com/ECDF6288-9FD1-56B8-FFB7-A7E5A4228A00/v1" +
                    "/files/SapphireDemo*57f3f577e4b0b14082481f27/girl*57f3f577e4b0b14082481f27.jpg";
*/
        }
        RelativeLayout.LayoutParams paramsF = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        paramsF.addRule(RelativeLayout.CENTER_HORIZONTAL, footer.getId());
        paramsF.addRule(RelativeLayout.BELOW, minusButton.getId());
        paramsF.setMargins(3,5,3,5);
        footer.setLayoutParams(paramsF);
        footer.setTextColor(Color.parseColor(defaultfooterTextColor));
        footer.setText(Ftext);
        footer.setTextSize(footerTextSize);
        footer.setClickable(false);
    }
 
Example 19
Source File: MessageAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
/**
 * load image into image view
 * 
 * @param thumbernailPath
 * @param iv
 * @param position
 * @return the image exists or not
 */
private boolean showImageView(final String thumbernailPath,
        final ImageView iv, final String localFullSizePath,
        String remoteDir, final EMMessage message) {
    // String imagename =
    // localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1,
    // localFullSizePath.length());
    // final String remote = remoteDir != null ? remoteDir+imagename :
    // imagename;
    final String remote = remoteDir;
    EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);
        iv.setClickable(true);
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                System.err.println("image view on click");
                Intent intent = new Intent(activity, ShowBigImage.class);
                File file = new File(localFullSizePath);
                if (file.exists()) {
                    Uri uri = Uri.fromFile(file);
                    intent.putExtra("uri", uri);
                    System.err
                            .println("here need to check why download everytime");
                } else {
                    // The local full size pic does not exist yet.
                    // ShowBigImage needs to download it from the server
                    // first
                    // intent.putExtra("", message.get);
                    ImageMessageBody body = (ImageMessageBody) message
                            .getBody();
                    intent.putExtra("secret", body.getSecret());
                    intent.putExtra("remotepath", remote);
                }
                if (message != null
                        && message.direct == EMMessage.Direct.RECEIVE
                        && !message.isAcked
                        && message.getChatType() != ChatType.GroupChat) {
                    try {
                        EMChatManager.getInstance().ackMessageRead(
                                message.getFrom(), message.getMsgId());
                        message.isAcked = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                activity.startActivity(intent);
            }
        });
        return true;
    } else {

        new LoadImageTask().execute(thumbernailPath, localFullSizePath,
                remote, message.getChatType(), iv, activity, message);
        return true;
    }

}
 
Example 20
Source File: HistoryDetailsActivity.java    From SecScanQR with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    generalHandler = new GeneralHandler(this);
    generalHandler.loadTheme();
    setContentView(R.layout.activity_history_details);
    tvCode = (TextView) findViewById(R.id.tvTxtqrcodeHistory);
    tvFormat = (TextView) findViewById(R.id.tvFormatHistory);
    codeImage = (ImageView) findViewById(R.id.resultImageHistory);
    codeImage.setClickable(true);

    action_navigation = (BottomNavigationView) findViewById(R.id.history_action_navigation);
    action_navigation.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);
    action_navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    historyDatabaseHelper = new DatabaseHelper(this);

    //Get the extra information from the history listview. and set the text in the textview eqaul to code
    Intent receivedIntent = getIntent();
    selectedCode = receivedIntent.getStringExtra(EXTRA_INFORMATION);
    tvCode.setText(selectedCode);
    selectedFormat = receivedIntent.getStringExtra(EXTRA_FORMAT);
    tvFormat.setText(selectedFormat);
    showQrImage();

    if(selectedCode.contains("BEGIN:VCARD") & selectedCode.contains("END:VCARD")){
        action_navigation.getMenu().removeItem(R.id.history_action_navigation_openInWeb);
    } else {
        action_navigation.getMenu().removeItem(R.id.history_action_navigation_createContact);
    }

    codeImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(HistoryDetailsActivity.this , GeneratorResultActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("CODE", selectedCode);
            int formatID = generalHandler.StringToBarcodeId(selectedFormat);
            bundle.putInt("FORMAT", formatID);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    });
}