From faf29824a7a64a19c6cc79b9aa4ab9df4bb99a98 Mon Sep 17 00:00:00 2001 From: chrqls Date: Fri, 27 Dec 2013 04:32:46 -0800 Subject: [PATCH 1/2] [#4] 'Preview iqsets' button is coming... yay! \o/ --- res/layout-large-land/iqset_details.xml | 60 ++++++++++ res/layout-large-land/preview_iqset_item.xml | 83 ++++++++++++++ res/layout-large-land/questions_item.xml | 1 - .../use_prepared_questions_item.xml | 14 ++- res/values/strings.xml | 1 + .../java/org/smilec/smile/domain/IQSet.java | 9 ++ .../ui/UsePreparedQuestionsActivity.java | 93 ++++++++-------- .../smile/ui/adapter/IQSetListAdapter.java | 99 ++++++++++++++++- .../smile/ui/adapter/IQSetPreviewAdapter.java | 103 ++++++++++++++++++ .../smile/ui/adapter/QuestionListAdapter.java | 15 +-- .../smile/ui/fragment/QuestionsFragment.java | 10 -- 11 files changed, 414 insertions(+), 74 deletions(-) create mode 100644 res/layout-large-land/iqset_details.xml create mode 100644 res/layout-large-land/preview_iqset_item.xml create mode 100644 src/main/java/org/smilec/smile/ui/adapter/IQSetPreviewAdapter.java diff --git a/res/layout-large-land/iqset_details.xml b/res/layout-large-land/iqset_details.xml new file mode 100644 index 0000000..93482d0 --- /dev/null +++ b/res/layout-large-land/iqset_details.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + diff --git a/res/layout-large-land/preview_iqset_item.xml b/res/layout-large-land/preview_iqset_item.xml new file mode 100644 index 0000000..1ecdb83 --- /dev/null +++ b/res/layout-large-land/preview_iqset_item.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-large-land/questions_item.xml b/res/layout-large-land/questions_item.xml index 9c1385d..e9147ae 100644 --- a/res/layout-large-land/questions_item.xml +++ b/res/layout-large-land/questions_item.xml @@ -1,7 +1,6 @@ + + + android:textColor="@color/pink" /> - + Complete Question QUESTION + IQSET Students diff --git a/src/main/java/org/smilec/smile/domain/IQSet.java b/src/main/java/org/smilec/smile/domain/IQSet.java index 9ccf1a4..bcaca01 100644 --- a/src/main/java/org/smilec/smile/domain/IQSet.java +++ b/src/main/java/org/smilec/smile/domain/IQSet.java @@ -3,6 +3,7 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Collection; import java.util.Date; import java.util.Locale; @@ -15,6 +16,7 @@ public class IQSet { private String sessionTitle; private String teacherName; private String groupName; + private Collection questions; public IQSet() { } @@ -80,4 +82,11 @@ public String getGroupName() { public void setGroupName(String groupName) { this.groupName = groupName; } + + public Collection getQuestions() { + return questions; + } + public void setQuestions(Collection questions) { + this.questions = questions; + } } diff --git a/src/main/java/org/smilec/smile/ui/UsePreparedQuestionsActivity.java b/src/main/java/org/smilec/smile/ui/UsePreparedQuestionsActivity.java index 3ef316b..cf454fc 100644 --- a/src/main/java/org/smilec/smile/ui/UsePreparedQuestionsActivity.java +++ b/src/main/java/org/smilec/smile/ui/UsePreparedQuestionsActivity.java @@ -18,6 +18,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.List; import org.smilec.smile.R; @@ -29,6 +30,7 @@ import org.smilec.smile.domain.Question; import org.smilec.smile.domain.Results; import org.smilec.smile.ui.adapter.IQSetListAdapter; +import org.smilec.smile.ui.adapter.QuestionListAdapter; import org.smilec.smile.util.ActivityUtil; import org.smilec.smile.util.CloseClickListenerUtil; import org.smilec.smile.util.DialogUtil; @@ -72,9 +74,11 @@ public class UsePreparedQuestionsActivity extends ListActivity { private String ip; private String status; - private List iqsets; +// private List iqsets; private IQSet iqset; private IQSetListAdapter iqsetListAdapter; + +// private ArrayAdapter previewIQSetAdapter; private ListView lvListQuestions; private Results results; @@ -154,35 +158,41 @@ private void loadValuesTime() { spinnerSeconds.setAdapter(adapterSeconds); } + /** + * Listener on the button to load iqsets + */ private class LoadButtonListener implements OnClickListener { @Override public void onClick(View v) { - if (status != null) { - Log.d("SMILE Teacher", "Status = " + status); - if (!status.equals("") && !status.equals("START_MAKE")) { - AlertDialog.Builder builder = new AlertDialog.Builder( - UsePreparedQuestionsActivity.this); - builder.setMessage(R.string.game_running).setCancelable(false) + + if (status != null && !status.equals("") && !status.equals("START_MAKE")) { + + Log.d("SMILE Teacher", "Status = " + status); + + AlertDialog.Builder builder = new AlertDialog.Builder(UsePreparedQuestionsActivity.this); + + builder.setMessage(R.string.game_running).setCancelable(false) .setNeutralButton("Ok", new DialogInterface.OnClickListener() { - @Override + + @Override public void onClick(DialogInterface dialog, int id) { new LoadTask(UsePreparedQuestionsActivity.this).execute(); } }); AlertDialog alert = builder.create(); alert.show(); - } else { - new LoadTask(UsePreparedQuestionsActivity.this).execute(); - } + } else { new LoadTask(UsePreparedQuestionsActivity.this).execute(); } ActivityUtil.showLongToast(UsePreparedQuestionsActivity.this, R.string.toast_starting); } - } + /** + * Listener on the checkbox enable/disable timer + */ private class CbQuestionsButtonListener implements OnClickListener { @Override @@ -199,34 +209,20 @@ public void onClick(View v) { } } - private void openGeneralActivity() { - Intent intent = new Intent(this, GeneralActivity.class); - intent.putExtra(GeneralActivity.PARAM_IP, ip); - intent.putExtra(GeneralActivity.PARAM_RESULTS, results); - intent.putExtra(GeneralActivity.PARAM_STATUS, status); - intent.putExtra(GeneralActivity.PARAM_HOURS, spinnerHours.getSelectedItem().toString()); - intent.putExtra(GeneralActivity.PARAM_MINUTES, spinnerMinutes.getSelectedItem().toString()); - intent.putExtra(GeneralActivity.PARAM_SECONDS, spinnerSeconds.getSelectedItem().toString()); - startActivity(intent); - - ActivityUtil.showLongToast(this, R.string.toast_starting); - - this.finish(); - } - + private File[] getQuestions() throws DataAccessException { return new QuestionsManager().getSavedQuestions(); } - private void loadQuestionsList() { + private void loadIQSets() { clearSelection(); List iqsets = new ArrayList(); - try { - iqsets = new SmilePlugServerManager().getIQSets(ip, UsePreparedQuestionsActivity.this); - } catch (NetworkErrorException e) { - e.printStackTrace(); - } + + try + { iqsets = new SmilePlugServerManager().getIQSets(ip, UsePreparedQuestionsActivity.this); } + catch (NetworkErrorException e) + { e.printStackTrace(); } iqsetListAdapter = new IQSetListAdapter(UsePreparedQuestionsActivity.this, iqsets,ip); lvListQuestions.setAdapter(iqsetListAdapter); @@ -295,24 +291,18 @@ protected File[] doInBackground(Void... params) { return null; } - /* - * File[] fileQuestions contains the 4 preloaded local files, but this is not used anymore - * and it is replaced by the iqsets - */ @Override protected void onPostExecute(File[] fileQuestions) { boolean iqsetsExist = false; - try { - iqsetsExist = new SmilePlugServerManager().iqsetsExist(ip, context); - } catch (NetworkErrorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + try + {iqsetsExist = new SmilePlugServerManager().iqsetsExist(ip, context); } + catch (NetworkErrorException e) + { e.printStackTrace(); } if (iqsetsExist) { - UsePreparedQuestionsActivity.this.loadQuestionsList(); + UsePreparedQuestionsActivity.this.loadIQSets(); } else { btOk.setEnabled(false); @@ -362,4 +352,19 @@ protected void onPostExecute(String message) { } } } + + private void openGeneralActivity() { + Intent intent = new Intent(this, GeneralActivity.class); + intent.putExtra(GeneralActivity.PARAM_IP, ip); + intent.putExtra(GeneralActivity.PARAM_RESULTS, results); + intent.putExtra(GeneralActivity.PARAM_STATUS, status); + intent.putExtra(GeneralActivity.PARAM_HOURS, spinnerHours.getSelectedItem().toString()); + intent.putExtra(GeneralActivity.PARAM_MINUTES, spinnerMinutes.getSelectedItem().toString()); + intent.putExtra(GeneralActivity.PARAM_SECONDS, spinnerSeconds.getSelectedItem().toString()); + startActivity(intent); + + ActivityUtil.showLongToast(this, R.string.toast_starting); + + this.finish(); + } } \ No newline at end of file diff --git a/src/main/java/org/smilec/smile/ui/adapter/IQSetListAdapter.java b/src/main/java/org/smilec/smile/ui/adapter/IQSetListAdapter.java index ee1f3c3..12fd18e 100644 --- a/src/main/java/org/smilec/smile/ui/adapter/IQSetListAdapter.java +++ b/src/main/java/org/smilec/smile/ui/adapter/IQSetListAdapter.java @@ -1,18 +1,37 @@ package org.smilec.smile.ui.adapter; +import java.util.Collection; import java.util.List; import org.smilec.smile.R; +import org.smilec.smile.bu.Constants; import org.smilec.smile.bu.SmilePlugServerManager; +import org.smilec.smile.domain.CurrentMessageStatus; import org.smilec.smile.domain.IQSet; +import org.smilec.smile.domain.Question; +import org.smilec.smile.ui.GeneralActivity; +import org.smilec.smile.util.ActivityUtil; +import org.smilec.smile.util.CloseClickListenerUtil; +import org.smilec.smile.util.ImageLoader; import android.accounts.NetworkErrorException; +import android.app.Dialog; import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.View.OnClickListener; import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.ListView; import android.widget.TextView; +import android.widget.Toast; +import android.widget.LinearLayout.LayoutParams; /* * This class is only used to fill the ListView in use_prepared_questions_dialog.xml @@ -21,12 +40,14 @@ * */ public class IQSetListAdapter extends ArrayAdapter { + private Context context; private String ip; // We load the list of iqsets to retrieve the values in getView(,,) public IQSetListAdapter(Context context,List iqsets, String ip) { super(context, 0, iqsets); + this.context = context; this.ip = ip; } @@ -57,18 +78,90 @@ public View getView(int position, View convertView, ViewGroup parent) { String idIQSet; int size = 0; + Collection questionsOfIQSet = null; try { idIQSet = new SmilePlugServerManager().getIdIQSetByPosition(ip, getContext(), position); - size = new SmilePlugServerManager().getListOfQuestions(ip, getContext(), idIQSet).size(); + questionsOfIQSet = new SmilePlugServerManager().getListOfQuestions(ip, getContext(), idIQSet); + size = questionsOfIQSet.size(); } catch (NetworkErrorException e) { e.printStackTrace(); } TextView tvSize = (TextView) convertView.findViewById(R.id.tv_size); - if(size < 10) tvSize.setText("0"+String.valueOf(size)); - else tvSize.setText(String.valueOf(size)); + if(size < 10) tvSize.setText("0"+String.valueOf(questionsOfIQSet.size())); + else tvSize.setText(String.valueOf(questionsOfIQSet.size())); + + ImageView ivDetails = (ImageView) convertView.findViewById(R.id.iv_details); + iqset.setQuestions(questionsOfIQSet); + ivDetails.setOnClickListener(new OpenIQSetDetailsListener(iqset)); } return convertView; } + + /** + * Class called to display the preview of an IQSet + */ + private class OpenIQSetDetailsListener implements OnClickListener { + + private IQSet iqsetToPreview; + + public OpenIQSetDetailsListener(IQSet iqset) { + this.iqsetToPreview = iqset; + } + + @Override + public void onClick(View v) { + + // Preparing "Details" view + Dialog detailsDialog = new Dialog(context, R.style.Dialog); + detailsDialog.setContentView(R.layout.iqset_details); + Display displaySize = ActivityUtil.getDisplaySize(getContext()); + detailsDialog.getWindow().setLayout(displaySize.getWidth(), displaySize.getHeight()); + detailsDialog.show(); + + // Preparing the values in the "Details" view + loadDetailOfIQSet(detailsDialog, iqsetToPreview); + } + } + +private void loadDetailOfIQSet(final Dialog detailsDialog, IQSet iqsetToPreview) { + + ImageButton btClose = (ImageButton) detailsDialog.findViewById(R.id.bt_close); + btClose.setOnClickListener(new CloseClickListenerUtil(detailsDialog)); + + TextView tvTitle = (TextView) detailsDialog.findViewById(R.id.tv_title); + tvTitle.setText(iqsetToPreview.getSessionTitle()); + + ListView lvQuestionsPreviewed = (ListView) detailsDialog.findViewById(R.id.lv_questions_preview); + ArrayAdapter data = new IQSetPreviewAdapter(context, (List) iqsetToPreview.getQuestions()); + lvQuestionsPreviewed.setAdapter(data); + +// ImageView tvImage = (ImageView) detailsDialog.findViewById(R.id.iv_image); + +// Display displaySize = ActivityUtil.getDisplaySize(context); +// float percentWidth = (float) (displaySize.getWidth() * 0.6); +// float percentHeight = (float) (displaySize.getHeight() * 0.6); +// int width = (int) (displaySize.getWidth() - percentWidth); +// int height = (int) (displaySize.getHeight() - percentHeight); +// LayoutParams lp = new LayoutParams(width, height); +// lp.setMargins(35, 20, 50, 0); +// tvImage.setLayoutParams(lp); + +// if (question.hasImage()) { +// byte[] data = ImageLoader.loadBitmap(Constants.HTTP + ip + question.getImageUrl()); +// +// if (data != null) { +// BitmapFactory.Options options = new BitmapFactory.Options(); +// Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options); +// if (bitmap != null) { +// tvImage.setImageBitmap(bitmap); +// } +// } + +// } else { +// tvImage.setVisibility(View.GONE); +// } + + } } diff --git a/src/main/java/org/smilec/smile/ui/adapter/IQSetPreviewAdapter.java b/src/main/java/org/smilec/smile/ui/adapter/IQSetPreviewAdapter.java new file mode 100644 index 0000000..e3fd175 --- /dev/null +++ b/src/main/java/org/smilec/smile/ui/adapter/IQSetPreviewAdapter.java @@ -0,0 +1,103 @@ +/** +Copyright 2012-2013 SMILE Consortium, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +**/ +package org.smilec.smile.ui.adapter; + +import java.util.List; + +import org.smilec.smile.R; +import org.smilec.smile.bu.Constants; +import org.smilec.smile.bu.SmilePlugServerManager; +import org.smilec.smile.domain.CurrentMessageStatus; +import org.smilec.smile.domain.Question; +import org.smilec.smile.domain.Results; +import org.smilec.smile.ui.GeneralActivity; +import org.smilec.smile.ui.widget.checkbox.InertCheckBox; +import org.smilec.smile.util.ActivityUtil; +import org.smilec.smile.util.CloseClickListenerUtil; +import org.smilec.smile.util.ImageLoader; + +import android.accounts.NetworkErrorException; +import android.app.Dialog; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.view.Display; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout.LayoutParams; +import android.widget.RatingBar; +import android.widget.TextView; +import android.widget.Toast; + +public class IQSetPreviewAdapter extends ArrayAdapter { + + private Context context; + + public IQSetPreviewAdapter(Context context, List items) { + super(context, android.R.layout.simple_list_item_multiple_choice, items); + + this.context = context; + } + + // For each position (<=> question in the session), we prepare the row + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + final Question question = super.getItem(position); + + if (convertView == null) { + Context context = getContext(); + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = inflater.inflate(R.layout.preview_iqset_item, parent, false); + } + + TextView tvQuestion = (TextView) convertView.findViewById(R.id.tv_question); + if (!question.getQuestion().equals("")) { tvQuestion.setText(question.getQuestion()); } + else { tvQuestion.setVisibility(View.GONE); } + + TextView tva1 = (TextView) convertView.findViewById(R.id.tv_alternative1); + if (!question.getOption1().equals("")) + { tva1.setText(context.getString(R.string.alternative1) + " " + question.getOption1()); } + else + { tva1.setVisibility(View.GONE); } + + TextView tva2 = (TextView) convertView.findViewById(R.id.tv_alternative2); + if (!question.getOption1().equals("")) + { tva2.setText(context.getString(R.string.alternative2) + " " + question.getOption2()); } + else + { tva2.setVisibility(View.GONE); } + + TextView tva3 = (TextView) convertView.findViewById(R.id.tv_alternative3); + if (!question.getOption1().equals("")) + { tva3.setText(context.getString(R.string.alternative3) + " " + question.getOption3()); } + else + { tva3.setVisibility(View.GONE); } + + TextView tva4 = (TextView) convertView.findViewById(R.id.tv_alternative4); + if (!question.getOption1().equals("")) + { tva4.setText(context.getString(R.string.alternative4) + " " + question.getOption4()); } + else + { tva4.setVisibility(View.GONE); } + + return convertView; + } +} diff --git a/src/main/java/org/smilec/smile/ui/adapter/QuestionListAdapter.java b/src/main/java/org/smilec/smile/ui/adapter/QuestionListAdapter.java index 47649dc..749d916 100644 --- a/src/main/java/org/smilec/smile/ui/adapter/QuestionListAdapter.java +++ b/src/main/java/org/smilec/smile/ui/adapter/QuestionListAdapter.java @@ -15,38 +15,25 @@ **/ package org.smilec.smile.ui.adapter; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.util.List; import org.smilec.smile.R; import org.smilec.smile.bu.Constants; -import org.smilec.smile.bu.QuestionsManager; import org.smilec.smile.bu.SmilePlugServerManager; import org.smilec.smile.domain.CurrentMessageStatus; import org.smilec.smile.domain.Question; import org.smilec.smile.domain.Results; import org.smilec.smile.ui.GeneralActivity; -import org.smilec.smile.ui.fragment.QuestionsFragment; import org.smilec.smile.ui.widget.checkbox.InertCheckBox; import org.smilec.smile.util.ActivityUtil; import org.smilec.smile.util.CloseClickListenerUtil; import org.smilec.smile.util.ImageLoader; import android.accounts.NetworkErrorException; -import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; -import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.util.Log; import android.view.Display; import android.view.LayoutInflater; import android.view.View; @@ -56,10 +43,10 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; -import android.widget.Toast; import android.widget.LinearLayout.LayoutParams; import android.widget.RatingBar; import android.widget.TextView; +import android.widget.Toast; public class QuestionListAdapter extends ArrayAdapter { diff --git a/src/main/java/org/smilec/smile/ui/fragment/QuestionsFragment.java b/src/main/java/org/smilec/smile/ui/fragment/QuestionsFragment.java index a762482..dce83af 100644 --- a/src/main/java/org/smilec/smile/ui/fragment/QuestionsFragment.java +++ b/src/main/java/org/smilec/smile/ui/fragment/QuestionsFragment.java @@ -15,15 +15,9 @@ **/ package org.smilec.smile.ui.fragment; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.ObjectInputStream.GetField; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; @@ -34,10 +28,8 @@ import org.smilec.smile.R; import org.smilec.smile.bu.BoardManager; import org.smilec.smile.bu.Constants; -import org.smilec.smile.bu.QuestionsManager; import org.smilec.smile.bu.SmilePlugServerManager; import org.smilec.smile.bu.exception.DataAccessException; -import org.smilec.smile.bu.json.CurrentMessageJSONParser; import org.smilec.smile.domain.Board; import org.smilec.smile.domain.Question; import org.smilec.smile.domain.Results; @@ -47,7 +39,6 @@ import org.smilec.smile.util.CloseClickListenerUtil; import org.smilec.smile.util.SendEmailAsyncTask; -import android.R.bool; import android.accounts.NetworkErrorException; import android.app.Activity; import android.app.Dialog; @@ -69,7 +60,6 @@ import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; -import android.widget.Toast; public class QuestionsFragment extends AbstractFragment { From 895245abcc3a5c66c435f8e2c1f6657e3363dca0 Mon Sep 17 00:00:00 2001 From: chrqls Date: Tue, 31 Dec 2013 00:03:46 -0800 Subject: [PATCH 2/2] [#4] Adding comments and removing useless ids --- res/layout-large-land/preview_iqset_item.xml | 1 - .../use_prepared_questions_item.xml | 1 - .../smile/ui/adapter/IQSetListAdapter.java | 35 ++++--------------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/res/layout-large-land/preview_iqset_item.xml b/res/layout-large-land/preview_iqset_item.xml index 1ecdb83..2699558 100644 --- a/res/layout-large-land/preview_iqset_item.xml +++ b/res/layout-large-land/preview_iqset_item.xml @@ -31,7 +31,6 @@ android:layout_width="fill_parent" > diff --git a/res/layout-large-land/use_prepared_questions_item.xml b/res/layout-large-land/use_prepared_questions_item.xml index 5351a37..924967d 100644 --- a/res/layout-large-land/use_prepared_questions_item.xml +++ b/res/layout-large-land/use_prepared_questions_item.xml @@ -87,7 +87,6 @@ android:layout_gravity="center_vertical" android:layout_marginLeft="1dip" android:layout_marginRight="3dip" - android:background="@color/gray" android:textColor="@color/black" /> questionsOfIQSet = null; @@ -87,10 +88,12 @@ public View getView(int position, View convertView, ViewGroup parent) { } catch (NetworkErrorException e) { e.printStackTrace(); } + // ...to count the number of questions TextView tvSize = (TextView) convertView.findViewById(R.id.tv_size); if(size < 10) tvSize.setText("0"+String.valueOf(questionsOfIQSet.size())); else tvSize.setText(String.valueOf(questionsOfIQSet.size())); + // ...and get values for the preview if listener is called ImageView ivDetails = (ImageView) convertView.findViewById(R.id.iv_details); iqset.setQuestions(questionsOfIQSet); ivDetails.setOnClickListener(new OpenIQSetDetailsListener(iqset)); @@ -100,7 +103,7 @@ public View getView(int position, View convertView, ViewGroup parent) { } /** - * Class called to display the preview of an IQSet + * Listener called to display the preview of an IQSet */ private class OpenIQSetDetailsListener implements OnClickListener { @@ -125,6 +128,9 @@ public void onClick(View v) { } } +/** + * Preparing the Dialog to show a preview of IQSet + */ private void loadDetailOfIQSet(final Dialog detailsDialog, IQSet iqsetToPreview) { ImageButton btClose = (ImageButton) detailsDialog.findViewById(R.id.bt_close); @@ -136,32 +142,5 @@ private void loadDetailOfIQSet(final Dialog detailsDialog, IQSet iqsetToPreview) ListView lvQuestionsPreviewed = (ListView) detailsDialog.findViewById(R.id.lv_questions_preview); ArrayAdapter data = new IQSetPreviewAdapter(context, (List) iqsetToPreview.getQuestions()); lvQuestionsPreviewed.setAdapter(data); - -// ImageView tvImage = (ImageView) detailsDialog.findViewById(R.id.iv_image); - -// Display displaySize = ActivityUtil.getDisplaySize(context); -// float percentWidth = (float) (displaySize.getWidth() * 0.6); -// float percentHeight = (float) (displaySize.getHeight() * 0.6); -// int width = (int) (displaySize.getWidth() - percentWidth); -// int height = (int) (displaySize.getHeight() - percentHeight); -// LayoutParams lp = new LayoutParams(width, height); -// lp.setMargins(35, 20, 50, 0); -// tvImage.setLayoutParams(lp); - -// if (question.hasImage()) { -// byte[] data = ImageLoader.loadBitmap(Constants.HTTP + ip + question.getImageUrl()); -// -// if (data != null) { -// BitmapFactory.Options options = new BitmapFactory.Options(); -// Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options); -// if (bitmap != null) { -// tvImage.setImageBitmap(bitmap); -// } -// } - -// } else { -// tvImage.setVisibility(View.GONE); -// } - } }