Android Open Source - Android-MarketBin Fragment Multiple






From Project

Back to project page Android-MarketBin.

License

The source code is released under:

MIT License

If you think the Android project Android-MarketBin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.haunted.marketbin.sample;
//  ww w  .  j  av  a2  s  . c om
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.haunted.marketbin.IMarketDescriptor;
import com.haunted.marketbin.MarketBin;
import com.haunted.marketbin.MarketLocator;
import com.haunted.marketbin.MarketUI;

import java.util.ArrayList;
import java.util.List;

public class FragmentMultiple extends Fragment {
    private ViewGroup phAvailableMarkets;
    private ViewGroup phUnavailableMarkets;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_multiple, container, false);
        assert v != null;
        phAvailableMarkets = (ViewGroup) v.findViewById(R.id.phAvailableMarkets);
        phUnavailableMarkets = (ViewGroup) v.findViewById(R.id.phUnavailableMarkets);
        return v;
    }

    @Override
    public void onResume() {
        super.onResume();
        MarketLocator locator = new MarketLocator(getActivity());
        ArrayList<? extends IMarketDescriptor> markets = MarketBin.getAllKnown();
        List<IMarketDescriptor> availableMarkets = locator.findAll(markets, true, true);
        if (availableMarkets != null && availableMarkets.size() > 0) {
            phAvailableMarkets.removeAllViews();
            for(IMarketDescriptor m: availableMarkets) {
                TextView tvLink = new TextView(getActivity());
                MarketUI.bindAppLink(tvLink, m, MainActivity.demoAppId);
                phAvailableMarkets.addView(tvLink);
                tvLink.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
                tvLink.setPadding(0, 7, 0, 7);
                markets.remove(m);
            }
        }

        if (markets.size() > 0) {
            phUnavailableMarkets.removeAllViews();
            for(IMarketDescriptor m: markets) {
                TextView tvName = new TextView(getActivity());
                tvName.setText(m.getMarketName());
                phUnavailableMarkets.addView(tvName);
            }
        }
    }
}




Java Source Code List

com.haunted.marketbin.IMarketDescriptor.java
com.haunted.marketbin.MarketBin.java
com.haunted.marketbin.MarketDescriptor.java
com.haunted.marketbin.MarketLocator.java
com.haunted.marketbin.MarketUI.java
com.haunted.marketbin.sample.FragmentCredits.java
com.haunted.marketbin.sample.FragmentMultiple.java
com.haunted.marketbin.sample.FragmentSingle.java
com.haunted.marketbin.sample.MainActivity.java
com.haunted.marketbin.sample.PackageDialogFragment.java