Search in sources :

Example 1 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project WordPress-Android by wordpress-mobile.

the class EditPostSettingsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.edit_post_settings_fragment, container, false);
    if (rootView == null || mPost == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    mHour = c.get(Calendar.HOUR_OF_DAY);
    mMinute = c.get(Calendar.MINUTE);
    mExcerptEditText = (EditText) rootView.findViewById(R.id.postExcerpt);
    mPasswordEditText = (EditText) rootView.findViewById(R.id.post_password);
    mPubDateText = (TextView) rootView.findViewById(R.id.pubDate);
    mPubDateText.setOnClickListener(this);
    mStatusSpinner = (Spinner) rootView.findViewById(R.id.status);
    mStatusSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updatePostSettingsAndSaveButton();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mSectionCategories = ((ViewGroup) rootView.findViewById(R.id.sectionCategories));
    TextView featuredImageLabel = (TextView) rootView.findViewById(R.id.featuredImageLabel);
    mFeaturedImageView = (NetworkImageView) rootView.findViewById(R.id.featuredImage);
    mFeaturedImageButton = (Button) rootView.findViewById(R.id.addFeaturedImage);
    if (AppPrefs.isVisualEditorEnabled() || AppPrefs.isAztecEditorEnabled()) {
        registerForContextMenu(mFeaturedImageView);
        mFeaturedImageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                view.showContextMenu();
            }
        });
        mFeaturedImageButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                launchMediaGalleryActivity();
            }
        });
    } else {
        featuredImageLabel.setVisibility(View.GONE);
        mFeaturedImageView.setVisibility(View.GONE);
        mFeaturedImageButton.setVisibility(View.GONE);
    }
    if (mPost.isPage()) {
        // remove post specific views
        mExcerptEditText.setVisibility(View.GONE);
        rootView.findViewById(R.id.sectionTags).setVisibility(View.GONE);
        rootView.findViewById(R.id.sectionCategories).setVisibility(View.GONE);
        rootView.findViewById(R.id.postFormatLabel).setVisibility(View.GONE);
        rootView.findViewById(R.id.postFormat).setVisibility(View.GONE);
    } else {
        // Default values
        mPostFormatKeys = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.post_format_keys)));
        mPostFormatNames = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.post_format_display_names)));
        // If we have specific values for this site, use them
        List<PostFormatModel> postFormatModels = mSiteStore.getPostFormats(mSite);
        for (PostFormatModel postFormatModel : postFormatModels) {
            if (!mPostFormatKeys.contains(postFormatModel.getSlug())) {
                mPostFormatKeys.add(postFormatModel.getSlug());
                mPostFormatNames.add(postFormatModel.getDisplayName());
            }
        }
        // Set up the Post Format spinner
        mPostFormatSpinner = (Spinner) rootView.findViewById(R.id.postFormat);
        ArrayAdapter<String> pfAdapter = new ArrayAdapter<>(getActivity(), R.layout.simple_spinner_item, mPostFormatNames);
        pfAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mPostFormatSpinner.setAdapter(pfAdapter);
        String activePostFormat = POST_FORMAT_STANDARD_KEY;
        if (!TextUtils.isEmpty(mPost.getPostFormat())) {
            activePostFormat = mPost.getPostFormat();
        }
        for (int i = 0; i < mPostFormatKeys.size(); i++) {
            if (mPostFormatKeys.get(i).equals(activePostFormat))
                mPostFormatSpinner.setSelection(i);
        }
        mPostFormatSpinner.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                return false;
            }
        });
        mTagsEditText = (SuggestionAutoCompleteText) rootView.findViewById(R.id.tags);
        if (mTagsEditText != null) {
            mTagsEditText.setTokenizer(new SuggestionAutoCompleteText.CommaTokenizer());
            setupSuggestionServiceAndAdapter();
        }
    }
    initSettingsFields();
    populateSelectedCategories();
    initLocation(rootView);
    return rootView;
}
Also used : PostFormatModel(org.wordpress.android.fluxc.model.PostFormatModel) ViewGroup(android.view.ViewGroup) Calendar(java.util.Calendar) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) NetworkImageView(com.android.volley.toolbox.NetworkImageView) MotionEvent(android.view.MotionEvent) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ArrayAdapter(android.widget.ArrayAdapter) SuggestionAutoCompleteText(org.wordpress.android.widgets.SuggestionAutoCompleteText)

Example 2 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project WordPress-Android by wordpress-mobile.

the class PlanFragment method addFeature.

private void addFeature(Feature feature) {
    if (feature == null)
        return;
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.plan_feature_item, mPlanContainerView, false);
    TextView txtTitle = (TextView) view.findViewById(R.id.text_feature_title);
    TextView txtDescription = (TextView) view.findViewById(R.id.text_feature_description);
    String title = HtmlUtils.fastUnescapeHtml(feature.getTitleForPlan(mPlanDetails.getProductID()));
    String description = HtmlUtils.fastUnescapeHtml(feature.getDescriptionForPlan(mPlanDetails.getProductID()));
    txtTitle.setText(title);
    txtDescription.setText(description);
    // TODO: right now icon is always empty, so we show noticon_publish as a placeholder
    NetworkImageView imgIcon = (NetworkImageView) view.findViewById(R.id.image_icon);
    String iconUrl = feature.getIconForPlan(mPlanDetails.getProductID());
    if (!TextUtils.isEmpty(iconUrl)) {
        imgIcon.setImageUrl(iconUrl, WordPress.sImageLoader);
    } else {
        imgIcon.setDefaultImageResId(R.drawable.ic_reader_blue_wordpress_18dp);
    }
    mPlanContainerView.addView(view);
}
Also used : ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) NetworkImageView(com.android.volley.toolbox.NetworkImageView) TextView(android.widget.TextView)

Example 3 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project WordPress-Android by wordpress-mobile.

the class ThemeBrowserFragment method onMovedToScrapHeap.

@Override
public void onMovedToScrapHeap(View view) {
    // cancel image fetch requests if the view has been moved to recycler.
    NetworkImageView niv = (NetworkImageView) view.findViewById(R.id.theme_grid_item_image);
    if (niv != null) {
        // this tag is set in the ThemeBrowserAdapter class
        String requestUrl = (String) niv.getTag();
        if (requestUrl != null) {
            // need a listener to cancel request, even if the listener does nothing
            ImageContainer container = WordPress.sImageLoader.get(requestUrl, new ImageListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                }

                @Override
                public void onResponse(ImageContainer response, boolean isImmediate) {
                }
            });
            container.cancelRequest();
        }
    }
}
Also used : VolleyError(com.android.volley.VolleyError) ImageListener(com.android.volley.toolbox.ImageLoader.ImageListener) NetworkImageView(com.android.volley.toolbox.NetworkImageView) ImageContainer(com.android.volley.toolbox.ImageLoader.ImageContainer)

Example 4 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project iosched by google.

the class ItemActivity method populateProductViews.

private void populateProductViews() {
    Bundle bundle = getIntent().getExtras();
    if (bundle == null) {
        String error = "Error retrieving product information.";
        Log.e(TAG, error);
        Snackbar.make(findViewById(R.id.ProductTitle), error, Snackbar.LENGTH_SHORT).show();
        fabMessage = error;
    } else {
        TextView productTitle = (TextView) findViewById(R.id.ProductTitle);
        productTitle.setText(bundle.getString(PRODUCT_TITLE));
        TextView productDescription = (TextView) findViewById(R.id.ProductDescription);
        productDescription.setText(bundle.getString(PRODUCT_DESCRIPTION));
        initSpinner();
        NetworkImageView productImage = (NetworkImageView) findViewById(R.id.ProductImage);
        ImageRequester.getInstance(this).setImageFromUrl(productImage, bundle.getString(PRODUCT_URL));
        fabMessage = getString(R.string.shrine_product_added_message);
    }
}
Also used : Bundle(android.os.Bundle) NetworkImageView(com.android.volley.toolbox.NetworkImageView) TextView(android.widget.TextView)

Example 5 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project Awful.apk by Awful.

the class AwfulEmote method getView.

public static void getView(View current, AwfulPreferences aPref, Cursor data) {
    TextView emoteText = (TextView) current.findViewById(R.id.emote_text);
    emoteText.setText(data.getString(data.getColumnIndex(TEXT)));
    emoteText.setTextColor(current.getResources().getColor(R.color.default_post_font));
    NetworkImageView emoteImage = (NetworkImageView) current.findViewById(R.id.emote_icon);
    emoteImage.setImageUrl(data.getString(data.getColumnIndex(URL)), NetworkUtils.getImageLoader());
}
Also used : NetworkImageView(com.android.volley.toolbox.NetworkImageView) TextView(android.widget.TextView)

Aggregations

NetworkImageView (com.android.volley.toolbox.NetworkImageView)9 TextView (android.widget.TextView)7 View (android.view.View)3 VolleyError (com.android.volley.VolleyError)3 Toolbar (android.support.v7.widget.Toolbar)2 ViewGroup (android.view.ViewGroup)2 RepresentativeCallback (oscar.riksdagskollen.Utilities.Callbacks.RepresentativeCallback)2 Intressent (oscar.riksdagskollen.Utilities.JSONModels.Intressent)2 Representative (oscar.riksdagskollen.Utilities.JSONModels.Representative)2 Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)1 LayoutInflater (android.view.LayoutInflater)1 MotionEvent (android.view.MotionEvent)1 WebChromeClient (android.webkit.WebChromeClient)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 LinearLayout (android.widget.LinearLayout)1