use of androidx.annotation.NonNull 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 androidx.annotation.NonNull 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();
}
use of androidx.annotation.NonNull in project Weather by Sparker0i.
the class MyAdapter method onCreateViewHolder.
// Create new views (invoked by the layout manager)
@NonNull
@Override
public MyAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// create a new view
TextView v = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.about_card, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
use of androidx.annotation.NonNull in project Conversations by siacs.
the class ShortcutService method createShortcut.
@NonNull
public Intent createShortcut(Contact contact, boolean legacy) {
Intent intent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !legacy) {
ShortcutInfo shortcut = getShortcutInfo(contact);
ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
intent = shortcutManager.createShortcutResultIntent(shortcut);
} else {
intent = createShortcutResultIntent(contact);
}
return intent;
}
use of androidx.annotation.NonNull in project Conversations by siacs.
the class CountryAdapter method onCreateViewHolder.
@NonNull
@Override
public CountryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
CountryItemBinding binding = DataBindingUtil.inflate(layoutInflater, R.layout.country_item, parent, false);
return new CountryViewHolder(binding);
}
Aggregations