use of com.afollestad.materialdialogs.DialogAction 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 com.afollestad.materialdialogs.DialogAction in project Timber by naman14.
the class SubStyleSelectorFragment method showPurchaseDialog.
private void showPurchaseDialog() {
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title("Purchase").content("This now playing style is available after a one time purchase of any amount. Support development and unlock this style?").positiveText("Support development").neutralText("Restore purchases").onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
startActivity(new Intent(getActivity(), DonateActivity.class));
dialog.dismiss();
}
}).onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(getActivity(), DonateActivity.class);
intent.putExtra("title", "Restoring purchases..");
intent.setAction("restore");
startActivity(intent);
dialog.dismiss();
}
}).show();
}
use of com.afollestad.materialdialogs.DialogAction in project XposedInstaller by rovo89.
the class StatusInstallerFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.reboot:
case R.id.soft_reboot:
case R.id.reboot_recovery:
final RootUtil.RebootMode mode = RootUtil.RebootMode.fromId(item.getItemId());
confirmReboot(mode.titleRes, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
RootUtil.reboot(mode, getActivity());
}
});
return true;
case R.id.dexopt_now:
new MaterialDialog.Builder(getActivity()).title(R.string.dexopt_now).content(R.string.this_may_take_a_while).progress(true, 0).cancelable(false).showListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {
new Thread("dexopt") {
@Override
public void run() {
RootUtil rootUtil = new RootUtil();
if (!rootUtil.startShell()) {
dialog.dismiss();
NavUtil.showMessage(getActivity(), getString(R.string.root_failed));
return;
}
rootUtil.execute("cmd package bg-dexopt-job", null);
dialog.dismiss();
XposedApp.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getActivity(), R.string.done, Toast.LENGTH_LONG).show();
}
});
}
}.start();
}
}).show();
return true;
case R.id.show_outdated:
mShowOutdated = !item.isChecked();
XposedApp.getPreferences().edit().putBoolean("framework_download_show_outdated", mShowOutdated).apply();
item.setChecked(mShowOutdated);
refreshZipViews(getView());
return true;
}
return super.onOptionsItemSelected(item);
}
use of com.afollestad.materialdialogs.DialogAction in project Weather by Sparker0i.
the class WeatherFragment method showNoInternet.
public void showNoInternet() {
new MaterialDialog.Builder(context()).title(getString(R.string.no_internet_title)).cancelable(false).content(getString(R.string.no_internet_content)).positiveText(getString(R.string.no_internet_mobile_data)).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
startActivityForResult(intent, 0);
}
}).negativeText(getString(R.string.no_internet_wifi)).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0);
}
}).show();
}
use of com.afollestad.materialdialogs.DialogAction in project Weather by Sparker0i.
the class WeatherActivity method checkForCity.
private void checkForCity(final String city) {
final FetchWeather wt = new FetchWeather(this);
final Context context = this;
new Thread() {
@Override
public void run() {
try {
json = wt.execute(city).get();
} catch (InterruptedException | ExecutionException ex) {
ex.printStackTrace();
}
if (json == null) {
handler.post(new Runnable() {
@Override
public void run() {
new MaterialDialog.Builder(context).title(getString(R.string.city_not_found)).content(getString(R.string.city_not_found)).onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).negativeText(getString(android.R.string.ok)).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
});
}
});
} else {
if (dbHelper.cityExists(json.day.getName() + "," + json.day.getSys().getCountry())) {
handler.post(new Runnable() {
@Override
public void run() {
new MaterialDialog.Builder(context).title(getString(R.string.city_already_exists)).content(getString(R.string.need_not_add)).negativeText(getString(android.R.string.ok)).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
}
});
} else {
dbHelper.addCity(json.day.getName() + "," + json.day.getSys().getCountry());
handler.post(new Runnable() {
@Override
public void run() {
SecondaryDrawerItem itemx = new SecondaryDrawerItem().withName(json.day.getName() + "," + json.day.getSys().getCountry()).withIcon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_place)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (!(f instanceof WeatherFragment)) {
wf = new WeatherFragment().setCity(json.day.getName() + "," + json.day.getSys().getCountry());
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, wf).commit();
}
return true;
}
});
drawer.addItemAtPosition(itemx, ++i);
}
});
}
}
}
}.start();
}
Aggregations