Search in sources :

Example 56 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project AdMoney by ErnestoGonAr.

the class Ingresos method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragmefnt
    View rootView = inflater.inflate(R.layout.fragment_ingresos, container, false);
    rootView.setTag(TAG);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_ingresos);
    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    mLayoutManager = new LinearLayoutManager(getActivity());
    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);
    mAdapter = new CustomAdapter_Ingresos(mDataset);
    // Set CustomAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mAdapter);
    return rootView;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 57 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project AdMoney by ErnestoGonAr.

the class Gastos method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_gastos, container, false);
    rootView.setTag(TAG);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_gastos);
    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    mLayoutManager = new LinearLayoutManager(getActivity());
    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);
    mAdapter = new CustomAdapter(mDataset);
    // Set CustomAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mAdapter);
    return rootView;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 58 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Rashr by DsLNeXuS.

the class InformationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_information_list, container, false);
    // Set the adapter
    if (view instanceof RecyclerView) {
        final Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        ArrayList<InformationItem> items = new ArrayList<>();
        items.add(new InformationItem("Device Name", RashrApp.DEVICE.getName()));
        items.add(new InformationItem("Manufacture", RashrApp.DEVICE.getManufacture()));
        String recoveryType = "";
        boolean recoveryWithPath = false;
        boolean recoveryWithBS = false;
        switch(RashrApp.DEVICE.getRecoveryType()) {
            case Device.PARTITION_TYPE_DD:
                recoveryType = "DD";
                recoveryWithPath = true;
                recoveryWithBS = RashrApp.DEVICE.getRecoveryBlocksize() > 0;
                break;
            case Device.PARTITION_TYPE_MTD:
                recoveryType = "MTD";
                break;
            case Device.PARTITION_TYPE_RECOVERY:
                recoveryType = "Flash over current Recovery";
                break;
            case Device.PARTITION_TYPE_NOT_SUPPORTED:
                recoveryType = "Not supported";
                break;
        }
        String kernelType = "";
        boolean kernelWithPath = false;
        boolean kernelWithBS = false;
        switch(RashrApp.DEVICE.getKernelType()) {
            case Device.PARTITION_TYPE_DD:
                kernelType = "DD";
                kernelWithPath = true;
                kernelWithBS = RashrApp.DEVICE.getKernelBlocksize() > 0;
                break;
            case Device.PARTITION_TYPE_MTD:
                kernelType = "MTD";
                break;
            case Device.PARTITION_TYPE_RECOVERY:
                kernelType = "Flash over current Recovery";
                break;
            case Device.PARTITION_TYPE_NOT_SUPPORTED:
                kernelType = "Not supported";
        }
        items.add(new InformationItem(getString(R.string.recovery_type), recoveryType));
        if (recoveryWithPath)
            items.add(new InformationItem("Recovery Path", RashrApp.DEVICE.getRecoveryPath()));
        if (recoveryWithBS)
            items.add(new InformationItem("Recovery Blocksize", String.valueOf(RashrApp.DEVICE.getRecoveryBlocksize())));
        items.add(new InformationItem("Kernel Partition Type", kernelType));
        if (kernelWithPath)
            items.add(new InformationItem("Kernel Path", RashrApp.DEVICE.getKernelPath()));
        if (kernelWithBS)
            items.add(new InformationItem("Kernel Blocksize", String.valueOf(RashrApp.DEVICE.getKernelBlocksize())));
        int total = 0;
        if (RashrApp.DEVICE.isCwmRecoverySupported()) {
            int tmp = RashrApp.DEVICE.getCwmRecoveryVersions().size();
            items.add(new InformationItem(getString(R.string.sCWM), String.valueOf(tmp)));
            total += tmp;
        }
        if (RashrApp.DEVICE.isTwrpRecoverySupported()) {
            int tmp = RashrApp.DEVICE.getTwrpRecoveryVersions().size();
            items.add(new InformationItem("TWRP Images", String.valueOf(tmp)));
            total += tmp;
        }
        if (RashrApp.DEVICE.isPhilzRecoverySupported()) {
            int tmp = RashrApp.DEVICE.getPhilzRecoveryVersions().size();
            items.add(new InformationItem("Philz Images", String.valueOf(tmp)));
            total += tmp;
        }
        if (RashrApp.DEVICE.isXZDualRecoverySupported()) {
            int tmp = RashrApp.DEVICE.getXZDualRecoveryVersions().size();
            items.add(new InformationItem("XZDual Images", String.valueOf(tmp)));
            total += tmp;
        }
        if (RashrApp.DEVICE.isStockRecoverySupported()) {
            int tmp = RashrApp.DEVICE.getStockRecoveryVersions().size();
            items.add(new InformationItem(getString(R.string.stock_recovery), String.valueOf(tmp)));
            total += tmp;
        }
        if (RashrApp.DEVICE.isStockKernelSupported()) {
            int tmp = RashrApp.DEVICE.getStockKernelVersions().size();
            items.add(new InformationItem(getString(R.string.stock_kernel), String.valueOf(tmp)));
            total += tmp;
        }
        items.add(new InformationItem(getString(R.string.total_images), String.valueOf(total)));
        for (String err : RashrApp.ERRORS) {
            items.add(new InformationItem("Error:", err));
        }
        recyclerView.setAdapter(new InformationRecyclerViewAdapter(items));
    }
    return view;
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 59 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Rashr by DsLNeXuS.

the class RecoverySystemFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    mActivity = (RashrActivity) getActivity();
    final ScrollView root = (ScrollView) inflater.inflate(R.layout.fragment_recovery_system, container, false);
    mContext = root.getContext();
    final AppCompatTextView tvTitle = (AppCompatTextView) root.findViewById(R.id.tvSysName);
    tvTitle.setText(mTitle.toUpperCase());
    final AppCompatTextView tvDesc = (AppCompatTextView) root.findViewById(R.id.tvRecSysDesc);
    tvDesc.setText(mDesc);
    final AppCompatSpinner spVersions = (AppCompatSpinner) root.findViewById(R.id.spVersions);
    ArrayList<String> formatedVersions = new ArrayList<>();
    for (String versionLinks : mVersions) {
        formatedVersions.add(formatName(versionLinks, mTitle));
    }
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(root.getContext(), android.R.layout.simple_list_item_1, formatedVersions);
    spVersions.setAdapter(adapter);
    spVersions.setSelection(0);
    final AppCompatTextView tvDev = (AppCompatTextView) root.findViewById(R.id.tvDevName);
    tvDev.setText(mDev);
    final AppCompatImageView imLogo = (AppCompatImageView) root.findViewById(R.id.ivRecLogo);
    if (mLogo == 0) {
        root.removeView(imLogo);
    } else {
        imLogo.setImageResource(mLogo);
    }
    final AppCompatButton bFlash = (AppCompatButton) root.findViewById(R.id.bFlashRecovery);
    bFlash.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            flashSupportedRecovery(mTitle, mVersions.get(spVersions.getSelectedItemPosition()));
        }
    });
    final LinearLayout ScreenshotLayout = (LinearLayout) root.findViewById(R.id.ScreenshotLayout);
    if (mScreenshotURL == null) {
        ((ViewGroup) ScreenshotLayout.getParent()).removeView(ScreenshotLayout);
    } else {
        try {
            Downloader jsonDownloader = new Downloader(new URL(mScreenshotURL + "/getScreenshots.php"), new File(mContext.getExternalCacheDir(), "screenhots.json"));
            jsonDownloader.setOverrideFile(true);
            jsonDownloader.setOnDownloadListener(new Downloader.OnDownloadListener() {

                @Override
                public void onSuccess(File file) {
                    try {
                        JSONArray arr = new JSONArray(Common.fileContent(file));
                        for (int i = 0; i < arr.length(); i++) {
                            final String name = arr.get(i).toString();
                            if (name.equals(".") || name.equals("..") || name.equals("getScreenshots.php"))
                                continue;
                            Downloader imageDownloader = new Downloader(new URL(mScreenshotURL + "/" + name), new File(file.getParentFile(), name));
                            //Do not redownload predownloaded images
                            imageDownloader.setOverrideFile(false);
                            imageDownloader.setOnDownloadListener(new Downloader.OnDownloadListener() {

                                @Override
                                public void onSuccess(File file) {
                                    AppCompatImageView iv = (AppCompatImageView) inflater.inflate(R.layout.recovery_screenshot, null);
                                    try {
                                        final BitmapFactory.Options options = new BitmapFactory.Options();
                                        options.inSampleSize = 8;
                                        Bitmap screenshot = BitmapFactory.decodeFile(file.toString());
                                        iv.setImageBitmap(screenshot);
                                        ScreenshotLayout.addView(iv);
                                    } catch (OutOfMemoryError e) {
                                        App.ERRORS.add("Screenshot " + file.toString() + " could not be decoded " + e.toString());
                                    }
                                }

                                @Override
                                public void onFail(Exception e) {
                                }
                            });
                            imageDownloader.download();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        onFail(e);
                    }
                }

                @Override
                public void onFail(Exception e) {
                    e.printStackTrace();
                }
            });
            jsonDownloader.download();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    return root;
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) Downloader(de.mkrtchyan.utils.Downloader) URL(java.net.URL) Bitmap(android.graphics.Bitmap) BitmapFactory(android.graphics.BitmapFactory) ViewGroup(android.view.ViewGroup) AppCompatTextView(android.support.v7.widget.AppCompatTextView) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) IOException(java.io.IOException) AppCompatImageView(android.support.v7.widget.AppCompatImageView) View(android.view.View) AppCompatImageView(android.support.v7.widget.AppCompatImageView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ScrollView(android.widget.ScrollView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) JSONException(org.json.JSONException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) AppCompatButton(android.support.v7.widget.AppCompatButton) ScrollView(android.widget.ScrollView) File(java.io.File) ArrayAdapter(android.widget.ArrayAdapter) LinearLayout(android.widget.LinearLayout)

Example 60 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project CloudReader by youlookwhat.

the class AndroidFragment method setAdapter.

/**
     * 设置adapter
     */
private void setAdapter(GankIoDataBean mAndroidBean) {
    mAndroidAdapter.clear();
    mAndroidAdapter.addAll(mAndroidBean.getResults());
    bindingView.xrvAndroid.setLayoutManager(new LinearLayoutManager(getActivity()));
    bindingView.xrvAndroid.setAdapter(mAndroidAdapter);
    mAndroidAdapter.notifyDataSetChanged();
    bindingView.xrvAndroid.refreshComplete();
    mIsFirst = false;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)688 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)612 View (android.view.View)593 TextView (android.widget.TextView)245 ArrayList (java.util.ArrayList)179 Intent (android.content.Intent)148 ImageView (android.widget.ImageView)132 Toolbar (android.support.v7.widget.Toolbar)118 GridLayoutManager (android.support.v7.widget.GridLayoutManager)111 AdapterView (android.widget.AdapterView)109 ViewGroup (android.view.ViewGroup)97 AlertDialog (android.support.v7.app.AlertDialog)91 Bundle (android.os.Bundle)85 ListView (android.widget.ListView)85 BindView (butterknife.BindView)85 Nullable (android.support.annotation.Nullable)78 DialogInterface (android.content.DialogInterface)71 Context (android.content.Context)65 ArrayAdapter (android.widget.ArrayAdapter)65 LayoutInflater (android.view.LayoutInflater)64