version name added to menu
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -54,4 +54,14 @@ public class BaseActivity extends AppCompatActivity {
|
||||
return pInfo.versionCode;
|
||||
}
|
||||
|
||||
public String getAppVersionName(){
|
||||
PackageInfo pInfo = null;
|
||||
try {
|
||||
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return pInfo.versionName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzacucina.android.R;
|
||||
import ch.pizzacucina.android.adapter.recycler.NavigationMenuRecyclerAdapter;
|
||||
import ch.pizzacucina.android.api.ApiConstants;
|
||||
import ch.pizzacucina.android.fragment.CartFragment;
|
||||
import ch.pizzacucina.android.fragment.OrderHistoryFragment;
|
||||
import ch.pizzacucina.android.fragment.StoreInfoFragment;
|
||||
@@ -434,6 +435,10 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private void openProductsScreen(CategoryModel clickedCategoryModel){
|
||||
|
||||
if(clickedCategoryModel.getId() == ApiConstants.PRODUCT_ID_VERSION_MENU){
|
||||
return;
|
||||
}
|
||||
|
||||
drawerLayout.closeDrawers();
|
||||
|
||||
if(clickedCategoryModel.isSpecialCategory()){
|
||||
|
||||
@@ -312,8 +312,7 @@ public class SplashActivity extends BaseActivity {
|
||||
if(response.isSuccessful() &&
|
||||
response.body().getData() != null &&
|
||||
response.body().isSuccess()){
|
||||
CategoryModel.checkNull(response.body().getData());
|
||||
SharedPrefsHelper.saveCategoryList(response.body().getData());
|
||||
saveCategoryList(response.body().getData());
|
||||
getPizzaCategoryIds();
|
||||
}
|
||||
else {
|
||||
@@ -330,6 +329,15 @@ public class SplashActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void saveCategoryList(ArrayList<CategoryModel> categoryList){
|
||||
CategoryModel versionNameCategoryModel = new CategoryModel();
|
||||
versionNameCategoryModel.setId(ApiConstants.PRODUCT_ID_VERSION_MENU);
|
||||
versionNameCategoryModel.setName("v" + getAppVersionName());
|
||||
categoryList.add(versionNameCategoryModel);
|
||||
CategoryModel.checkNull(categoryList);
|
||||
SharedPrefsHelper.saveCategoryList(categoryList);
|
||||
}
|
||||
|
||||
private void getPizzaCategoryIds(){
|
||||
Call<ResponseArray<Integer>> call = ApiService.apiInterface.getPizzaCategoryIds(SessionHelper.getSelectedStore().getStoreName());
|
||||
call.enqueue(new Callback<ResponseArray<Integer>>() {
|
||||
|
||||
@@ -10,6 +10,7 @@ public class ApiConstants {
|
||||
public static final int PRODUCT_ID_WUNSCHPIZZA = 56;
|
||||
public static final int PRODUCT_ID_ABEND_MENU = 733;
|
||||
public static final int PRODUCT_ID_MITTAGS_MENU = 732;
|
||||
public static final int PRODUCT_ID_VERSION_MENU = -111;
|
||||
|
||||
public static final String CAMPAIGN_CODE_PIZZAPASS = "PIZZAPASS";
|
||||
public static final String CAMPAIGN_CODE_KEBAPPASS = "KEBAPPASS";
|
||||
|
||||
@@ -41,6 +41,10 @@ public class CategoryModel implements Serializable{
|
||||
public void checkNull(){
|
||||
if(name == null)
|
||||
name = "";
|
||||
if(specialProductId == null)
|
||||
specialProductId = "";
|
||||
if(subCategoryList == null)
|
||||
subCategoryList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static void checkNull(ArrayList<CategoryModel> categoryList){
|
||||
|
||||
Reference in New Issue
Block a user