Search in sources :

Example 6 with NetworkImageView

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

the class PlanFragment method showPlans.

private void showPlans() {
    if (!isAdded())
        return;
    if (mPlanDetails == null) {
        // TODO This should never happen - Fix this. Close the activity?
        AppLog.w(AppLog.T.PLANS, "empty plan data in fragment");
        return;
    }
    int iconSize = getActivity().getResources().getDimensionPixelSize(R.dimen.plan_icon_size);
    NetworkImageView imgPlan = (NetworkImageView) getView().findViewById(R.id.image_plan_icon);
    String iconUrl = PlansUtils.getIconUrlForPlan(mPlanDetails, iconSize);
    if (!TextUtils.isEmpty(iconUrl)) {
        imgPlan.setImageUrl(iconUrl, WordPress.sImageLoader);
        imgPlan.setVisibility(View.VISIBLE);
    } else {
        imgPlan.setVisibility(View.GONE);
    }
    // show product short name in bold, ex: "WordPress.com <b>Premium</b>"
    TextView txtProductName = (TextView) getView().findViewById(R.id.text_product_name);
    String productShortName = mPlanDetails.getProductNameShort();
    String productName = mPlanDetails.getProductName().replace(productShortName, "<b>" + productShortName + "</b>");
    txtProductName.setText(Html.fromHtml(productName));
    TextView txtTagLine = (TextView) getView().findViewById(R.id.text_tagline);
    txtTagLine.setText(HtmlUtils.fastUnescapeHtml(mPlanDetails.getTagline()));
    addFeaturesToHighlight();
}
Also used : NetworkImageView(com.android.volley.toolbox.NetworkImageView) TextView(android.widget.TextView)

Example 7 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project Riksdagskollen by OAndell.

the class DocumentReaderActivity method populateViewWithDocumentInformation.

/**
 * Fills contentview with content as soon as it has been fethced from the server
 */
private void populateViewWithDocumentInformation() {
    TextView titleTV = findViewById(R.id.act_doc_reader_title);
    TextView authorTV = findViewById(R.id.act_doc_reader_author);
    final TextView recipientTV = findViewById(R.id.act_doc_reader_recipient);
    TextView body = findViewById(R.id.act_doc_reader_body);
    portaitContainer = findViewById(R.id.act_doc_reader_portrait_container);
    for (Intressent i : document.getDokintressent().getIntressenter()) {
        final View portraitView;
        TextView nameTv;
        if (i.getRoll().equals("undertecknare")) {
            portraitView = LayoutInflater.from(this).inflate(R.layout.intressent_layout, null);
            final NetworkImageView portrait = portraitView.findViewById(R.id.intressent_portait);
            portrait.setDefaultImageResId(R.mipmap.ic_default_person);
            nameTv = portraitView.findViewById(R.id.intressent_name);
            nameTv.setText(i.getNamn() + " (" + i.getPartibet() + ")");
            app.getRiksdagenAPIManager().getRepresentative(i.getIntressent_id(), new RepresentativeCallback() {

                @Override
                public void onPersonFetched(Representative representative) {
                    portrait.setImageUrl(representative.getBild_url_192(), app.getRequestManager().getmImageLoader());
                }

                @Override
                public void onFail(VolleyError error) {
                }
            });
            portaitContainer.addView(portraitView);
        }
    }
    titleTV.setText(document.getTitel());
    authorTV.setText(String.format("av %s", document.getUndertitel()));
    // TODO: ta ut den riktiga mottagaren ur texten och sätt den här
    recipientTV.setText("Till en person");
    body.setText(docBody);
}
Also used : VolleyError(com.android.volley.VolleyError) Intressent(oscar.riksdagskollen.Utilities.JSONModels.Intressent) NetworkImageView(com.android.volley.toolbox.NetworkImageView) TextView(android.widget.TextView) Representative(oscar.riksdagskollen.Utilities.JSONModels.Representative) RepresentativeCallback(oscar.riksdagskollen.Utilities.Callbacks.RepresentativeCallback) NetworkImageView(com.android.volley.toolbox.NetworkImageView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with NetworkImageView

use of com.android.volley.toolbox.NetworkImageView in project Riksdagskollen by OAndell.

the class MotionActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_motion);
    document = getIntent().getParcelableExtra("document");
    TextView titleTV = findViewById(R.id.act_doc_reader_title);
    TextView authorTV = findViewById(R.id.act_doc_reader_author);
    loadingView = findViewById(R.id.loading_view);
    context = this;
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle("Motion");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    titleTV.setText(document.getTitel());
    authorTV.setText(document.getUndertitel());
    WebViewClient webViewClient = new CustomWebViewClient();
    final WebView webView = findViewById(R.id.webview);
    webView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, final int newProgress) {
            if (newProgress == 100) {
                loadingView.setVisibility(View.GONE);
            }
        }
    });
    webView.setWebViewClient(webViewClient);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setInitialScale(1);
    // Disable text-select to make consistent with rest of app
    webView.setLongClickable(false);
    webView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            return true;
        }
    });
    final RikdagskollenApp app = RikdagskollenApp.getInstance();
    app.getRiksdagenAPIManager().getDocumentBody(document, new StringRequestCallback() {

        @Override
        public void onResponse(String response) {
            Document doc = Jsoup.parse(response);
            // Remove title
            doc.head().append("<meta name=\"viewport\" content='width=device-width, initial-scale=2.0,text/html, charset='utf-8'>\n");
            doc.head().appendElement("link").attr("rel", "stylesheet").attr("type", "text/css").attr("href", "motion_style.css");
            doc.select("div>span.sidhuvud_publikation").remove();
            doc.select("div>span.sidhuvud_beteckning").remove();
            doc.select("div>span.MotionarLista").remove();
            doc.select("div.pconf>h1").remove();
            doc.select("div>hr.sidhuvud_linje").remove();
            doc.select("head>style").remove();
            doc.select("body>div>br").remove();
            // Clear default styling
            String result = doc.toString().replaceAll("class=\\\"[A-Öa-ö0-9]+\\\"", "");
            result = result.replaceAll("style=\"[A-Öa-ö-_:;\\s0-9.%']+\"", "");
            webView.loadDataWithBaseURL("file:///android_asset/", result, "text/html", "UTF-8", null);
            System.out.println(result);
        }

        @Override
        public void onFail(VolleyError error) {
        }
    });
    LinearLayout portaitContainer = findViewById(R.id.act_doc_reader_portrait_container);
    for (Intressent i : document.getDokintressent().getIntressenter()) {
        final View portraitView;
        TextView nameTv;
        if (i.getRoll().equals("undertecknare")) {
            portraitView = LayoutInflater.from(this).inflate(R.layout.intressent_layout, null);
            final NetworkImageView portrait = portraitView.findViewById(R.id.intressent_portait);
            portrait.setDefaultImageResId(R.mipmap.ic_default_person);
            nameTv = portraitView.findViewById(R.id.intressent_name);
            nameTv.setText(i.getNamn() + " (" + i.getPartibet() + ")");
            app.getRiksdagenAPIManager().getRepresentative(i.getIntressent_id(), new RepresentativeCallback() {

                @Override
                public void onPersonFetched(Representative representative) {
                    portrait.setImageUrl(representative.getBild_url_192(), app.getRequestManager().getmImageLoader());
                }

                @Override
                public void onFail(VolleyError error) {
                }
            });
            portaitContainer.addView(portraitView);
        }
    }
}
Also used : VolleyError(com.android.volley.VolleyError) RikdagskollenApp(oscar.riksdagskollen.RikdagskollenApp) Intressent(oscar.riksdagskollen.Utilities.JSONModels.Intressent) NetworkImageView(com.android.volley.toolbox.NetworkImageView) StringRequestCallback(oscar.riksdagskollen.Utilities.JSONModels.StringRequestCallback) PartyDocument(oscar.riksdagskollen.Utilities.JSONModels.PartyDocument) Document(org.jsoup.nodes.Document) RepresentativeCallback(oscar.riksdagskollen.Utilities.Callbacks.RepresentativeCallback) NetworkImageView(com.android.volley.toolbox.NetworkImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) WebChromeClient(android.webkit.WebChromeClient) TextView(android.widget.TextView) Representative(oscar.riksdagskollen.Utilities.JSONModels.Representative) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar) WebViewClient(android.webkit.WebViewClient)

Example 9 with NetworkImageView

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

the class ProductListActivity method initCollapsingToolbar.

private void initCollapsingToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.AppBar);
    int collapsingToolbarImageIndex = 6;
    int collapsingImageToolbarSize = 1200;
    NetworkImageView collapsingToolbarImage = (NetworkImageView) findViewById(R.id.CollapsingToolbarImage);
    StringBuilder collapsingToolbarImageUrl = new StringBuilder(productEntryList.get(collapsingToolbarImageIndex).url);
    collapsingToolbarImageUrl.append("=s");
    collapsingToolbarImageUrl.append(collapsingImageToolbarSize);
    setSupportActionBar(toolbar);
    CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.CollapsingToolbarLayout);
    collapsingToolbarLayout.setTitle(toolbar.getTitle());
    collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.TextAppearance_Shrine_Logo);
    collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.TextAppearance_Shrine_Logo);
    imageRequester.setImageFromUrl(collapsingToolbarImage, collapsingToolbarImageUrl.toString());
    Point windowSize = new Point();
    getWindowManager().getDefaultDisplay().getSize(windowSize);
    int windowWidth = windowSize.x;
    collapsingToolbarImage.setX(collapsingToolbarImage.getX() - windowWidth / 4);
    collapsingToolbarLayout.setScrimVisibleHeightTrigger((int) getResources().getDimension(R.dimen.shrine_tall_toolbar_height) / 2);
}
Also used : NetworkImageView(com.android.volley.toolbox.NetworkImageView) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) Point(android.graphics.Point) Point(android.graphics.Point) Toolbar(android.support.v7.widget.Toolbar)

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