Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add price to Scanner View #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.drobisch.partkeeprscannrapp"
Expand All @@ -20,13 +20,13 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.4.0'
implementation 'com.android.support:design:23.4.0'

compile 'com.journeyapps:zxing-android-embedded:3.4.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ContinuousCaptureActivity extends Activity {
private TextView mPartNameView;
private TextView mPartStockView;
private TextView mPartLocationView;
private EditText mAVGPriceField;



Expand Down Expand Up @@ -95,6 +96,7 @@ protected void onCreate(Bundle savedInstanceState) {
mPartNameView = (TextView) findViewById(R.id.partName);
mPartLocationView = (TextView) findViewById(R.id.partLocation);
mPartStockView = (TextView) findViewById(R.id.partStock);
mAVGPriceField = (EditText) findViewById(R.id.avgPrice) ;

mPartNameView.setText("");
mPartLocationView.setText("");
Expand All @@ -120,6 +122,7 @@ public void onClick(View view) {
barcodeView = (DecoratedBarcodeView) findViewById(R.id.barcode_scanner);
barcodeView.setStatusText("");
barcodeView.decodeContinuous(callback);

}

private void updatePartInfo(int partID) {
Expand All @@ -130,7 +133,7 @@ private void updatePartInfo(int partID) {
private void addStock() {
Log.d("CaptureActivity", "addStock");
if(mPartPartID != -1) {
ApiPartTask task = new ApiPartTask(mUser, mPassword, mServer, mPartPartID,"addStock", "quantity=1&price=0&comment=");
ApiPartTask task = new ApiPartTask(mUser, mPassword, mServer, mPartPartID,"addStock", "quantity=1&price=" + mAVGPriceField.getText().toString() + "&comment=");
task.execute((Void) null);
}
}
Expand Down Expand Up @@ -270,6 +273,7 @@ public class ApiPartTask extends AsyncTask<Void, Void, Boolean> {
private Integer mPartStock = 0;
private String mPartLocation = "";
private Integer mPartID;
private double mPartAvgPrice = 0;
private Boolean error = false;
private String errorString;

Expand Down Expand Up @@ -337,6 +341,7 @@ protected Boolean doInBackground(Void... params) {
JSONObject jsonStorage = json.getJSONObject("storageLocation");
mPartLocation = (String) jsonStorage.get("name");
mPartStock = json.getInt("stockLevel");
mPartAvgPrice = json.getDouble("averagePrice");
} catch (JSONException e) {
e.printStackTrace();
error = true;
Expand All @@ -351,6 +356,7 @@ protected void onPostExecute(final Boolean success) {
mPartLocationView.setText(mPartLocation);
mPartStockView.setText(mPartStock.toString());
mPartPartID = mPartID;
mAVGPriceField.setText(String.valueOf(Math.round(mPartAvgPrice *100.0) /100.0));
if(error == true) {
mPartPartID = -1;
Toast infoToast = Toast.makeText(getApplicationContext(),errorString,Toast.LENGTH_SHORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
public class PartkeeprScannrApplication extends Application {
public void onCreate () {
super.onCreate();
// Setup handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.drobisch.partkeeprscannrapp;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import android.content.SharedPreferences;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;


import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.Button;

import static android.content.Context.MODE_PRIVATE;

public class SettingsActivity extends AppCompatActivity {

private AutoCompleteTextView mServerView;
Expand Down
Loading