Example usage for android.util TypedValue applyDimension

List of usage examples for android.util TypedValue applyDimension

Introduction

In this page you can find the example usage for android.util TypedValue applyDimension.

Prototype

public static float applyDimension(int unit, float value, DisplayMetrics metrics) 

Source Link

Document

Converts an unpacked complex data value holding a dimension to its final floating point value.

Usage

From source file:com.aujur.ebookreader.reading.options.ReadingOptionsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    super.onViewCreated(view, savedInstanceState);

    adapter = new MyPagerAdapter(getActivity().getSupportFragmentManager());

    pager.setAdapter(adapter);/*  ww w . j a  v a  2 s . c om*/

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setPageMarginDrawable(R.color.medium_gray);

    tabs.setViewPager(pager);

    changeColor(currentColor);

}

From source file:com.astuetz.viewpager.extensions.gramis.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.inject(this);
    setSupportActionBar(toolbar);/* ww w  . j a v  a  2 s  .  c  o  m*/
    // create our manager instance after the content view is set
    mTintManager = new SystemBarTintManager(this);
    // enable status bar tint
    mTintManager.setStatusBarTintEnabled(true);
    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(0);

    String[] mainMenu = { "?", "?", "??", "" };

    AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            switch (position) {
            case 0:
                Intent intent0 = new Intent(MainActivity.this, MainActivity.class);
                startActivity(intent0);
                break;
            case 1:
                Intent intent1 = new Intent(MainActivity.this, IconsActivity.class);
                startActivity(intent1);
                break;
            case 2:
                Intent intent2 = new Intent(MainActivity.this, ActiveActivity.class);
                startActivity(intent2);
                break;
            case 3:
                Intent intent3 = new Intent(MainActivity.this, ProfileActivity.class);
                startActivity(intent3);
                break;
            }
        }
    };

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            mainMenu);
    listViewMainMenu.setAdapter(adapter);
    listViewMainMenu.setOnItemClickListener(onItemClickListener);
}

From source file:com.chale22.ico01.IconActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_icon);
    mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.setType("text/plain");
    mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new.");

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);

    adapter = new IconPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);/*from  ww  w  .  j ava  2s. c  o  m*/

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

}

From source file:com.collcloud.frame.viewpager.main.PagerTabMainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_pagertab__main);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);// w w  w . j ava2s . co m

    //initView();
    //      viewPagerAdapter = new  ViewPagerAdapter(lists);
    //      pager.setAdapter(viewPagerAdapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

    tabs.setOnPageChangeListener(new OnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            /*initListView(position);
            clickTitleItem(position);*/
            Log.i(tag, "onPageSelected position is:" + position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }
    });

    changeColor(currentColor);

}

From source file:com.csform.android.uiapptemplate.TabShopActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_shop);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.activity_tab_shop_tabs);
    pager = (ViewPager) findViewById(R.id.activity_tab_shop_pager);
    image = (ImageView) findViewById(R.id.activity_tab_shop_image);
    like = (TextView) findViewById(R.id.activity_tab_shop_like);
    favorite = (TextView) findViewById(R.id.activity_tab_shop_favorite);
    share = (TextView) findViewById(R.id.activity_tab_shop_share);

    like.setOnClickListener(this);
    favorite.setOnClickListener(this);
    share.setOnClickListener(this);

    ImageUtil.displayImage(image, "http://pengaja.com/uiapptemplate/newphotos/shop/7.jpg", null);

    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);//from w w w  . ja v  a  2 s .com
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(1);

    tabs.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() {
        @Override
        public void onTabReselected(int position) {
            Toast.makeText(TabShopActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.dashihui.afford.ui.activity.AtyFragmentDiscount.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aty_order_frag);

    mTopTitle_txt = (TextView) findViewById(R.id.title);
    mTopTitle_txt.setText("");
    mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack);
    mIbtnBack.setOnClickListener(this);

    tabs = (WdtPagerSlidingTabStrip) findViewById(R.id.apps_fragment_tabs);
    pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager);
    Intent intent = getIntent();//from w  w  w. ja v  a  2  s.c  o  m
    //??1  2 ?? ???searchClassifyType
    mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    // ???N??
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(intent.getIntExtra(TABCODE, 0));
    tabs.setViewPager(pager);

    changeColor(currentColor);
}

From source file:com.dashihui.afford.ui.activity.AtyFragmentOrdert.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aty_order_frag);

    mTopTitle_txt = (TextView) findViewById(R.id.title);
    mTopTitle_txt.setText("?");
    mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack);
    mIbtnBack.setOnClickListener(this);

    tabs = (WdtPagerTab) findViewById(R.id.apps_fragment_tabs);
    pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager);
    Intent intent = getIntent();//w w  w.  j a  v  a2  s .c  om
    //??1  2 ?? ???searchClassifyType
    mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    // ???N??
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(intent.getIntExtra(TABCODE, 0));
    tabs.setViewPager(pager);
    tabs.setPosition(intent.getIntExtra(TABCODE, 0));

    LogUtils.e("position=============>" + intent.getIntExtra(TABCODE, 0));
    tabs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i1) {
        }

        @Override
        public void onPageSelected(int i) {
            FragmentOrder fragmentOrder = FragmentOrder.newInstance(AtyFragmentOrdert.this, i);
        }

        @Override
        public void onPageScrollStateChanged(int i) {

        }
    });
}

From source file:com.dashihui.afford.ui.activity.AtyFragmentService.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aty_orderserver_frag);

    mTopTitle_txt = (TextView) findViewById(R.id.title);
    mTopTitle_txt.setText("??");
    mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack);
    mIbtnBack.setOnClickListener(this);

    tabs = (WdtPagerSlidingTabStrip) findViewById(R.id.apps_fragment_tabs);
    pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager);
    Intent intent = getIntent();/*from   w  w w  . j a  v a2  s .c om*/
    //??1  2 ?? ???searchClassifyType
    mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    // ???N??
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(intent.getIntExtra("tabCode", 0));
    tabs.setViewPager(pager);

    changeColor(currentColor);
}

From source file:com.android.settings.localepicker.LocaleDragAndDropAdapter.java

public LocaleDragAndDropAdapter(Context context, List<LocaleStore.LocaleInfo> feedItemList) {
    this.mFeedItemList = feedItemList;

    this.mContext = context;

    final float dragElevation = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            context.getResources().getDisplayMetrics());

    this.mItemTouchHelper = new ItemTouchHelper(
            new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0 /* no swipe */) {

                @Override/*from   w  ww . ja  v  a2 s .  c  o m*/
                public boolean onMove(RecyclerView view, RecyclerView.ViewHolder source,
                        RecyclerView.ViewHolder target) {
                    onItemMove(source.getAdapterPosition(), target.getAdapterPosition());
                    return true;
                }

                @Override
                public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) {
                    // Swipe is disabled, this is intentionally empty.
                }

                private static final int SELECTION_GAINED = 1;
                private static final int SELECTION_LOST = 0;
                private static final int SELECTION_UNCHANGED = -1;
                private int mSelectionStatus = SELECTION_UNCHANGED;

                @Override
                public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                        float dX, float dY, int actionState, boolean isCurrentlyActive) {

                    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
                    // We change the elevation if selection changed
                    if (mSelectionStatus != SELECTION_UNCHANGED) {
                        viewHolder.itemView
                                .setElevation(mSelectionStatus == SELECTION_GAINED ? dragElevation : 0);
                        mSelectionStatus = SELECTION_UNCHANGED;
                    }
                }

                @Override
                public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
                    super.onSelectedChanged(viewHolder, actionState);
                    if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
                        mSelectionStatus = SELECTION_GAINED;
                    } else if (actionState == ItemTouchHelper.ACTION_STATE_IDLE) {
                        mSelectionStatus = SELECTION_LOST;
                    }
                }
            });
}

From source file:com.bluelinelabs.conductor.demo.widget.ElasticDragDismissFrameLayout.java

public ElasticDragDismissFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    dragDismissDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80,
            getResources().getDisplayMetrics());
    dragDismissFraction = 0.7f;//from www . jav  a  2s.  com
    dragDismissScale = 0.8f;
    shouldScale = true;
}