use of android.support.v7.widget.RecyclerView.ViewHolder in project AdvancedMaterialDrawer by madcyph3r.
the class ThemeFragment method createAdapter.
private void createAdapter(RecyclerView recyclerView) {
final List<ExampleData> content = new ArrayList<>();
content.add(new ExampleData("Dark Theme", DarkThemeActivity.class));
content.add(new ExampleData("Light Theme", LightThemeActivity.class));
content.add(new ExampleData("My Theme", MyThemeActivity.class));
content.add(new ExampleData("Unique Toolbar Color", UniqueToolbarColorActivity.class));
content.add(new ExampleData("Actionbar Overlay", ActionBarOverlayActivity.class));
content.add(new ExampleData("KitKat Translucent Statusbar", KitKatTranslucentStatusBarActivity.class));
content.add(new ExampleData("Actionbar Own Font", ActionBarOwnFontActivity.class));
content.add(new ExampleData("Own Drawer Width", OwnDrawerWidthActivity.class));
content.add(new ExampleData("Only Icons Menu", OnlyIconsActivity.class));
final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
headerImage.setImageResource(R.drawable.l_8);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
return holder;
}
@Override
public int getItemCount() {
return content.size();
}
});
adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View view) {
((MainActivity) getActivity()).setActionBarAlpha(percentage);
}
});
adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {
@Override
public void onClick(View view, int i) {
if (i >= 0) {
Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
startActivity(intent);
}
}
});
recyclerView.setAdapter(adapter);
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project AdvancedMaterialDrawer by madcyph3r.
the class BackPatternFragment method createAdapter.
private void createAdapter(RecyclerView recyclerView) {
final List<ExampleData> content = new ArrayList<>();
content.add(new ExampleData("Custom Back Pattern", BackPatternCustomActivity.class));
content.add(new ExampleData("Default Back Pattern", BackPatternDefaultActivity.class));
content.add(new ExampleData("StartIndex Back Pattern", BackPatternStartIndexActivity.class));
content.add(new ExampleData("Last Section Fragment Back Pattern", BackPatternLastSectionActivity.class));
final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
headerImage.setImageResource(R.drawable.l_1);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
return holder;
}
@Override
public int getItemCount() {
return content.size();
}
});
adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View view) {
((MainActivity) getActivity()).setActionBarAlpha(percentage);
}
});
adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {
@Override
public void onClick(View view, int i) {
if (i >= 0) {
Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
startActivity(intent);
}
}
});
recyclerView.setAdapter(adapter);
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project xabber-android by redsolution.
the class GroupedContactAdapter method getAccountView.
private View getAccountView(int position, View convertView, ViewGroup parent) {
final View view;
final ContactListAccountItemViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.contact_list_account_group_item, parent, false);
viewHolder = new ContactListAccountItemViewHolder(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(accountElevation);
}
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (ContactListAccountItemViewHolder) view.getTag();
}
final AccountConfiguration configuration = (AccountConfiguration) getItem(position);
final String account = configuration.getAccount();
viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClickListener.onAccountMenuClick(v, account);
}
});
final int level = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountGroupColors[level]));
viewHolder.name.setText(GroupManager.getInstance().getGroupName(account, configuration.getUser()));
viewHolder.smallRightText.setText(configuration.getOnline() + "/" + configuration.getTotal());
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
String statusText = accountItem.getStatusText().trim();
if (statusText.isEmpty()) {
statusText = activity.getString(accountItem.getDisplayStatusMode().getStringID());
}
viewHolder.secondLineMessage.setText(statusText);
if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
} else {
viewHolder.avatar.setVisibility(View.GONE);
}
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(AccountViewer.createAccountInfoIntent(activity, account));
}
});
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
if (showOfflineMode == ShowOfflineMode.normal) {
if (SettingsManager.contactsShowOffline()) {
showOfflineMode = ShowOfflineMode.always;
} else {
showOfflineMode = ShowOfflineMode.never;
}
}
viewHolder.smallRightIcon.setImageLevel(showOfflineMode.ordinal());
StatusMode statusMode = AccountManager.getInstance().getAccount(configuration.getAccount()).getDisplayStatusMode();
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
viewHolder.offlineShadow.setVisibility(View.VISIBLE);
} else {
viewHolder.offlineShadow.setVisibility(View.GONE);
}
return view;
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project android-advancedrecyclerview by h6ah4i.
the class LauncherButtonsAdapter method onCreateViewHolder.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_item_launcher_button, parent, false);
ViewHolder holder = new ViewHolder(v);
holder.mButton.setOnClickListener(this);
return holder;
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project AwesomeRecyclerView by forceLain.
the class ArticleAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) {
ArticleViewHolder articleViewHolder = (ArticleViewHolder) viewHolder;
Article article = articles.get(position);
articleViewHolder.textContent.setText(article.text);
articleViewHolder.textTitle.setText(article.title);
if (article.image.startsWith(SCHEME_ASSETS)) {
String fileName = article.image.replace(SCHEME_ASSETS, "");
AssetManager assetManager = viewHolder.itemView.getContext().getAssets();
InputStream is = null;
try {
is = assetManager.open(fileName);
Bitmap bitmap = BitmapFactory.decodeStream(is);
articleViewHolder.imageView.setImageBitmap(bitmap);
} catch (IOException e) {
Log.e(TAG, Log.getStackTraceString(e));
} finally {
IOUtils.closeQuietly(is);
}
}
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (itemClickListener != null) {
itemClickListener.onItemClicked(position);
}
}
});
}
Aggregations