Search in sources :

Example 21 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project weiui by kuaifan.

the class Tabbar method addPageView.

/**
 * 添加页面
 * @param barBean
 */
private void addPageView(TabbarBean barBean) {
    View view = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.layout_weiui_tabbar_page, null);
    SwipeRefreshLayout v_swipeRefresh = view.findViewById(R.id.v_swipeRefresh);
    FrameLayout v_container = view.findViewById(R.id.v_container);
    ProgressBar v_progress = view.findViewById(R.id.v_progress);
    // 
    WXSDKBean sdkBean = new WXSDKBean();
    sdkBean.setSwipeRefresh(v_swipeRefresh);
    sdkBean.setContainer(v_container);
    sdkBean.setProgress(v_progress);
    sdkBean.setView(barBean.getView());
    if (barBean.getView() instanceof String) {
        sdkBean.setType("urlView");
        WXSDKList.put(barBean.getTabName(), sdkBean);
        addWXSDKView(barBean.getTabName());
    } else if (barBean.getView() instanceof TabbarPageView) {
        sdkBean.setType("pageView");
        WXSDKList.put(barBean.getTabName(), sdkBean);
        addWXPageView(barBean.getTabName());
    }
    // 
    if (getDomObject().getEvents().contains(weiuiConstants.Event.REFRESH_LISTENER)) {
        sdkBean.getSwipeRefresh().setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
        sdkBean.getSwipeRefresh().setOnRefreshListener(() -> {
            Map<String, Object> data = new HashMap<>();
            data.put("tabName", barBean.getTabName());
            data.put("position", getTabPosition(barBean.getTabName()));
            fireEvent(weiuiConstants.Event.REFRESH_LISTENER, data);
        });
        sdkBean.setSwipeRefreshEnable(true);
    } else {
        sdkBean.setSwipeRefreshEnable(false);
        sdkBean.getSwipeRefresh().setEnabled(false);
    }
    // 
    mTabEntity.add(new TabbarEntity(barBean));
    mViewList.add(view);
    mTabPagerAdapter.setListViews(mViewList);
    mTabPagerAdapter.notifyDataSetChanged();
}
Also used : WXSDKBean(vip.kuaifan.weiui.ui.component.tabbar.bean.WXSDKBean) HashMap(java.util.HashMap) FrameLayout(android.widget.FrameLayout) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ProgressBar(android.widget.ProgressBar) TabbarEntity(vip.kuaifan.weiui.ui.component.tabbar.entity.TabbarEntity)

Example 22 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project CoordinatorLayoutDemo by JamFF.

the class ItemFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_item_list, container, false);
    View list = view.findViewById(R.id.list);
    if (view instanceof SwipeRefreshLayout) {
        mRefreshLayout = (SwipeRefreshLayout) view;
        mRefreshLayout.setOnRefreshListener(this);
        mRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.BLACK);
    }
    if (list instanceof RecyclerView) {
        // Set RecyclerView adapter
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) list;
        List<DataBean> beanList = new ArrayList<>();
        if (mOrientation != LinearLayout.VERTICAL && mOrientation != LinearLayout.HORIZONTAL) {
            mOrientation = LinearLayout.VERTICAL;
        }
        if (mColumnCount <= 1) {
            mColumnCount = 1;
            recyclerView.setLayoutManager(new LinearLayoutManager(context, mOrientation, mReverseLayout));
            for (int i = 0; i < DATAS.ICONS.length; i++) {
                DataBean bean = new DataBean();
                bean.setIcon(DATAS.ICONS[i]);
                bean.setName("图片-" + i);
                beanList.add(bean);
            }
        } else {
            if (mStaggered) {
                StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(mColumnCount, mOrientation);
                layoutManager.setReverseLayout(mReverseLayout);
                recyclerView.setLayoutManager(layoutManager);
                for (int i = 0; i < DATAS.PICS.length; i++) {
                    DataBean bean = new DataBean();
                    bean.setIcon(DATAS.PICS[i]);
                    bean.setName("图片-" + i);
                    beanList.add(bean);
                }
            } else {
                recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount, mOrientation, mReverseLayout));
                for (int i = 0; i < DATAS.ICONS.length; i++) {
                    DataBean bean = new DataBean();
                    bean.setIcon(DATAS.ICONS[i]);
                    bean.setName("图片-" + i);
                    beanList.add(bean);
                }
            }
        }
        recyclerView.setAdapter(new MyItemRecyclerViewAdapter(beanList, mColumnCount, mListener));
    }
    return view;
}
Also used : Context(android.content.Context) GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ArrayList(java.util.ArrayList) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DataBean(com.example.fj.second.model.DataBean) MyItemRecyclerViewAdapter(com.example.fj.second.adapter.MyItemRecyclerViewAdapter)

Example 23 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project TamTime by flyingrub.

the class LineRouteFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.view_swype_refresh, container, false);
    recyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
    circularIndeterminate = (ProgressBarCircularIndeterminate) view.findViewById(R.id.progressBarCircularIndeterminate);
    refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity());
    recyclerView.addItemDecoration(itemDecoration);
    direction = Data.getData().getMap().getLine(linePosition).getDirections().get(routePosition);
    adapter = new OneRouteAdapter(direction.getStops(), getContext(), isTheoritical);
    recyclerView.setAdapter(adapter);
    adapter.SetOnItemClickListener(new OneRouteAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View v, int position) {
            selectitem(position);
        }
    });
    if (isTheoritical) {
        getActivity().setTitle("Théorique : Ligne " + Data.getData().getMap().getLine(linePosition).getShortName());
    } else {
        getActivity().setTitle("Ligne " + Data.getData().getMap().getLine(linePosition).getShortName());
    }
    circularIndeterminate.setVisibility(View.GONE);
    refreshLayout.setVisibility(View.VISIBLE);
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            Data.getData().update();
        }
    });
    refreshLayout.setColorSchemeResources(R.color.primaryColor);
    setHasOptionsMenu(true);
    return view;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(flying.grub.tamtime.adapter.DividerItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) OneRouteAdapter(flying.grub.tamtime.adapter.OneRouteAdapter)

Example 24 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project TamTime by flyingrub.

the class StopLineFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.view_swype_refresh, container, false);
    recyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
    circularIndeterminate = (ProgressBarCircularIndeterminate) view.findViewById(R.id.progressBarCircularIndeterminate);
    refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
    recyclerView.setHasFixedSize(true);
    recyclerView.setBackgroundColor(getResources().getColor(R.color.windowBackgroundCard));
    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter = new OneStopAdapter(stopZone.getStops(line));
    recyclerView.setAdapter(adapter);
    adapter.SetOnItemClickListener(new OneStopAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View v, int position) {
        // Unneeded ?
        }
    });
    circularIndeterminate.setVisibility(View.GONE);
    refreshLayout.setVisibility(View.VISIBLE);
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            Data.getData().update();
        }
    });
    refreshLayout.setColorSchemeResources(R.color.primaryColor);
    return view;
}
Also used : OneStopAdapter(flying.grub.tamtime.adapter.OneStopAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 25 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project samourai-wallet-android by Samourai-Wallet.

the class BalanceActivity method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_balance);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    if (SamouraiWallet.getInstance().isTestNet()) {
        setTitle(getText(R.string.app_name) + ":" + "TestNet");
    }
    LayoutInflater inflator = BalanceActivity.this.getLayoutInflater();
    tvBalanceBar = (LinearLayout) inflator.inflate(R.layout.balance_layout, null);
    tvBalanceBar.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (isBTC) {
                isBTC = false;
            } else {
                isBTC = true;
            }
            displayBalance();
            txAdapter.notifyDataSetChanged();
            return false;
        }
    });
    tvBalanceAmount = (TextView) tvBalanceBar.findViewById(R.id.BalanceAmount);
    tvBalanceUnits = (TextView) tvBalanceBar.findViewById(R.id.BalanceUnits);
    ibQuickSend = (FloatingActionsMenu) findViewById(R.id.wallet_menu);
    actionSend = (FloatingActionButton) findViewById(R.id.send);
    actionSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(BalanceActivity.this, SendActivity.class);
            intent.putExtra("via_menu", true);
            startActivity(intent);
        }
    });
    actionReceive = (FloatingActionButton) findViewById(R.id.receive);
    actionReceive.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            try {
                HD_Wallet hdw = HD_WalletFactory.getInstance(BalanceActivity.this).get();
                if (hdw != null) {
                    Intent intent = new Intent(BalanceActivity.this, ReceiveActivity.class);
                    startActivity(intent);
                }
            } catch (IOException | MnemonicException.MnemonicLengthException e) {
                ;
            }
        }
    });
    actionBIP47 = (FloatingActionButton) findViewById(R.id.bip47);
    actionBIP47.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(BalanceActivity.this, com.samourai.wallet.bip47.BIP47Activity.class);
            startActivity(intent);
        }
    });
    txs = new ArrayList<Tx>();
    txStates = new HashMap<String, Boolean>();
    txList = (ListView) findViewById(R.id.txList);
    txAdapter = new TransactionAdapter();
    txList.setAdapter(txAdapter);
    txList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
            if (position == 0) {
                return;
            }
            long viewId = view.getId();
            View v = (View) view.getParent();
            final Tx tx = txs.get(position - 1);
            ImageView ivTxStatus = (ImageView) v.findViewById(R.id.TransactionStatus);
            TextView tvConfirmationCount = (TextView) v.findViewById(R.id.ConfirmationCount);
            if (viewId == R.id.ConfirmationCount || viewId == R.id.TransactionStatus) {
                if (txStates.containsKey(tx.getHash()) && txStates.get(tx.getHash()) == true) {
                    txStates.put(tx.getHash(), false);
                    displayTxStatus(false, tx.getConfirmations(), tvConfirmationCount, ivTxStatus);
                } else {
                    txStates.put(tx.getHash(), true);
                    displayTxStatus(true, tx.getConfirmations(), tvConfirmationCount, ivTxStatus);
                }
            } else {
                String message = getString(R.string.options_unconfirmed_tx);
                // RBF
                if (tx.getConfirmations() < 1 && tx.getAmount() < 0.0 && RBFUtil.getInstance().contains(tx.getHash())) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(BalanceActivity.this);
                    builder.setTitle(R.string.app_name);
                    builder.setMessage(message);
                    builder.setCancelable(true);
                    builder.setPositiveButton(R.string.options_bump_fee, new DialogInterface.OnClickListener() {

                        public void onClick(final DialogInterface dialog, int whichButton) {
                            if (rbfTask == null || rbfTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
                                rbfTask = new RBFTask();
                                rbfTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, tx.getHash());
                            }
                        }
                    });
                    builder.setNegativeButton(R.string.options_block_explorer, new DialogInterface.OnClickListener() {

                        public void onClick(final DialogInterface dialog, int whichButton) {
                            doExplorerView(tx.getHash());
                        }
                    });
                    AlertDialog alert = builder.create();
                    alert.show();
                } else // CPFP receive
                if (tx.getConfirmations() < 1 && tx.getAmount() >= 0.0) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(BalanceActivity.this);
                    builder.setTitle(R.string.app_name);
                    builder.setMessage(message);
                    builder.setCancelable(true);
                    builder.setPositiveButton(R.string.options_bump_fee, new DialogInterface.OnClickListener() {

                        public void onClick(final DialogInterface dialog, int whichButton) {
                            if (cpfpTask == null || cpfpTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
                                cpfpTask = new CPFPTask();
                                cpfpTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, tx.getHash());
                            }
                        }
                    });
                    builder.setNegativeButton(R.string.options_block_explorer, new DialogInterface.OnClickListener() {

                        public void onClick(final DialogInterface dialog, int whichButton) {
                            doExplorerView(tx.getHash());
                        }
                    });
                    AlertDialog alert = builder.create();
                    alert.show();
                } else // CPFP spend
                if (tx.getConfirmations() < 1 && tx.getAmount() < 0.0) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(BalanceActivity.this);
                    builder.setTitle(R.string.app_name);
                    builder.setMessage(message);
                    builder.setCancelable(true);
                    builder.setPositiveButton(R.string.options_bump_fee, new DialogInterface.OnClickListener() {

                        public void onClick(final DialogInterface dialog, int whichButton) {
                            if (cpfpTask == null || cpfpTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
                                cpfpTask = new CPFPTask();
                                cpfpTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, tx.getHash());
                            }
                        }
                    });
                    builder.setNegativeButton(R.string.options_block_explorer, new DialogInterface.OnClickListener() {

                        public void onClick(final DialogInterface dialog, int whichButton) {
                            doExplorerView(tx.getHash());
                        }
                    });
                    AlertDialog alert = builder.create();
                    alert.show();
                } else {
                    doExplorerView(tx.getHash());
                    return;
                }
            }
        }
    });
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().post(new Runnable() {

                @Override
                public void run() {
                    refreshTx(false, true, true, false);
                }
            });
        }
    });
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);
    IntentFilter filter = new IntentFilter(ACTION_INTENT);
    LocalBroadcastManager.getInstance(BalanceActivity.this).registerReceiver(receiver, filter);
    // TorUtil.getInstance(BalanceActivity.this).setStatusFromBroadcast(false);
    registerReceiver(torStatusReceiver, new IntentFilter(OrbotHelper.ACTION_STATUS));
    boolean notifTx = false;
    boolean fetch = false;
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey("notifTx")) {
        notifTx = extras.getBoolean("notifTx");
    }
    if (extras != null && extras.containsKey("uri")) {
        fetch = extras.getBoolean("fetch");
    }
    refreshTx(notifTx, fetch, false, true);
    if (PrefsUtil.getInstance(BalanceActivity.this).getValue(PrefsUtil.PAYNYM_CLAIMED, false) == false && PrefsUtil.getInstance(BalanceActivity.this).getValue(PrefsUtil.PAYNYM_REFUSED, false) == false) {
        doClaimPayNym();
    }
    if (!AppUtil.getInstance(BalanceActivity.this).isClipboardSeen()) {
        doClipboardCheck();
    }
}
Also used : AlertDialog(android.app.AlertDialog) HD_Wallet(com.samourai.wallet.hd.HD_Wallet) DialogInterface(android.content.DialogInterface) ScriptBuilder(org.bitcoinj.script.ScriptBuilder) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) MnemonicException(org.bitcoinj.crypto.MnemonicException) TextView(android.widget.TextView) ImageView(android.widget.ImageView) IntentFilter(android.content.IntentFilter) Tx(com.samourai.wallet.api.Tx) PushTx(com.samourai.wallet.send.PushTx) Bundle(android.os.Bundle) Handler(android.os.Handler) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) MotionEvent(android.view.MotionEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) AdapterView(android.widget.AdapterView)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)102 View (android.view.View)55 RecyclerView (android.support.v7.widget.RecyclerView)43 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)41 TextView (android.widget.TextView)29 Bundle (android.os.Bundle)21 Intent (android.content.Intent)17 Handler (android.os.Handler)17 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)16 AdapterView (android.widget.AdapterView)15 ListView (android.widget.ListView)15 ArrayList (java.util.ArrayList)13 ImageView (android.widget.ImageView)10 ViewGroup (android.view.ViewGroup)9 Context (android.content.Context)8 LayoutInflater (android.view.LayoutInflater)8 GridLayoutManager (android.support.v7.widget.GridLayoutManager)7 PandaRecyclerView (com.instructure.pandarecycler.PandaRecyclerView)7 SearchView (android.support.v7.widget.SearchView)6 Toolbar (android.support.v7.widget.Toolbar)6