mirror of
				https://github.com/bspeice/UNCCGameDay
				synced 2025-11-04 02:10:35 -05:00 
			
		
		
		
	ClearAllAlerts Button code built
This commit is contained in:
		@ -8,7 +8,9 @@ import android.content.Intent;
 | 
			
		||||
import android.content.SharedPreferences;
 | 
			
		||||
import android.content.SharedPreferences.Editor;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.widget.ArrayAdapter;
 | 
			
		||||
import android.widget.Button;
 | 
			
		||||
import android.widget.ListView;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -36,6 +38,14 @@ public class Home extends MenuActivity {
 | 
			
		||||
		super.onCreate(savedInstanceState);
 | 
			
		||||
		setContentView(R.layout.activity_home);
 | 
			
		||||
		
 | 
			
		||||
		//ClearAllAlerts button
 | 
			
		||||
		//sets list to display only unread alerts
 | 
			
		||||
        final Button button = (Button) findViewById(R.id.clearAlertsButton);
 | 
			
		||||
        button.setOnClickListener(new View.OnClickListener() {
 | 
			
		||||
            public void onClick(View v) {
 | 
			
		||||
            	displayUnread();	
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
		
 | 
			
		||||
		
 | 
			
		||||
		// Start up the AlarmManager to fetch alerts in the background
 | 
			
		||||
@ -73,6 +83,25 @@ public class Home extends MenuActivity {
 | 
			
		||||
	    listView.setAdapter(adapter);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void displayUnread()
 | 
			
		||||
	{
 | 
			
		||||
		
 | 
			
		||||
		List<Alert> alerts = new AlertDB(this).fetchUnread();
 | 
			
		||||
		
 | 
			
		||||
		String[] printArray = new String[alerts.size()];
 | 
			
		||||
	
 | 
			
		||||
		//get message from each alert and put in printArray
 | 
			
		||||
    	for(int i = 0; i < alerts.size(); i++)
 | 
			
		||||
    	{
 | 
			
		||||
    		printArray[i] = alerts.get(i).getMessage();
 | 
			
		||||
    	}
 | 
			
		||||
    	
 | 
			
		||||
	    ListView listView = (ListView)findViewById(R.id.alertsListView);
 | 
			
		||||
	    ArrayAdapter<String> adapter =
 | 
			
		||||
	            new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, printArray);
 | 
			
		||||
	    listView.setAdapter(adapter);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * On first run.
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user