Skip to content

Commit

Permalink
add log output
Browse files Browse the repository at this point in the history
- fixes #58
  • Loading branch information
niccokunzmann committed Aug 21, 2018
1 parent 9af3a3e commit 946aae1
Show file tree
Hide file tree
Showing 18 changed files with 303 additions and 100 deletions.
9 changes: 5 additions & 4 deletions app/src/main/java/eu/quelltext/mundraub/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
Expand All @@ -12,7 +11,9 @@
import java.io.IOException;
import java.io.InputStreamReader;

public class AboutActivity extends AppCompatActivity {
import eu.quelltext.mundraub.error.ErrorAwareActivity;

public class AboutActivity extends ErrorAwareActivity {

private Button buttonViewSource;
private Button buttonViewFreedoms;
Expand Down Expand Up @@ -83,13 +84,13 @@ private void selectLicense(String path) {
}
textSelectedLicense.setText(text.toString());
} catch (IOException e) {
e.printStackTrace();
log.printStackTrace(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
log.printStackTrace(e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;

import eu.quelltext.mundraub.error.ErrorAwareActivity;
import eu.quelltext.mundraub.plant.Plant;

public class ChooseMapPosition extends AppCompatActivity {
public class ChooseMapPosition extends ErrorAwareActivity {

public static final String ARG_PLANT_ID = "plant_id";
private Plant plant;
Expand All @@ -32,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
// load plant from arguments
plant = Plant.withId(getIntent().getStringExtra(ARG_PLANT_ID));
} else {
Log.e("ChooseMapPosition","No plant was specified.");
log.e("ChooseMapPosition","No plant was specified.");
finish();
}
saveButton = (Button) findViewById(R.id.button_ok);
Expand Down Expand Up @@ -71,7 +71,7 @@ void setPositionToPlant() {
alertAboutPositionGuess();
}
String url = position.getMapURLWithMarker();
Log.d("ChooseMapPosition", "set url to " + url);
log.d("ChooseMapPosition", "set url to " + url);
webView.loadUrl(url);
webView.reload();
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/eu/quelltext/mundraub/ChoosePlantType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import java.util.ArrayList;
import java.util.List;

import eu.quelltext.mundraub.error.ErrorAwareActivity;
import eu.quelltext.mundraub.plant.PlantCategory;

public class ChoosePlantType extends AppCompatActivity {
public class ChoosePlantType extends ErrorAwareActivity {

private RecyclerView plantTypesView;

Expand Down Expand Up @@ -84,7 +85,7 @@ public void setCategory(final PlantCategory category, final PlantCategoryResult
@Override
public void onClick(View v)
{
Log.d("onClick", category.toString());
log.d("onClick", category.toString());
result.resolve(category);
}
});
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/eu/quelltext/mundraub/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public final class Helper {
import eu.quelltext.mundraub.error.ErrorAware;

public final class Helper extends ErrorAware {
public static void deleteDir(File file) {
// from https://stackoverflow.com/a/29175213/1320237
File[] contents = file.listFiles();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/eu/quelltext/mundraub/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
Expand All @@ -18,11 +17,12 @@
import android.widget.TextView;

import eu.quelltext.mundraub.api.API;
import eu.quelltext.mundraub.error.ErrorAwareActivity;

/**
* A login screen that offers login via email/password.
*/
public class LoginActivity extends AppCompatActivity {
public class LoginActivity extends ErrorAwareActivity {

// UI references.
private AutoCompleteTextView usernameView;
Expand Down
15 changes: 7 additions & 8 deletions app/src/main/java/eu/quelltext/mundraub/NewPlantActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Expand All @@ -27,11 +25,12 @@
import java.io.FileOutputStream;
import java.io.IOException;

import eu.quelltext.mundraub.error.ErrorAwareActivity;
import eu.quelltext.mundraub.map.MapCache;
import eu.quelltext.mundraub.plant.Plant;
import eu.quelltext.mundraub.plant.PlantCategory;

public class NewPlantActivity extends AppCompatActivity {
public class NewPlantActivity extends ErrorAwareActivity {
/*
- intent.putString(NewPlantActivity.ARG_PLANT_ID, plant_id)
will open this view on a specific plant
Expand Down Expand Up @@ -299,7 +298,7 @@ private boolean tryCreateLocationManager() {
// for ActivityCompat#requestPermissions for more details.
// TODO: or create alert box:
// protected void alertbox in http://rdcworld-android.blogspot.com/2012/01/get-current-location-coordinates-city.html
Log.d("DEBUG", "Access to GPS position is not granted.");
log.d("DEBUG", "Access to GPS position is not granted.");
return false;
}
if (locationManager != null) {
Expand Down Expand Up @@ -341,24 +340,24 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
try {
// from https://stackoverflow.com/a/28720264/1320237
File savedPicture = File.createTempFile("plant", ".jpg", getExternalCacheDir());
Log.d("CameraDemo", "photo " + photo + " to " + savedPicture);
log.d("CameraDemo", "photo " + photo + " to " + savedPicture);
FileOutputStream fos = new FileOutputStream(savedPicture);
photo.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
plant.setPicture(savedPicture);
} catch (FileNotFoundException e) {
e.printStackTrace();
log.printStackTrace(e);
} catch (IOException e) {
e.printStackTrace();
log.printStackTrace(e);
}
loadViewFromPlant();
}
}

public void setPlantCategory(PlantCategory plantCategory) {
this.plant.setCategory(plantCategory);
Log.d("NewPlantActivity", "Set plant category to " + plantCategory.toString());
log.d("NewPlantActivity", "Set plant category to " + plantCategory.toString());
loadViewFromPlant();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

import eu.quelltext.mundraub.error.ErrorAwareActivity;
import eu.quelltext.mundraub.plant.Plant;

/**
Expand All @@ -19,7 +19,7 @@
* item details are presented side-by-side with a list of items
* in a {@link PlantListActivity}.
*/
public class PlantDetailActivity extends AppCompatActivity {
public class PlantDetailActivity extends ErrorAwareActivity {

public static final String ARG_PLANT_ID = "plant_id";
String plantId;
Expand Down
19 changes: 11 additions & 8 deletions app/src/main/java/eu/quelltext/mundraub/PlantListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -23,6 +21,8 @@
import java.util.Date;
import java.util.List;

import eu.quelltext.mundraub.error.ErrorAwareActivity;
import eu.quelltext.mundraub.error.Logger;
import eu.quelltext.mundraub.plant.Plant;

/**
Expand All @@ -33,7 +33,7 @@
* item details. On tablets, the activity presents the list of items and
* item details side-by-side using two vertical panes.
*/
public class PlantListActivity extends AppCompatActivity {
public class PlantListActivity extends ErrorAwareActivity {

private static final String ARG_RECYCLER_VIEW_STATE = "recycler_view_state";
/**
Expand Down Expand Up @@ -105,7 +105,7 @@ protected void onSaveInstanceState(Bundle outState) {


private void updateRecyclerView() {
Log.d("DEBUG", "updateRecyclerView");
log.d("DEBUG", "updateRecyclerView");
loadRecyclerViewState();
adapter.update();
}
Expand All @@ -122,6 +122,7 @@ public static class SimpleItemRecyclerViewAdapter
private final PlantListActivity mParentActivity;
private List<Plant> plants;
private final boolean mTwoPane;
private final Logger.Log log;
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -143,22 +144,24 @@ public void onClick(View view) {
}
}
};

public void update() {
load();
Log.d("RECYCLER", "changed start");
log.d("RECYCLER", "changed start");
notifyDataSetChanged();
Log.d("RECYCLER", "changed stop");
log.d("RECYCLER", "changed stop");
}

private void load() {
Log.d("RECYCLER", "load start");
log.d("RECYCLER", "load start");
plants = Plant.all();
Collections.sort(plants);
Log.d("RECYCLER", "load stop");
log.d("RECYCLER", "load stop");
}

SimpleItemRecyclerViewAdapter(PlantListActivity parent,
boolean twoPane) {
log = Logger.newFor(this);
mParentActivity = parent;
mTwoPane = twoPane;
load();
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/eu/quelltext/mundraub/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import android.os.AsyncTask;

import eu.quelltext.mundraub.R;
import eu.quelltext.mundraub.error.ErrorAware;
import eu.quelltext.mundraub.plant.Plant;

public abstract class API {
public abstract class API extends ErrorAware {

private static final API dummyAPI = new DummyAPI();
private static final API mundraubAPI = new MundraubAPI();
Expand All @@ -14,7 +15,7 @@ public abstract class API {
public final int TASK_CANCELLED = R.string.task_was_cancelled;

private boolean isLoggedIn;

public static final API instance() {
if (useDummy) {
return dummyAPI;
Expand Down
Loading

0 comments on commit 946aae1

Please sign in to comment.