use of android.support.v7.widget.RecyclerView.Adapter in project SR-Tracker-for-Overwatch by Rexios80.
the class StatsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
v = inflater.inflate(R.layout.stats_fragment, container, false);
if (dpWidth() > 750) {
LinearLayout llStats = (LinearLayout) v.findViewById(R.id.ll_stats);
int cardBackground = ContextCompat.getColor(getActivity(), R.color.cardBackground);
llStats.setBackgroundColor(cardBackground);
}
lvStats = (ListView) v.findViewById(R.id.lv_stats);
adapter = new StatsListViewAdapter(getActivity(), new DatabaseParser(getContext()).getStatsList(), getContext());
lvStats.setAdapter(adapter);
lvStats.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long arg3) {
String timeString = ((HashMap<String, String>) adapter.getItem(position)).get("time");
String snackbarText;
if (timeString == null || timeString.equals("0")) {
snackbarText = "No time recorded";
} else {
long time = Long.parseLong(timeString);
SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yy - h:mm a");
Date date = new Date(time);
snackbarText = dateFormat.format(date);
}
Snackbar.make(getActivity().findViewById(android.R.id.content), snackbarText, Snackbar.LENGTH_LONG).show();
}
});
lvStats.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> a, View v, int position, long arg3) {
String noteString = ((HashMap<String, String>) adapter.getItem(position)).get("note");
if (noteString == null || noteString.equals("")) {
Snackbar.make(getActivity().findViewById(android.R.id.content), "No note recorded", Snackbar.LENGTH_LONG).show();
return true;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustom);
builder.setMessage(noteString).show();
return true;
}
});
return v;
}
use of android.support.v7.widget.RecyclerView.Adapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionAdapterUtils method addDismiss.
public static void addDismiss(final RecyclerView recyclerView) {
ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.START | ItemTouchHelper.END) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return true;
}
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
return viewHolder.getItemViewType() == R.layout.condition_card ? super.getSwipeDirs(recyclerView, viewHolder) : 0;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
DashboardAdapter adapter = (DashboardAdapter) recyclerView.getAdapter();
Object item = adapter.getItem(viewHolder.getItemId());
if (item instanceof Condition) {
((Condition) item).silence();
}
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(recyclerView);
}
use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
player = (VideoView) findViewById(R.id.player);
if (player != null) {
player.setOnDragListener(this);
player.setOnHoverListener(this);
player.setOnLongClickListener(this);
}
thumbnailLarge = (ImageView) findViewById(R.id.thumbnail_large);
if (thumbnailLarge != null) {
thumbnailLarge.setOnDragListener(this);
thumbnailLarge.setOnHoverListener(this);
thumbnailLarge.setOnLongClickListener(this);
}
setLayoutManager(new LinearLayoutManager(this));
adapter = new VideoAdapter(getRecyclerView());
setAdapter(adapter);
getRecyclerView().requestFocus();
if (icicle != null) {
isInPermission = icicle.getBoolean(STATE_IN_PERMISSION, false);
}
if (hasFilesPermission()) {
loadVideos();
} else if (!isInPermission) {
isInPermission = true;
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_PERMS);
}
}
use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final RecyclerView pager = (RecyclerView) findViewById(R.id.pager);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
pager.setLayoutManager(layoutManager);
snapperCarr.attachToRecyclerView(pager);
adapter = new PageAdapter(pager, getLayoutInflater());
pager.setAdapter(adapter);
final TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
for (int i = 0; i < adapter.getItemCount(); i++) {
tabs.addTab(tabs.newTab().setText(adapter.getTabText(this, i)));
}
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
pager.smoothScrollToPosition(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
// unused
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
// unused
}
});
pager.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int tab = layoutManager.findFirstCompletelyVisibleItemPosition();
if (tab >= 0 && tab < tabs.getTabCount()) {
tabs.getTabAt(tab).select();
}
}
});
}
use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setLayoutManager(new LinearLayoutManager(this));
adapter = new IconicAdapter(getRecyclerView());
setAdapter(adapter);
}
Aggregations