Commit 79d8faed by User

Stock Audit changes noted version 1.1

parent d0891c19
...@@ -9,18 +9,18 @@ android { ...@@ -9,18 +9,18 @@ android {
applicationId "w.soulofpluto.posstock" applicationId "w.soulofpluto.posstock"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionCode 1 versionCode 2
versionName "1.0" versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
} }
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
shrinkResources false shrinkResources false
zipAlignEnabled false zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
...@@ -35,23 +35,15 @@ dependencies { ...@@ -35,23 +35,15 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'com.squareup.okhttp:okhttp:2.5.0' implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0' implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation platform('com.google.firebase:firebase-bom:28.4.0') implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics:18.2.1' implementation 'com.google.firebase:firebase-crashlytics:18.2.1'
implementation 'com.karumi:dexter:6.2.3' implementation 'com.karumi:dexter:6.2.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
...@@ -12,6 +12,7 @@ import static android.content.Context.ACTIVITY_SERVICE; ...@@ -12,6 +12,7 @@ import static android.content.Context.ACTIVITY_SERVICE;
*/ */
public class AppUtils { public class AppUtils {
public static void deleteCache(Context context) { public static void deleteCache(Context context) {
Log.e("AppUtils ====<","Calling deleteCache"); Log.e("AppUtils ====<","Calling deleteCache");
try { try {
......
...@@ -29,8 +29,8 @@ public class Constants{ ...@@ -29,8 +29,8 @@ public class Constants{
//public static String BASE_URL = "https://49588a.emporter.eu/"; //public static String BASE_URL = "https://49588a.emporter.eu/";
//public static String BASE_URL = "https://30ad04.emporter.eu/"; //public static String BASE_URL = "https://30ad04.emporter.eu/";
//public static String BASE_URL = "http://182.18.167.139/"; //public static String BASE_URL = "http://182.18.167.139/";
public static String BASE_URL = "http://192.168.34.16/"; //public static String BASE_URL = "http://192.168.34.16/";
//public static String BASE_URL = "http://posapi.plutokm.com/"; public static String BASE_URL = "http://posapi.plutokm.com/";
public static String MenuBar = Constants.BASE_URL + "/Users/generateUserMenuBarLinksForAndroidApp"; public static String MenuBar = Constants.BASE_URL + "/Users/generateUserMenuBarLinksForAndroidApp";
public static String Logout = Constants.BASE_URL + "/login/doLogout/"; public static String Logout = Constants.BASE_URL + "/login/doLogout/";
public static String Login = Constants.BASE_URL + "/login/doLogin"; public static String Login = Constants.BASE_URL + "/login/doLogin";
...@@ -65,6 +65,8 @@ public class Constants{ ...@@ -65,6 +65,8 @@ public class Constants{
public static StringBuilder stringBuilder; public static StringBuilder stringBuilder;
public static void getToast(Context context, String data){ public static void getToast(Context context, String data){
/* ((Activity)context).runOnUiThread(() -> {
});*/
Toast toast = Toast.makeText(context, data, Toast.LENGTH_SHORT); Toast toast = Toast.makeText(context, data, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0); toast.setGravity(Gravity.CENTER, 0, 0);
toast.show(); toast.show();
...@@ -215,29 +217,29 @@ public class Constants{ ...@@ -215,29 +217,29 @@ public class Constants{
return null; return null;
} }
public static String Barcode(String mrp){ public static String Barcode(String bar){
if(mrp.length() == 11){ if(bar.length() == 11){
return mrp; return bar;
}else if(mrp.length() == 10){ }else if(bar.length() == 10){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 9){ }else if(bar.length() == 9){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 8){ }else if(bar.length() == 8){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 7){ }else if(bar.length() == 7){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 6){ }else if(bar.length() == 6){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 5){ }else if(bar.length() == 5){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 4){ }else if(bar.length() == 4){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 3){ }else if(bar.length() == 3){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 2){ }else if(bar.length() == 2){
return mrp+" "; return bar+" ";
}else if(mrp.length() == 1){ }else if(bar.length() == 1){
return mrp+" "; return bar+" ";
} }
return null; return null;
} }
...@@ -585,7 +587,7 @@ public class Constants{ ...@@ -585,7 +587,7 @@ public class Constants{
return null; return null;
} }
public static String IndianRupeesformat(String amount){ public static String IndianRupeeFormat(String amount){
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in")); NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
String moneyString = formatter.format(Double.valueOf(amount)); String moneyString = formatter.format(Double.valueOf(amount));
return moneyString; return moneyString;
......
...@@ -26,10 +26,11 @@ import java.util.concurrent.TimeUnit; ...@@ -26,10 +26,11 @@ import java.util.concurrent.TimeUnit;
*/ */
public class DashBoardActivity extends AppCompatActivity implements View.OnClickListener { public class DashBoardActivity extends AppCompatActivity implements View.OnClickListener {
Toolbar dashboard_toolbar; Toolbar dashboard_toolbar;
Button stock_audit,rack_qty,searchBy_Barcode, transfer; Button stock_audit, rack_qty, searchBy_Barcode, transfer;
TextView version; TextView version;
PreferenceManager preferenceManager; PreferenceManager preferenceManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState){ protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -91,6 +92,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick ...@@ -91,6 +92,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
Constants.ProgressDialogDismiss(); Constants.ProgressDialogDismiss();
} }
@Override @Override
public void onResponse(Response response) throws IOException{ public void onResponse(Response response) throws IOException{
Constants.ProgressDialogDismiss(); Constants.ProgressDialogDismiss();
if(response.isSuccessful()){ if(response.isSuccessful()){
...@@ -104,7 +106,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick ...@@ -104,7 +106,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
preferenceManager.setLogged(false); preferenceManager.setLogged(false);
preferenceManager.setCustToken(""); preferenceManager.setCustToken("");
preferenceManager.setStoreId(""); preferenceManager.setStoreId("");
Login.logout(DashBoardActivity.this); Login.Logout(DashBoardActivity.this);
}else{ }else{
Constants.getToast(DashBoardActivity.this,jsonObject.getString("msg")); Constants.getToast(DashBoardActivity.this,jsonObject.getString("msg"));
} }
......
...@@ -44,10 +44,10 @@ import static w.soulofpluto.posstockaudit.Constants.Logout; ...@@ -44,10 +44,10 @@ import static w.soulofpluto.posstockaudit.Constants.Logout;
ArrayList<String> arrayList; ArrayList<String> arrayList;
RecyclerView recyclerView; RecyclerView recyclerView;
private static final int REQUEST_PERMISSION = 100; private static final int REQUEST_PERMISSION = 100;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState){ protected void onCreate(@Nullable Bundle savedInstanceState){
setContentView(R.layout.activity_home); setContentView(R.layout.activity_home);
//requestRuntimePermission();
home_toolbar = findViewById(R.id.home_toolbar); home_toolbar = findViewById(R.id.home_toolbar);
version = findViewById(R.id.version); version = findViewById(R.id.version);
recyclerView = findViewById(R.id.menu_list); recyclerView = findViewById(R.id.menu_list);
...@@ -87,8 +87,8 @@ import static w.soulofpluto.posstockaudit.Constants.Logout; ...@@ -87,8 +87,8 @@ import static w.soulofpluto.posstockaudit.Constants.Logout;
if (requestCode != REQUEST_PERMISSION || grantResults.length == 0) { if (requestCode != REQUEST_PERMISSION || grantResults.length == 0) {
return; return;
} }
} }
private void setUI(){ private void setUI(){
final OkHttpClient client = new OkHttpClient(); final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS); client.setConnectTimeout(250, TimeUnit.SECONDS);
...@@ -137,7 +137,7 @@ import static w.soulofpluto.posstockaudit.Constants.Logout; ...@@ -137,7 +137,7 @@ import static w.soulofpluto.posstockaudit.Constants.Logout;
try{ try{
Log.e("session", object.getString("msg")); Log.e("session", object.getString("msg"));
Constants.getToast(HomeActivity.this, object.getString("msg")); Constants.getToast(HomeActivity.this, object.getString("msg"));
Login.logout(HomeActivity.this); Login.Logout(HomeActivity.this);
}catch(JSONException e) { }catch(JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -154,11 +154,13 @@ import static w.soulofpluto.posstockaudit.Constants.Logout; ...@@ -154,11 +154,13 @@ import static w.soulofpluto.posstockaudit.Constants.Logout;
} }
}); });
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu){ public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu, menu); getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
@Override @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item){ public boolean onOptionsItemSelected(@NonNull MenuItem item){
switch(item.getItemId()){ switch(item.getItemId()){
...@@ -206,7 +208,7 @@ import static w.soulofpluto.posstockaudit.Constants.Logout; ...@@ -206,7 +208,7 @@ import static w.soulofpluto.posstockaudit.Constants.Logout;
preferenceManager.setCustToken(""); preferenceManager.setCustToken("");
preferenceManager.setStoreId(""); preferenceManager.setStoreId("");
preferenceManager.setBLUETOOTH(""); preferenceManager.setBLUETOOTH("");
Login.logout(HomeActivity.this); Login.Logout(HomeActivity.this);
} else { } else {
Constants.getToast(HomeActivity.this, jsonObject.getString("msg")); Constants.getToast(HomeActivity.this, jsonObject.getString("msg"));
} }
...@@ -222,6 +224,7 @@ import static w.soulofpluto.posstockaudit.Constants.Logout; ...@@ -222,6 +224,7 @@ import static w.soulofpluto.posstockaudit.Constants.Logout;
} }
}); });
} }
@Override @Override
public void onBackPressed(){ public void onBackPressed(){
int count = 0; int count = 0;
......
...@@ -48,8 +48,8 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad ...@@ -48,8 +48,8 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
private PreferenceManager preferenceManager; private PreferenceManager preferenceManager;
private String Store_Name; private String Store_Name;
public static void logout(Context context){ public static void Logout(Context context){
AppUtils.clearAppData(context); //AppUtils.clearAppData(context);
Activity activity = (Activity) context; Activity activity = (Activity) context;
Intent in_logout = new Intent(context, Login.class); Intent in_logout = new Intent(context, Login.class);
in_logout.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); in_logout.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
...@@ -122,17 +122,17 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad ...@@ -122,17 +122,17 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
store.setStoreName(jsonObject.getString(getResources().getString(R.string.store_name))); store.setStoreName(jsonObject.getString(getResources().getString(R.string.store_name)));
stores.add(store); stores.add(store);
} }
ArrayAdapter<Store> adapter = new ArrayAdapter<Store>(Login.this, R.layout.spinner_item, stores); ArrayAdapter<Store> adapter = new ArrayAdapter<>(Login.this, R.layout.spinner_item, stores);
storeId.setAdapter(adapter); storeId.setAdapter(adapter);
} }
} }
}else{ }else{
Constants.getToast(Login.this,getResources().getString(R.string.no_stores)); Constants.getToast(Login.this,getResources().getString(R.string.no_stores));
storeId.setAdapter(null); storeId.setAdapter(null);
} }
} }
}else{ }else{
runOnUiThread(() -> Constants.getToast(Login.this,Response)); runOnUiThread(() -> Constants.getToast(Login.this,Response));
} }
}catch(JSONException e){ }catch(JSONException e){
e.printStackTrace(); e.printStackTrace();
......
...@@ -92,9 +92,16 @@ public class MainActivity extends AppCompatActivity { ...@@ -92,9 +92,16 @@ public class MainActivity extends AppCompatActivity {
preferenceManager.setLogged(false); preferenceManager.setLogged(false);
preferenceManager.setCustToken(""); preferenceManager.setCustToken("");
preferenceManager.setStoreId(""); preferenceManager.setStoreId("");
Login.logout(MainActivity.this); Login.Logout(MainActivity.this);
} else { } else {
Constants.getToast(MainActivity.this, jsonObject.getString(getResources().getString(R.string.msg))); runOnUiThread(() -> {
try {
Constants.getToast(MainActivity.this, jsonObject.getString(getResources().getString(R.string.msg)));
} catch (JSONException e) {
e.printStackTrace();
}
});
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
...@@ -185,18 +192,29 @@ public class MainActivity extends AppCompatActivity { ...@@ -185,18 +192,29 @@ public class MainActivity extends AppCompatActivity {
if (object1.has(getResources().getString(R.string.data))) { if (object1.has(getResources().getString(R.string.data))) {
plansArrayList.clear(); plansArrayList.clear();
JSONArray jsonArray = object1.getJSONArray(getResources().getString(R.string.data)); JSONArray jsonArray = object1.getJSONArray(getResources().getString(R.string.data));
for (int i = 0; i < jsonArray.length(); i++) { if(jsonArray.length()>0){
JSONObject jsonObject = jsonArray.getJSONObject(i); for (int i = 0; i < jsonArray.length(); i++) {
Plans plans = new Plans(); JSONObject jsonObject = jsonArray.getJSONObject(i);
plans.setPlanId(String.valueOf(jsonObject.getInt("id"))); Plans plans = new Plans();
plans.setName(jsonObject.getString("stock_audit_name")); plans.setPlanId(String.valueOf(jsonObject.getInt("id")));
plans.setDivision(Constants.convertString(jsonObject.getString("item_divisions"))); plans.setName(jsonObject.getString("stock_audit_name"));
plans.setSection(Constants.convertString(jsonObject.getString("item_sections"))); plans.setDivision(Constants.convertString(jsonObject.getString("item_divisions")));
plansArrayList.add(plans); plans.setSection(Constants.convertString(jsonObject.getString("item_sections")));
plansArrayList.add(plans);
}
CustomAdapter customAdapter = new CustomAdapter(MainActivity.this, plansArrayList);
plans_list.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false));
plans_list.setAdapter(customAdapter);
}else if (object1.has(getResources().getString(R.string.msg))) {
runOnUiThread(() -> {
try {
Constants.getToast(MainActivity.this, object1.getString(getResources().getString(R.string.msg)));
} catch (JSONException e) {
e.printStackTrace();
}
});
} }
CustomAdapter customAdapter = new CustomAdapter(MainActivity.this, plansArrayList);
plans_list.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false));
plans_list.setAdapter(customAdapter);
} else if (object1.has(getResources().getString(R.string.msg))) { } else if (object1.has(getResources().getString(R.string.msg))) {
runOnUiThread(() -> { runOnUiThread(() -> {
try { try {
...@@ -218,7 +236,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -218,7 +236,7 @@ public class MainActivity extends AppCompatActivity {
preferenceManager.setLogged(false); preferenceManager.setLogged(false);
preferenceManager.setCustToken(""); preferenceManager.setCustToken("");
preferenceManager.setStoreId(""); preferenceManager.setStoreId("");
Login.logout(MainActivity.this); Login.Logout(MainActivity.this);
} }
} }
} }
......
...@@ -38,6 +38,7 @@ import com.squareup.okhttp.Response; ...@@ -38,6 +38,7 @@ import com.squareup.okhttp.Response;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -67,10 +68,10 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -67,10 +68,10 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
MediaPlayer mp; MediaPlayer mp;
String Rack_No; String Rack_No;
public static void start(Context context, Plans plans, String rackno){ public static void start(Context context, Plans plans, String rackNo){
Intent in = new Intent(context, PlanDetails.class); Intent in = new Intent(context, PlanDetails.class);
in.putExtra("key", plans); in.putExtra("key", plans);
in.putExtra("rack",rackno); in.putExtra("rack",rackNo);
context.startActivity(in); context.startActivity(in);
} }
...@@ -196,44 +197,45 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -196,44 +197,45 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
np.printStackTrace(); np.printStackTrace();
} }
}else{ }else{
Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)); runOnUiThread(() -> Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)));
} }
}else{ }else{
if(TextUtils.isEmpty(qty.getText().toString())){ if(TextUtils.isEmpty(qty.getText().toString())){
runOnUiThread(() -> { runOnUiThread(() -> {
barcode.setText(""); barcode.setText("");
Constants.getToast(PlanDetails.this, "Enter Qty"); runOnUiThread(() -> Constants.getToast(PlanDetails.this, "Enter Qty"));
}); });
}else{ }else{
float value = Float.parseFloat(qty.getText().toString()); float value = Float.parseFloat(qty.getText().toString());
if(value > 0){ if(value > 0){
if(Constants.isNetworkAvailable(PlanDetails.this)){ if(Constants.isNetworkAvailable(PlanDetails.this)){
//barcode.setFocusable(false);
if(arrayList.size() > 0) { if(arrayList.size() > 0) {
if (Constants.Existing(arrayList, barcode.getText().toString().replace("\n", ""))) { if (Constants.Existing(arrayList, barcode.getText().toString().replace("\n", ""))) {
getNotification("Already scanned this item"); getNotification("Already scanned this item");
return; return;
} }
} }
try { try{
UploadBarcode(barcode.getText().toString().replace("\n", ""), qty.getText().toString(), plans.getPlanId()); UploadBarcode(barcode.getText().toString().replace("\n", ""), qty.getText().toString(), plans.getPlanId());
Constants.ProgressDialogShow(PlanDetails.this); Constants.ProgressDialogShow(PlanDetails.this);
barcode.setText(""); }catch(NullPointerException np){
}catch (NullPointerException np){
np.printStackTrace(); np.printStackTrace();
} }
}else{ }else{
Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)); runOnUiThread(() -> Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)));
} }
} }
} }
} }
} }
}else{ }else{
getNotification(getResources().getString(R.string.connection)); //getNotification(getResources().getString(R.string.connection));
runOnUiThread(() -> Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)));
} }
}catch(NullPointerException np){ }catch(NullPointerException np){
np.printStackTrace(); np.printStackTrace();
} }
} }
@Override @Override
...@@ -251,16 +253,16 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -251,16 +253,16 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
Constants.ProgressDialogShow(PlanDetails.this); Constants.ProgressDialogShow(PlanDetails.this);
UploadAllBarCodes(Constants.BarcodeComplete,rack_number.getText().toString()); UploadAllBarCodes(Constants.BarcodeComplete,rack_number.getText().toString());
}else{ }else{
Constants.getToast(PlanDetails.this,"Enter Rack Id"); runOnUiThread(() -> Constants.getToast(PlanDetails.this,"Enter Rack Id"));
} }
}else{ }else{
Constants.getToast(PlanDetails.this,getResources().getString(R.string.connection)); runOnUiThread(() -> Constants.getToast(PlanDetails.this,getResources().getString(R.string.connection)));
} }
}else{ }else{
Constants.getToast(PlanDetails.this, "No Scan items "); runOnUiThread(() -> Constants.getToast(PlanDetails.this, "No Scan items "));
} }
}else{ }else{
Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)); runOnUiThread(() -> Constants.getToast(PlanDetails.this, getResources().getString(R.string.connection)));
} }
break; break;
} }
...@@ -269,15 +271,30 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -269,15 +271,30 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
public void getNotification(String text){ public void getNotification(String text){
runOnUiThread(() -> { runOnUiThread(() -> {
mp = MediaPlayer.create(PlanDetails.this, R.raw.beep); mp = MediaPlayer.create(PlanDetails.this, R.raw.beep);
if(mp.isPlaying()) { if (mp != null && mp.isPlaying()) {
Log.e("Media Player start"," ====>1");
mp.stop(); mp.stop();
try { try {
mp.prepare(); mp.prepare();
mp.start();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}catch (IllegalStateException e1){
e1.printStackTrace();
}catch (NullPointerException np){
np.printStackTrace();
}
} else {
try {
Log.e("Media Player start"," ====>2");
mp.start();
mp.setLooping(true);
}catch (IllegalStateException i){
i.printStackTrace();
}catch (NullPointerException n){
n.printStackTrace();
} }
} }
mp.start();
final Dialog dialog1 = new Dialog(PlanDetails.this); final Dialog dialog1 = new Dialog(PlanDetails.this);
dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog1.setContentView(R.layout.activity_dialog); dialog1.setContentView(R.layout.activity_dialog);
...@@ -293,8 +310,16 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -293,8 +310,16 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
barcode.setFocusable(true); barcode.setFocusable(true);
barcode.requestFocus(); barcode.requestFocus();
barcode.setText(""); barcode.setText("");
mp.stop(); try {
mp.release(); if (mp !=null && mp.isPlaying()) {
mp.stop();
mp.release();
}
}catch (IllegalStateException ise){
ise.printStackTrace();
}catch (NullPointerException npe){
npe.printStackTrace();
}
}); });
}); });
} }
...@@ -432,7 +457,7 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -432,7 +457,7 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
plans.setColumnId(1); plans.setColumnId(1);
} }
arrayList.add(plans); arrayList.add(plans);
Collections.sort(arrayList,Plans.sortByName); Collections.sort(arrayList,Plans.sortById);
setUI(arrayList); setUI(arrayList);
if(arrayList.size() > 0){ if(arrayList.size() > 0){
runOnUiThread(() -> { runOnUiThread(() -> {
...@@ -640,7 +665,8 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen ...@@ -640,7 +665,8 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
preferenceManager.setLogged(true); preferenceManager.setLogged(true);
dialog.dismiss(); dialog.dismiss();
}else{ }else{
Toast.makeText(PlanDetails.this,obj.getString(getResources().getString(R.string.msg)), Toast.LENGTH_SHORT).show(); Constants.getToast(PlanDetails.this,obj.getString(getResources().getString(R.string.msg)));
//Toast.makeText(PlanDetails.this,obj.getString(getResources().getString(R.string.msg)), Toast.LENGTH_SHORT).show();
} }
} }
}catch(JSONException e){ }catch(JSONException e){
......
...@@ -27,8 +27,6 @@ public class Plans implements Parcelable { ...@@ -27,8 +27,6 @@ public class Plans implements Parcelable {
ColumnId = columnId; ColumnId = columnId;
} }
protected Plans(Parcel in) { protected Plans(Parcel in) {
PlanId = in.readString(); PlanId = in.readString();
Name = in.readString(); Name = in.readString();
...@@ -44,7 +42,6 @@ public class Plans implements Parcelable { ...@@ -44,7 +42,6 @@ public class Plans implements Parcelable {
public Plans createFromParcel(Parcel in) { public Plans createFromParcel(Parcel in) {
return new Plans(in); return new Plans(in);
} }
@Override @Override
public Plans[] newArray(int size) { public Plans[] newArray(int size) {
return new Plans[size]; return new Plans[size];
...@@ -52,7 +49,6 @@ public class Plans implements Parcelable { ...@@ -52,7 +49,6 @@ public class Plans implements Parcelable {
}; };
public Plans() { public Plans() {
} }
public String getPlanId() { public String getPlanId() {
...@@ -122,5 +118,5 @@ public class Plans implements Parcelable { ...@@ -122,5 +118,5 @@ public class Plans implements Parcelable {
return Name; return Name;
} }
public static Comparator<Plans> sortByName = (t1, t2) -> t2.getColumnId()- t1.getColumnId(); public static Comparator<Plans> sortById = (t1, t2) -> t2.getColumnId() - t1.getColumnId();
} }
...@@ -25,39 +25,39 @@ public class RackWiseAdapter extends RecyclerView.Adapter<RackWiseAdapter.ViewHo ...@@ -25,39 +25,39 @@ public class RackWiseAdapter extends RecyclerView.Adapter<RackWiseAdapter.ViewHo
@NonNull @NonNull
@Override @Override
public RackWiseAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ public RackWiseAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem = layoutInflater.inflate(R.layout.rackwise_item, parent, false); View listItem = layoutInflater.inflate(R.layout.rackwise_item, parent, false);
RackWiseAdapter.ViewHolder viewHolder = new RackWiseAdapter.ViewHolder(listItem); RackWiseAdapter.ViewHolder viewHolder = new RackWiseAdapter.ViewHolder(listItem);
return viewHolder; return viewHolder;
} }
@Override @Override
public void onBindViewHolder(@NonNull RackWiseAdapter.ViewHolder holder, final int position){ public void onBindViewHolder(@NonNull RackWiseAdapter.ViewHolder holder, final int position) {
final RackWise items = arrayList.get(position); final RackWise items = arrayList.get(position);
if(items.getId() == 0){ if( items.getId() == 0 ){
// holder.rack_id.setText(Html.fromHtml(Constants.Id + "0")); holder.rack_id.setText("");
}else{ }else{
holder.rack_id.setText(Html.fromHtml(Constants.Id + items.getId())); holder.rack_id.setText(Html.fromHtml(Constants.Id + items.getId()));
} }
holder.rack_userid.setText(Html.fromHtml(Constants.User+items.getScanned_by())); holder.rack_UserId.setText(Html.fromHtml(Constants.User + items.getScanned_by()));
holder.rack_from.setText(Html.fromHtml(Constants.From+items.getScanning_start_at())); holder.rack_from.setText(Html.fromHtml(Constants.From + items.getScanning_start_at()));
holder.rack_to.setText(Html.fromHtml(Constants.To+items.getScanning_end_at())); holder.rack_to.setText(Html.fromHtml(Constants.To + items.getScanning_end_at()));
holder.rack_qty.setText(String.valueOf(items.getQty())); holder.rack_qty.setText(String.valueOf(items.getQty()));
} }
@Override @Override
public int getItemCount(){ public int getItemCount() {
return arrayList.size(); return arrayList.size();
} }
public class ViewHolder extends RecyclerView.ViewHolder{ public class ViewHolder extends RecyclerView.ViewHolder {
public TextView rack_id,rack_qty,rack_userid,rack_from,rack_to; public TextView rack_id,rack_qty,rack_UserId,rack_from,rack_to;
public ViewHolder(View itemView){ public ViewHolder(View itemView) {
super(itemView); super(itemView);
rack_id = itemView.findViewById(R.id.rack_id); rack_id = itemView.findViewById(R.id.rack_id);
rack_qty = itemView.findViewById(R.id.rack_qty); rack_qty = itemView.findViewById(R.id.rack_qty);
rack_userid = itemView.findViewById(R.id.rack_userid); rack_UserId = itemView.findViewById(R.id.rack_userid);
rack_from = itemView.findViewById(R.id.rack_from); rack_from = itemView.findViewById(R.id.rack_from);
rack_to = itemView.findViewById(R.id.rack_to); rack_to = itemView.findViewById(R.id.rack_to);
} }
......
...@@ -86,28 +86,28 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -86,28 +86,28 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
try{ try{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = new Date(); Date todayDate = new Date();
Date from = getDateWithOffset(-Constants.Value, new Date()); Date from = getDateWithOffset(-Constants.Value, new Date());
String fromDate = currentDate.format(from); String fromDate = currentDate.format(from);
String thisDate = currentDate.format(todayDate); String thisDate = currentDate.format(todayDate);
Log.e("Last date",fromDate); //Log.e("Last date" ,fromDate);
Log.e("Today date",thisDate); //Log.e("Today date",thisDate);
object.put(getResources().getString(R.string.auditstatus),"In Progress"); object.put(getResources().getString(R.string.auditstatus),"In Progress");
object.put(getResources().getString(R.string.fromdate),fromDate); object.put(getResources().getString(R.string.fromdate), fromDate);
object.put(getResources().getString(R.string.todate),thisDate); object.put(getResources().getString(R.string.todate), thisDate);
} }
}catch(JSONException e){ }catch(JSONException e){
e.printStackTrace(); e.printStackTrace();
} }
Log.e("Rackwise object ====>",object.toString()); Log.e("Rackwise object ====>",object.toString());
RequestBody body = RequestBody.create(JSON,object.toString()); RequestBody body = RequestBody.create(JSON,object.toString());
final OkHttpClient client = new OkHttpClient(); final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS); client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS); client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS); client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(Url) .url (Url)
.post(body) .post (body)
.addHeader(Constants.Type, Constants.App_json) .addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken()) .addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken),preferenceManager.getStoreId()) .addHeader(getResources().getString(R.string.storeidtoken),preferenceManager.getStoreId())
...@@ -125,8 +125,8 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -125,8 +125,8 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
try{ try{
Constants.ProgressDialogDismiss(); Constants.ProgressDialogDismiss();
final String Response = response.body().string(); final String Response = response.body().string();
Handler handler = new Handler(Looper.getMainLooper());
Log.e("Store Response " , Response); Log.e("Store Response " , Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> { handler.post(() -> {
try{ try{
if(response.code() == 200){ if(response.code() == 200){
...@@ -160,29 +160,29 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -160,29 +160,29 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
}); });
} }
}else if(object1.getInt(getResources().getString(R.string.success)) == 3){ }else if(object1.getInt(getResources().getString(R.string.success)) == 3){
runOnUiThread(() -> { runOnUiThread(() -> {
try{ try{
Constants.getToast(RackWiseQty.this, object1.getString(getResources().getString(R.string.msg))); Constants.getToast(RackWiseQty.this, object1.getString(getResources().getString(R.string.msg)));
}catch(JSONException e) { }catch(JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
preferenceManager.setUserId(""); preferenceManager.setUserId("");
preferenceManager.setLogged(false); preferenceManager.setLogged(false);
preferenceManager.setCustToken(""); preferenceManager.setCustToken("");
preferenceManager.setStoreId(""); preferenceManager.setStoreId("");
Login.logout(RackWiseQty.this); Login.Logout(RackWiseQty.this);
} }
} }
} }
}catch(JSONException e){ }catch(JSONException e){
e.printStackTrace(); e.printStackTrace();
} }
}); });
}catch(NullPointerException io){ }catch(NullPointerException io){
io.printStackTrace(); io.printStackTrace();
}finally{ }finally{
response.body().close(); response.body().close();
} }
} }
}); });
...@@ -195,8 +195,8 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -195,8 +195,8 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
rackid = plan.PlanId; rackid = plan.PlanId;
if(rackid.equalsIgnoreCase("0")){ if(rackid.equalsIgnoreCase("0")){
runOnUiThread(() -> { runOnUiThread(() -> {
total_scanned.setText(Html.fromHtml(Constants.getVal(0))); total_scanned.setText(Html.fromHtml(Constants.getVal(0)));
rack_recylerview.setAdapter(null); rack_recylerview.setAdapter(null);
}); });
}else{ }else{
if(Constants.isNetworkAvailable(this)){ if(Constants.isNetworkAvailable(this)){
...@@ -209,7 +209,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -209,7 +209,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
npe.printStackTrace(); npe.printStackTrace();
} }
}else{ }else{
Constants.getToast(RackWiseQty.this,getResources().getString(R.string.connection)); runOnUiThread(() -> Constants.getToast(RackWiseQty.this,getResources().getString(R.string.connection)));
} }
} }
break; break;
...@@ -218,11 +218,11 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -218,11 +218,11 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
@Override @Override
public void onNothingSelected(AdapterView<?> adapterView) { public void onNothingSelected(AdapterView<?> adapterView) {
} }
private void getRackWiseData(String planid){ private void getRackWiseData(String planId){
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
try{ try{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
object.put(getResources().getString(R.string.plan_id),planid); object.put(getResources().getString(R.string.plan_id),planId);
} }
}catch(JSONException e){ }catch(JSONException e){
e.printStackTrace(); e.printStackTrace();
...@@ -254,7 +254,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -254,7 +254,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
try{ try{
Constants.ProgressDialogDismiss(); Constants.ProgressDialogDismiss();
final String Response = response.body().string(); final String Response = response.body().string();
Log.e("Rackwise Response " , Response); Log.e("RackWise Response " , Response);
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> { handler.post(() -> {
try{ try{
...@@ -265,18 +265,17 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -265,18 +265,17 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
if(object1.has(getResources().getString(R.string.data))){ if(object1.has(getResources().getString(R.string.data))){
rackWiseArrayList.clear(); rackWiseArrayList.clear();
JSONObject headerObject = object1.getJSONObject(getResources().getString(R.string.data)); JSONObject headerObject = object1.getJSONObject(getResources().getString(R.string.data));
final int count = headerObject.getInt("total_scanned_items"); final int count = headerObject.getInt("total_scanned_items");
Log.e("TOTAL SCANNED ITEMS : ",String.valueOf(count)); //Log.e("TOTAL SCANNED ITEMS : ",String.valueOf(count));
runOnUiThread(() -> total_scanned.setText(Html.fromHtml(Constants.getVal(count)))); runOnUiThread(() -> total_scanned.setText(Html.fromHtml(Constants.getVal(count))));
JSONArray jsonArray = headerObject.getJSONArray("rack_info"); JSONArray jsonArray = headerObject.getJSONArray("rack_info");
//JSONArray jsonArray = object.getJSONArray(getResources().getString(R.string.data));
for(int i = 0; i < jsonArray.length(); i++){ for(int i = 0; i < jsonArray.length(); i++){
JSONObject jsonObject = jsonArray.getJSONObject(i); JSONObject jsonObject = jsonArray.getJSONObject(i);
RackWise rackWise = new RackWise(); RackWise rackWise = new RackWise();
if(jsonObject.getString("rack_id").equalsIgnoreCase("null")){ if(jsonObject.getString("rack_id").equalsIgnoreCase("null")){
rackWise.setId(0); rackWise.setId(0);
}else { }else {
rackWise.setId(Integer.parseInt(jsonObject.getString("rack_id"))); rackWise.setId(Integer.parseInt(jsonObject.getString("rack_id")));
} }
rackWise.setScanned_by(String.valueOf(jsonObject.getInt("scanned_by"))); rackWise.setScanned_by(String.valueOf(jsonObject.getInt("scanned_by")));
rackWise.setScanning_start_at(jsonObject.getString("scanning_start_at")); rackWise.setScanning_start_at(jsonObject.getString("scanning_start_at"));
...@@ -302,14 +301,14 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem ...@@ -302,14 +301,14 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
try{ try{
Constants.getToast(RackWiseQty.this, object1.getString(getResources().getString(R.string.msg))); Constants.getToast(RackWiseQty.this, object1.getString(getResources().getString(R.string.msg)));
}catch(JSONException e) { }catch(JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
preferenceManager.setUserId(""); preferenceManager.setUserId("");
preferenceManager.setLogged(false); preferenceManager.setLogged(false);
preferenceManager.setCustToken(""); preferenceManager.setCustToken("");
preferenceManager.setStoreId(""); preferenceManager.setStoreId("");
Login.logout(RackWiseQty.this); Login.Logout(RackWiseQty.this);
} }
} }
} }
......
...@@ -43,9 +43,9 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset; ...@@ -43,9 +43,9 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset;
Spinner searchbybarcode_spinner; Spinner searchbybarcode_spinner;
EditText searchby_barcode; EditText searchby_barcode;
TextView searchbybarcode_rack; TextView searchbybarcode_rack;
ArrayList<Plans> arrayList; ArrayList<Plans> arrayList;
PreferenceManager preferenceManager; PreferenceManager preferenceManager;
String planid; String planid;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState){ protected void onCreate(@Nullable Bundle savedInstanceState){
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -65,19 +65,15 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset; ...@@ -65,19 +65,15 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset;
Constants.getToast(SearchByBarcode.this,getResources().getString(R.string.connection)); Constants.getToast(SearchByBarcode.this,getResources().getString(R.string.connection));
} }
searchbybarcode_spinner.setOnItemSelectedListener(this); searchbybarcode_spinner.setOnItemSelectedListener(this);
/*
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
searchby_barcode.setShowSoftInputOnFocus(false);
}*/
searchby_barcode.addTextChangedListener(new Checked()); searchby_barcode.addTextChangedListener(new Checked());
} }
@Override @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item){ public boolean onOptionsItemSelected(@NonNull MenuItem item){
switch (item.getItemId()){ switch (item.getItemId()){
case android.R.id.home: case android.R.id.home:
finish(); finish();
break; break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
...@@ -103,18 +99,15 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset; ...@@ -103,18 +99,15 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset;
.url(Constants.BarcodeSearch) .url(Constants.BarcodeSearch)
.post(body) .post(body)
.addHeader(Constants.Type, Constants.App_json) .addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken()) .addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId()) .addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build(); .build();
client.newCall(request).enqueue(new Callback(){ client.newCall(request).enqueue(new Callback(){
@Override @Override
public void onFailure(Request request, final IOException e){ public void onFailure(Request request, final IOException e){
runOnUiThread(new Runnable(){ runOnUiThread(() -> {
@Override Constants.getToast(SearchByBarcode.this, e.getMessage());
public void run(){ Constants.ProgressDialogDismiss();
Constants.getToast(SearchByBarcode.this, e.getMessage());
Constants.ProgressDialogDismiss();
}
}); });
} }
@Override @Override
...@@ -124,56 +117,52 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset; ...@@ -124,56 +117,52 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset;
final String Response = response.body().string(); final String Response = response.body().string();
Log.e("Barcode Search", Response); Log.e("Barcode Search", Response);
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable(){ handler.post(() -> {
@Override try{
public void run(){ final JSONObject object1 = new JSONObject(Response);
try{ if(response.code() == 200) {
final JSONObject object = new JSONObject(Response); if (object1.has(getResources().getString(R.string.success))) {
if(response.code() == 200) { if(object1.getInt(getResources().getString(R.string.success)) == 1) {
if (object.has(getResources().getString(R.string.success))) { Log.e("Length",String.valueOf(getResources().getString(R.string.data).length()));
if(object.getInt(getResources().getString(R.string.success)) == 1) { if(object1.has(getResources().getString(R.string.data))){
Log.e("Length",String.valueOf(getResources().getString(R.string.data).length())); if(object1.getString(getResources().getString(R.string.msg)).equalsIgnoreCase("no data found")){
if(object.has(getResources().getString(R.string.data))){ searchby_barcode.setText("");
if(object.getString(getResources().getString(R.string.msg)).equalsIgnoreCase("no data found")){ searchbybarcode_rack.setText(object1.getString(getResources().getString(R.string.msg)));
searchby_barcode.setText(""); //Constants.getToast(SearchByBarcode.this, object.getString(getResources().getString(R.string.msg)));
searchbybarcode_rack.setText(object.getString(getResources().getString(R.string.msg))); }else{
//Constants.getToast(SearchByBarcode.this, object.getString(getResources().getString(R.string.msg))); searchby_barcode.setText("");
}else{ try{
searchby_barcode.setText(""); JSONObject jsonObject = object1.getJSONObject(getResources().getString(R.string.data));
try{ searchbybarcode_rack.setText(Html.fromHtml(Constants.Id) + jsonObject.getString("rack_id") + "\n"
JSONObject jsonObject = object.getJSONObject(getResources().getString(R.string.data)); + (Html.fromHtml(Constants.Barcode) + jsonObject.getString("barcode")) + "\n"
searchbybarcode_rack.setText(Html.fromHtml(Constants.Id) + jsonObject.getString("rack_id") + "\n" + (Html.fromHtml(Constants.From) + jsonObject.getString("scanning_start_at")) + "\n"
+ (Html.fromHtml(Constants.Barcode) + jsonObject.getString("barcode")) + "\n" + (Html.fromHtml(Constants.To) + jsonObject.getString("scanning_end_at")));
+ (Html.fromHtml(Constants.From) + jsonObject.getString("scanning_start_at")) + "\n" }catch(JSONException e){
+ (Html.fromHtml(Constants.To) + jsonObject.getString("scanning_end_at"))); e.printStackTrace();
}catch(JSONException e){ }
e.printStackTrace();
}
}
} }
}else if(object.getInt(getResources().getString(R.string.success)) == 3){ }
runOnUiThread(new Runnable(){ }else if(object1.getInt(getResources().getString(R.string.success)) == 3){
@Override runOnUiThread(() -> {
public void run(){
try{
Constants.getToast(SearchByBarcode.this, object.getString(getResources().getString(R.string.msg)));
}catch(JSONException e){
e.printStackTrace();
}
}
});
}else{
try{ try{
Constants.getToast(SearchByBarcode.this, object.getString(getResources().getString(R.string.msg))); Constants.getToast(SearchByBarcode.this, object1.getString(getResources().getString(R.string.msg)));
}catch(JSONException e){ }catch(JSONException e){
e.printStackTrace(); e.printStackTrace();
} }
} });
}else{
runOnUiThread(() -> {
try {
Constants.getToast(SearchByBarcode.this, object1.getString(getResources().getString(R.string.msg)));
} catch (JSONException e) {
e.printStackTrace();
}
});
} }
} }
} catch (JSONException e) {
e.printStackTrace();
} }
} catch (JSONException e) {
e.printStackTrace();
} }
}); });
}catch(NullPointerException io){ }catch(NullPointerException io){
...@@ -208,7 +197,9 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset; ...@@ -208,7 +197,9 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset;
Constants.ProgressDialogShow(SearchByBarcode.this); Constants.ProgressDialogShow(SearchByBarcode.this);
} }
} else { } else {
Constants.getToast(SearchByBarcode.this, getResources().getString(R.string.connection)); runOnUiThread(() -> {
Constants.getToast(SearchByBarcode.this, getResources().getString(R.string.connection));
});
} }
} }
} }
...@@ -270,65 +261,56 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset; ...@@ -270,65 +261,56 @@ import static w.soulofpluto.posstockaudit.Constants.getDateWithOffset;
final String Response = response.body().string(); final String Response = response.body().string();
Log.e("SearchByBarcode" , Response); Log.e("SearchByBarcode" , Response);
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable(){ handler.post(() -> {
@Override try{
public void run(){ if(response.code() == 200){
try{ final JSONObject object1 = new JSONObject(Response);
if(response.code() == 200){ if(object1.has(getResources().getString(R.string.success))){
final JSONObject object = new JSONObject(Response); arrayList = new ArrayList<>();
if(object.has(getResources().getString(R.string.success))){ if(object1.getInt(getResources().getString(R.string.success)) == 1){
arrayList = new ArrayList<>(); if(object1.has(getResources().getString(R.string.data))){
if(object.getInt(getResources().getString(R.string.success)) == 1){ arrayList.clear();
if(object.has(getResources().getString(R.string.data))){ Plans plan = new Plans();
arrayList.clear(); plan.setPlanId("0");
Plans plan = new Plans(); plan.setName("Select PlanId");
plan.setPlanId("0"); arrayList.add(plan);
plan.setName("Select PlanId"); JSONArray jsonArray = object1.getJSONArray(getResources().getString(R.string.data));
arrayList.add(plan); for (int i = 0; i < jsonArray.length(); i++) {
JSONArray jsonArray = object.getJSONArray(getResources().getString(R.string.data)); JSONObject jsonObject = jsonArray.getJSONObject(i);
for (int i = 0; i < jsonArray.length(); i++) { Plans plans = new Plans();
JSONObject jsonObject = jsonArray.getJSONObject(i); plans.setPlanId(String.valueOf(jsonObject.getInt("id")));
Plans plans = new Plans(); plans.setName(jsonObject.getString("stock_audit_name"));
plans.setPlanId(String.valueOf(jsonObject.getInt("id"))); arrayList.add(plans);
plans.setName(jsonObject.getString("stock_audit_name"));
arrayList.add(plans);
}
ArrayAdapter<Plans> adapter = new ArrayAdapter<Plans>(SearchByBarcode.this, android.R.layout.simple_dropdown_item_1line, arrayList);
searchbybarcode_spinner.setAdapter(adapter);
}else if (object.has(getResources().getString(R.string.msg))){
runOnUiThread(new Runnable() {
@Override
public void run() {
try{
Constants.getToast(SearchByBarcode.this, object.getString(getResources().getString(R.string.msg)));
}catch(JSONException e){
e.printStackTrace();
}
}
});
} }
}else if(object.getInt(getResources().getString(R.string.success)) == 3){ ArrayAdapter<Plans> adapter = new ArrayAdapter<Plans>(SearchByBarcode.this, android.R.layout.simple_dropdown_item_1line, arrayList);
runOnUiThread(new Runnable() { searchbybarcode_spinner.setAdapter(adapter);
@Override }else if (object1.has(getResources().getString(R.string.msg))){
public void run() { runOnUiThread(() -> {
try{ try{
Constants.getToast(SearchByBarcode.this, object.getString(getResources().getString(R.string.msg))); Constants.getToast(SearchByBarcode.this, object1.getString(getResources().getString(R.string.msg)));
}catch(JSONException e) { }catch(JSONException e){
e.printStackTrace(); e.printStackTrace();
}
} }
}); });
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(SearchByBarcode.this);
} }
}else if(object1.getInt(getResources().getString(R.string.success)) == 3){
runOnUiThread(() -> {
try{
Constants.getToast(SearchByBarcode.this, object1.getString(getResources().getString(R.string.msg)));
}catch(JSONException e) {
e.printStackTrace();
}
});
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.Logout(SearchByBarcode.this);
} }
} }
}catch(JSONException e){
e.printStackTrace();
} }
}catch(JSONException e){
e.printStackTrace();
} }
}); });
}catch(NullPointerException io){ }catch(NullPointerException io){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment