Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.techlatin.loge;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.Color;
- import android.location.Location;
- import android.location.LocationListener;
- import android.location.LocationManager;
- import android.support.v7.app.ActionBarActivity;
- import android.support.v7.app.ActionBar;
- import android.support.v4.app.Fragment;
- import android.os.Bundle;
- import android.view.LayoutInflater;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- import android.os.Build;
- import android.widget.Button;
- import android.widget.TextView;
- public class ZZE_NewLocations extends ActionBarActivity {
- String session_id;
- String session_name;
- String Lat;
- String Lng;
- String zzBINIDQR;
- String ErrorText;
- Boolean thereWasAnError = false;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_zze__new_locations);
- if (savedInstanceState == null) {
- getSupportFragmentManager().beginTransaction()
- .add(R.id.container, new PlaceholderFragment())
- .commit();
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.zze__new_locations, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- /**
- * A placeholder fragment containing a simple view.
- */
- public static class PlaceholderFragment extends Fragment {
- public PlaceholderFragment() {
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_zze__new_locations, container, false);
- return rootView;
- }
- }
- //==========================================================
- private boolean resumeHasRun = false;
- @Override
- protected void onResume(){
- //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
- //btnst01.setEnabled(false);
- super.onResume();
- if (!resumeHasRun){
- resumeHasRun = true;
- //return;
- }
- // get the session stuff here
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- session_id = extras.getString("session_id");
- session_name = extras.getString("session_name");
- }
- final TextView xxSESSION_NAME = (TextView) findViewById(R.id.tvSESSION_NAME01);
- xxSESSION_NAME.setText(session_name);
- final TextView xxSESSION_ID = (TextView) findViewById(R.id.tvSESSION_ICD01);
- xxSESSION_ID.setText(session_id);
- Do_WHATABOUT_ZZE();
- }
- private void Do_WHATABOUT_ZZE(){
- // will explain what this screen is about
- TextView tv_zze_WhatAbout = (TextView) findViewById(R.id.tv_ZZE_WHAT_ABOUT);
- tv_zze_WhatAbout.setText("This screen is for NEW deployments of Existing and New Assets. You should use this screen only ONCE per Asset.");
- }
- //====================================================================================
- public void btnClickZZBGetLatLong (View view){
- locStartListener();
- }
- public void locStartListener(){
- // Acquire a reference to the system Location Manager
- LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
- // Define a listener that responds to location updates
- LocationListener locationListener = new LocationListener() {
- TextView xxLat = (TextView) findViewById(R.id.tvLat);
- TextView xxLong = (TextView) findViewById(R.id.tvLng);
- public void onLocationChanged(Location location) {
- // Called when a new location is found by the network location provider.
- //makeUseOfNewLocation(location);
- location.getLatitude();
- location.getLongitude();
- //xxLat.setText( location.getLatitude().toString() );
- xxLat.setText( String.valueOf(location.getLatitude()) );
- xxLat.setBackgroundColor(Color.GREEN);
- xxLong.setText(String.valueOf(location.getLongitude()));
- xxLong.setBackgroundColor(Color.GREEN);
- Lat = xxLat.getText().toString();
- Lng = xxLong.getText().toString();
- //Button btnst02 = (Button) findViewById(R.id.btnStep2_submit);
- //btnst02.setEnabled(true);
- }
- public void onStatusChanged(String provider, int status, Bundle extras) {}
- public void onProviderEnabled(String provider) {}
- public void onProviderDisabled(String provider) {}
- };
- // Register the listener with the Location Manager to receive location updates
- //locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
- }
- //================================================================
- //QRCode Reading
- public void btnZZZB_STEP01_SCAN01_click (View view){
- Intent intent = new Intent("com.google.zxing.client.android.SCAN");
- //intent.putExtra("SCAN_MODE", "PRODUCT_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
- intent.putExtra("SCAN_MODE", "QR_CODE_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
- intent.putExtra("SAVE_HISTORY", false);//this stops saving ur barcode in barcode scanner app's history
- startActivityForResult(intent, 0);
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == 0) {
- if (resultCode == RESULT_OK) {
- //String contents = data.getStringExtra("SCAN_RESULT"); //this is the result
- // zzBINIDQR = data.getStringExtra("SCAN_RESULT");
- // TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
- // tvtest000.setText(BINID_QR);
- // tvtest000.setBackgroundColor(Color.GREEN);
- //BINID_QR = contents;
- //Button btnst01a = (Button) findViewById(R.id.btnStep1_submit);
- //btnst01.setEnabled(true);
- }
- else if (resultCode == RESULT_CANCELED) {
- // Handle cancel
- //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
- //btnst01.setEnabled(false);
- zzBINIDQR = "--- no result ---";
- // TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
- // tvtest000.setText(BINID_QR);
- // tvtest000.setBackgroundColor(Color.RED);
- }
- }
- }
- //======================== FRAGMENTS ===============================
- public void btnClick_zze_01__loc_id(View view){
- setContentView(R.layout.fragment_zze_01__loc_id);
- }
- //======================== FRAGMENTS ===============================
- public void btnClick_zze_09__return(View view){
- setContentView(R.layout.fragment_zze__new_locations);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment