Example usage for android.view ViewGroup addView

List of usage examples for android.view ViewGroup addView

Introduction

In this page you can find the example usage for android.view ViewGroup addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java

private void setupRecyclerViewAsync(@NonNull final ViewGroup viewGroup) {
    final ProgressDialog progressDialog = ProgressDialog.show(this,
            getResources().getString(R.string.progress_loading_posts),
            getResources().getString(R.string.progress_please_wait), true, false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    DatabaseLink.DatabaseListener listener = new DatabaseLink.DatabaseListener() {
        @Override//from www .j a va2s . co  m
        void onGetResponse(String str) {
            final Post[] posts;
            try {
                JSONObject json = new JSONObject(str);
                posts = DatabaseLink.parseJson(json);
            } catch (JSONException e) {
                onError("JSON is invalid. Error: " + e.getMessage() + ", JSON: " + str);
                return;
            }

            if (progressDialog.isShowing())
                progressDialog.dismiss();

            final Post[] sortedPosts = sortPosts(posts);

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // Inflate layout post_list
                    View rootView = View.inflate(PostListActivity.this, R.layout.post_list, null);
                    RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.post_list);

                    // Setup refresh action
                    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) rootView
                            .findViewById(R.id.swipe_refresh);
                    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                        @Override
                        public void onRefresh() {
                            recreate();
                        }
                    });

                    // Set adapter with posts
                    recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(sortedPosts));

                    // Add to ViewGroup
                    viewGroup.addView(rootView);
                }
            });
        }

        @Override
        void onError(String error) {
            if (progressDialog.isShowing())
                progressDialog.dismiss();

            new AlertDialog.Builder(progressDialog.getContext()).setTitle("Error").setMessage(error).show();
        }
    };

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction()))
        DatabaseLink.instance.getPostsWithTag(listener, intent.getStringExtra(SearchManager.QUERY));
    else
        DatabaseLink.instance.getAllPosts(listener);
    Log.v("TrafficTimeWaste", "Querying db...");
}

From source file:connect.app.com.connect.calendar.DayPickerPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final View itemView = mInflater.inflate(mLayoutResId, container, false);

    final SimpleMonthView v = (SimpleMonthView) itemView.findViewById(mCalendarViewId);
    //        v.setOnDayClickListener(mOnDayClickListener);
    //        v.setMonthTextAppearance(mMonthTextAppearance);
    //        v.setDayOfWeekTextAppearance(mDayOfWeekTextAppearance);
    //        v.setDayTextAppearance(mDayTextAppearance);
    ////from   w w w  .  ja  va  2 s . c  om
    //        if (mDaySelectorColor != null) {
    //            v.setDaySelectorColor(mDaySelectorColor);
    //        }
    //
    //        if (mDayHighlightColor != null) {
    //            v.setDayHighlightColor(mDayHighlightColor);
    //        }
    //
    //        if (mCalendarTextColor != null) {
    //            v.setMonthTextColor(mCalendarTextColor);
    //            v.setDayOfWeekTextColor(mCalendarTextColor);
    //            v.setDayTextColor(mCalendarTextColor);
    //        }

    final int month = getMonthForPosition(position);
    final int year = getYearForPosition(position);

    final int selectedDay;
    if (mSelectedDay != null && mSelectedDay.get(Calendar.MONTH) == month) {
        selectedDay = mSelectedDay.get(Calendar.DAY_OF_MONTH);
    } else {
        selectedDay = -1;
    }

    final int enabledDayRangeStart;
    if (mMinDate.get(Calendar.MONTH) == month && mMinDate.get(Calendar.YEAR) == year) {
        enabledDayRangeStart = mMinDate.get(Calendar.DAY_OF_MONTH);
    } else {
        enabledDayRangeStart = 1;
    }

    final int enabledDayRangeEnd;
    if (mMaxDate.get(Calendar.MONTH) == month && mMaxDate.get(Calendar.YEAR) == year) {
        enabledDayRangeEnd = mMaxDate.get(Calendar.DAY_OF_MONTH);
    } else {
        enabledDayRangeEnd = 31;
    }

    //        v.setMonthParams(selectedDay, month, year, mFirstDayOfWeek,
    //                enabledDayRangeStart, enabledDayRangeEnd);

    final ViewHolder holder = new ViewHolder(position, itemView, v);
    mItems.put(position, holder);

    container.addView(itemView);

    return holder;
}

From source file:com.orange.ocara.ui.activity.ResultAuditActivity.java

private void updateAnomalies(Audit audit) {

    ViewGroup anomalyContainerView = (ViewGroup) findViewById(com.orange.ocara.R.id.anomaly_container);
    anomalyContainerView.removeAllViews();

    for (AuditObject auditObject : audit.getObjects()) {
        final List<Comment> comments = auditObject.getComments();
        final String auditObjectName = auditObject.getName();
        final Uri auditObjectIcon = Uri.parse(auditObject.getObjectDescription().getIcon().toString());
        if (auditObject.getResponse().equals(Response.NOK) || !auditObject.getComments().isEmpty()) {
            final AuditObjectAnomalyView auditObjectAnomalyView = AuditObjectAnomalyView_
                    .build(getApplicationContext());
            auditObjectAnomalyView.setOnGroupClickListener(new AuditObjectAnomalyView.OnGroupClickListener() {
                @Override/* ww  w  .ja va  2s  .  co  m*/
                public void onExpand(AuditObjectAnomalyView view) {
                    scrollTo(view);
                }
            });

            auditObjectAnomalyView
                    .setOnCommentClickListener(new AuditObjectAnomalyView.OnCommentClickListener() {
                        @Override
                        public void onCommentClick(Comment comment, View CommentView) {
                            ResultAuditActivity.this.onCommentClicked(auditObjectIcon, auditObjectName,
                                    comments, comment, CommentView);
                        }
                    });
            auditObjectAnomalyView.bind(auditObject);
            anomalyContainerView.addView(auditObjectAnomalyView);
        }
    }

    anomalyLayout.setVisibility(anomalyContainerView.getChildCount() > 0 ? View.VISIBLE : View.GONE);
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final View itemView = mInflater.inflate(mLayoutResId, container, false);

    final SimpleMonthView v = (SimpleMonthView) itemView.findViewById(mCalendarViewId);
    v.setOnDayClickListener(mOnDayClickListener);
    v.setMonthTextAppearance(mMonthTextAppearance);
    v.setDayOfWeekTextAppearance(mDayOfWeekTextAppearance);
    v.setDayTextAppearance(mDayTextAppearance);

    if (mDaySelectorColor != null) {
        v.setDaySelectorColor(mDaySelectorColor);
    }/*  w w w. j  av  a  2 s  .com*/

    if (mDayHighlightColor != null) {
        v.setDayHighlightColor(mDayHighlightColor);
    }

    if (mCalendarTextColor != null) {
        v.setMonthTextColor(mCalendarTextColor);
        v.setDayOfWeekTextColor(mCalendarTextColor);
        v.setDayTextColor(mCalendarTextColor);
    }

    final int month = getMonthForPosition(position);
    final int year = getYearForPosition(position);

    final int[] selectedDay = resolveSelectedDayBasedOnType(month, year);

    final int enabledDayRangeStart;
    if (mMinDate.get(Calendar.MONTH) == month && mMinDate.get(Calendar.YEAR) == year) {
        enabledDayRangeStart = mMinDate.get(Calendar.DAY_OF_MONTH);
    } else {
        enabledDayRangeStart = 1;
    }

    final int enabledDayRangeEnd;
    if (mMaxDate.get(Calendar.MONTH) == month && mMaxDate.get(Calendar.YEAR) == year) {
        enabledDayRangeEnd = mMaxDate.get(Calendar.DAY_OF_MONTH);
    } else {
        enabledDayRangeEnd = 31;
    }

    if (Config.DEBUG) {
        Log.i(TAG, "mSelectedDay.getType(): " + (mSelectedDay != null ? mSelectedDay.getType() : null));
    }

    v.setMonthParams(month, year, mFirstDayOfWeek, enabledDayRangeStart, enabledDayRangeEnd, selectedDay[0],
            selectedDay[1], mSelectedDay != null ? mSelectedDay.getType() : null);

    final ViewHolder holder = new ViewHolder(position, itemView, v);
    mItems.put(position, holder);

    container.addView(itemView);

    return holder;
}

From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;/* w w  w  .j av a 2 s.c  o m*/
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

From source file:cz.muni.fi.japanesedictionary.fragments.DisplayTranslation.java

@Override
public void receiveSentences(List<TatoebaSentence> sentences) {
    if (getActivity() == null || getView() == null || mInflater == null) {
        return;//from   ww w. j a v a  2s .c  o m
    }
    View tatoebaProgressBar = getView().findViewById(R.id.detail_example_sentences_progress_bar);
    tatoebaProgressBar.setVisibility(View.GONE);

    if (sentences == null) {
        getView().findViewById(R.id.translation_tatoeba_container).setVisibility(View.GONE);
        return;
    }

    ViewGroup tatoebaContainer = (ViewGroup) getView().findViewById(R.id.detail_example_sentences_container);
    for (TatoebaSentence sentence : sentences) {
        View sentenceLine = mInflater.inflate(R.layout.sentence_line, tatoebaContainer, false);
        sentenceLine.setTag(sentence);
        TextView sentenceText = (TextView) sentenceLine.findViewById(R.id.sentence_line_text);
        sentenceText.setText(sentence.getJapaneseSentence());
        TextView sentenceTranslation = (TextView) sentenceLine.findViewById(R.id.sentence_line_translation);
        String translation;
        if (mEnglish && sentence.getEnglish() != null) {
            translation = sentence.getEnglish();
        } else if (mDutch && sentence.getDutch() != null) {
            translation = sentence.getDutch();
        } else if (mFrench && sentence.getFrench() != null) {
            translation = sentence.getFrench();
        } else if (mGerman && sentence.getGerman() != null) {
            translation = sentence.getGerman();
        } else if (mRussian && sentence.getRussian() != null) {
            translation = sentence.getRussian();
        } else {
            translation = sentence.getEnglish();
        }
        sentenceTranslation.setText(translation);

        sentenceLine.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                TatoebaSentence sentence = (TatoebaSentence) v.getTag();
                Log.d(LOG_TAG, "open sentence: " + sentence);
                mCallbackTranslation.showSentenceDetail(sentence);
            }
        });
        tatoebaContainer.addView(sentenceLine);
    }
}

From source file:com.razza.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;/*from w ww.jav  a2  s  .  com*/
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LogUtils.LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void restoreLayouts() {
    if (root != null) {
        ViewGroup wrapper = (ViewGroup) root.findViewById(R.id.detail_wrapper);
        if (root.indexOfChild(keyboardPlaceholder) != -1) {
            root.removeView(keyboardPlaceholder);
        }/* ww  w  . j  a v a 2s .com*/
        keyboardPlaceholder = null;
        if (wrapper.indexOfChild(timestampsView) == -1) {
            wrapper.addView(timestampsView);
        }
    }
}

From source file:nya.miku.wishmaster.http.cloudflare.InterceptingAntiDDOS.java

/**  anti-DDOS , ? ? ??  webview  httpclient (? ?? ? ?-?  API >= 11) */
Cookie check(final CloudflareException exception, final ExtendedHttpClient httpClient,
        final CancellableTask task, final Activity activity) {
    synchronized (lock) {
        if (processing)
            return null;
        processing = true;/*ww  w .j  av a 2s.c om*/
    }
    processing2 = true;
    currentCookie = null;

    final HttpRequestModel rqModel = HttpRequestModel.builder().setGET().build();
    final CookieStore cookieStore = httpClient.getCookieStore();
    CloudflareChecker.removeCookie(cookieStore, exception.getRequiredCookieName());
    final ViewGroup layout = (ViewGroup) activity.getWindow().getDecorView().getRootView();
    final WebViewClient client = new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
            HttpResponseModel responseModel = null;
            try {
                responseModel = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, null, task);
                for (int i = 0; i < 3 && responseModel.statusCode == 400; ++i) {
                    Logger.d(TAG, "HTTP 400");
                    responseModel.release();
                    responseModel = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, null, task);
                }
                for (Cookie cookie : cookieStore.getCookies()) {
                    if (CloudflareChecker.isClearanceCookie(cookie, url, exception.getRequiredCookieName())) {
                        Logger.d(TAG, "Cookie found: " + cookie.getValue());
                        currentCookie = cookie;
                        processing2 = false;
                        return new WebResourceResponse("text/html", "UTF-8",
                                new ByteArrayInputStream("cookie received".getBytes()));
                    }
                }
                BufOutputStream output = new BufOutputStream();
                IOUtils.copyStream(responseModel.stream, output);
                return new WebResourceResponse(null, null, output.toInputStream());
            } catch (Exception e) {
                Logger.e(TAG, e);
            } finally {
                if (responseModel != null)
                    responseModel.release();
            }
            return new WebResourceResponse("text/html", "UTF-8",
                    new ByteArrayInputStream("something wrong".getBytes()));
        }
    };

    activity.runOnUiThread(new Runnable() {
        @SuppressLint("SetJavaScriptEnabled")
        @Override
        public void run() {
            webView = new WebView(activity);
            webView.setVisibility(View.GONE);
            layout.addView(webView);
            webView.setWebViewClient(client);
            webView.getSettings().setUserAgentString(HttpConstants.USER_AGENT_STRING);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.loadUrl(exception.getCheckUrl());
        }
    });

    long startTime = System.currentTimeMillis();
    while (processing2) {
        long time = System.currentTimeMillis() - startTime;
        if ((task != null && task.isCancelled()) || time > CloudflareChecker.TIMEOUT) {
            processing2 = false;
        }
    }

    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            try {
                layout.removeView(webView);
                webView.stopLoading();
                webView.clearCache(true);
                webView.destroy();
                webView = null;
            } finally {
                processing = false;
            }
        }
    });
    return currentCookie;
}

From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java

@Override
public void onRequestcompleted(int requestCode, Object result) {
    timeoutHandler.removeCallbacks(timeout);
    if (mPd != null && mPd.isShowing()) {
        // clear pd from memory to avoid progress bar freeze when showed again
        removeDialog(DIALOG_PROGRESS);/*from www.ja  v  a2 s. co  m*/
    }
    // //Log.d(Constants.PROJECT_TAG, "Request result " + (String) result);

    if (requestCode == AVService.REQUEST_IMAGE) {
        new AlertDialog.Builder(this).setMessage(R.string.news_photo_added)
                .setPositiveButton(android.R.string.ok, null).show();
        requestAdditionalPhotos();
        return;
    }

    if (requestCode == AVService.REQUEST_JSON && result != null) {
        try {
            JSONObject answer = new JSONArray((String) result).getJSONObject(0);
            boolean isIncident = JsonData.VALUE_REQUEST_NEW_INCIDENT
                    .equals(answer.getString(JsonData.PARAM_REQUEST));
            boolean isOk = (JsonData.VALUE_INCIDENT_SAVED == (answer.getJSONObject(JsonData.PARAM_ANSWER)
                    .getInt(JsonData.PARAM_STATUS)));

            if (isIncident && isOk) {
                /*
                 * FileInputStream fis_close = openFileInput(CAPTURE_CLOSE);
                 * FileInputStream fis_far = openFileInput(CAPTURE_FAR);
                 */

                File img_close = new File(getFilesDir() + "/" + CAPTURE_CLOSE);
                if (!img_close.exists()
                        || ((ImageView) findViewById(R.id.ImageView_close)).getDrawable() == null) {
                    img_close = null;
                }
                File img_far = new File(getFilesDir() + "/" + CAPTURE_ARROW);
                if (!img_far.exists() || ((ImageView) findViewById(R.id.ImageView_far)).getDrawable() == null) {
                    img_far = null;
                }

                // if (!img_far.exists()) {
                // img_far = new File(getFilesDir() + "/" + CAPTURE_FAR);
                // }

                // TODO add a listener which handles commands properly
                AVService.getInstance(this).postImage(null, Utils.getUdid(this), img_comment,
                        answer.getJSONObject(JsonData.PARAM_ANSWER).getString(JsonData.ANSWER_INCIDENT_ID),
                        img_far, img_close, true);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                AlertDialog alert;
                builder.setMessage(R.string.report_detail_new_report_ok).setCancelable(false)
                        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                finish();
                            }
                        });
                alert = builder.create();
                alert.show();
            } else {

                // hotfix nico : here we can have valid answer for incident updates !!!
                // handle answer and display popup here instead of when we click on buttons
                int statuscode = answer.getJSONObject(JsonData.PARAM_ANSWER).getInt(JsonData.PARAM_STATUS);

                if (statuscode == 0) {
                    // FIXME end activity when resolve incident ??
                    switch (mCurrentAction) {
                    case ACTION_GET_IMAGES:
                        //Log.d("AlerteVoirie_PM", "images : " + result);
                        JSONArray imgList = answer.getJSONObject(JsonData.PARAM_ANSWER)
                                .getJSONArray(JsonData.PARAM_PHOTOS);
                        ViewGroup photocontainer = (ViewGroup) findViewById(R.id.extra_images_container);
                        photocontainer.removeAllViews();
                        LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
                                LayoutParams.WRAP_CONTENT);
                        for (int i = 0; i < imgList.length() - 2; i++) {
                            JSONObject imgObj = imgList.getJSONObject(i);
                            //Log.d("AlerteVoirie_PM", "received image obj : " + imgObj);
                            View v = getLayoutInflater().inflate(R.layout.extra_photo, null);
                            v.setLayoutParams(params);
                            TextView date = (TextView) v.findViewById(R.id.textView_date);
                            TextView comment = (TextView) v.findViewById(R.id.textView_comment);
                            ImageView icon = (ImageView) v.findViewById(R.id.imageView_icon);

                            // format date
                            String dateString = imgObj.getString(JsonData.PARAM_IMAGES_DATE);
                            date.setText(getFormatedDate(dateString));

                            comment.setText(imgObj.getString(JsonData.PARAM_IMAGES_COMMENT));
                            imgd.download(imgObj.getString(JsonData.PARAM_IMAGES_URL), icon);
                            photocontainer.addView(v);
                        }
                        if (imgList.length() > 2) {
                            findViewById(R.id.TextView_additional_photos_header).setVisibility(View.VISIBLE);
                        } else {
                            findViewById(R.id.TextView_additional_photos_header).setVisibility(View.GONE);
                        }
                        break;
                    case ACTION_CONFIRM_INCIDENT:
                        findViewById(R.id.existing_incidents_confirmed).setEnabled(false);
                        new AlertDialog.Builder(this).setMessage(R.string.news_incidents_confirmed)
                                .setPositiveButton(android.R.string.ok, null).show();
                        break;
                    case ACTION_INVALID_INCIDENT: {
                        AlertDialog dialog = new AlertDialog.Builder(this)
                                .setMessage(R.string.news_incidents_invalidated)
                                .setPositiveButton(android.R.string.ok, null).create();
                        dialog.setOnDismissListener(new OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialog) {
                                finish();
                            }
                        });
                        dialog.show();
                        break;
                    }
                    case ACTION_SOLVE_INCIDENT: {
                        AlertDialog dialog = new AlertDialog.Builder(this)
                                .setMessage(R.string.news_incidents_resolved)
                                .setPositiveButton(android.R.string.ok, null).create();
                        dialog.setOnDismissListener(new OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialog) {
                                finish();
                            }
                        });
                        dialog.show();
                        break;
                    }
                    default:
                        // assume it's a generic update request in other cases ...
                        new AlertDialog.Builder(this).setMessage(R.string.report_detail_update_ok)
                                .setPositiveButton(android.R.string.ok, null).show();
                        break;
                    }
                } else {
                    // other things
                    // FIXME show popups instead of toasts !
                    if ((answer.getJSONObject(JsonData.PARAM_ANSWER).getInt(JsonData.PARAM_STATUS)) == 18) {
                        findViewById(R.id.existing_incidents_confirmed).setEnabled(false);
                        Toast.makeText(this, getString(R.string.incident_already_confirmed), Toast.LENGTH_LONG)
                                .show();
                    } else {
                        //Log.d("AlerteVoirie_PM", "erreur ?");
                        Toast.makeText(this, getString(R.string.server_error), Toast.LENGTH_LONG).show();
                    }
                }
            }
        } catch (JSONException e) {
            Log.e(Constants.PROJECT_TAG, "Erreur d'envoi d'image", e);
        } /*
           * catch (FileNotFoundException e) {
           * // TODO Auto-generated catch block
           * Log.e(Constants.PROJECT_TAG,"File not found",e);
           * }
           */

    } else if (requestCode == AVService.REQUEST_ERROR) {
        AVServiceErrorException error = (AVServiceErrorException) result;
        String errorString = null;
        switch (error.errorCode) {
        case 19:
            // already invalidated
            errorString = getString(R.string.error_already_invalidated);
            break;

        default:
            errorString = getString(R.string.server_error);
            break;
        }

        new AlertDialog.Builder(this).setTitle(R.string.error_popup_title).setMessage(errorString)
                .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).show();
    }

}