use of io.praveen.typenote.SQLite.BinDatabaseHandler in project Android-NotesApp by HelloPraveen.
the class BinActivity method onCreate.
@TargetApi(Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bin);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(BinActivity.this);
premium = preferences.getInt("premium", 0);
interstitialAd = new InterstitialAd(BinActivity.this);
interstitialAd.setAdUnitId("ca-app-pub-8429477298745270/2004640333");
interstitialAd.loadAd(new AdRequest.Builder().build());
i = new Intent(BinActivity.this, MainActivity.class);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
SpannableStringBuilder SS = new SpannableStringBuilder("Trash");
SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(SS);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
final BinDatabaseHandler db = new BinDatabaseHandler(this);
l = db.getAllNotes();
final RecyclerView recyclerView = findViewById(R.id.binRecyclerView);
final RelativeLayout rl = findViewById(R.id.binPlaceholder);
if (l.isEmpty()) {
recyclerView.setVisibility(View.GONE);
rl.setVisibility(View.VISIBLE);
}
NoteAdapter mAdapter = new NoteAdapter(l);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(mAdapter);
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), new ClickListener() {
@Override
public void onClick(View view, final int position) {
final Note note = l.get(position);
final String mNote = note.getNote();
final int mStar = note.getStar();
final String mDate = note.getDate();
final String mTitle = note.getTitle();
new MaterialStyledDialog.Builder(BinActivity.this).setIcon(R.drawable.ic_settings_backup_restore).setDescription("You may choose to restore your note or delete it permanently!").setPositiveText("DELETE").onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
BinDatabaseHandler db = new BinDatabaseHandler(BinActivity.this);
List<Note> l2 = db.getAllNotes();
final Note note2 = l2.get(position);
db.deleteNote(note2);
i.putExtra("note", true);
i.putExtra("delete", true);
if (interstitialAd.isLoaded() && premium != 1) {
interstitialAd.show();
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
startActivity(i);
finish();
}
});
} else {
startActivity(i);
finish();
}
}
}).setNegativeText("RESTORE").onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
BinDatabaseHandler db = new BinDatabaseHandler(BinActivity.this);
DatabaseHandler db2 = new DatabaseHandler(BinActivity.this);
db2.addNote(new Note(mNote, mDate, mStar, mTitle));
List<Note> l2 = db.getAllNotes();
final Note note2 = l2.get(position);
db.deleteNote(note2);
i.putExtra("note", true);
i.putExtra("restore", true);
if (interstitialAd.isLoaded() && premium != 1) {
interstitialAd.show();
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
startActivity(i);
finish();
}
});
} else {
startActivity(i);
finish();
}
}
}).setNeutralText("DISMISS").onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
}
}).setHeaderColor(R.color.colorPrimary).withIconAnimation(false).withDivider(true).show();
}
}));
}
use of io.praveen.typenote.SQLite.BinDatabaseHandler in project Android-NotesApp by HelloPraveenIO.
the class BinActivity method onCreate.
@TargetApi(Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bin);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(BinActivity.this);
premium = preferences.getInt("premium", 0);
interstitialAd = new InterstitialAd(BinActivity.this);
interstitialAd.setAdUnitId("ca-app-pub-8429477298745270/2004640333");
interstitialAd.loadAd(new AdRequest.Builder().build());
i = new Intent(BinActivity.this, MainActivity.class);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
SpannableStringBuilder SS = new SpannableStringBuilder("Trash");
SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(SS);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
final BinDatabaseHandler db = new BinDatabaseHandler(this);
l = db.getAllNotes();
final RecyclerView recyclerView = findViewById(R.id.binRecyclerView);
final RelativeLayout rl = findViewById(R.id.binPlaceholder);
if (l.isEmpty()) {
recyclerView.setVisibility(View.GONE);
rl.setVisibility(View.VISIBLE);
}
NoteAdapter mAdapter = new NoteAdapter(l);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(mAdapter);
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), new ClickListener() {
@Override
public void onClick(View view, final int position) {
final Note note = l.get(position);
final String mNote = note.getNote();
final int mStar = note.getStar();
final String mDate = note.getDate();
final String mTitle = note.getTitle();
new MaterialStyledDialog.Builder(BinActivity.this).setIcon(R.drawable.ic_settings_backup_restore).setDescription("You may choose to restore your note or delete it permanently!").setPositiveText("DELETE").onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
BinDatabaseHandler db = new BinDatabaseHandler(BinActivity.this);
List<Note> l2 = db.getAllNotes();
final Note note2 = l2.get(position);
db.deleteNote(note2);
i.putExtra("note", true);
i.putExtra("delete", true);
if (interstitialAd.isLoaded() && premium != 1) {
interstitialAd.show();
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
startActivity(i);
finish();
}
});
} else {
startActivity(i);
finish();
}
}
}).setNegativeText("RESTORE").onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
BinDatabaseHandler db = new BinDatabaseHandler(BinActivity.this);
DatabaseHandler db2 = new DatabaseHandler(BinActivity.this);
db2.addNote(new Note(mNote, mDate, mStar, mTitle));
List<Note> l2 = db.getAllNotes();
final Note note2 = l2.get(position);
db.deleteNote(note2);
i.putExtra("note", true);
i.putExtra("restore", true);
if (interstitialAd.isLoaded() && premium != 1) {
interstitialAd.show();
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
startActivity(i);
finish();
}
});
} else {
startActivity(i);
finish();
}
}
}).setNeutralText("DISMISS").onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
}
}).setHeaderColor(R.color.colorPrimary).withIconAnimation(false).withDivider(true).show();
}
}));
}
use of io.praveen.typenote.SQLite.BinDatabaseHandler in project Android-NotesApp by HelloPraveenIO.
the class ViewActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.copy) {
Snackbar.make(tv, "Copied!", Snackbar.LENGTH_SHORT).show();
} else if (item.getItemId() == R.id.edit) {
Intent intent = new Intent(ViewActivity.this, EditActivity.class);
intent.putExtra("note", noteText);
intent.putExtra("id", id);
intent.putExtra("title", noteTitle);
intent.putExtra("imp", imp);
startActivity(intent);
} else if (item.getItemId() == R.id.share) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, noteTitle + "\n\n" + noteText);
sendIntent.setType("text/plain");
startActivity(sendIntent);
} else if (item.getItemId() == android.R.id.home)
onBackPressed();
else if (item.getItemId() == R.id.delete) {
final DatabaseHandler db = new DatabaseHandler(this);
List<Note> l = db.getAllNotes();
final Note note = l.get(position);
db.deleteNote(note);
BinDatabaseHandler db2 = new BinDatabaseHandler(ViewActivity.this);
db2.addNote(new Note(note.getNote(), note.getDate(), note.getStar(), note.getTitle()));
Intent i = new Intent(ViewActivity.this, MainActivity.class);
i.putExtra("delete", true);
i.putExtra("note", true);
startActivity(i);
finish();
}
return true;
}
use of io.praveen.typenote.SQLite.BinDatabaseHandler in project Android-NotesApp by HelloPraveen.
the class ViewActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.copy) {
Snackbar.make(tv, "Copied!", Snackbar.LENGTH_SHORT).show();
} else if (item.getItemId() == R.id.edit) {
Intent intent = new Intent(ViewActivity.this, EditActivity.class);
intent.putExtra("note", noteText);
intent.putExtra("id", id);
intent.putExtra("title", noteTitle);
intent.putExtra("imp", imp);
startActivity(intent);
} else if (item.getItemId() == R.id.share) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, noteTitle + "\n\n" + noteText);
sendIntent.setType("text/plain");
startActivity(sendIntent);
} else if (item.getItemId() == android.R.id.home)
onBackPressed();
else if (item.getItemId() == R.id.delete) {
final DatabaseHandler db = new DatabaseHandler(this);
List<Note> l = db.getAllNotes();
final Note note = l.get(position);
db.deleteNote(note);
BinDatabaseHandler db2 = new BinDatabaseHandler(ViewActivity.this);
db2.addNote(new Note(note.getNote(), note.getDate(), note.getStar(), note.getTitle()));
Intent i = new Intent(ViewActivity.this, MainActivity.class);
i.putExtra("delete", true);
i.putExtra("note", true);
startActivity(i);
finish();
}
return true;
}
Aggregations