Search in sources :

Example 16 with ContextCompat.getDrawable

use of android.support.v4.content.ContextCompat.getDrawable in project philm by chrisbanes.

the class PhilmImageView method setImageResourceImpl.

void setImageResourceImpl(@DrawableRes int resId) {
    if (mAvatarMode) {
        BitmapDrawable d = (BitmapDrawable) ContextCompat.getDrawable(getContext(), resId);
        RoundedBitmapDrawable rd = RoundedBitmapDrawableFactory.create(getResources(), d.getBitmap());
        rd.setCircular(true);
        setImageDrawable(rd);
    } else {
        setImageResource(resId);
    }
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable)

Example 17 with ContextCompat.getDrawable

use of android.support.v4.content.ContextCompat.getDrawable in project ride-read-android by Ride-Read.

the class TimeLineFragment method initView.

private void initView(View v) {
    final TabLayout tablayout = (TabLayout) v.findViewById(R.id.main_timeline_tablayout);
    tablayout.setSelectedTabIndicatorColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
    LinearLayout linearLayout = (LinearLayout) tablayout.getChildAt(0);
    linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
    linearLayout.setDividerPadding(20);
    linearLayout.setDividerDrawable(ContextCompat.getDrawable(getContext(), R.drawable.timleline_tablayout_divider));
    initViewPager(v);
    tablayout.setupWithViewPager(viewPager);
    for (int i = 0; i < tablayout.getTabCount(); i++) {
        TabLayout.Tab tab = tablayout.getTabAt(i);
        tab.setText(tabTitle[i]);
    }
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            tablayout.setScrollPosition(position, positionOffset, true);
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager) LinearLayout(android.widget.LinearLayout)

Example 18 with ContextCompat.getDrawable

use of android.support.v4.content.ContextCompat.getDrawable in project Rashr by DsLNeXuS.

the class BackupActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_backup);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    ActionBar actionbar = getSupportActionBar();
    if (actionbar != null) {
        actionbar.setDisplayHomeAsUpEnabled(true);
    }
    mAdapter = new BackupRestorePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mAdapter);
    mSlidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {

        @Override
        public int getIndicatorColor(int position) {
            TypedValue typedValue = new TypedValue();
            Resources.Theme theme = mContext.getTheme();
            theme.resolveAttribute(R.attr.colorAccent, typedValue, true);
            return typedValue.data;
        }

        @Override
        public int getDividerColor(int position) {
            return 0;
        }
    });
    mSlidingTabLayout.setViewPager(mPager);
    mFab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isRecovery = mPager.getCurrentItem() == 0;
            createBackup(isRecovery);
        }
    });
    mFab.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_add_white));
    mSlidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            if (position == 0) {
                if (App.Device.isRecoveryBackupPossible()) {
                    mFab.setVisibility(View.VISIBLE);
                } else {
                    mFab.setVisibility(View.INVISIBLE);
                }
            } else {
                if (App.Device.isKernelBackupPossible()) {
                    mFab.setVisibility(View.VISIBLE);
                } else {
                    mFab.setVisibility(View.INVISIBLE);
                }
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
}
Also used : SlidingTabLayout(de.mkrtchyan.recoverytools.view.SlidingTabLayout) BindView(butterknife.BindView) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) RecyclerView(android.support.v7.widget.RecyclerView) ViewPager(android.support.v4.view.ViewPager) ActionBar(android.support.v7.app.ActionBar) TypedValue(android.util.TypedValue)

Example 19 with ContextCompat.getDrawable

use of android.support.v4.content.ContextCompat.getDrawable in project Ruisi by freedom10086.

the class MySmileyPicker method init.

private void init() {
    View v = LayoutInflater.from(mContext).inflate(R.layout.my_smiley_view, null);
    TabLayout tab = v.findViewById(R.id.mytab);
    RecyclerView recyclerView = v.findViewById(R.id.recyclerView);
    getSmileys();
    tab.addTab(tab.newTab().setText("贴吧"));
    tab.addTab(tab.newTab().setText("金馆长"));
    tab.addTab(tab.newTab().setText("AC娘"));
    RecyclerView.LayoutManager layoutManager = new GridLayoutManager(mContext, 7, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    adapter = new SmileyAdapter(mContext, (v1, position) -> {
        ImageView img = (ImageView) v1;
        smileyClick(img.getDrawable(), position);
        dismiss();
    }, smileys);
    tab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            changeSmiley(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
    recyclerView.setAdapter(adapter);
    setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.rec_solid_primary_bg));
    setFocusable(true);
    setContentView(v);
}
Also used : Context(android.content.Context) GridLayoutManager(android.support.v7.widget.GridLayoutManager) LayoutInflater(android.view.LayoutInflater) ContextCompat(android.support.v4.content.ContextCompat) Pair(android.util.Pair) ImageView(android.widget.ImageView) PopupWindow(android.widget.PopupWindow) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Drawable(android.graphics.drawable.Drawable) ViewGroup(android.view.ViewGroup) R(me.yluo.ruisiapp.R) ArrayList(java.util.ArrayList) TabLayout(android.support.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) SmileyAdapter(me.yluo.ruisiapp.adapter.SmileyAdapter) View(android.view.View) Log(android.util.Log) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SmileyAdapter(me.yluo.ruisiapp.adapter.SmileyAdapter) TabLayout(android.support.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 20 with ContextCompat.getDrawable

use of android.support.v4.content.ContextCompat.getDrawable in project chefly_android by chef-ly.

the class ListViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_list_view, container, false);
    listView = (ListView) v.findViewById(R.id.list);
    emptyView = v.findViewById(R.id.emptyList);
    if (title.equals("Favorites")) {
        emptyView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.emptylist));
    } else {
        emptyView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.emptylistwelcome));
    }
    listView.setAdapter(new ListViewFragment.RecipeAdapter(getContext(), list, mListener));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView l, View v, int position, long id) {
            Intent intent = new Intent(getContext(), RecipeDetailActivity.class);
            RecipeInformation recipe = ((RecipeInformation) l.getAdapter().getItem(position));
            // intent.putExtra("recipe", String.valueOf(recipeID));
            intent.putExtra("recipeDetail", recipe);
            Log.d(TAG + "/" + title, "Recipe Clicked: id -> " + recipe.getId());
            startActivity(intent);
        }
    });
    final LoaderManager.LoaderCallbacks callbacks = this;
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (title.equals(RECIPES)) {
                // TODO remove limit and or wait for user to scroll past end of list to load more
                if (firstVisibleItem + visibleItemCount + 2 == totalItemCount && totalItemCount != 0 && totalItemCount < 25) {
                    if (!isLoading.get()) {
                        Log.d(TAG + "/" + title, "Getting more recipes from server");
                        isLoading.set(true);
                        RequestMethod requestPackage = new RequestMethod();
                        if (searchText.length() == 0) {
                            // requestPackage.setEndPoint(urlString + qMark + urlRequestNumber + requestNumRandom);
                            requestPackage.setEndPoint(urlString + urlQ + urlPageNum + requestNumRandom);
                            requestNumRandom++;
                        } else {
                            // requestPackage.setEndPoint(urlStringSearch + searchText + urlRequestNumber + requestNumSearch);
                            requestPackage.setEndPoint(urlStringSearch + searchText + urlA + urlPageNum + requestNumSearch);
                            requestNumSearch++;
                        }
                        requestPackage.setMethod("GET");
                        Log.d(TAG, "Get more recipes from -> " + requestPackage.getEndpoint());
                        Bundle bundle = new Bundle();
                        bundle.putParcelable("requestPackage", requestPackage);
                        // Log.d(TAG, "onScroll: SearchQuery -> " + searchText);
                        getLoaderManager().initLoader((new Date()).hashCode(), bundle, callbacks).forceLoad();
                    }
                }
            }
        }
    });
    final Handler h = new Handler();
    h.postDelayed(new Runnable() {

        @Override
        public void run() {
            listView.setEmptyView(emptyView);
        }
    }, 500);
    // Inflate the layout for this fragment
    return v;
}
Also used : RequestMethod(com.se491.chef_ly.http.RequestMethod) Bundle(android.os.Bundle) AbsListView(android.widget.AbsListView) Handler(android.os.Handler) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) RecipeInformation(com.se491.chef_ly.model.RecipeInformation) Date(java.util.Date) LoaderManager(android.support.v4.app.LoaderManager) AdapterView(android.widget.AdapterView)

Aggregations

View (android.view.View)13 ImageView (android.widget.ImageView)10 Drawable (android.graphics.drawable.Drawable)9 TextView (android.widget.TextView)6 Bundle (android.os.Bundle)5 ContextCompat (android.support.v4.content.ContextCompat)5 ViewPager (android.support.v4.view.ViewPager)5 ViewGroup (android.view.ViewGroup)5 Context (android.content.Context)4 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)3 Color (android.graphics.Color)3 Handler (android.os.Handler)3 NonNull (android.support.annotation.NonNull)3 Fragment (android.support.v4.app.Fragment)3 RoundedBitmapDrawable (android.support.v4.graphics.drawable.RoundedBitmapDrawable)3 RecyclerView (android.support.v7.widget.RecyclerView)3 TypedValue (android.util.TypedValue)3 LayoutInflater (android.view.LayoutInflater)3 FrameLayout (android.widget.FrameLayout)3