Office Hours — Today, November 28

Tuesday, November 21

Nov 28
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:00 AM
HighwayRob
has entered the room
HighwayRob
HI Mark, I got some simpler questions. We need to discuss some conslting hours later.
Mark M.
hello!
go right ahead with the simpler questions!
9:05 AM
HighwayRob
I should of been better prepared. OK...most layouts show the Service call: 9999 on top, my new layout shows the title that is displayed when app opens. GOt a feeling I am not extending or implementing something. Want it to display the Service Call #
Mark M.
call setTitle() on the activity to set the title that appears in the action bar
HighwayRob
Which brings me to the next issue,
View paste
        String sc_Num = params.getNumber();
        setTitle("Service Call: " + sc_Num);
cannot resolove symbol on parmas
9:10 AM
Mark M.
then there is nothing by that name, apparently
you copied and pasted this from somewhere
see where that "somewhere" is getting params
and try reproducing that in your new location as well
HighwayRob
hold on...here is that stuff. Give me a minute.
THe FieldActivityENtryList cannot resolve method putextras
View paste
       AdapterView.OnItemClickListener itemClickListener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> listView, View v, int position, long id) {
                //Bundle params = this.getIntent().getExtras();
                if (position == 0){
                    //Toast.makeText(FieldActivityEntryOptionsList.this,"Going for opt 0 techmangeneral", Toast.LENGTH_LONG).show();
                    //Log.d("FAEOList", "Going for option 0");
                    Intent intent = new Intent(FieldActivityEntryOptionsList.this, TechManGeneralEntryActivity.class );
                    ServiceCall params = getIntent().getParcelableExtra("serviceCall");
                    intent.putExtras(params);
                    startActivity(intent);
                }
            }
        };
Problems passing the paramters \ bundles betweenthese activities
Mark M.
well, params is commented out
//Bundle params = this.getIntent().getExtras();
you cannot reference something that is commented out
HighwayRob
WHenI uncommenthat, it cannot resolve getintent
9:15 AM
Mark M.
getIntent() is a method on Activity
this is not an Activity -- this is an AdapterView.OnItemClickListener
HighwayRob
View paste
public class FieldActivityEntryOptionsList extends Activity {
do I need to modify the above?
Mark M.
Bundle params = FieldActivityEntryOptionsList.this.getIntent().getExtras();
HighwayRob
ok...that partsa appears to have no errorsnow.
View paste
        AdapterView.OnItemClickListener itemClickListener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> listView, View v, int position, long id) {
                //Bundle params = this.getIntent().getExtras();
                Bundle params = FieldActivityEntryOptionsList.this.getIntent().getExtras();
                if (position == 0){
                    //Toast.makeText(FieldActivityEntryOptionsList.this,"Going for opt 0 techmangeneral", Toast.LENGTH_LONG).show();
                    //Log.d("FAEOList", "Going for option 0");
                    Intent intent = new Intent(FieldActivityEntryOptionsList.this, TechManGeneralEntryActivity.class );
                    //ServiceCall params = getIntent().getParcelableExtra("serviceCall");
                    intent.putExtras(params);
                    startActivity(intent);
                }
            }
        };
9:20 AM
HighwayRob
Nice. Cant wait until I am smart. It's taking time.
Mark M.
just a reminder: chat transcripts get publicly archived, so be judicious about what is in any screenshots, etc.
HighwayRob
OK..now that we have come this far. Once I add more data entry fields and add an UPDATE button and the user clicks update, I need to get the GUID (or whatever its is called in android world) how do I translate that the spinner is on entry '2' and entry 2 is associated to Steve Coomes and {4545-ed99-.....} The spinner is tied to some array adapter.
Mark M.
call getSelectedItem() to get whatever model object is in your adapter at the selected position
in other words, if you have an ArrayAdapter<Person>, getSelectedItem() returns the Person that is selected in the Spinner
9:25 AM
Mark M.
or, if you prefer, call getSelectedItemPosition() to get the zero-based index of the current selection
HighwayRob
Need the EmployeeID
View paste (8 more lines)
public ArrayList<EmployeeMaster> getEmployeeMaster() {
		Log.d("ServiceCallDataManager", "Inside getEmployeeMaster");
		ArrayList<EmployeeMaster> res = new ArrayList<EmployeeMaster>();
		Cursor mCursor = db.query(EMPLOYEEMASTER, EMPLOYEEMASTER_COLUMNS, null, null,
				null, null, "LastName", null);
		while (mCursor.moveToNext()) {
			EmployeeMaster employeeMaster = employeeMasterfromCursor(mCursor);
			res.add(employeeMaster);
		}
		return res;
	}

	private EmployeeMaster employeeMasterfromCursor(Cursor mCursor) {
		return new EmployeeMaster(
				mCursor.getString(mCursor
...
Mark M.
does EmployeeMaster have the EmployeeID?
it looks like it should
HighwayRob
View paste
private EmployeeMaster employeeMasterfromCursor(Cursor mCursor) {
		return new EmployeeMaster(
				mCursor.getString(mCursor
						.getColumnIndex("EmployeeID")),
				mCursor.getString(mCursor.getColumnIndex("FirstName")),
				mCursor.getString(mCursor
						.getColumnIndex("LastName")),
				mCursor.getString(mCursor.getColumnIndex("CompanyEmail")),
				mCursor.getString(mCursor.getColumnIndex("CompanyCellNbr")),
				mCursor.getString(mCursor.getColumnIndex("Status"))
		);
	}
Mark M.
does your Spinner use an ArrayAdapter<EmployeeMaster> ?
HighwayRob
View paste
       ServiceCallDataManager dataManager=ServiceCallDataManager.getInstance();
        ArrayList<EmployeeMaster> employees= dataManager.getEmployeeMaster();
        ArrayAdapter<EmployeeMaster> techlist=new
                ArrayAdapter<EmployeeMaster>(this,android.R.layout.simple_spinner_item,
                employees);
        techlist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spin.setAdapter(techlist);
Mark M.
spin.getSelectedItem() will return you the selected EmployeeMaster
call whatever method there is on EmployeeMaster to get the EmployeeID
HighwayRob
ok..I will give this a whirl right now....but not thinking I got syntax correct.
9:35 AM
HighwayRob
View paste
ok...close, but no cigar. Cannot resolve spin.....(I need more resolve)
 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        Toast.makeText(TechManGeneralEntryActivity.this, Integer.toString(position), Toast.LENGTH_LONG).show();
        Toast.makeText(TechManGeneralEntryActivity.this, spin.getSelectedItem(position).toString, Toast.LENGTH_LONG).show();
View paste
 public String getEmployeeID() {
		return scEmployeeID;
	}
Mark M.
parent is your Spinner
change the type to AdapterView<EmployeeMaster>
then call parent.getSelectedItem() to get the selected EmployeeMaster
9:40 AM
HighwayRob
Mark M.
post here the entire OnItemSelectedListener that this onItemSelected() method is a part of
9:45 AM
Leora
has entered the room
Mark M.
Rob, let me take a question from Leora, and I'll be back with you shortly
Leora: hi! how can I help you today?
Leora
Hi Mark.
I was wondering how I can debug Room orm - it doesn't seem to be inserting my entry
Yet no indication of failing...
Mark M.
how are you determining that it is not inserting your entry?
Leora
All I know is when I query, I get nothin back
Mark M.
are you sure that your query matches the data that you inserted?
Leora
Well, I query @Query("SELECT * FROM downloads")
so it should be returning something
Mark M.
have you examined the database directly (Device File Explorer, Stetho, etc.) to see if the problem is with the insert or the query?
9:50 AM
Leora
No, I was wondering if it was hard-copied somewhere
thanks! will do
Mark M.
let me take a question from Rob, and I'll return to you in a bit if there's time
Rob: your turn! do you have another question?
HighwayRob
View paste
2.)    As techs take picture, can we have the app remember the last Location
they selected while using the APP. They typically take a couple of pics of the same light, then move on.
Having to scroll and re-select the location each time is not efficient.  It can forget it when it closes or they change jobs.

3.)    Does the Image transfer screen stop transmitting when the screen
saver turns the screen off? Seems like it does. If so, can we fix this?

4.)    Attached are images I took, the last two being 'Full' size. Also
attached the ZIP file, the extracted pics from the ZIP and the original images emailed from the phone.
Why are the extracted file sizes different from the originals?
I know the PackageHandler does some resizing and I would think the APP does some also.  Let's discuss the process. I would like the images in the email to be a little sharper.

5.)    Please document and communicate your changes to me so I can make
these fixes in the updated version of the APP I am working on (adding field activity data entry)  that will be released next year.
oops delete that, wroing paste
wronge paste
View paste (23 more lines)
public class TechManGeneralEntryActivity extends Activity implements AdapterView.OnItemSelectedListener {

    private static final String[] items={"Rob", "Steve", "Joe", "Bill"};
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.techmangeneralentry);
        ServiceCall params = getIntent().getParcelableExtra("serviceCall");
        String sc_Num = params.getNumber();
        setTitle("Service Call: " + sc_Num);
        Spinner spin =(Spinner) findViewById(R.id.technicianspinner);
        spin.setOnItemSelectedListener(this);

        //ArrayAdapter<String> techlist=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
        //techlist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
...
Mark M.
the simplest solution is to make spin be a field in the activity, not a local variable
then your onItemSelected() method can refer to spin directly
and that means you can roll back to AdapterView<?> for the first parameter to onItemSelected()
alternatively, IIRC, you could change "implements AdapterView.OnItemSelectedListener" to "implements AdapterView<EmployeeMaster>.OnItemSelectedListener"
at which point AdapterView<EmployeeMaster> should be OK in your onItemSelected() first parameter
9:55 AM
Mark M.
Leora: do you have another question?
Leora
umm, just trying to find the db file
HighwayRob
I am getting your point. Your time running out. Since I may have many spinners on a screen, option 1 may be good. Let me take a shot and send you an email. Thank you.
Mark M.
Rob: OK
Leora
i put in gradle arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
Mark M.
Leora: if you are using Device File Explorer, it should be at /data/data/.../databases, where ... is your application ID
your Gradle snippet is the schema, not the database
Leora
oh :/
Mark M.
the database will be on the device or emulator
Leora
yes, it's not under the package
Mark M.
so you either need to copy it off of there (e.g., with Device File Explorer in Android Studio 3.0) or embed something in your app to allow you to examine it (e.g., Stetho)
Leora
what would the extension be? .db
Mark M.
it would be whatever you named it
Leora
ahhh
Mark M.
IIRC, extensions are not added automatically
Leora
(re instructions)
IIRC?
Mark M.
"if I recall correctly"
10:00 AM
Leora
ok great advice! thanks! here i go...
Mark M.
that's a wrap for today's chat
Leora
:)
Mark M.
the transcript will be archived at https://commonsware.com/office-hours/ shortly
the next chat is tomorrow at 7:30pm US Eastern
have a pleasant day!
HighwayRob
has left the room
Leora
has left the room
Mark M.
turned off guest access

Tuesday, November 21

 

Office Hours

People in this transcript

  • HighwayRob
  • Leora
  • Mark Murphy

Files in this transcript