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);
}
}
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) {
}
});
}
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) {
}
});
}
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);
}
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;
}
Aggregations