Skip to content

Commit

Permalink
Improve UX
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
itchix committed May 12, 2015
1 parent c8dcb4c commit daac4a3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 37 deletions.
2 changes: 0 additions & 2 deletions app/app.iml
Expand Up @@ -78,7 +78,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.dm7.barcodescanner/core/1.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.dm7.barcodescanner/zxing/1.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.steamcrafted/load-toast/1.0.6/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/uk.co.chrisjenx/calligraphy/2.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Expand Down Expand Up @@ -115,6 +114,5 @@
<orderEntry type="library" exported="" name="jsoup-1.8.2" level="project" />
<orderEntry type="library" exported="" name="jackson-databind-2.5.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
<orderEntry type="library" exported="" name="calligraphy-2.1.0" level="project" />
</component>
</module>
6 changes: 2 additions & 4 deletions app/build.gradle
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "openfoodfacts.github.scrachx.openfood"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "0.1"
versionCode 2
versionName "0.1.1"
}
buildTypes {
release {
Expand Down Expand Up @@ -55,8 +55,6 @@ dependencies {

compile 'net.steamcrafted:load-toast:1.0.6'

compile 'uk.co.chrisjenx:calligraphy:2.1.0'

compile 'me.dm7.barcodescanner:zxing:1.7'

compile 'com.koushikdutta.ion:ion:2.+'
Expand Down
Expand Up @@ -155,10 +155,7 @@ public void onPositive(MaterialDialog dialog) {
e.printStackTrace();
}

user.post(getActivity(), params, sp.getImgupload_front().replace(".png", "_small.png"), sp.getBarcode());
SaveListAdapter sl = (SaveListAdapter) listView.getAdapter();
saveItems.remove(i);
sl.notifyDataSetChanged();
user.post(getActivity(), params, sp.getImgupload_front().replace(".png", "_small.png"), sp.getBarcode(), listView, i, saveItems);

}
}
Expand Down Expand Up @@ -188,6 +185,12 @@ public class FillAdapter extends AsyncTask<Context, Void, Context> {

@Override
protected void onPreExecute() {
List<SendProduct> listSaveProduct = SendProduct.listAll(SendProduct.class);
if(listSaveProduct.size() == 0){
Toast.makeText(getActivity(), R.string.txtNoData, Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getActivity(), R.string.txtLoading, Toast.LENGTH_LONG).show();
}
}

@Override
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.widget.ListView;
import android.widget.Toast;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
Expand All @@ -12,16 +13,19 @@
import org.json.JSONObject;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;

import openfoodfacts.github.scrachx.openfood.R;
import openfoodfacts.github.scrachx.openfood.fragments.OfflineEditFragment;
import openfoodfacts.github.scrachx.openfood.network.FoodUserClient;
import openfoodfacts.github.scrachx.openfood.views.adapters.SaveListAdapter;

/**
* Created by scotscriven on 10/05/15.
*/
public class FoodUserClientUsage {

public void post(final Activity activity, RequestParams params, final String img, final String barcode){
public void post(final Activity activity, RequestParams params, final String img, final String barcode, final ListView lv, final int pos, final ArrayList<SaveItem> saveItems){
FoodUserClient.post("/cgi/product_jqm2.pl", params, new JsonHttpResponseHandler() {

LoadToast lt = new LoadToast(activity);
Expand Down Expand Up @@ -51,7 +55,7 @@ public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
try {
paramsImg.put("imgupload_front", myFile);
} catch(FileNotFoundException e) {e.getMessage();}
postImg(activity, paramsImg, barcode, length);
postImg(activity, paramsImg, barcode, length, lv, pos, saveItems);
}
} catch (JSONException e) {
e.printStackTrace();
Expand All @@ -71,7 +75,7 @@ public void onRetry ( int retryNo){
});
}

public void postImg(final Activity activity, final RequestParams params, final String barcode, final long length){
public void postImg(final Activity activity, final RequestParams params, final String barcode, final long length, final ListView lv, final int pos, final ArrayList<SaveItem> saveItems){
FoodUserClient.post("/cgi/product_image_upload.pl", params, new JsonHttpResponseHandler() {

LoadToast lt = new LoadToast(activity);
Expand All @@ -94,6 +98,9 @@ public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
} else {
lt.success();
SendProduct.deleteAll(SendProduct.class, "barcode = ?", barcode);
SaveListAdapter sl = (SaveListAdapter) lv.getAdapter();
saveItems.remove(pos);
sl.notifyDataSetChanged();
}
} catch (JSONException e) {
e.printStackTrace();
Expand Down
Expand Up @@ -127,36 +127,14 @@ public void onItemClick(AdapterView<?> parent, View view, int position,
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// toggle nav drawer on selecting action bar app icon/title
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle action bar actions click
switch (item.getItemId()) {
case R.id.action_settings:
return true;
default:
return super.onOptionsItemSelected(item);
}
}

/***
* Called when invalidateOptionsMenu() is triggered
*/
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// if nav drawer is opened, hide the action items
boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
return super.onPrepareOptionsMenu(menu);
return super.onOptionsItemSelected(item);
}

/**
Expand Down
Expand Up @@ -98,7 +98,6 @@ public void onClick(View v) {
SendProduct product = new SendProduct(barcode, name.getText().toString(), energy.getText().toString(),
"kJ", weight.getText().toString(), settings.getString("imgUrl", ""), store.getText().toString());
product.save();
Toast.makeText(getApplicationContext(), R.string.dataSaved, Toast.LENGTH_LONG).show();
}
Toast.makeText(getApplicationContext(), R.string.txtDialogsContentInfoSave, Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
Expand Down

0 comments on commit daac4a3

Please sign in to comment.