use of com.pankaj.maukascholars.database.DBHandler in project Precisely by Pankaj-Baranwal.
the class SavedActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Constants.toolbar_title = "Saved Opportunities";
setContentView(R.layout.activity_profile);
RecyclerView recyclerView = findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
DBHandler db = new DBHandler(this);
mItems = db.getAllSavedEvents();
if (mItems.size() == 0) {
RelativeLayout empty_layout = findViewById(R.id.empty_layout);
empty_layout.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
} else {
adapter = new SavedEventsAdapter(mItems, this);
recyclerView.setAdapter(adapter);
SwipeableRecyclerViewTouchListener swipeTouchListener = new SwipeableRecyclerViewTouchListener(recyclerView, new SwipeableRecyclerViewTouchListener.SwipeListener() {
@Override
public boolean canSwipeLeft(int position) {
return true;
}
@Override
public boolean canSwipeRight(int position) {
return true;
}
@Override
public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
deleteData(position);
adapter.notifyItemRemoved(position);
}
adapter.notifyDataSetChanged();
Toast.makeText(SavedActivity.this, "Deleted!", Toast.LENGTH_SHORT).show();
}
@Override
public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
deleteData(position);
adapter.notifyItemRemoved(position);
}
adapter.notifyDataSetChanged();
Toast.makeText(SavedActivity.this, "Deleted!", Toast.LENGTH_SHORT).show();
}
});
recyclerView.addOnItemTouchListener(swipeTouchListener);
}
}
use of com.pankaj.maukascholars.database.DBHandler in project Precisely by Pankaj-Baranwal.
the class VerticalViewPagerActivity method saveEvent.
private void saveEvent(int position) {
DBHandler db = new DBHandler(this);
if (db.getEvent(mItems.get(position).getId()) != null && db.getEvent(mItems.get(position).getId()).getSaved() == 1) {
Toast.makeText(this, "Already saved!", Toast.LENGTH_SHORT).show();
} else {
if (db.getEvent(mItems.get(position).getId()) != null)
mItems.get(position).setStarred(1);
mItems.get(position).setSaved(1);
db.addEvent(mItems.get(position));
Toast.makeText(this, "Event Saved!", Toast.LENGTH_SHORT).show();
}
}
use of com.pankaj.maukascholars.database.DBHandler in project Precisely by Pankaj-Baranwal.
the class SavedActivity method deleteData.
void deleteData(final int position) {
DBHandler db = new DBHandler(this);
db.deleteEvent(mItems.get(position).getId());
mItems.remove(position);
}
use of com.pankaj.maukascholars.database.DBHandler in project Precisely by Pankaj-Baranwal.
the class VerticalViewPagerActivity method starEvent.
private void starEvent(int position) {
DBHandler db = new DBHandler(this);
if (db.getEvent(mItems.get(position).getId()) != null && db.getEvent(mItems.get(position).getId()).getStarred() == 1) {
Toast.makeText(this, "Already starred!", Toast.LENGTH_SHORT).show();
} else {
if (db.getEvent(mItems.get(position).getId()) != null)
mItems.get(position).setSaved(1);
mItems.get(position).setStarred(1);
db.addEvent(mItems.get(position));
Toast.makeText(this, "Event Starred!", Toast.LENGTH_SHORT).show();
scheduleReminder(mItems.get(position).getDeadline(), mItems.get(position).getTitle() + "\n" + mItems.get(position).getLink());
}
}
use of com.pankaj.maukascholars.database.DBHandler in project Precisely by Pankaj-Baranwal.
the class StarredActivity method deleteData.
void deleteData(final int position) {
DBHandler db = new DBHandler(this);
db.deleteEvent(mItems.get(position).getId());
mItems.remove(position);
}
Aggregations