| 
									
										
										
										
											2011-02-05 13:54:32 +00:00
										 |  |  | package org.aprsdroid.app | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-21 18:12:35 +00:00
										 |  |  | import _root_.android.app.ListActivity | 
					
						
							|  |  |  | import _root_.android.content._ | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | import _root_.android.database.Cursor | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | import _root_.android.net.Uri | 
					
						
							| 
									
										
										
										
											2011-02-05 13:54:32 +00:00
										 |  |  | import _root_.android.os.{Bundle, Handler} | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | import _root_.android.util.Log | 
					
						
							| 
									
										
										
										
											2011-04-08 22:27:07 +00:00
										 |  |  | import _root_.android.view.{Menu, MenuItem, View, Window} | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | import _root_.android.view.View.OnClickListener | 
					
						
							|  |  |  | import _root_.android.widget.{ListView,SimpleCursorAdapter} | 
					
						
							| 
									
										
										
										
											2011-02-05 13:54:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 18:23:49 +00:00
										 |  |  | class StationActivity extends StationHelper(R.string.app_sta) | 
					
						
							| 
									
										
										
										
											2011-05-26 10:31:48 +00:00
										 |  |  | 		with OnClickListener { | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 	lazy val storage = StorageDatabase.open(this) | 
					
						
							|  |  |  | 	lazy val postlist = findViewById(R.id.postlist).asInstanceOf[ListView] | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 	lazy val mycall = prefs.getCallSsid() | 
					
						
							| 
									
										
										
										
											2011-07-14 22:27:12 +00:00
										 |  |  | 	lazy val pla = new StationListAdapter(this, prefs, mycall, targetcall, StationListAdapter.SSIDS) | 
					
						
							| 
									
										
										
										
											2011-05-20 23:29:15 +00:00
										 |  |  | 	lazy val la = new PostListAdapter(this) | 
					
						
							| 
									
										
										
										
											2011-04-21 16:41:00 +00:00
										 |  |  | 	lazy val locReceiver = new LocationReceiver2[Cursor](load_cursor, replace_cursor, cancel_cursor) | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-05 13:54:32 +00:00
										 |  |  | 	override def onCreate(savedInstanceState: Bundle) { | 
					
						
							|  |  |  | 		super.onCreate(savedInstanceState) | 
					
						
							|  |  |  | 		setContentView(R.layout.stationactivity) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 		getListView().setOnCreateContextMenuListener(this); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-16 21:33:37 +00:00
										 |  |  | 		onStartLoading() | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 		setListAdapter(pla) | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 		postlist.setAdapter(la) | 
					
						
							| 
									
										
										
										
											2011-04-21 16:41:00 +00:00
										 |  |  | 		registerReceiver(locReceiver, new IntentFilter(AprsService.UPDATE)) | 
					
						
							|  |  |  | 		locReceiver.startTask(null) | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 18:25:53 +00:00
										 |  |  | 		Array(R.id.map, R.id.qrzcom, R.id.aprsfi).foreach((id) => { | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 				findViewById(id).setOnClickListener(this) | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	override def onDestroy() { | 
					
						
							|  |  |  | 		super.onDestroy() | 
					
						
							|  |  |  | 		pla.onDestroy() | 
					
						
							| 
									
										
										
										
											2011-04-21 16:41:00 +00:00
										 |  |  | 		unregisterReceiver(locReceiver) | 
					
						
							|  |  |  | 		la.changeCursor(null) | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 18:23:49 +00:00
										 |  |  | 	override def onPrepareOptionsMenu(menu : Menu) : Boolean = { | 
					
						
							|  |  |  | 		menu.findItem(R.id.details).setVisible(false) | 
					
						
							|  |  |  | 		menu.findItem(R.id.messagesclear).setVisible(false) | 
					
						
							| 
									
										
										
										
											2011-03-23 23:03:11 +00:00
										 |  |  | 		true | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 	override def onListItemClick(l : ListView, v : View, position : Int, id : Long) { | 
					
						
							|  |  |  | 		//super.onListItemClick(l, v, position, id)
 | 
					
						
							|  |  |  | 		val c = getListView().getItemAtPosition(position).asInstanceOf[Cursor] | 
					
						
							| 
									
										
										
										
											2011-07-14 22:27:12 +00:00
										 |  |  | 		val call = c.getString(StorageDatabase.Station.COLUMN_CALL) | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 		Log.d("StationActivity", "onListItemClick: %s".format(call)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (targetcall == call) { | 
					
						
							|  |  |  | 			// click on own callssid
 | 
					
						
							| 
									
										
										
										
											2011-05-26 10:31:48 +00:00
										 |  |  | 			trackOnMap(call) | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2011-05-26 10:31:48 +00:00
										 |  |  | 			openDetails(call) | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 			finish() | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-03-22 20:59:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-26 23:52:56 +00:00
										 |  |  | 	// button actions
 | 
					
						
							|  |  |  | 	override def onClick(view : View) { | 
					
						
							| 
									
										
										
										
											2011-05-26 10:31:48 +00:00
										 |  |  | 		callsignAction(view.getId, targetcall) | 
					
						
							| 
									
										
										
										
											2011-03-21 18:12:35 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-04-16 21:33:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 16:41:00 +00:00
										 |  |  | 	def load_cursor(i : Intent) = { | 
					
						
							| 
									
										
										
										
											2017-05-23 15:02:47 +00:00
										 |  |  | 		val c = storage.getStaPosts(targetcall, "300") | 
					
						
							| 
									
										
										
										
											2011-04-21 16:41:00 +00:00
										 |  |  | 		c.getCount() | 
					
						
							|  |  |  | 		c | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	def replace_cursor(c : Cursor) { | 
					
						
							|  |  |  | 		la.changeCursor(c) | 
					
						
							| 
									
										
										
										
											2011-07-14 22:27:12 +00:00
										 |  |  | 		// do not call onStopLoading, StationListAdapter takes much longer
 | 
					
						
							| 
									
										
										
										
											2011-04-21 16:41:00 +00:00
										 |  |  | 		//onStopLoading()
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	def cancel_cursor(c : Cursor) { | 
					
						
							|  |  |  | 		c.close() | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-05 13:54:32 +00:00
										 |  |  | } |