Example usage for android.util SparseArray SparseArray

List of usage examples for android.util SparseArray SparseArray

Introduction

In this page you can find the example usage for android.util SparseArray SparseArray.

Prototype

public SparseArray() 

Source Link

Document

Creates a new SparseArray containing no mappings.

Usage

From source file:com.powermonitor.epitech.Charts.LineChartFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
    View v = inflater.inflate(R.layout.linechart, container, false);
    title = (TextView) v.findViewById(R.id.title);
    if (!titleStr.isEmpty())
        title.setText(titleStr);//from w ww .  j av a  2s  .com
    this.chart = (LineChart) v.findViewById(R.Charts.LineChart);
    sets = new ArrayList<LineDataSet>();
    xVals = new ArrayList<String>();
    dates = new SparseArray<String>();
    data = new LineData(xVals, sets);
    setsSave = new SparseArray<LineDataSet>();
    colors = new int[] { color.holo_blue_dark, color.holo_green_dark, color.holo_orange_dark, color.holo_purple,
            color.holo_red_dark };

    this.chart.setData(data);
    this.chart.getXAxis().setPosition(XAxis.XAxisPosition.TOP);
    this.chart.setDescription("");
    this.chart.getAxisRight().setEnabled(false);
    return v;
}

From source file:com.nightlynexus.viewstatepageradapter.ViewStatePagerAdapter.java

@Override
public final Object instantiateItem(ViewGroup container, int position) {
    if (detached == null) {
        detached = new SparseArray<>();
    }/*from ww w  .j ava 2 s . c  om*/
    View view = createView(container, position);
    if (view == null) {
        throw new NullPointerException("createView must not return null. (position: " + position + ")");
    }
    SparseArray<Parcelable> viewState = detached.get(position);
    if (viewState != null) {
        view.restoreHierarchyState(viewState);
    }
    container.addView(view);
    attached.put(position, view);
    return view;
}

From source file:com.xlythe.engine.theme.Theme.java

@SuppressWarnings("rawtypes")
public static void buildResourceMap(Class r) {
    RES_MAP = new SparseArray<Theme.Res>();
    try {//from w w  w.  j a v  a 2 s. com
        Log.d("Theme", "Building resource map");

        Class color = Class.forName(r.getName() + "$color");
        for (Field f : color.getFields()) {
            RES_MAP.put(f.getInt(null), new Res(COLOR, f.getName()));
        }
        Log.d("Theme", "color loaded");

        Class drawable = Class.forName(r.getName() + "$drawable");
        for (Field f : drawable.getFields()) {
            RES_MAP.put(f.getInt(null), new Res(DRAWABLE, f.getName()));
        }
        Log.d("Theme", "drawable loaded");

        Class bool = Class.forName(r.getName() + "$bool");
        for (Field f : bool.getFields()) {
            RES_MAP.put(f.getInt(null), new Res(BOOLEAN, f.getName()));
        }
        Log.d("Theme", "bool loaded");

        Class raw = Class.forName(r.getName() + "$raw");
        for (Field f : raw.getFields()) {
            RES_MAP.put(f.getInt(null), new Res(RAW, f.getName()));
        }
        Log.d("Theme", "raw loaded");
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // Do nothing here
    }
}

From source file:com.devilyang.musicstation.swinginadapters.AnimationAdapter.java

public AnimationAdapter(BaseAdapter baseAdapter) {
    super(baseAdapter);
    mAnimators = new SparseArray<Animator>();

    mAnimationStartMillis = -1;// w  w  w. j a  v a2 s  . c  om
    mLastAnimatedPosition = -1;

    if (baseAdapter instanceof AnimationAdapter) {
        ((AnimationAdapter) baseAdapter).setHasParentAnimationAdapter(true);
    }
}

From source file:net.xisberto.phonetodesktop.WaitListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.activity_link_list);
    selectedItems = new SparseArray<Long>();
}

From source file:com.github.barteksc.pdfviewpager.adapter.PDFPagerAdapter.java

public PDFPagerAdapter(Context context, String pdfPath, float pageScale) {
    this.pdfPath = pdfPath;
    this.context = context;
    this.pageScale = pageScale;
    bitmaps = new SparseArray<>();
    asyncTasks = new SparseArray<>();
    init();//from   ww  w . j a v  a  2  s .  c  om
}

From source file:com.ruesga.android.wallpapers.photophase.adapters.DispositionAdapter.java

/**
 * Constructor of <code>DispositionAdapter</code>.
 *
 * @param ctx The current context//from  w  ww  .  jav  a  2s. co m
 * @param dispositions An array with all dispositions
 * @param resizeFrame The resize frame
 * @param callback The callback where return selection events
 */
public DispositionAdapter(Context ctx, List<Dispositions> dispositions, ResizeFrame resizeFrame,
        OnFrameSelectedListener callback) {
    super();
    mDispositions = dispositions;
    mResizeFrame = resizeFrame;
    mCallback = callback;
    mFirstAnimation = true;
    mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mCurrentViews = new SparseArray<DispositionView>();
}

From source file:com.ruesga.rview.misc.NotificationsHelper.java

@SuppressWarnings("Convert2streamapi")
public static void recreateNotifications(Context ctx) {
    List<NotificationEntity> entities = NotificationEntity.getAllNotifications(ctx, true, true);
    SparseArray<Account> notifications = new SparseArray<>();
    for (NotificationEntity entity : entities) {
        if (notifications.indexOfKey(entity.mGroupId) < 0) {
            notifications.put(entity.mGroupId, ModelHelper.getAccountFromHash(ctx, entity.mAccountId));
        }//w  ww  . j a v  a2s.  c om
    }

    int count = notifications.size();
    for (int i = 0; i < count; i++) {
        int groupId = notifications.keyAt(i);
        Account account = notifications.valueAt(i);
        dismissNotification(ctx, groupId);
        createNotification(ctx, account, groupId, false);
    }
}

From source file:com.powermonitor.epitech.ViewModules.java

@Override
public void onCreate(Bundle saveInstance) {
    super.onCreate(saveInstance);
    setContentView(R.layout.viewmodules);
    modNames = new SparseArray<String>();
    this.list = (ListView) findViewById(R.id.ViewModules_modulesListView);
    this.dataList = new ArrayList<Module>();

    try {/*w ww  .j av a 2 s .  c om*/
        modulesID = new JSONArray(getIntent().getStringExtra("ModulesID"));
        for (int i = 0; i < modulesID.length(); i++) {
            JSONObject obj = modulesID.getJSONObject(i);
            modNames.put(obj.getInt("id"), obj.getString("name"));
            this.dataList.add(new Module(obj.getInt("id"), obj.getString("name"), null, true));
        }
    } catch (JSONException e) {
        e.printStackTrace();
        modulesID = new JSONArray();
    }

    // List view
    //        Communication.INSTANCE.getModulesList(new RequestHandler(this) {
    //            @Override
    //            public void onResult(JSONObject result, JSONObject params) {
    //                JSONArray modList;
    //                try {
    //                    modList = result.getJSONArray("modules");
    //                    for (int i = 0; i < modList.length(); i++) {
    //                        JSONObject obj = modList.getJSONObject(i);
    //                        Module mod = new Module(obj.getInt("id"), obj.getString("name"), null, true);
    //                        ViewModules.this.modNames.append(mod.id, mod.getName());
    //                        ViewModules.this.dataList.add(mod);
    //                    }
    //                    adapter.notifyDataSetChanged();
    //                } catch (JSONException ex) {
    //                    Logger.getLogger(ViewModules.class.getName()).log(Level.SEVERE, null, ex);
    //                }
    //            }
    //        });
    //this.dataList.add(new Module(0));
    this.adapter = new ModuleListAdapter(this, R.layout.modulerow_min, this.dataList);
    this.list.setAdapter(this.adapter);

    // Date filter
    dateFrom = (EditText) findViewById(R.id.ViewModules_dateFrom);
    dateTo = (EditText) findViewById(R.id.ViewModules_dateTo);
    dateFrom.setOnClickListener(new OnDateClickListener());
    dateTo.setOnClickListener(new OnDateClickListener());

    // Chart
    this.chartViewAdapter = new ChartViewAdapter(getSupportFragmentManager());
    this.chartViewPager = (ViewPager) this.findViewById(R.id.ViewModules_pager);
    this.chartViewPager.setAdapter(this.chartViewAdapter);
    this.chartViewPager.setOffscreenPageLimit(2);

    // Button Validate
    this.validate = (Button) findViewById(R.id.ViewModules_bValidate);
    this.validate.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            LineChartFragment chart = (LineChartFragment) ViewModules.this.chartViewAdapter.getFragment(0);
            LineChartFragment chart2 = (LineChartFragment) ViewModules.this.chartViewAdapter.getFragment(1);
            LineChartFragment chart3 = (LineChartFragment) ViewModules.this.chartViewAdapter.getFragment(2);
            if (chart != null)
                chart.empty();
            if (chart2 != null)
                chart2.empty();
            if (chart3 != null)
                chart3.empty();
            if (ViewModules.this.dateFrom.getTag() == null || ViewModules.this.dateTo.getTag() == null) {
                ErrorDialog eDialog = new ErrorDialog(ViewModules.this,
                        "Veuillez entrer une date de dbut et une date de fin", null);
                eDialog.show();
                return;
            }
            //                for (int i = 0; i < ViewModules.this.adapter.getCount(); i++) {
            //                    CheckBox cb = (CheckBox) list.getChildAt(i).findViewById(R.id.name);
            //                    if (cb.isChecked()) {
            //                        Communication.INSTANCE.getModuleConsoData(ViewModules.this.dataList.get(i).id,
            //                                ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 2,
            //                                ViewModules.this.onConsoDataFetched);
            //                    }
            //                }

            for (int id = 0; id < modulesID.length(); id++) {
                try {
                    int moduleID = modulesID.getJSONObject(id).getInt("id");
                    Communication.INSTANCE.getModuleConsoData(moduleID,
                            ((Long) ViewModules.this.dateFrom.getTag()).intValue(),
                            ((Long) ViewModules.this.dateTo.getTag()).intValue(), 1,
                            ViewModules.this.onConsoDataFetchedW);
                    Communication.INSTANCE.getModuleConsoData(moduleID,
                            ((Long) ViewModules.this.dateFrom.getTag()).intValue(),
                            ((Long) ViewModules.this.dateTo.getTag()).intValue(), 2,
                            ViewModules.this.onConsoDataFetchedA);
                    Communication.INSTANCE.getModuleConsoData(moduleID,
                            ((Long) ViewModules.this.dateFrom.getTag()).intValue(),
                            ((Long) ViewModules.this.dateTo.getTag()).intValue(), 3,
                            ViewModules.this.onConsoDataFetchedV);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            //                Communication.INSTANCE.getModuleConsoData(ViewModules.this.dataList.get(2).id,
            //                        ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 2,
            //                        ViewModules.this.onConsoDataFetched);
        }
    });
}

From source file:com.github.monxalo.android.widget.SectionCursorAdapter.java

public SectionCursorAdapter(Context context, Cursor c, int headerLayout, String columnName) {
    super(context, c, 0);

    mSectionsIndexer = new SparseArray<String>();

    mHeaderRes = headerLayout;/*ww w . j  a va2 s  . com*/
    mGroupColumn = c.getColumnIndex(columnName);
    mLayoutInflater = LayoutInflater.from(context);

    if (c != null) {
        calculateSectionHeaders();
        c.registerDataSetObserver(mDataSetObserver);
    }
}