Search in sources :

Example 1 with NotificationsAdapter

use of ca.etsmtl.applets.etsmobile.ui.adapter.NotificationsAdapter in project ETSMobile-Android2 by ApplETS.

the class NotificationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notifications);
    securePreferences = new SecurePreferences(this);
    progressBar = (ProgressBar) findViewById(R.id.progressBar_notifications);
    listView = (ListView) findViewById(R.id.listView_notifications);
    progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.ets_red_fonce), PorterDuff.Mode.MULTIPLY);
    progressBar.setVisibility(View.VISIBLE);
    notificationsAdapter = new NotificationsAdapter(this, R.layout.row_notification, new ArrayList<MonETSNotification>());
    listView.setAdapter(notificationsAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            MonETSNotification item = notificationsAdapter.getItem(position);
            String url = item.getUrl();
            if (URLUtil.isValidUrl(url)) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }
        }
    });
    syncAdapterWithDB();
    Utility.loadNotifications(this, this);
}
Also used : MonETSNotification(ca.etsmtl.applets.etsmobile.model.MonETSNotification) ArrayList(java.util.ArrayList) Intent(android.content.Intent) SecurePreferences(ca.etsmtl.applets.etsmobile.util.SecurePreferences) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) NotificationsAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.NotificationsAdapter) AdapterView(android.widget.AdapterView)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 MonETSNotification (ca.etsmtl.applets.etsmobile.model.MonETSNotification)1 NotificationsAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.NotificationsAdapter)1 SecurePreferences (ca.etsmtl.applets.etsmobile.util.SecurePreferences)1 ArrayList (java.util.ArrayList)1