Skip to content

Commit

Permalink
fixed elephant poaching bug #67
Browse files Browse the repository at this point in the history
  • Loading branch information
vintuwei committed Nov 20, 2015
1 parent f62bdbd commit ac639cb
Show file tree
Hide file tree
Showing 22 changed files with 384 additions and 312 deletions.
2 changes: 1 addition & 1 deletion gen/android/support/v7/appcompat/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public static final class layout {
public static final int abc_search_dropdown_item_icons_2line = 0x7f030014;
public static final int abc_search_view = 0x7f030015;
public static final int abc_simple_dropdown_hint = 0x7f030016;
public static final int support_simple_spinner_dropdown_item = 0x7f030045;
public static final int support_simple_spinner_dropdown_item = 0x7f030047;
}
public static final class string {
public static final int abc_action_bar_home_description = 0x7f0a0001;
Expand Down
562 changes: 288 additions & 274 deletions gen/com/ihub/rangerapp/R.java

Large diffs are not rendered by default.

36 changes: 29 additions & 7 deletions res/layout/amazing_list_view.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<com.ihub.rangerapp.view.AmazingListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="20dp" >


<TextView
android:id="@+id/noRecordsLabel"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/no_records_label"
android:visibility="gone"
android:textSize="16sp"
android:textColor="@color/bg" />

<com.ihub.rangerapp.view.AmazingListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" />

</LinearLayout>

31 changes: 26 additions & 5 deletions res/layout/list.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="20dp" >


<TextView
android:id="@+id/noRecordsLabel"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/no_records_label"
android:visibility="gone"
android:textSize="16sp"
android:textColor="@color/bg" />

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

</LinearLayout>

3 changes: 2 additions & 1 deletion res/layout/swiperefresh_loadmore_list.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<string name="no_of_animals_seen">No of Animals Seen</string>
<string name="select_date">Select Date</string>
<string name="end_shift_view_msg">End Shift Coordinates</string>
<string name="no_records_label">You haven\'t filed any report under this section</string>

<!-- http://openweathermap.org/weather-conditions -->
<string-array name="weather_conditions">
Expand Down
6 changes: 3 additions & 3 deletions src/com/ihub/rangerapp/RangerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public static String getUniqueDeviceID() {
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(RangerApp.get().getApplicationContext().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
return deviceUuid.toString();
}

private void initLoaders() {
dataLoaders.put(GameMeatLoader.class.getSimpleName(), new GameMeatLoader());

dataLoaders.put(GameMeatLoader.class.getSimpleName(), new GameMeatLoader());
dataLoaders.put(CharcoalBagsLoader.class.getSimpleName(), new CharcoalBagsLoader());
dataLoaders.put(CharcoalKilnsLoader.class.getSimpleName(), new CharcoalKilnsLoader());
dataLoaders.put(ElephantPoachingLoader.class.getSimpleName(), new ElephantPoachingLoader());
Expand All @@ -66,4 +66,4 @@ private void initLoaders() {
public DataLoader getLoader(String name) {
return dataLoaders.get(name);
}
}
}
6 changes: 3 additions & 3 deletions src/com/ihub/rangerapp/SyncTaskActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void syncItem(int group, int item, List<Integer> ids) {

if(Schemas.SHIFTS_TABLE.equals(tableName)) {
syncShifts(group, item, ids);
} else if(Schemas.GAME_MEAT_TABLE.equals(tableName)) {
} else if(Schemas.BUSH_MEAT_TABLE.equals(tableName)) {
syncGameMeat(group, item, ids);
} else if(Schemas.CHARCOAL_BAGS_TABLE.equals(tableName)) {
syncCharcoalBags(group, item, ids);
Expand Down Expand Up @@ -289,8 +289,8 @@ public String getTableName(String groupName) {

if("Shifts".equals(groupName)) {
return Schemas.SHIFTS_TABLE;
} else if("Game Meat".equals(groupName)) {
return Schemas.GAME_MEAT_TABLE;
} else if("Bush Meat".equals(groupName)) {
return Schemas.BUSH_MEAT_TABLE;
} else if("Charcoal Bags Incidents".equals(groupName)) {
return Schemas.CHARCOAL_BAGS_TABLE;
} else if("Charcoal Kilns Incidents".equals(groupName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down
7 changes: 4 additions & 3 deletions src/com/ihub/rangerapp/data/service/GameMeatServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down Expand Up @@ -57,10 +58,10 @@ public Map<String, Object> save(Integer id, String animal, Integer noOfAnimals,
try {

if(id == -1) {
db.insert(Schemas.GAME_MEAT_TABLE, null, values);
db.insert(Schemas.BUSH_MEAT_TABLE, null, values);
result.put("status", "success");
} else {
db.update(Schemas.GAME_MEAT_TABLE, values, BaseColumns._ID + "=" + id, null);
db.update(Schemas.BUSH_MEAT_TABLE, values, BaseColumns._ID + "=" + id, null);
result.put("status", "success");
}

Expand Down Expand Up @@ -90,7 +91,7 @@ public void sync(Integer id, AsyncHttpResponseHandler handler) {
try{

SQLiteDatabase db = getWritableDatabase(RangerApp.get());
cursor = db.rawQuery("SELECT * FROM " + Schemas.GAME_MEAT_TABLE +" WHERE " + BaseColumns._ID +"=?", new String[] {id + ""});
cursor = db.rawQuery("SELECT * FROM " + Schemas.BUSH_MEAT_TABLE +" WHERE " + BaseColumns._ID +"=?", new String[] {id + ""});

if(cursor.getCount() > 0) {
cursor.moveToFirst();
Expand Down
1 change: 1 addition & 0 deletions src/com/ihub/rangerapp/data/service/ShiftServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.data.sqlite.Schemas.Shift;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down
16 changes: 7 additions & 9 deletions src/com/ihub/rangerapp/data/service/SyncServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.ihub.rangerapp.data.service;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;
import android.util.Log;
import android.util.Pair;
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.DB;
Expand All @@ -24,11 +22,11 @@ public Integer startSync() {

UserService userService = new UserServiceImpl();
Long userID = userService.getCurrentUserID();
values.put(Schemas.RANGER_ID, userID);
values.put(Schemas.ExportsTable.START_TIME, new Date().getTime() + "");
Long id = db.insert(Schemas.EXPORTS_TABLE, null, values);

values.put(Schemas.RANGER_ID, userID);
values.put(Schemas.ExportsTable.START_TIME, new Date().getTime() + "");

Long id = db.insert(Schemas.EXPORTS_TABLE, null, values);

return id.intValue();
}
Expand Down Expand Up @@ -84,9 +82,9 @@ public List<Pair<String, Integer>> loadCounts() {
data.add(new Pair<String, Integer>("Shifts", getCount(sql)));

sql = "SELECT count(*) FROM " +
Schemas.GAME_MEAT_TABLE + " WHERE " + Schemas.LAST_SYNC_DATE + " IS NULL OR " + Schemas.REQUIRES_SYNC + " = 1";
Schemas.BUSH_MEAT_TABLE + " WHERE " + Schemas.LAST_SYNC_DATE + " IS NULL OR " + Schemas.REQUIRES_SYNC + " = 1";

data.add(new Pair<String, Integer>("Game Meat", getCount(sql)));
data.add(new Pair<String, Integer>("Bush Meat", getCount(sql)));

sql = "SELECT count(*) FROM " +
Schemas.CHARCOAL_BAGS_TABLE + " WHERE " + Schemas.LAST_SYNC_DATE + " IS NULL OR " + Schemas.REQUIRES_SYNC + " = 1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.ihub.rangerapp.RangerApp;
import com.ihub.rangerapp.data.sqlite.Schemas;
import com.ihub.rangerapp.util.DateUtil;
import com.ihub.rangerapp.util.UrlUtils;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand Down
6 changes: 3 additions & 3 deletions src/com/ihub/rangerapp/data/sqlite/Schemas.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Schemas {

public static String USERS_TABLE = "tbl_users";
public static String SHIFTS_TABLE = "tbl_shifts";
public static String GAME_MEAT_TABLE = "tbl_game_meat";
public static String BUSH_MEAT_TABLE = "tbl_game_meat";
public static String CHARCOAL_KILN_TABLE = "tbl_charcoal_kilns";
public static String CHARCOAL_LOGS_TABLE = "tbl_charcoal_logs";
public static String CHARCOAL_BAGS_TABLE = "tbl_charcoal_bags";
Expand Down Expand Up @@ -247,7 +247,7 @@ private static void createCharcoalBagsTable(SQLiteDatabase db) {
}

private static void createGameMeatTable(SQLiteDatabase db) {
String sql = "create table " + GAME_MEAT_TABLE + "(" +
String sql = "create table " + BUSH_MEAT_TABLE + "(" +
BaseColumns._ID + " integer primary key autoincrement," +
GameMeat.ANIMAL + " text," +
GameMeat.NO_OF_ANIMALS + " INTEGER, " +
Expand Down Expand Up @@ -461,7 +461,7 @@ public static void onUpgrage(SQLiteDatabase db, int oldVersion, int newVersion)

private static void deleteSchemas(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + SHIFTS_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + GAME_MEAT_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + BUSH_MEAT_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + CHARCOAL_KILN_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + CHARCOAL_LOGS_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + CHARCOAL_BAGS_TABLE);
Expand Down
7 changes: 7 additions & 0 deletions src/com/ihub/rangerapp/list/RefreshListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public abstract class RefreshListView extends BaseView implements OnRefreshListener {
Expand All @@ -47,6 +48,8 @@ public abstract class RefreshListView extends BaseView implements OnRefreshListe

Boolean isRefresh = false;

TextView noRecordsLabel;

int selectedPosition = -1;

public RefreshListView() {}
Expand All @@ -73,6 +76,8 @@ public void onActivityCreated(Bundle savedInstanceState) {
R.color.color4
);

noRecordsLabel = (TextView) this.getView().findViewById(R.id.noRecordsLabel);

listView = (ListView) this.getView().findViewById(android.R.id.list);

listView.setOnItemClickListener(new OnItemClickListener() {
Expand Down Expand Up @@ -115,6 +120,8 @@ public void onLoad(List<Model> data, Map<String, Object> params) {
hideSwipeProgress();

isRefresh = false;

noRecordsLabel.setVisibility((data == null || data.size() == 0) ? View.VISIBLE : View.GONE);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/com/ihub/rangerapp/loader/ElephantPoachingLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public String tableName() {

public List<Model> loadFromLocalDb(PagingLoadConfig config) {


List<Model> data = new ArrayList<Model>();

RangerApp application = RangerApp.get();
Expand Down
2 changes: 1 addition & 1 deletion src/com/ihub/rangerapp/loader/GameMeatLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GameMeatLoader extends DataLoader {

@Override
public String tableName() {
return Schemas.GAME_MEAT_TABLE;
return Schemas.BUSH_MEAT_TABLE;
}

public List<Model> loadFromLocalDb(PagingLoadConfig config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ihub.rangerapp.data.service;
package com.ihub.rangerapp.util;

public class UrlUtils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void addReviewItems(Model m, Date date){
activity.addReviewItem(new SummaryItem("Extra Notes", model.getExtraNotes(), "", 11));
activity.addReviewItem(new SummaryItem("Ranch", model.getRanch(), "", 12));

if("Yes".equals(model.getIvoryPresence())) {
if("yes".equals(model.getIvoryPresence().toLowerCase())) {
activity.addReviewItem(new SummaryItem("Left Tusk Weight", model.getLeftTuskWeight() + "", "", 13));
activity.addReviewItem(new SummaryItem("Right Tusk Weight", model.getRightTuskWeight() + "", "", 14));
}
Expand Down

0 comments on commit ac639cb

Please sign in to comment.