Android Open Source - makler Alert Checker From Project Back to project page makler .
License The source code is released under:
GNU General Public License
If you think the Android project makler listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package pl.net.newton.Makler.db.alert;
/ * w w w . j a v a 2 s . c o m * /
import java.util.List;
import pl.net.newton.Makler.R;
import pl.net.newton.Makler.ui.QuoteDetails;
import pl.net.newton.Makler.common.Configuration;
import pl.net.newton.Makler.db.quote.QuoteField;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public class AlertChecker {
private Context ctx;
private AlertsDao alertsDb;
private Configuration config;
private NotificationManager notifManager;
public AlertChecker(Context ctx, AlertsDao alertsDb, Configuration config) {
this.ctx = ctx;
this.alertsDb = alertsDb;
this.config = config;
this.notifManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
}
public void checkAlerts() {
List<Alert> alerts = alertsDb.getAll();
for (Alert a : alerts) {
if (!a.getUsed() && a.isAlarming()) {
launchAlert(a);
}
}
}
@SuppressWarnings("deprecation" )
private void launchAlert(Alert a) {
alertsDb.markAsUsed(a);
int icon;
String ringTone;
if (a.getEvent() == Event.WZR_DO || a.getEvent() == Event.WZR_O || a.getEvent() == Event.WZR_POW) {
icon = R.drawable.stock_up;
ringTone = config.getAlertRingtoneRise();
} else {
icon = R.drawable.stock_down;
ringTone = config.getAlertRingtoneFall();
}
Intent intent = new Intent(ctx, QuoteDetails.class);
intent.putExtra("symbol" , a.getQuote().get(QuoteField.SYMBOL));
intent.putExtra("fromAlert" , true);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
Notification notification = new Notification(icon, "Alert" , System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(ctx, "Alert maklera" , a.notification(ctx), pendingIntent);
if (!"" .equals(ringTone)) {
notification.sound = Uri.parse(ringTone);
}
notifManager.notify(0, notification);
}
}
Java Source Code List pl.net.newton.Makler.common.Configuration.java pl.net.newton.Makler.common.DateFormatUtils.java pl.net.newton.Makler.common.GpwUtils.java pl.net.newton.Makler.common.LocaleUtils.java pl.net.newton.Makler.common.NumberFormatUtils.java pl.net.newton.Makler.db.Constants.java pl.net.newton.Makler.db.DbHelper.java pl.net.newton.Makler.db.SqlConnection.java pl.net.newton.Makler.db.alert.AlertBuilder.java pl.net.newton.Makler.db.alert.AlertChecker.java pl.net.newton.Makler.db.alert.AlertValue.java pl.net.newton.Makler.db.alert.Alert.java pl.net.newton.Makler.db.alert.AlertsDao.java pl.net.newton.Makler.db.alert.Event.java pl.net.newton.Makler.db.alert.Subject.java pl.net.newton.Makler.db.quote.QuoteField.java pl.net.newton.Makler.db.quote.Quote.java pl.net.newton.Makler.db.quote.QuotesDao.java pl.net.newton.Makler.db.service.SqlProvider.java pl.net.newton.Makler.db.symbol.SymbolBuilder.java pl.net.newton.Makler.db.symbol.Symbol.java pl.net.newton.Makler.db.symbol.SymbolsDb.java pl.net.newton.Makler.db.wallet.WalletDb.java pl.net.newton.Makler.db.wallet.WalletItemBuilder.java pl.net.newton.Makler.db.wallet.WalletItem.java pl.net.newton.Makler.gpw.DefaultQuotesReceiver.java pl.net.newton.Makler.gpw.QuotesReceiver.java pl.net.newton.Makler.gpw.ex.GpwException.java pl.net.newton.Makler.gpw.service.QuotesListener.java pl.net.newton.Makler.gpw.service.QuotesService.java pl.net.newton.Makler.gpw.service.UpdatingThread.java pl.net.newton.Makler.history.BossaProvider.java pl.net.newton.Makler.history.ByteArrayUtils.java pl.net.newton.Makler.history.Cache.java pl.net.newton.Makler.history.ChannelTools.java pl.net.newton.Makler.history.EntryListWithIndexes.java pl.net.newton.Makler.history.EntryList.java pl.net.newton.Makler.history.HistoryFilter.java pl.net.newton.Makler.history.HistoryProvider.java pl.net.newton.Makler.history.service.HistoryListener.java pl.net.newton.Makler.history.service.HistoryService.java pl.net.newton.Makler.httpClient.Connector.java pl.net.newton.Makler.receivers.QuotesAlarmReceiver.java pl.net.newton.Makler.receivers.StartupReceiver.java pl.net.newton.Makler.service.ServiceManager.java pl.net.newton.Makler.ui.About.java pl.net.newton.Makler.ui.AbstractActivity.java pl.net.newton.Makler.ui.Alerts.java pl.net.newton.Makler.ui.FullScreenGraph.java pl.net.newton.Makler.ui.Preferences.java pl.net.newton.Makler.ui.QuoteDetails.java pl.net.newton.Makler.ui.Quotes.java pl.net.newton.Makler.ui.Symbols.java pl.net.newton.Makler.ui.WalletForm.java pl.net.newton.Makler.ui.WalletItemCalculator.java pl.net.newton.Makler.ui.Wallet.java pl.net.newton.Makler.ui.adapter.AlertsAdapter.java pl.net.newton.Makler.ui.adapter.QuotesAdapter.java pl.net.newton.Makler.ui.adapter.SymbolsAdapter.java pl.net.newton.Makler.ui.adapter.WalletAdapter.java pl.net.newton.Makler.ui.graph.GraphView.java pl.net.newton.Makler.ui.graph.MaklerGraphicalView.java