Commit 2db04546 by User

added keyboard open searchbybarcode

parent 40384fd7
......@@ -2,8 +2,6 @@ package w.soulofpluto.posstock;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
......@@ -15,7 +13,7 @@ import retrofit2.http.Path;
* Created by Ramesh on 05/09/20.
*/
public interface ApiService {
public interface ApiService{
//String BASE_URL = "https://aeebe1.emporter.eu/pos_actions/";
//String Token = "41f34d7009db337f6213be52f7151108";
//String StoreId = "980";
......@@ -23,16 +21,15 @@ import retrofit2.http.Path;
"Accept: application/json","Content-Type:multipart/form-data"})*/
/*@Multipart
@POST("uploadBarcodeImages")
Call<ResponseBody> uploadMultiple(
@Part("Pos-Access-Token") RequestBody token,
Call<ResponseBody> uploadMultiple(@Part("Pos-Access-Token") RequestBody token,
@Part("Pos-User-Access-Store-Id") RequestBody storeId,
@Part("barcode") RequestBody barcode,
@Part List<MultipartBody.Part> files);*/
@Headers({"Content-type: application/json"})
@POST("/login/doLogin")
Call<Response> login(@Body RequestBody body);
@GET("/login/getStoresMappedToUser/{id}")
Call<Response> getStoreId(@Path("id") String id);
}
......@@ -9,18 +9,14 @@ import android.view.Gravity;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
import com.squareup.okhttp.MediaType;
import org.json.JSONArray;
import org.json.JSONException;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.StringTokenizer;
/*
Create by Ramesh Babu
......@@ -54,6 +50,7 @@ public class Constants{
public static String Plan_Id = "<font color=#3700B3><b>PLAN ID : </b></font>";
public static String Name = "<font color=#3700B3><b>NAME : </b></font>";
public static String VERSION = "1.1";
public static int Value = 7;
public static ProgressDialog progressDialog;
public static void getToast(Context context, String data){
......
......@@ -10,8 +10,6 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
......@@ -23,49 +21,42 @@ import com.squareup.okhttp.Response;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/*
Create by Ramesh Babu
*/
public class DashBoardActivity extends AppCompatActivity implements View.OnClickListener {
Toolbar dashboad_toolbar;
Toolbar dashboard_toolbar;
Button stock_audit,rack_qty,searchby_barcode;
TextView version;
PreferenceManager preferenceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
stock_audit = findViewById(R.id.stock_audit);
rack_qty = findViewById(R.id.rack_qty);
searchby_barcode = findViewById(R.id.searchby_barcode);
dashboad_toolbar = findViewById(R.id.dashboard_toolbar);
dashboard_toolbar= findViewById(R.id.dashboard_toolbar);
version = findViewById(R.id.version);
preferenceManager= new PreferenceManager(this);
setSupportActionBar(dashboad_toolbar);
setSupportActionBar(dashboard_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.dashboard));
stock_audit.setOnClickListener(this);
rack_qty.setOnClickListener(this);
searchby_barcode.setOnClickListener(this);
version.setText(Html.fromHtml(Constants.Ver_Text +Constants.VERSION));
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item){
switch(item.getItemId()){
/*case android.R.id.home:
finish();
break;*/
case R.id.dashboard_logout:
if(Constants.isNetworkAvailable(DashBoardActivity.this)){
Logout(Constants.Logout+preferenceManager.getUserId());
......@@ -99,7 +90,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
if(response.isSuccessful()){
String res = response.body().string();
Log.e("Dashboard Logout ", res);
try {
try{
JSONObject jsonObject = new JSONObject(res);
if(jsonObject.has("success")){
if(jsonObject.getInt("success") == 1){
......@@ -112,7 +103,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
Constants.getToast(DashBoardActivity.this,jsonObject.getString("msg"));
}
}
} catch (JSONException e) {
}catch(JSONException e){
e.printStackTrace();
}catch (NullPointerException np){
np.printStackTrace();
......@@ -124,7 +115,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
@Override
public void onClick(View view){
switch (view.getId()){
switch(view.getId()){
case R.id.stock_audit:
Intent in_main = new Intent(this,MainActivity.class);
startActivity(in_main);
......@@ -151,13 +142,13 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
//.setMessage("Are you sure to Exit")
.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
public void onClick(DialogInterface dialogInterface, int i){
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
public void onClick(DialogInterface dialogInterface, int i){
}
})
.show();
......
package w.soulofpluto.posstock;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
......@@ -13,13 +11,11 @@ import android.os.Looper;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -28,7 +24,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import static w.soulofpluto.posstock.Constants.JSON;
import static w.soulofpluto.posstock.Constants.getDateWithOffset;
......@@ -37,6 +32,7 @@ public class MainActivity extends AppCompatActivity {
RecyclerView plans_list;
PreferenceManager preferenceManager;
ArrayList<Plans> plansArrayList;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
......@@ -49,6 +45,7 @@ public class MainActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getResources().getString(R.string.test)+ " UserId : " +preferenceManager.getUserId());
}
@Override
protected void onStart(){
if(Constants.isNetworkAvailable(MainActivity.this)){
......@@ -59,6 +56,7 @@ public class MainActivity extends AppCompatActivity {
}
super.onStart();
}
public void Logout(String Url){
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
......@@ -101,14 +99,16 @@ public class MainActivity extends AppCompatActivity {
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item){
switch (item.getItemId()){
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case android.R.id.home:
finish();
break;
......@@ -123,18 +123,19 @@ public class MainActivity extends AppCompatActivity {
}
return super.onOptionsItemSelected(item);
}
private void FetchData(String Url){
JSONObject object = new JSONObject();
try{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = new Date();
Date from = getDateWithOffset(-7, new Date());
String fromdate = currentDate.format(from);
Date from = getDateWithOffset(-Constants.Value, new Date());
String fromDate = currentDate.format(from);
String thisDate = currentDate.format(todayDate);
Log.e("Last date",fromdate);
Log.e("Last date",fromDate);
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.android_version),Constants.VERSION);
}
......@@ -186,7 +187,6 @@ public class MainActivity extends AppCompatActivity {
JSONObject jsonObject = jsonArray.getJSONObject(i);
Plans plans = new Plans();
plans.setPlanId(String.valueOf(jsonObject.getInt("id")));
plans.setName(jsonObject.getString("stock_audit_name"));
plans.setDivision(Constants.convertString(jsonObject.getString("item_divisions")));
plans.setSection(Constants.convertString(jsonObject.getString("item_sections")));
......
......@@ -87,7 +87,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = new Date();
Date from = getDateWithOffset(-7, new Date());
Date from = getDateWithOffset(-Constants.Value, new Date());
String fromDate = currentDate.format(from);
String thisDate = currentDate.format(todayDate);
Log.e("Last date",fromDate);
......
......@@ -65,9 +65,10 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
Constants.getToast(SearchByBarcode.this,getResources().getString(R.string.connection));
}
searchbybarcode_spinner.setOnItemSelectedListener(this);
/*
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
searchby_barcode.setShowSoftInputOnFocus(false);
}
}*/
searchby_barcode.addTextChangedListener(new Checked());
}
......@@ -95,9 +96,9 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
Log.e("Search", object.toString());
RequestBody body = RequestBody.create(JSON, object.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
client.setConnectTimeout(25, TimeUnit.SECONDS);
client.setReadTimeout(25, TimeUnit.SECONDS);
client.setWriteTimeout(25, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.BarcodeSearch)
.post(body)
......@@ -191,20 +192,27 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
@Override
public void onTextChanged(CharSequence val, int i, int i1, int i2){
try{
if(Constants.isNetworkAvailable(SearchByBarcode.this)){
if(val.toString().contains("\n")){
if(Constants.isNetworkAvailable(SearchByBarcode.this)){
if(planid.equalsIgnoreCase("0")){
Constants.getToast(SearchByBarcode.this,"Choose Plan Id");
if(Constants.isNetworkAvailable(SearchByBarcode.this)) {
if(val.toString().length() > 0) {
if(planid.equalsIgnoreCase("0")) {
Constants.getToast(SearchByBarcode.this, "Choose Plan Id");
searchby_barcode.setText("");
}else{
getBarcodeCheck(planid,searchby_barcode.getText().toString().replace("\n", ""));
}
}
if (val.toString().contains("\n")) {
if (Constants.isNetworkAvailable(SearchByBarcode.this)) {
if (planid.equalsIgnoreCase("0")) {
Constants.getToast(SearchByBarcode.this, "Choose Plan Id");
searchby_barcode.setText("");
} else {
getBarcodeCheck(planid, searchby_barcode.getText().toString().replace("\n", ""));
Constants.ProgressDialogShow(SearchByBarcode.this);
}
}else{
} else {
Constants.getToast(SearchByBarcode.this, getResources().getString(R.string.connection));
}
}
}
}
}catch(NullPointerException np){
np.printStackTrace();
}
......@@ -220,7 +228,7 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = new Date();
Date from = getDateWithOffset(-7, new Date());
Date from = getDateWithOffset(-Constants.Value, new Date());
String fromDate = currentDate.format(from);
String thisDate = currentDate.format(todayDate);
Log.e("Last date",fromDate);
......@@ -234,9 +242,9 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
Log.e("Searchby object ====>",object.toString());
RequestBody body = RequestBody.create(JSON,object.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
client.setConnectTimeout(25, TimeUnit.SECONDS);
client.setReadTimeout(25, TimeUnit.SECONDS);
client.setWriteTimeout(25, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Url)
.post(body)
......
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