-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from xLaMbChOpSx/master
Database Viewer
- Loading branch information
Showing
17 changed files
with
694 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package com.SecUpwN.AIMSICD; | ||
|
||
import com.SecUpwN.AIMSICD.adapters.BaseInflaterAdapter; | ||
import com.SecUpwN.AIMSICD.adapters.CardItemData; | ||
import com.SecUpwN.AIMSICD.adapters.CellCardInflater; | ||
import com.SecUpwN.AIMSICD.adapters.OpenCellIdCardInflater; | ||
|
||
import android.app.Activity; | ||
import android.database.Cursor; | ||
import android.os.AsyncTask; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.AdapterView.OnItemSelectedListener; | ||
import android.widget.Button; | ||
import android.widget.ListView; | ||
import android.widget.Spinner; | ||
import android.widget.TableLayout; | ||
|
||
public class DbViewer extends Activity { | ||
|
||
private final AIMSICDDbAdapter mDb = new AIMSICDDbAdapter(this); | ||
private Spinner tblSpinner; | ||
private String mTableSelected; | ||
private boolean mMadeSelection; | ||
private ListView lv; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.db_view); | ||
lv = (ListView) findViewById(R.id.list_view); | ||
lv.addHeaderView(new View(this)); | ||
lv.addFooterView(new View(this)); | ||
tblSpinner = (Spinner) findViewById(R.id.table_spinner); | ||
tblSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, | ||
int position, long id) { | ||
mTableSelected = String.valueOf(tblSpinner.getSelectedItem()); | ||
mMadeSelection = true; | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parentView) { | ||
mMadeSelection = false; | ||
} | ||
|
||
}); | ||
|
||
Button loadTable = (Button) findViewById(R.id.load_table_data); | ||
|
||
loadTable.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (mMadeSelection) { | ||
new MyAsync().execute(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private void BuildTable(Cursor tableData) { | ||
if (tableData != null && tableData.moveToFirst()) { | ||
|
||
if (mTableSelected.equals("OpenCellID Data")) { | ||
BaseInflaterAdapter<CardItemData> adapter = new BaseInflaterAdapter<CardItemData>( | ||
new OpenCellIdCardInflater()); | ||
while (tableData.moveToNext()) { | ||
CardItemData data = new CardItemData("CellID: " + tableData.getString(0), | ||
"LAC: " + tableData.getString(1), "MCC: " + tableData.getString(2), | ||
"MNC: " + tableData.getString(3), "Latitude: " + tableData.getString(4), | ||
"Longitude: " + tableData.getString(5), "Average Signal Strength: " + tableData.getString(6), | ||
"Samples: " + tableData.getString(7)); | ||
adapter.addItem(data, false); | ||
} | ||
lv.setAdapter(adapter); | ||
} else { | ||
BaseInflaterAdapter<CardItemData> adapter = new BaseInflaterAdapter<CardItemData>( | ||
new CellCardInflater()); | ||
while (tableData.moveToNext()){ | ||
CardItemData data = new CardItemData("CellID: " + tableData.getString(0), | ||
"LAC: " + tableData.getString(1), | ||
"Network Type: " + tableData.getString(2), | ||
"Latitude: " + tableData.getString(3), | ||
"Longitude: " + tableData.getString(4), | ||
"Signal Strength: " + tableData.getString(5)); | ||
adapter.addItem(data, false); | ||
} | ||
lv.setAdapter(adapter); | ||
} | ||
} else { | ||
Helpers.sendMsg(this, "Table contains no data to display"); | ||
} | ||
} | ||
|
||
private class MyAsync extends AsyncTask<Cursor, Cursor, Cursor> { | ||
|
||
@Override | ||
protected void onPreExecute() { | ||
super.onPreExecute(); | ||
} | ||
|
||
@Override | ||
protected Cursor doInBackground(Cursor... params) { | ||
mDb.open(); | ||
if (mTableSelected.equals("Cell Data")) { | ||
return mDb.getCellData(); | ||
} else if (mTableSelected.equals("Signal Strength Data")) { | ||
return mDb.getSignalData(); | ||
} else if (mTableSelected.equals("Location Data")) { | ||
return mDb.getLocationData(); | ||
} else if (mTableSelected.equals("OpenCellID Data")) { | ||
return mDb.getOpenCellIDData(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
protected void onPostExecute(Cursor result) { | ||
super.onPostExecute(result); | ||
BuildTable(result); | ||
mDb.close(); | ||
} | ||
} | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
app/src/main/java/com/SecUpwN/AIMSICD/adapters/BaseInflaterAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.SecUpwN.AIMSICD.adapters; | ||
|
||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BaseInflaterAdapter<T> extends BaseAdapter | ||
{ | ||
private List<T> m_items = new ArrayList<T>(); | ||
private IAdapterViewInflater<T> m_viewInflater; | ||
|
||
public BaseInflaterAdapter(IAdapterViewInflater<T> viewInflater) | ||
{ | ||
m_viewInflater = viewInflater; | ||
} | ||
|
||
public BaseInflaterAdapter(List<T> items, IAdapterViewInflater<T> viewInflater) | ||
{ | ||
m_items.addAll(items); | ||
m_viewInflater = viewInflater; | ||
} | ||
|
||
public void setViewInflater(IAdapterViewInflater<T> viewInflater, boolean notifyChange) | ||
{ | ||
m_viewInflater = viewInflater; | ||
|
||
if (notifyChange) | ||
notifyDataSetChanged(); | ||
} | ||
|
||
public void addItem(T item, boolean notifyChange) | ||
{ | ||
m_items.add(item); | ||
|
||
if (notifyChange) | ||
notifyDataSetChanged(); | ||
} | ||
|
||
public void addItems(List<T> items, boolean notifyChange) | ||
{ | ||
m_items.addAll(items); | ||
|
||
if (notifyChange) | ||
notifyDataSetChanged(); | ||
} | ||
|
||
public void clear(boolean notifyChange) | ||
{ | ||
m_items.clear(); | ||
|
||
if (notifyChange) | ||
notifyDataSetChanged(); | ||
} | ||
|
||
@Override | ||
public int getCount() | ||
{ | ||
return m_items.size(); | ||
} | ||
|
||
@Override | ||
public Object getItem(int pos) | ||
{ | ||
return getTItem(pos); | ||
} | ||
|
||
public T getTItem(int pos) | ||
{ | ||
return m_items.get(pos); | ||
} | ||
|
||
@Override | ||
public long getItemId(int pos) | ||
{ | ||
return pos; | ||
} | ||
|
||
@Override | ||
public View getView(int pos, View convertView, ViewGroup parent) | ||
{ | ||
return m_viewInflater != null ? m_viewInflater.inflate(this, pos, convertView, parent) : null; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/SecUpwN/AIMSICD/adapters/CardItemData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.SecUpwN.AIMSICD.adapters; | ||
|
||
public class CardItemData | ||
{ | ||
private String mCellID; | ||
private String mLac; | ||
private String mMcc; | ||
private String mMnc; | ||
private String mNet; | ||
private String mSignal; | ||
private String mAvgSigStr; | ||
private String mSamples; | ||
private String mLat; | ||
private String mLng; | ||
|
||
|
||
public CardItemData(String cellID, String lac, String mcc, String mnc, String lat, String lng, | ||
String avgSigStr, String samples) | ||
{ | ||
mCellID = cellID; | ||
mLac = lac; | ||
mMcc = mcc; | ||
mMnc = mnc; | ||
mLat = lat; | ||
mLng = lng; | ||
mAvgSigStr = avgSigStr; | ||
mSamples = samples; | ||
} | ||
|
||
public CardItemData(String cellID, String lac, String net, String lat, String lng, String signal) | ||
{ | ||
mCellID = cellID; | ||
mLac = lac; | ||
mNet = net; | ||
mLat = lat; | ||
mLng = lng; | ||
mSignal = signal; | ||
} | ||
|
||
public String getCellID() { | ||
return mCellID; | ||
} | ||
|
||
public String getLac() { | ||
return mLac; | ||
} | ||
|
||
public String getMcc() { | ||
return mMcc; | ||
} | ||
|
||
public String getMnc() { | ||
return mMnc; | ||
} | ||
|
||
public String getNet() { | ||
return mNet; | ||
} | ||
|
||
public String getSignal() { | ||
return mSignal; | ||
} | ||
|
||
public String getAvgSigStr() { | ||
return mAvgSigStr; | ||
} | ||
|
||
public String getSamples() { | ||
return mSamples; | ||
} | ||
|
||
public String getLat() { | ||
return mLat; | ||
} | ||
|
||
public String getLng() { | ||
return mLng; | ||
} | ||
} |
Oops, something went wrong.