Example usage for android.view View getContext

List of usage examples for android.view View getContext

Introduction

In this page you can find the example usage for android.view View getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java

 protected void DoubtBox1 () {
   // TODO Auto-generated method stub

   dialogDoubt1 = new Dialog(MainActivity_Reciever.this);
   dialogDoubt1.requestWindowFeature(Window.FEATURE_NO_TITLE);
   dialogDoubt1.setContentView(R.layout.activity_doubtlist_reciever);  //here

   mainListView = (ListView)dialogDoubt1.findViewById(R.id.mainListView);


   //list ki shuruat




   /*String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
         "Jupiter", "Saturn", "Uranus", "Neptune"};
   planetList.addAll( Arrays.asList(planets) );*/

   // Create ArrayAdapter using the planet list.
   listAdapter = new ArrayAdapter<String>(MainActivity_Reciever.this, R.layout.simplerow_reciever, planetList);
   mainListView.setAdapter(listAdapter);

   mainListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
      public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                              final int pos, long id) {
         // TODO Auto-generated method stub
         itemValue = (String) mainListView.getItemAtPosition(pos);
         DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override//from  ww  w .  j ava2s  .co  m
            public void onClick(DialogInterface dialog, int which) {
               switch (which) {
                  case DialogInterface.BUTTON_POSITIVE:

                     new delete().execute();
                     break;

                  case DialogInterface.BUTTON_NEGATIVE:
                     //No button clicked
                     break;
               }
            }
         };

         AlertDialog.Builder builder = new AlertDialog.Builder(arg1.getContext());
         builder.setMessage("Are you sure to delete this doubt ?").setPositiveButton("Yes", dialogClickListener)
               .setNegativeButton("No", dialogClickListener).show();

         return true;

      }
   });




   dialogDoubt1.show();

}

From source file:com.activiti.android.app.fragments.app.AppInstancesFragment.java

@Override
public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    adapter.notifyDataSetChanged();//from w ww.  ja  v  a 2s  . c o m

    RuntimeAppInstance item = RuntimeAppInstanceManager.getInstance(getActivity()).getByProviderId(id);
    boolean back = true;
    if (drawerId != null) {
        // Analytics
        AnalyticsHelper.reportOperationEvent(getActivity(), AnalyticsManager.CATEGORY_SESSION,
                AnalyticsManager.ACTION_SWITCH, AnalyticsManager.LABEL_APPS, 1, false);

        ((AppInstanceCursorAdapter) l.getAdapter()).setSelected(item.getId());
        ((AppInstanceCursorAdapter) l.getAdapter()).notifyDataSetInvalidated();

        // Flag last used Application
        InternalAppPreferences.savePref(getActivity(), getAccount().getId(),
                InternalAppPreferences.PREF_LAST_APP_USED, item.getId());
        InternalAppPreferences.savePref(getActivity(), getAccount().getId(),
                InternalAppPreferences.PREF_LAST_APP_NAME, item.getName());

        // Clean Right Menu.
        resetRightMenu();

        ((MainActivity) getActivity()).hideSlideMenu();
        back = false;
        getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }

    TasksFragment.with((MainActivity) v.getContext()).appName(item.getName()).appId(item.getId()).back(back)
            .display();
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.PlusStreamRowViewBinder.java

public static void bindActivityView(final View rootView, Activity activity, ImageLoader imageLoader,
        boolean singleSourceMode) {
    // Prepare view holder.
    ViewHolder tempViews = (ViewHolder) rootView.getTag();
    final ViewHolder views;
    if (tempViews != null) {
        views = tempViews;// w  ww.  j  ava2 s  .  c o m
    } else {
        views = new ViewHolder();
        rootView.setTag(views);

        // Author and metadata box
        views.authorContainer = rootView.findViewById(R.id.stream_author_container);
        views.userImage = (ImageView) rootView.findViewById(R.id.stream_user_image);
        views.userName = (TextView) rootView.findViewById(R.id.stream_user_name);
        views.time = (TextView) rootView.findViewById(R.id.stream_time);

        // Author's content
        views.content = (TextView) rootView.findViewById(R.id.stream_content);

        // Original share box
        views.originalContainer = rootView.findViewById(R.id.stream_original_container);
        views.originalAuthor = (TextView) rootView.findViewById(R.id.stream_original_author);
        views.originalContent = (TextView) rootView.findViewById(R.id.stream_original_content);

        // Media box
        views.mediaContainer = rootView.findViewById(R.id.stream_media_container);
        views.mediaBackground = (ImageView) rootView.findViewById(R.id.stream_media_background);
        views.mediaOverlay = (ImageView) rootView.findViewById(R.id.stream_media_overlay);
        views.mediaTitle = (TextView) rootView.findViewById(R.id.stream_media_title);
        views.mediaSubtitle = (TextView) rootView.findViewById(R.id.stream_media_subtitle);

        // Interactions box
        views.interactionsContainer = rootView.findViewById(R.id.stream_interactions_container);
        views.plusOnes = (TextView) rootView.findViewById(R.id.stream_plus_ones);
        views.shares = (TextView) rootView.findViewById(R.id.stream_shares);
        views.comments = (TextView) rootView.findViewById(R.id.stream_comments);
    }

    final Context context = rootView.getContext();
    final Resources res = context.getResources();

    // Determine if this is a reshare (affects how activity fields are to be interpreted).
    Activity.PlusObject.Actor originalAuthor = activity.getObject().getActor();
    boolean isReshare = "share".equals(activity.getVerb()) && originalAuthor != null;

    // Author and metadata box
    views.authorContainer.setVisibility(singleSourceMode ? View.GONE : View.VISIBLE);
    views.userName.setText(activity.getActor().getDisplayName());

    // Find user profile image url
    String userImageUrl = null;
    if (activity.getActor().getImage() != null) {
        userImageUrl = activity.getActor().getImage().getUrl();
    }

    // Load image from network in background thread using Volley library
    imageLoader.get(userImageUrl, views.userImage, PLACEHOLDER_USER_IMAGE);

    long thenUTC = activity.getUpdated().getValue() + activity.getUpdated().getTimeZoneShift() * 60000;
    views.time.setText(DateUtils.getRelativeTimeSpanString(thenUTC, System.currentTimeMillis(),
            DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_RELATIVE));

    // Author's additional content
    String selfContent = isReshare ? activity.getAnnotation() : activity.getObject().getContent();
    views.content.setMaxLines(singleSourceMode ? 1000 : 5);
    if (!TextUtils.isEmpty(selfContent)) {
        views.content.setVisibility(View.VISIBLE);
        views.content.setText(Html.fromHtml(selfContent));
    } else {
        views.content.setVisibility(View.GONE);
    }

    // Original share box
    if (isReshare) {
        views.originalContainer.setVisibility(View.VISIBLE);

        // Set original author text, highlight author name
        final String author = res.getString(R.string.stream_originally_shared, originalAuthor.getDisplayName());
        final SpannableStringBuilder spannableAuthor = new SpannableStringBuilder(author);
        spannableAuthor.setSpan(new StyleSpan(Typeface.BOLD),
                author.length() - originalAuthor.getDisplayName().length(), author.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        views.originalAuthor.setText(spannableAuthor, TextView.BufferType.SPANNABLE);

        String originalContent = activity.getObject().getContent();
        views.originalContent.setMaxLines(singleSourceMode ? 1000 : 3);
        if (!TextUtils.isEmpty(originalContent)) {
            views.originalContent.setVisibility(View.VISIBLE);
            views.originalContent.setText(Html.fromHtml(originalContent));
        } else {
            views.originalContent.setVisibility(View.GONE);
        }
    } else {
        views.originalContainer.setVisibility(View.GONE);
    }

    // Media box

    // Set media content.
    List<Activity.PlusObject.Attachments> attachments = activity.getObject().getAttachments();
    if (attachments != null && attachments.size() > 0) {
        Activity.PlusObject.Attachments attachment = attachments.get(0);
        String objectType = attachment.getObjectType();
        String imageUrl = attachment.getImage() != null ? attachment.getImage().getUrl() : null;
        if (imageUrl == null && attachment.getThumbnails() != null && attachment.getThumbnails().size() > 0) {
            Thumbnails thumb = attachment.getThumbnails().get(0);
            imageUrl = thumb.getImage() != null ? thumb.getImage().getUrl() : null;
        }

        // Load image from network in background thread using Volley library
        imageLoader.get(imageUrl, views.mediaBackground, PLACEHOLDER_MEDIA_IMAGE);

        boolean overlayStyle = false;

        views.mediaOverlay.setImageDrawable(null);
        if (("photo".equals(objectType) || "video".equals(objectType) || "album".equals(objectType))
                && !TextUtils.isEmpty(imageUrl)) {
            overlayStyle = true;
            views.mediaOverlay
                    .setImageResource("video".equals(objectType) ? R.drawable.ic_stream_media_overlay_video
                            : R.drawable.ic_stream_media_overlay_photo);

        } else if ("article".equals(objectType) || "event".equals(objectType)) {
            overlayStyle = false;
            views.mediaTitle.setText(attachment.getDisplayName());
            if (!TextUtils.isEmpty(attachment.getUrl())) {
                Uri uri = Uri.parse(attachment.getUrl());
                views.mediaSubtitle.setText(uri.getHost());
            } else {
                views.mediaSubtitle.setText("");
            }
        }

        views.mediaContainer.setVisibility(View.VISIBLE);
        views.mediaContainer.setBackgroundResource(
                overlayStyle ? R.color.plus_stream_media_background : android.R.color.black);
        if (overlayStyle) {
            views.mediaBackground.clearColorFilter();
        } else {
            views.mediaBackground.setColorFilter(res.getColor(R.color.plus_media_item_tint));
        }
        views.mediaOverlay.setVisibility(overlayStyle ? View.VISIBLE : View.GONE);
        views.mediaTitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE);
        views.mediaSubtitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE);
    } else {
        views.mediaContainer.setVisibility(View.GONE);
        views.mediaBackground.setImageDrawable(null);
        views.mediaOverlay.setImageDrawable(null);
    }

    // Interactions box
    final int plusOneCount = (activity.getObject().getPlusoners() != null)
            ? activity.getObject().getPlusoners().getTotalItems().intValue()
            : 0;
    if (plusOneCount > 0) {
        views.plusOnes.setVisibility(View.VISIBLE);
        views.plusOnes.setText(getPlusOneString(plusOneCount));
    } else {
        views.plusOnes.setVisibility(View.GONE);
    }

    final int commentCount = (activity.getObject().getReplies() != null)
            ? activity.getObject().getReplies().getTotalItems().intValue()
            : 0;
    if (commentCount > 0) {
        views.comments.setVisibility(View.VISIBLE);
        views.comments.setText(Integer.toString(commentCount));
    } else {
        views.comments.setVisibility(View.GONE);
    }

    final int resharerCount = (activity.getObject().getResharers() != null)
            ? activity.getObject().getResharers().getTotalItems().intValue()
            : 0;
    if (resharerCount > 0) {
        views.shares.setVisibility(View.VISIBLE);
        views.shares.setText(Integer.toString(resharerCount));
    } else {
        views.shares.setVisibility(View.GONE);
    }

    views.interactionsContainer.setVisibility(
            (plusOneCount > 0 || commentCount > 0 || resharerCount > 0) ? View.VISIBLE : View.GONE);
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * VIN??//from  w  ww.  ja v  a2  s.  co  m
 */
private void checkVinAndGetCarSettings() {
    InputMethodManager imm = (InputMethodManager) rootView.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(findViewById(R.id.vin_edit).getWindowToken(), 0);

    final String vinString = getEditViewText(rootView, R.id.vin_edit);

    // ?
    if (vinString.equals("")) {
        Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show();
        findViewById(R.id.vin_edit).requestFocus();
        return;
    }

    // VIN?
    if (!isVin(vinString)) {
        View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null);
        TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea);
        TextView content = new TextView(view1.getContext());
        content.setText("VIN?: " + vinString + "\n"
                + "VIN?????\n");
        content.setTextSize(20f);
        contentArea.addView(content);

        setTextView(view1, R.id.title, getResources().getString(R.string.alert));

        AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view1)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        setEditViewText(rootView, R.id.brand_edit, "");
                        findViewById(R.id.brand_select_button).setEnabled(false);

                        // ???VIN
                        getCarSettingsFromServer();
                    }
                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        findViewById(R.id.vin_edit).requestFocus();
                    }
                }).create();

        dialog.show();
        return;
    }

    setEditViewText(rootView, R.id.brand_edit, "");
    findViewById(R.id.brand_select_button).setEnabled(false);

    // ???VIN
    getCarSettingsFromServer();
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * /*from w  w w  .java  2s  .  c  o  m*/
 */
private void selectCarManually() {
    if (!mCarSettings.getBrandString().equals("")) {
        View view1 = ((Activity) rootView.getContext()).getLayoutInflater().inflate(R.layout.popup_layout,
                null);
        TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea);
        TextView content = new TextView(view1.getContext());
        content.setText(R.string.reMatch);
        content.setTextSize(20f);
        contentArea.addView(content);

        setTextView(view1, R.id.title, getResources().getString(R.string.alert));

        AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view1)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        mHideContentCallback.hideContent();
                        showSelectCarDialog();
                    }
                }).setNegativeButton(R.string.cancel, null).create();

        dialog.show();
    } else {
        showSelectCarDialog();
    }
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;/*w ww.j a  va  2  s .c  om*/

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    runDelayedAnim(new Runnable() {
        @Override
        public void run() {
            if (!isAdded()) {
                // We have been detached before this could run,
                // so just bail
                return;
            }

            dialogView.setVisibility(View.VISIBLE);

            // Fade in the activity background protection
            ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
            oa.setDuration(ANIMATE_IN_DURATION);
            oa.setStartDelay(SECONDARY_ANIMATE_DELAY);
            oa.setInterpolator(new DecelerateInterpolator(1.0f));
            oa.start();

            boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL;
            int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
            int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                    : actionContainerView.getMeasuredWidth();

            // Fade in and slide in the ContentFragment
            // TextViews from the start.
            prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

            // Fade in and slide in the ActionFragment from the
            // end.
            prepareAndAnimateView(actionContainerView, endDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);

            // Fade in the selector.
            if (mSelectorAnimator != null) {
                mSelectorAnimator.fadeIn();
            }
        }
    });
}

From source file:com.android.incallui.CallCardFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mPulseAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.call_status_pulse);

    mPhoneNumber = (TextView) view.findViewById(R.id.phoneNumber);
    mPrimaryName = (TextView) view.findViewById(R.id.name);
    mNumberLabel = (TextView) view.findViewById(R.id.label);
    mSecondaryCallInfo = view.findViewById(R.id.secondary_call_info);
    mSecondaryCallProviderInfo = view.findViewById(R.id.secondary_call_provider_info);
    mCallCardContent = view.findViewById(R.id.call_card_content);
    mPhotoLarge = (ImageView) view.findViewById(R.id.photoLarge);
    mPhotoLarge.setOnClickListener(new View.OnClickListener() {
        @Override/*from www. j a v a  2 s. co  m*/
        public void onClick(View v) {
            getPresenter().onContactPhotoClick();
        }
    });

    mContactContext = view.findViewById(R.id.contact_context);
    mContactContextTitle = (TextView) view.findViewById(R.id.contactContextTitle);
    mContactContextListView = (ListView) view.findViewById(R.id.contactContextInfo);
    // This layout stores all the list header layouts so they can be easily removed.
    mContactContextListHeaders = new LinearLayout(getView().getContext());
    mContactContextListView.addHeaderView(mContactContextListHeaders);

    mCallStateIcon = (ImageView) view.findViewById(R.id.callStateIcon);
    mCallStateVideoCallIcon = (ImageView) view.findViewById(R.id.videoCallIcon);
    mWorkProfileIcon = (ImageView) view.findViewById(R.id.workProfileIcon);
    mCallStateLabel = (TextView) view.findViewById(R.id.callStateLabel);
    mHdAudioIcon = (ImageView) view.findViewById(R.id.hdAudioIcon);
    mForwardIcon = (ImageView) view.findViewById(R.id.forwardIcon);
    mCallNumberAndLabel = view.findViewById(R.id.labelAndNumber);
    mCallTypeLabel = (TextView) view.findViewById(R.id.callTypeLabel);
    mElapsedTime = (TextView) view.findViewById(R.id.elapsedTime);
    mPrimaryCallCardContainer = view.findViewById(R.id.primary_call_info_container);
    mPrimaryCallInfo = (ViewGroup) view.findViewById(R.id.primary_call_banner);
    mCallButtonsContainer = view.findViewById(R.id.callButtonFragment);
    mPhotoSmall = (ImageView) view.findViewById(R.id.photoSmall);
    mPhotoSmall.setVisibility(View.GONE);
    mInCallMessageLabel = (TextView) view.findViewById(R.id.connectionServiceMessage);
    mProgressSpinner = view.findViewById(R.id.progressSpinner);

    mFloatingActionButtonContainer = view.findViewById(R.id.floating_end_call_action_button_container);
    mFloatingActionButton = (ImageButton) view.findViewById(R.id.floating_end_call_action_button);
    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getPresenter().endCallClicked();
        }
    });
    mFloatingActionButtonController = new FloatingActionButtonController(getActivity(),
            mFloatingActionButtonContainer, mFloatingActionButton);

    mSecondaryCallInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getPresenter().secondaryInfoClicked();
            updateFabPositionForSecondaryCallInfo();
        }
    });

    mCallStateButton = view.findViewById(R.id.callStateButton);
    mCallStateButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            getPresenter().onCallStateButtonTouched();
            return false;
        }
    });

    mManageConferenceCallButton = view.findViewById(R.id.manage_conference_call_button);
    mManageConferenceCallButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InCallActivity activity = (InCallActivity) getActivity();
            activity.showConferenceFragment(true);
        }
    });

    mPrimaryName.setElegantTextHeight(false);
    mCallStateLabel.setElegantTextHeight(false);
    mCallSubject = (TextView) view.findViewById(R.id.callSubject);
}

From source file:com.krayzk9s.imgurholo.ui.AlbumsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    boolean newData = false;
    if (savedInstanceState == null && urls == null) {
        urls = new ArrayList<String>();
        ids = new ArrayList<String>();
        newData = true;//www  .  j a v  a2  s. co  m
    } else if (savedInstanceState != null) {
        urls = savedInstanceState.getStringArrayList("urls");
        ids = savedInstanceState.getStringArrayList("ids");
    }
    View view = inflater.inflate(R.layout.image_layout, container, false);
    errorText = (TextView) view.findViewById(R.id.error);
    mPullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.ptr_layout);
    ActionBarPullToRefresh.from(getActivity())
            // Mark All Children as pullable
            .allChildrenArePullable()
            // Set the OnRefreshListener
            .listener(this)
            // Finally commit the setup to our PullToRefreshLayout
            .setup(mPullToRefreshLayout);
    ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) errorText.getLayoutParams();
    mlp.setMargins(0, 0, 0, 0);
    view.setPadding(0, getActivity().getActionBar().getHeight(), 0, 0);
    noImageView = (TextView) view.findViewById(R.id.no_images);
    GridView gridview = (GridView) view.findViewById(R.id.grid_layout);
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    SharedPreferences settings = activity.getApiCall().settings;
    gridview.setColumnWidth(Utils.dpToPx(
            Integer.parseInt(settings.getString(getString(R.string.icon_size), getString(R.string.onetwenty))),
            getActivity()));
    imageAdapter = new ImageAdapter(view.getContext());
    gridview.setAdapter(imageAdapter);
    gridview.setOnItemClickListener(new GridItemClickListener());
    if (newData) {
        getImages();
    }
    gridview.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {

        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int i2, int i3) {
            if (lastInView == -1)
                lastInView = firstVisibleItem;
            else if (lastInView > firstVisibleItem) {
                getActivity().getActionBar().show();
                lastInView = firstVisibleItem;
            } else if (lastInView < firstVisibleItem) {
                getActivity().getActionBar().hide();
                lastInView = firstVisibleItem;
            }
        }
    });
    return view;
}

From source file:ca.ualberta.app.activity.CreateQuestionActivity.java

/**
 * This method will be called when the current question is submitted, then
 * map the thread to the corresponding question and save all details into
 * the question.//from  ww  w  .  j  ava 2  s.co m
 * 
 * @param view
 *            View passed to the activity to check which button was pressed.
 */
public void submit_question(View view) {
    String title = titleText.getText().toString();
    String content = contentText.getText().toString();
    if (title.trim().length() == 0)
        noTitleEntered();
    else {
        if (edit == false) {
            newQuestion = new Question(content, User.author.getUserId(), title, imageString);
            if (addLocation == true) {
                newQuestion.setLocationName(locationName);
                newQuestion.setLocationCoordinates(locationCoordinates);
            }
            User.author.addAQuestion(newQuestion.getID());
        } else {
            newQuestion = new Question(content, User.author.getUserId(), title, imageString);
            newQuestion.setID(questionID);
        }
        if (InternetConnectionChecker.isNetworkAvailable()) {
            authorMapController.updateAuthor(this, User.author);
            Thread addQuestionThread = new AddQuestionThread(newQuestion);
            addQuestionThread.start();
            cacheController.addMyQuestion(view.getContext(), newQuestion);
        } else {
            if (edit == false) {
                Toast.makeText(this,
                        "Question added to Waiting List, it will be post when Internet is connected.",
                        Toast.LENGTH_LONG).show();
                pushController.addWaitngListQuestions(getApplicationContext(), newQuestion);
            } else {

                pushController.updateWaitingListQuestion(getApplicationContext(), newQuestion);
            }
            finish();
        }
    }
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * /*from   ww  w  . j av  a  2 s  .c om*/
 * @param arrayId
 * @param editViewId
 */
private void choose(final int arrayId, final int editViewId) {
    View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null);

    final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1).create();

    TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea);

    final ListView listView = new ListView(view1.getContext());

    listView.setAdapter(new ArrayAdapter<String>(view1.getContext(), android.R.layout.simple_list_item_1,
            view1.getResources().getStringArray(arrayId)));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            dialog.dismiss();
            String temp = (String) listView.getItemAtPosition(i);
            setEditViewText(rootView, editViewId, temp);
        }
    });

    contentArea.addView(listView);

    setTextView(view1, R.id.title, getResources().getString(R.string.alert));

    dialog.show();
}