DT @21.12.2015: Last changes commited

This commit is contained in:
Dennis Thießen
2015-12-21 13:38:58 +01:00
parent 24ec175a43
commit acf1eaa8b0
5 changed files with 40 additions and 84 deletions

View File

@@ -41,6 +41,7 @@ public class MainActivity extends BaseActivity{
Handler mHandler = new Handler();
private final static int INTERVAL = 1000 * 20; //20 seconds
private TextView count;
private Button report;
private Button map;
@@ -50,6 +51,8 @@ public class MainActivity extends BaseActivity{
super.onCreate(savedInstanceState);
userHasToBeLoggedIn();
count = (TextView) findViewById(R.id.txt_main_incidents);
Intent intent = getIntent();
msg_input = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
@@ -145,8 +148,9 @@ public class MainActivity extends BaseActivity{
boolean error = jObj.getBoolean("error");
if (!error) {
TextView count = (TextView) findViewById(R.id.txt_main_incidents);
count.setText(jObj.getString("total"));
JSONObject jCount = jObj.getJSONObject("msg");
count.setText(jCount.getString("total"));
} else {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error getting incident count (server returned error): " + errorMsg);

View File

@@ -147,10 +147,10 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
private void addMarkersToMap(){
LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
mHeatMapPositionList.clear();
//Loop through all the items that are available to be placed on the map
Log.d("Zoom", "Bounds: NE:" + bounds.northeast +" SW: " + bounds.southwest);
for(IncidentReport item : myMarkers)
{
//If the item is within the the bounds of the screen
if(bounds.contains(item.getPosition()))
{
mHeatMapPositionList.add(item.getPosition());
@@ -259,10 +259,11 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
tvSuspect.setText(clickedClusterItem.getSuspectString(getApplicationContext()));
tvUsername.setText(getString(R.string.lbl_mapsinfowindow_author) + ": " + clickedClusterItem.getFromUsername());
tvScore.setText(getString(R.string.lbl_mapsinfowindow_score) + ": " + clickedClusterItem.getVotedScore());
tvVictim.setText(clickedClusterItem.getFidVictimCategory());
tvTime.setText(clickedClusterItem.getTimeString(getApplicationContext()));
rbScore.setRating(clickedClusterItem.getScoreStars());
//TODO
//tvScore.setText(clickedClusterItem.getVotedScore());
//tvVictim.setText(clickedClusterItem.getFidVictimCategory());
//tvTime.setText(clickedClusterItem.getTimeString(getApplicationContext()));
//rbScore.setRating(clickedClusterItem.getScoreStars());
}
return myContentsView;
}
@@ -417,7 +418,6 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
@Override
public void onResponse(String response) {
Log.d(TAG, "Map positions response: " + response);
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
@@ -428,19 +428,18 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
for(int i=0;i<incidents.length();i++){
JSONObject incident = incidents.getJSONObject(i);
LatLng pos = new LatLng(Double.parseDouble(incident.getString("latitude")),Double.parseDouble(incident.getString("longitude")));
myMarkers.add(new IncidentReport(incident,pos));
myMarkers.add(new IncidentReport(incident,new LatLng(incident.getDouble("latitude"),incident.getDouble("longitude"))));
}
addHeatMap();
} else {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error getting map positions (server returned error): " + errorMsg);
showMessage(errorMsg);
}
hideDialog();
} catch (JSONException e) {
e.printStackTrace();
hideDialog();
}
}
@@ -455,7 +454,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "getincidentswithpositionandscorev2");
params.put("tag", "getincidentswithpositionandscore");
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));

View File

@@ -42,7 +42,7 @@ public class ViewReportActivity extends BaseActivity {
private EditText txtDate;
private EditText txtTime;
private TextView txtPositionDetail;
private BootstrapLabel scorelabel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -58,9 +58,9 @@ public class ViewReportActivity extends BaseActivity {
txtTime = (EditText) findViewById(R.id.input_viewreport_time);
txtPosition = (EditText) findViewById(R.id.input_viewreport_position);
txtPositionDetail = (TextView) findViewById(R.id.lbl_viewreport_position_detail);
scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
getIncident(uid);
getIncidentVoteScore(uid);
findViewById(R.id.btn_viewreport_upvote).setOnClickListener(new View.OnClickListener() {
@Override
@@ -196,6 +196,8 @@ public class ViewReportActivity extends BaseActivity {
txtDescription.setText(incident.getString("text_long"));
txtCrimeCategory.setText(incident.getString("cat_name"));
scorelabel.setText(jObj.getString("score"));
String[] happened_at = incident.getString("happened_at").split(" ");
txtDate.setText(happened_at[0]);
txtTime.setText(happened_at[1].substring(0, 5));
@@ -272,59 +274,6 @@ public class ViewReportActivity extends BaseActivity {
};
}
public void getIncidentVoteScore(Integer uid) {
String tag_string_req = "getincidentvotescore";
StringRequest strReq = getStringRequestGetIncidentVoteScore(uid);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
private StringRequest getStringRequestGetIncidentVoteScore(final Integer incidentid) {
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "IncidentScore with ID response: " + response);
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
BootstrapLabel scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
scorelabel.setText(jObj.getString("points"));
} else {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error get incident vote score (Server returned error): " + errorMsg);
showMessage(errorMsg);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error get incident vote score: " + error.getMessage());
showMessage(getString(R.string.errormsg_couldnotretrieve));
hideDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "getincidentvotescore");
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));
params.put("incidentid", incidentid.toString());
return params;
}
};
}
public void makeUpvote(Integer uid) {
String tag_string_req = "addvote";
StringRequest strReq = getStringRequestAddVote(uid, "1");

View File

@@ -90,7 +90,7 @@ public class IncidentReport implements ClusterItem {
this.incidentPosition = new LatLng(mIncident.getDouble("latitude"),mIncident.getDouble("longitude"));
}
this.votedScore = mIncident.getInt("id");
this.votedScore = mIncident.getInt("score");
this.createdAt = mIncident.getString("created_at");
this.updatedAt = mIncident.getString("updated_at");
this.fromUsername = mIncident.getString("username");
@@ -257,29 +257,29 @@ public class IncidentReport implements ClusterItem {
}
public String getIncidentCategoryName(Context context){
return context.getResources().getStringArray(R.array.cat_situation_main)[this.fidIncidentCategory];
return context.getResources().getStringArray(R.array.cat_situation_main)[this.fidIncidentCategory-1];
}
public String getIncidentSubCategoryName(Context context){
String returnName = "";
switch(this.fidIncidentCategory){
case 1:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_general)[this.fidIncidentSubCategory];
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_general)[this.fidIncidentSubCategory-1];
break;
case 2:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_verbal)[this.fidIncidentSubCategory];
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_verbal)[this.fidIncidentSubCategory-1];
break;
case 3:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_force)[this.fidIncidentSubCategory];
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_force)[this.fidIncidentSubCategory-1];
break;
case 4:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_force_serious)[this.fidIncidentSubCategory];
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_force_serious)[this.fidIncidentSubCategory-1];
break;
case 5:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_nature)[this.fidIncidentSubCategory];
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_nature)[this.fidIncidentSubCategory-1];
break;
case 6:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_infrastructure)[this.fidIncidentSubCategory];
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_infrastructure)[this.fidIncidentSubCategory-1];
break;
}
return returnName;
@@ -289,10 +289,10 @@ public class IncidentReport implements ClusterItem {
String returnString = "";
switch (this.fidTimeCategory){
case 1:
returnString = context.getResources().getStringArray(R.array.cat_time_main)[this.fidTimeCategory];
returnString = context.getResources().getStringArray(R.array.cat_time_main)[this.fidTimeCategory-1];
break;
case 2:
returnString = context.getResources().getStringArray(R.array.cat_time_sub_periodical)[this.fidTimeSubCategory];
returnString = context.getResources().getStringArray(R.array.cat_time_sub_periodical)[this.fidTimeSubCategory-1];
break;
case 3:
if((this.fromTime != null) && !(this.fromTime.equals("00:00:00"))){
@@ -309,14 +309,14 @@ public class IncidentReport implements ClusterItem {
}
break;
case 5:
returnString = context.getResources().getStringArray(R.array.cat_time_main)[this.fidTimeCategory];
returnString = context.getResources().getStringArray(R.array.cat_time_main)[this.fidTimeCategory-1];
break;
}
return returnString;
}
public String getSuspectString(Context context){
return context.getResources().getStringArray(R.array.cat_suspect_main)[this.fidSuspectCategory];
return context.getResources().getStringArray(R.array.cat_suspect_main)[this.fidSuspectCategory-1];
}
public int getCategoryColor(){

View File

@@ -6,19 +6,23 @@
android:orientation="vertical"
android:paddingLeft="6dp"
android:paddingRight="7dp"
android:paddingTop="8dp"
android:paddingTop="7dp"
android:paddingBottom="8dp"
android:background="@drawable/infowindow">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:textColor="#a6000000"
android:id="@+id/txt_infowindow_category"
android:text="Header"
android:text="Headerfffffffffffffffffffffffffffffffff"
android:textSize="18dp"
android:paddingLeft="30dp"
android:typeface="serif" />
android:typeface="serif"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"/>
<LinearLayout
android:orientation="horizontal"