Search in sources :

Example 16 with ImageView

use of android.widget.ImageView in project SimplifyReader by chentao0707.

the class CommonImagePickerListActivity method initViewsAndEvents.

@Override
protected void initViewsAndEvents() {
    setTitle(getResources().getString(R.string.title_image_picker));
    mListViewAdapter = new ListViewDataAdapter<ImageBucket>(new ViewHolderCreator<ImageBucket>() {

        @Override
        public ViewHolderBase<ImageBucket> createViewHolder(int position) {
            return new ViewHolderBase<ImageBucket>() {

                ImageView mItemImage;

                TextView mItemTitle;

                @Override
                public View createView(LayoutInflater layoutInflater) {
                    View convertView = layoutInflater.inflate(R.layout.list_item_common_image_picker, null);
                    mItemImage = ButterKnife.findById(convertView, R.id.list_item_common_image_picker_thumbnail);
                    mItemTitle = ButterKnife.findById(convertView, R.id.list_item_common_image_picker_title);
                    return convertView;
                }

                @Override
                public void showData(int position, ImageBucket itemData) {
                    if (null != itemData) {
                        String imagePath = itemData.bucketList.get(0).getImagePath();
                        if (!CommonUtils.isEmpty(imagePath)) {
                            ImageLoader.getInstance().displayImage("file://" + imagePath, mItemImage, ImageLoaderHelper.getInstance(mContext).getDisplayOptions());
                        }
                        int count = itemData.count;
                        String title = itemData.bucketName;
                        if (!CommonUtils.isEmpty(title)) {
                            mItemTitle.setText(title + "(" + count + ")");
                        }
                    }
                }
            };
        }
    });
    mImagePickerListView.setAdapter(mListViewAdapter);
    mImagePickerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (null != mListViewAdapter && null != mListViewAdapter.getDataList() && !mListViewAdapter.getDataList().isEmpty() && position < mListViewAdapter.getDataList().size()) {
                Bundle extras = new Bundle();
                extras.putParcelableArrayList(KEY_BUNDLE_ALBUM_PATH, mListViewAdapter.getDataList().get(position).bucketList);
                extras.putString(KEY_BUNDLE_ALBUM_NAME, mListViewAdapter.getDataList().get(position).bucketName);
                readyGoForResult(CommonImagePickerDetailActivity.class, IMAGE_PICKER_DETAIL_REQUEST_CODE, extras);
            }
        }
    });
    mAlbumLoadTask = new AsyncTask<Void, Void, List<ImageBucket>>() {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            toggleShowLoading(true, null);
            ImagePickerHelper.getHelper().init(mContext);
        }

        @Override
        protected List<ImageBucket> doInBackground(Void... params) {
            return ImagePickerHelper.getHelper().getImagesBucketList();
        }

        @Override
        protected void onPostExecute(List<ImageBucket> list) {
            toggleShowLoading(false, null);
            mListViewAdapter.getDataList().addAll(list);
            mListViewAdapter.notifyDataSetChanged();
        }
    };
    mAlbumLoadTask.execute();
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ImageBucket(com.github.obsessive.library.picker.ImageBucket) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) List(java.util.List) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator)

Example 17 with ImageView

use of android.widget.ImageView in project SimplifyReader by chentao0707.

the class HomeActivity method initializeViews.

@Override
public void initializeViews(List<BaseLazyFragment> fragments, List<NavigationEntity> navigationList) {
    mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            setTitle(getString(R.string.app_name));
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (null != mNavListAdapter) {
                setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
            }
        }
    };
    mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
    if (null != fragments && !fragments.isEmpty()) {
        mViewPager.setEnableScroll(false);
        mViewPager.setOffscreenPageLimit(fragments.size());
        mViewPager.setAdapter(new VPFragmentAdapter(getSupportFragmentManager(), fragments));
    }
    mNavListAdapter = new ListViewDataAdapter<NavigationEntity>(new ViewHolderCreator<NavigationEntity>() {

        @Override
        public ViewHolderBase<NavigationEntity> createViewHolder(int position) {
            return new ViewHolderBase<NavigationEntity>() {

                ImageView itemIcon;

                TextView itemName;

                @Override
                public View createView(LayoutInflater layoutInflater) {
                    View convertView = layoutInflater.inflate(R.layout.list_item_navigation, null);
                    itemIcon = ButterKnife.findById(convertView, R.id.list_item_navigation_icon);
                    itemName = ButterKnife.findById(convertView, R.id.list_item_navigation_name);
                    return convertView;
                }

                @Override
                public void showData(int i, NavigationEntity navigationEntity) {
                    itemIcon.setImageResource(navigationEntity.getIconResId());
                    itemName.setText(navigationEntity.getName());
                    if (mCurrentMenuCheckedPos == i) {
                        // checked
                        itemName.setTextColor(getResources().getColor(mCheckedListItemColorResIds[i]));
                    } else {
                        // unchecked
                        itemName.setTextColor(getResources().getColor(android.R.color.black));
                    }
                }
            };
        }
    });
    mNavListView.setAdapter(mNavListAdapter);
    mNavListAdapter.getDataList().addAll(navigationList);
    mNavListAdapter.notifyDataSetChanged();
    setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
    mNavListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mCurrentMenuCheckedPos = position;
            mNavListAdapter.notifyDataSetChanged();
            mDrawerLayout.closeDrawer(Gravity.LEFT);
            mViewPager.setCurrentItem(mCurrentMenuCheckedPos, false);
        }
    });
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) HomeView(com.github.obsessive.simplifyreader.view.HomeView) TextView(android.widget.TextView) ListView(android.widget.ListView) NavigationEntity(com.github.obsessive.simplifyreader.bean.NavigationEntity) VPFragmentAdapter(com.github.obsessive.simplifyreader.ui.adpter.VPFragmentAdapter) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator)

Example 18 with ImageView

use of android.widget.ImageView in project GeekNews by codeestX.

the class CircularAnimUtil method startActivityForResult.

/**
     * 从指定View开始向四周伸张(伸张颜色或图片为colorOrImageRes), 然后进入另一个Activity,
     * 返回至 @thisActivity 后显示收缩动画。
     */
@SuppressLint("NewApi")
public static void startActivityForResult(final Activity thisActivity, final Intent intent, final Integer requestCode, final Bundle bundle, final View triggerView, int colorOrImageRes, long durationMills) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
        thisActivity.startActivity(intent);
        return;
    }
    int[] location = new int[2];
    triggerView.getLocationInWindow(location);
    final int cx = location[0] + triggerView.getWidth() / 2;
    final int cy = location[1] + triggerView.getHeight() / 2;
    final ImageView view = new ImageView(thisActivity);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setImageResource(colorOrImageRes);
    final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView();
    int w = decorView.getWidth();
    int h = decorView.getHeight();
    decorView.addView(view, w, h);
    // 计算中心点至view边界的最大距离
    int maxW = Math.max(cx, w - cx);
    int maxH = Math.max(cy, h - cy);
    final int finalRadius = (int) Math.sqrt(maxW * maxW + maxH * maxH) + 1;
    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
    int maxRadius = (int) Math.sqrt(w * w + h * h) + 1;
    // 若使用默认时长,则需要根据水波扩散的距离来计算实际时间
    if (durationMills == PERFECT_MILLS) {
        // 算出实际边距与最大边距的比率
        double rate = 1d * finalRadius / maxRadius;
        // 水波扩散的距离与扩散时间成正比
        durationMills = (long) (PERFECT_MILLS * rate);
    }
    final long finalDuration = durationMills;
    anim.setDuration(finalDuration);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (requestCode == null)
                thisActivity.startActivity(intent);
            else if (bundle == null)
                thisActivity.startActivityForResult(intent, requestCode);
            else
                thisActivity.startActivityForResult(intent, requestCode, bundle);
            // 默认渐隐过渡动画.
            thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            // 默认显示返回至当前Activity的动画.
            triggerView.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, finalRadius, 0);
                    anim.setDuration(finalDuration);
                    anim.addListener(new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            super.onAnimationEnd(animation);
                            try {
                                decorView.removeView(view);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    anim.start();
                }
            }, 1000);
        }
    });
    anim.start();
}
Also used : Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ImageView(android.widget.ImageView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 19 with ImageView

use of android.widget.ImageView in project UltimateAndroid by cymcsg.

the class ParallaxSwipeBackActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    //通过反射来改变SlidingPanelayout的值
    try {
        slidingPaneLayout = new SlidingPaneLayout(this);
        Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
        f_overHang.setAccessible(true);
        f_overHang.set(slidingPaneLayout, 0);
        slidingPaneLayout.setPanelSlideListener(this);
        slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.onCreate(savedInstanceState);
    mFileTemp = new File(getCacheDir(), WINDOWBITMAP);
    defaultTranslationX = dip2px(defaultTranslationX);
    shadowWidth = dip2px(shadowWidth);
    //behindframeLayout
    FrameLayout behindframeLayout = new FrameLayout(this);
    behindImageView = new ImageView(this);
    behindImageView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    behindframeLayout.addView(behindImageView, 0);
    //containerLayout
    LinearLayout containerLayout = new LinearLayout(this);
    containerLayout.setOrientation(LinearLayout.HORIZONTAL);
    containerLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    containerLayout.setLayoutParams(new ViewGroup.LayoutParams(getWindowManager().getDefaultDisplay().getWidth() + shadowWidth, ViewGroup.LayoutParams.MATCH_PARENT));
    //you view container
    frameLayout = new FrameLayout(this);
    frameLayout.setBackgroundColor(getResources().getColor(android.R.color.white));
    frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    //add shadow
    shadowImageView = new ImageView(this);
    shadowImageView.setBackgroundResource(R.drawable.parallax_swipe_back_shadow);
    shadowImageView.setLayoutParams(new LinearLayout.LayoutParams(shadowWidth, LinearLayout.LayoutParams.MATCH_PARENT));
    containerLayout.addView(shadowImageView);
    containerLayout.addView(frameLayout);
    containerLayout.setTranslationX(-shadowWidth);
    //添加两个view
    slidingPaneLayout.addView(behindframeLayout, 0);
    slidingPaneLayout.addView(containerLayout, 1);
}
Also used : Field(java.lang.reflect.Field) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 20 with ImageView

use of android.widget.ImageView in project philm by chrisbanes.

the class SideMenuFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View view = inflater.inflate(R.layout.fragment_drawer, container, false);
    mListView = (ListView) view.findViewById(android.R.id.list);
    mListView.setOnItemClickListener(this);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mAdapter = new SideMenuItemAdapter();
    mListView.setAdapter(mAdapter);
    mAddAccountLayout = view.findViewById(R.id.layout_add_account);
    mAddAccountLayout.setOnClickListener(this);
    mProfileLayout = view.findViewById(R.id.layout_profile);
    mUsernameTextView = (TextView) view.findViewById(R.id.textview_username);
    mFullnameTextView = (TextView) view.findViewById(R.id.textview_fullname);
    mAvatarImageView = (ImageView) view.findViewById(R.id.imageview_account_avatar);
    mCheckinLayout = view.findViewById(R.id.layout_checkin);
    mCheckinLayout.setOnClickListener(this);
    mCheckinImageView = (PhilmImageView) view.findViewById(R.id.imageview_checkin_movie);
    mCheckinImageView.setAutoFade(false);
    mCheckinTitleTextView = (TextView) mCheckinLayout.findViewById(R.id.textview_title);
    final int darkenByte = Math.round(255 * CHECKIN_BACKDROP_DARKEN);
    mColorFilter = new LightingColorFilter(Color.rgb(darkenByte, darkenByte, darkenByte), 0);
    return view;
}
Also used : LightingColorFilter(android.graphics.LightingColorFilter) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) PhilmImageView(app.philm.in.view.PhilmImageView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

ImageView (android.widget.ImageView)2176 View (android.view.View)1100 TextView (android.widget.TextView)963 Drawable (android.graphics.drawable.Drawable)192 Intent (android.content.Intent)191 LinearLayout (android.widget.LinearLayout)187 Bitmap (android.graphics.Bitmap)175 ViewGroup (android.view.ViewGroup)161 LayoutInflater (android.view.LayoutInflater)155 OnClickListener (android.view.View.OnClickListener)142 AdapterView (android.widget.AdapterView)108 ListView (android.widget.ListView)101 RecyclerView (android.support.v7.widget.RecyclerView)97 FrameLayout (android.widget.FrameLayout)95 Button (android.widget.Button)80 BitmapDrawable (android.graphics.drawable.BitmapDrawable)75 Bundle (android.os.Bundle)73 Test (org.junit.Test)70 RelativeLayout (android.widget.RelativeLayout)69 Context (android.content.Context)65