@Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Log.d(TAG, "onActivityCreated: started " + hashCode());

    executeSavedInstanceState(savedInstanceState);

    Fragment fragment = null;
    if (getArguments() == null || getArguments().getBoolean(Extra.CREATE_WORKER_FRAGMENT, true)) {
      FragmentManager fm = getFragmentManager();
      fragment = fm.findFragmentByTag(POIsListWorkerFragment.TAG);
      Log.d(TAG, "Found worker fragment:" + fragment);
      if (fragment == null) {
        fragment = new POIsListWorkerFragment();
        fm.beginTransaction().add(fragment, POIsListWorkerFragment.TAG).commit();
      }

    } else if (!getArguments().getBoolean(Extra.CREATE_WORKER_FRAGMENT, false)) {
      Log.d(TAG, "Connecting to Combined Worker Fragment");
      FragmentManager fm = getFragmentManager();
      fragment = fm.findFragmentByTag(CombinedWorkerFragment.TAG);
    }

    mWorkerFragment = (WorkerFragment) fragment;
    mWorkerFragment.registerDisplayFragment(this);
    Log.d(TAG, "result mWorkerFragment = " + mWorkerFragment);

    if (UtilsMisc.isTablet(getActivity()))
      mPullToRefreshListView.getRefreshableView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  }
 @Override
 protected void checkApiCallClientErrors(HttpClientErrorException e) throws RestServiceException {
   HttpStatus status = e.getStatusCode();
   if (status.value() == statusAuthFailed) {
     Log.e(getTag(), "authorization failed - email or password not valid");
     processException(RestServiceException.ERROR_AUTHORIZATION_ERROR, e, false);
   } else if (status.value() == statusOSMFailed) {
     Log.e(getTag(), "osm failed");
     processException(RestServiceException.ERROR_NOT_OSM_CONNECTED, e, false);
   }
 }
  public void onEventMainThread(MyLocationManager.LocationEvent event) {
    Log.d(TAG, "updateLocation: location = " + event.location);
    mLastLocation = mLocation;
    mLocation = event.location;
    resetCursorLoaderUri();

    if (isNewDistanceFar()) {
      Log.d(TAG, "updateLocation: isNewDistanceFar results true");
      requestUpdate(null);
    }
  }
Exemplo n.º 4
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the logging
    Log.init();

    // Log a message (only on dev platform)
    Log.i(this, "onCreate");

    setContentView(R.layout.main);
  }
 @Override
 public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
   Cursor wrappingCursor = new POIsCursorWrapper(cursor, mLocation);
   Log.d(TAG, "cursorloader - new cursor - cursor size = " + wrappingCursor.getCount());
   mCursor = wrappingCursor;
   update();
 }
  @Override
  public void executeBundle(Bundle bundle) {
    Log.d(TAG, "executeState fragment is visible = " + isVisible());
    if (bundle == null) return;

    if (bundle.getBoolean(Extra.REQUEST, false)) mWorkerFragment.requestUpdate(null);
  }
  @Override
  public void onLoaderReset(Loader<Cursor> arg0) {
    Log.d(TAG, "onLoaderReset - need to set it to null");

    mCursor = null;
    update();
  }
 public void onEventMainThread(UserQueryHelper.UserQueryUpdateEvent e) {
   Log.d(TAG, "onUserQueryChanged: received event");
   mQuery = e.query;
   if (mLocation != null) {
     getLoaderManager().restartLoader(LOADER_ID_LIST, null, this);
   }
 }
  @Override
  public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Log.d(TAG, "onCreateLoader");

    return new CursorLoader(
        getActivity(), POIs.createUriSorted(mLocation), POIs.PROJECTION, mQuery, null, null);
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   Log.d(TAG, "onActivityResult: requestCode = " + requestCode + " resultCode = " + resultCode);
   if (requestCode == SELECT_WHEELCHAIRSTATE) {
     if (resultCode == RESULT_OK) {
       // newly selected wheelchair state as action data
       if (data != null) {
         WheelchairState state =
             WheelchairState.valueOf(data.getIntExtra(Extra.WHEELCHAIR_STATE, Extra.UNKNOWN));
         updateDatabase(poiIdSelected, state);
         Log.d(TAG, "starting SyncServiceHelper.executeUpdateServer");
         SyncServiceHelper.executeUpdateServer(this, null);
       }
     }
   }
 }
  private void updateDatabase(long id, WheelchairState state) {
    Log.d(TAG, "updating id = " + id + " state = " + state.asRequestParameter());
    if (id == Extra.ID_UNKNOWN || state == null) return;

    ContentValues values = new ContentValues();
    values.put(POIs.WHEELCHAIR, state.getId());
    values.put(POIs.DIRTY, POIs.DIRTY_STATE);

    PrepareDatabaseHelper.editCopy(getContentResolver(), id, values);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate " + hashCode());
    setHasOptionsMenu(true);

    mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    // noinspection deprecation
    mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    mOrientationAvailable = mSensor != null;
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Log.d(TAG, "onCreate");
   setRetainInstance(true);
   mDistance = getDistanceFromPreferences();
   mReceiver = new DetachableResultReceiver(new Handler());
   mReceiver.setReceiver(this);
   mBus = EventBus.getDefault();
   retrieveInitialLocation();
 }
  @Override
  public void prepareDatabase() throws RestServiceException {
    if (mContentIsEqual) {
      Log.i(TAG, "content is equal according to etag - doing nothing");
      return;
    }

    getResolver().delete(CategoriesContent.CONTENT_URI, null, null);
    DataOperationsCategories doc = new DataOperationsCategories(getResolver());
    doc.insert(getTempStore());
    clearTempStore();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setSupportProgressBarIndeterminateVisibility(false);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    setContentView(R.layout.activity_multipane);

    // FragmentManager.enableDebugLogging(true);

    if (savedInstanceState != null) executeState(savedInstanceState);
    else executeDefaultInstanceState();

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    createSearchModeCustomView(actionBar);

    mResizeButton.setOnClickListener(this);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    mWorkerFragment = (CombinedWorkerFragment) fm.findFragmentByTag(CombinedWorkerFragment.TAG);
    if (mWorkerFragment == null) {
      mWorkerFragment = new CombinedWorkerFragment();
      t.add(mWorkerFragment, CombinedWorkerFragment.TAG);
    }

    mListFragment = (POIsListFragment) fm.findFragmentById(R.id.list_layout);
    if (mListFragment == null) {
      mListFragment = POIsListFragment.newInstance(false, true);
      t.add(R.id.list_layout, mListFragment, POIsListFragment.TAG);
    }

    mMapFragment = (POIsMapsforgeFragment) fm.findFragmentById(R.id.map_layout);
    if (mMapFragment == null) {
      mMapFragment = POIsMapsforgeFragment.newInstance(false, true);
      t.add(R.id.map_layout, mMapFragment, POIsMapsforgeFragment.TAG);
    }

    mDetailFragment = (POIDetailFragment) fm.findFragmentById(R.id.detail_layout);
    if (mDetailFragment == null) {
      mDetailFragment = POIDetailFragment.newInstance();
      t.add(R.id.detail_layout, mDetailFragment);
    }

    t.commit();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView " + hashCode());

    View v = inflater.inflate(R.layout.fragment_list, container, false);
    mPullToRefreshListView = (PullToRefreshListView) v.findViewById(R.id.pull_to_refresh_listview);
    mPullToRefreshListView.setOnRefreshListener(this);
    mAdapter = new POIsListCursorAdapter(getActivity(), null, false);
    mPullToRefreshListView.getRefreshableView().setAdapter(mAdapter);

    mBus = WheelmapApp.getBus();
    mBus.register(this);

    return v;
  }
  @Override
  public void execute(long id) throws RestServiceException {
    CategoriesRequestBuilder requestBuilder =
        new CategoriesRequestBuilder(getServer(), getApiKey(), AcceptType.JSON);
    if (mLocale != null) {
      requestBuilder.locale(mLocale);
    }

    clearTempStore();
    setEtag(mEtag);
    retrieveSinglePage(requestBuilder);
    if (mEtag != null && mEtag.equals(getEtag()) && getTempStore().isEmpty()) {
      mContentIsEqual = true;
    }

    LastUpdateContent.storeEtag(getResolver(), LastUpdateContent.MODULE_CATEGORIES, getEtag());
    Log.d(TAG, "etag = " + getEtag());
  }
  private void setCursor(Cursor cursor) {
    Log.d(
        TAG,
        "setCursor cursor "
            + ((cursor != null) ? cursor.hashCode() : "null")
            + " count = "
            + ((cursor != null) ? cursor.getCount() : "null")
            + " isNewCursor = "
            + (cursor != mCursor));
    if (cursor == mCursor) return;

    mCursor = cursor;
    if (mCursor != null) {
      mDirectionCursorWrapper = new DirectionCursorWrapper(mCursor);
    } else {
      mDirectionCursorWrapper = null;
    }
    mAdapter.swapCursor(mDirectionCursorWrapper);
    markItemClear();
    refreshListPosition();
  }
 /** {@inheritDoc} */
 public void onReceiveResult(int resultCode, Bundle resultData) {
   Log.d(TAG, "onReceiveResult resultCode = " + resultCode);
   switch (resultCode) {
     case RestService.STATUS_RUNNING:
       {
         setRefreshStatus(true);
         break;
       }
     case RestService.STATUS_FINISHED:
       {
         setRefreshStatus(false);
         break;
       }
     case RestService.STATUS_ERROR:
       {
         setRefreshStatus(false);
         final RestServiceException e = resultData.getParcelable(Extra.EXCEPTION);
         if (mListener != null) {
           mListener.onError(e);
         }
         break;
       }
   }
 }
Exemplo n.º 20
0
 @Override
 public void onReady() {
   super.onReady();
   addResultText.setText(String.valueOf(result));
   Log.i("Displayed result " + result + " to user");
 }
 @Override
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   Log.d(TAG, "onNewIntent");
   setIntent(intent);
 }
 @Override
 public void onRefreshing(boolean isRefreshing) {
   Log.d(TAG, "onRefreshing isRefreshing = " + isRefreshing);
   setSupportProgressBarIndeterminateVisibility(isRefreshing);
 }
 @Override
 public void onSearchModeChange(boolean isSearchMode) {
   Log.d(TAG, "onSearchModeChange: showing custom view in actionbar");
   getSupportActionBar().setDisplayShowCustomEnabled(true);
 }
 private void setMovableGone() {
   mMovableVisible = false;
   Log.d(TAG, "setMovableGone height = " + (-mMovableLayout.getHeight()));
   mMovableLayout.setVisibility(View.INVISIBLE);
 }
 @Override
 public void onRefresh(PullToRefreshBase<ListView> refreshView) {
   Log.d(TAG, "onRefresh pulled");
   mFirstVisiblePosition = 0;
   if (mWorkerFragment != null) mWorkerFragment.requestUpdate(null);
 }
 @Override
 public void requestUpdate(Bundle bundle) {
   Log.d(TAG, "requestUpdate mLocation = " + mLocation + " mDistance = " + mDistance);
   RestServiceHelper.retrieveNodesByDistance(getActivity(), mLocation, mDistance, mReceiver);
 }
 @Subscribe
 public void onDistanceUnitChanged(DistanceUnitChangedEvent e) {
   Log.d(TAG, "onDistanceUnitChanged");
   mAdapter.changeAdapter();
 }
 public POIsListFragment() {
   super();
   Log.d(TAG, "constructor called " + hashCode());
 }