Search in sources :

Example 1 with DetectionStringAdapter

use of com.secupwn.aimsicd.data.adapter.DetectionStringAdapter in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class DbViewerFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    DbViewerSpinnerAdapter mSpinnerAdapter = new DbViewerSpinnerAdapter(getActivity(), R.layout.item_spinner_db_viewer);
    tblSpinner.setAdapter(mSpinnerAdapter);
    tblSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, final int position, long id) {
            Object selectedItem = tblSpinner.getSelectedItem();
            if (!(selectedItem instanceof StatesDbViewer)) {
                return;
            }
            mTableSelected = (StatesDbViewer) selectedItem;
            realm.refresh();
            switch(position) {
                case 0:
                    setListAdapter(new BaseStationAdapter(getActivity(), realm.allObjects(BaseTransceiverStation.class), true));
                    break;
                case 1:
                    setListAdapter(new MeasureAdapter(getActivity(), realm.allObjects(Measure.class), true));
                    break;
                case 2:
                    setListAdapter(new ImportAdapter(getActivity(), realm.allObjects(Import.class), true));
                    break;
                case 3:
                    setListAdapter(new DefaultLocationAdapter(getActivity(), realm.allObjects(DefaultLocation.class), true));
                    break;
                case // Silent SMS
                4:
                    setListAdapter(new SmsDataAdapter(getActivity(), realm.allObjects(SmsData.class), true));
                    break;
                case 5:
                    setListAdapter(new MeasuredCellStrengthAdapter(getActivity(), realm.allObjects(Measure.class), true));
                    break;
                case 6:
                    setListAdapter(new EventAdapter(getActivity(), realm.allObjects(Event.class), true));
                    break;
                case 7:
                    setListAdapter(new DetectionStringAdapter(getActivity(), realm.allObjects(SmsDetectionString.class), true));
                    break;
                default:
                    throw new IllegalArgumentException("Unknown type of table");
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parentView) {
        }
    });
}
Also used : SmsDataAdapter(com.secupwn.aimsicd.data.adapter.SmsDataAdapter) MeasuredCellStrengthAdapter(com.secupwn.aimsicd.adapters.MeasuredCellStrengthAdapter) Import(com.secupwn.aimsicd.data.model.Import) SmsDetectionString(com.secupwn.aimsicd.data.model.SmsDetectionString) ImportAdapter(com.secupwn.aimsicd.data.adapter.ImportAdapter) MeasureAdapter(com.secupwn.aimsicd.data.adapter.MeasureAdapter) DefaultLocationAdapter(com.secupwn.aimsicd.data.adapter.DefaultLocationAdapter) DefaultLocation(com.secupwn.aimsicd.data.model.DefaultLocation) DbViewerSpinnerAdapter(com.secupwn.aimsicd.adapters.DbViewerSpinnerAdapter) Measure(com.secupwn.aimsicd.data.model.Measure) SmsData(com.secupwn.aimsicd.data.model.SmsData) BaseTransceiverStation(com.secupwn.aimsicd.data.model.BaseTransceiverStation) StatesDbViewer(com.secupwn.aimsicd.enums.StatesDbViewer) InjectView(io.freefair.android.injection.annotation.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) EventAdapter(com.secupwn.aimsicd.data.adapter.EventAdapter) DetectionStringAdapter(com.secupwn.aimsicd.data.adapter.DetectionStringAdapter) BaseStationAdapter(com.secupwn.aimsicd.data.adapter.BaseStationAdapter) Event(com.secupwn.aimsicd.data.model.Event) AdapterView(android.widget.AdapterView)

Example 2 with DetectionStringAdapter

use of com.secupwn.aimsicd.data.adapter.DetectionStringAdapter in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class AdvancedUserActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    realm = Realm.getDefaultInstance();
    RealmResults<SmsDetectionString> msgItems = realm.allObjects(SmsDetectionString.class);
    listViewAdv.setAdapter(new DetectionStringAdapter(this, msgItems, true));
    listViewAdv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> a, View v, int position, long id) {
            final SmsDetectionString detectionString = (SmsDetectionString) listViewAdv.getItemAtPosition(position);
            String string = detectionString.getDetectionString();
            realm.executeTransaction(new Realm.Transaction() {

                @Override
                public void execute(Realm realm) {
                    detectionString.removeFromRealm();
                }
            });
            Toast.makeText(getApplicationContext(), getString(R.string.deleted) + ": " + string, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    insertButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (editAdvUserDet.getText().toString().contains("\"")) {
                Toast.makeText(AdvancedUserActivity.this, R.string.double_quote_will_cause_db_error, Toast.LENGTH_SHORT).show();
            } else {
                realm.executeTransaction(new Realm.Transaction() {

                    @Override
                    public void execute(Realm realm) {
                        SmsDetectionString detectionString = realm.createObject(SmsDetectionString.class);
                        detectionString.setDetectionString(editAdvUserDet.getText().toString());
                        detectionString.setSmsType(spinner.getSelectedItem().toString());
                        Toast.makeText(AdvancedUserActivity.this, R.string.the_string_was_added_to_db, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    });
}
Also used : SmsDetectionString(com.secupwn.aimsicd.data.model.SmsDetectionString) SmsDetectionString(com.secupwn.aimsicd.data.model.SmsDetectionString) InjectView(io.freefair.android.injection.annotation.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) DetectionStringAdapter(com.secupwn.aimsicd.data.adapter.DetectionStringAdapter) AdapterView(android.widget.AdapterView) Realm(io.realm.Realm)

Aggregations

View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 DetectionStringAdapter (com.secupwn.aimsicd.data.adapter.DetectionStringAdapter)2 SmsDetectionString (com.secupwn.aimsicd.data.model.SmsDetectionString)2 InjectView (io.freefair.android.injection.annotation.InjectView)2 DbViewerSpinnerAdapter (com.secupwn.aimsicd.adapters.DbViewerSpinnerAdapter)1 MeasuredCellStrengthAdapter (com.secupwn.aimsicd.adapters.MeasuredCellStrengthAdapter)1 BaseStationAdapter (com.secupwn.aimsicd.data.adapter.BaseStationAdapter)1 DefaultLocationAdapter (com.secupwn.aimsicd.data.adapter.DefaultLocationAdapter)1 EventAdapter (com.secupwn.aimsicd.data.adapter.EventAdapter)1 ImportAdapter (com.secupwn.aimsicd.data.adapter.ImportAdapter)1 MeasureAdapter (com.secupwn.aimsicd.data.adapter.MeasureAdapter)1 SmsDataAdapter (com.secupwn.aimsicd.data.adapter.SmsDataAdapter)1 BaseTransceiverStation (com.secupwn.aimsicd.data.model.BaseTransceiverStation)1 DefaultLocation (com.secupwn.aimsicd.data.model.DefaultLocation)1 Event (com.secupwn.aimsicd.data.model.Event)1 Import (com.secupwn.aimsicd.data.model.Import)1 Measure (com.secupwn.aimsicd.data.model.Measure)1 SmsData (com.secupwn.aimsicd.data.model.SmsData)1