Skip to content

Commit

Permalink
Single Item not allowed in match
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Aggarwal authored and opticod committed Jan 29, 2017
1 parent 1cf58ae commit 7310b97
Showing 1 changed file with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,21 @@ public void handleMessage(Message message) {
private ProgressDialog mApkGenerationDialog;


public void openBottomSheet (View v) {

View view = getLayoutInflater ().inflate (R.layout.bottom_sheet_view, null);
TextView txtSaveApk = (TextView)view.findViewById( R.id.txt_save_apk);
TextView txtSaveProject = (TextView)view.findViewById( R.id.txt_save_project);
TextView txtShareApk = (TextView)view.findViewById( R.id.txt_share_apk);
final TextView txtShareProject = (TextView)view.findViewById( R.id.txt_share_project);

final Dialog mBottomSheetDialog = new Dialog (TemplateEditor.this,
public void openBottomSheet(View v) {

View view = getLayoutInflater().inflate(R.layout.bottom_sheet_view, null);
TextView txtSaveApk = (TextView) view.findViewById(R.id.txt_save_apk);
TextView txtSaveProject = (TextView) view.findViewById(R.id.txt_save_project);
TextView txtShareApk = (TextView) view.findViewById(R.id.txt_share_apk);
final TextView txtShareProject = (TextView) view.findViewById(R.id.txt_share_project);
final Dialog mBottomSheetDialog = new Dialog(TemplateEditor.this,
R.style.MaterialDialogSheet);
mBottomSheetDialog.setContentView (view);
mBottomSheetDialog.setCancelable (true);
mBottomSheetDialog.getWindow ().setLayout (LinearLayout.LayoutParams.MATCH_PARENT,
mBottomSheetDialog.setContentView(view);
mBottomSheetDialog.setCancelable(true);
mBottomSheetDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
mBottomSheetDialog.getWindow ().setGravity (Gravity.BOTTOM);
mBottomSheetDialog.show ();
mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM);
mBottomSheetDialog.show();


//save project
Expand Down Expand Up @@ -164,7 +163,7 @@ private void saveApk() {
String aliasName = getString(R.string.alias_name);
String aliaspassword = getString(R.string.alias_password);
KeyStoreDetails keyStoreDetails = new KeyStoreDetails(keyPassword, aliasName, aliaspassword);
if(saveProject().equals("File already exists")){
if (saveProject().equals("File already exists")) {
return;
}
SignerThread signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this));
Expand Down Expand Up @@ -535,9 +534,7 @@ private void setUpTemplateEditor() {

} catch (InstantiationException e) {
e.printStackTrace();
}
catch ( IllegalAccessException e)
{
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -598,16 +595,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
switch (id) {
case R.id.action_delete:
final int restorePosition = selectedPosition;
final Object object = selectedTemplate.deleteItem(TemplateEditor.this,selectedPosition);
final Object object = selectedTemplate.deleteItem(TemplateEditor.this, selectedPosition);
selectedPosition = -1;
restoreSelectedView();
Snackbar.make(findViewById(R.id.relative_layout),
R.string.snackbar_deleted_message,Snackbar.LENGTH_LONG)
R.string.snackbar_deleted_message, Snackbar.LENGTH_LONG)
.setAction(R.string.snackbar_undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedTemplate.restoreItem(TemplateEditor.this,restorePosition,object);
Snackbar.make(v,R.string.snackbar_restored_message,Snackbar.LENGTH_LONG).show();
selectedTemplate.restoreItem(TemplateEditor.this, restorePosition, object);
Snackbar.make(v, R.string.snackbar_restored_message, Snackbar.LENGTH_LONG).show();
}
}).show();
break;
Expand Down Expand Up @@ -694,10 +691,10 @@ private String saveProject() {
EditText authorEditText = (EditText) findViewById(R.id.author_name);
titleEditText = (EditText) findViewById(R.id.template_title);
assert findViewById(R.id.author_name) != null;
assert ( findViewById(R.id.author_name)) != null;
assert (findViewById(R.id.author_name)) != null;
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
assert findViewById(R.id.template_title) != null;
assert ( findViewById(R.id.template_title)) != null;
assert (findViewById(R.id.template_title)) != null;
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();
if ("".equals(author)) {
assert authorEditText != null;
Expand Down Expand Up @@ -747,6 +744,12 @@ private String saveProject() {
Toast.makeText(this, "Unable to perform action: Add Meta Details", Toast.LENGTH_SHORT).show();
return null;
}

if (templateId == 7 && selectedTemplate.getItems(doc).size() == 2) {
Toast.makeText(this, "Please enter atleast 2 items", Toast.LENGTH_SHORT).show();
return null;
}

for (Element item : selectedTemplate.getItems(doc)) {
dataElement.appendChild(item);
}
Expand All @@ -759,13 +762,12 @@ private String saveProject() {
saveFileName = saveFileName.replaceAll(" ", "-");


boolean isSaved=FileUtils.saveXmlFile(toolkit.getSavedDir(), saveFileName, doc);
if(isSaved) {
boolean isSaved = FileUtils.saveXmlFile(toolkit.getSavedDir(), saveFileName, doc);
if (isSaved) {
oldFileName = toolkit.getSavedDir() + saveFileName;
Toast.makeText(this, "Project Successfully Saved!", Toast.LENGTH_SHORT).show();
return oldFileName;
}
else {
} else {
titleEditText.setError("File Already exists");
return "File already exists";
}
Expand Down Expand Up @@ -794,9 +796,9 @@ public void onBackPressed() {
*/
private String saveDraft() {

assert ( findViewById(R.id.author_name)) != null;
assert (findViewById(R.id.author_name)) != null;
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
assert ( findViewById(R.id.template_title)) != null;
assert (findViewById(R.id.template_title)) != null;
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();


Expand Down Expand Up @@ -826,6 +828,7 @@ private String saveDraft() {
doc.appendChild(rootElement);
Element dataElement = doc.createElement("data");
rootElement.appendChild(dataElement);

if (selectedTemplate.getItems(doc).size() == 0) {
Toast.makeText(this, "Unable to perform action: No Data", Toast.LENGTH_SHORT).show();
return null;
Expand All @@ -834,6 +837,10 @@ private String saveDraft() {
Toast.makeText(this, "Unable to perform action: No Meta Details", Toast.LENGTH_SHORT).show();
return null;
}
if (templateId == 7 && selectedTemplate.getItems(doc).size() == 2) {
Toast.makeText(this, "Please enter atleast 2 items", Toast.LENGTH_SHORT).show();
return null;
}
for (Element item : selectedTemplate.getItems(doc)) {
dataElement.appendChild(item);
}
Expand Down Expand Up @@ -884,9 +891,7 @@ private void startSimulator() {
if (message == null || message.equals("")) {
Toast.makeText(this, "Build unsuccessful", Toast.LENGTH_SHORT).show();
return;
}
else if("File already exists".equals(message))
{
} else if ("File already exists".equals(message)) {
titleEditText.setError("Template Already exists");
return;
}
Expand Down

0 comments on commit 7310b97

Please sign in to comment.