List of usage examples for android.support.v4.util SparseArrayCompat append
public void append(int i, E e)
From source file:com.dm.material.dashboard.candybar.helpers.ReportBugsHelper.java
public static void checkForBugs(@NonNull Context context) { new AsyncTask<Void, Void, Boolean>() { MaterialDialog dialog;/* w w w . j a v a 2s. c o m*/ StringBuilder sb; File folder; String file; @Override protected void onPreExecute() { super.onPreExecute(); sb = new StringBuilder(); folder = FileHelper.getCacheDirectory(context); file = folder.toString() + "/" + "reportbugs.zip"; MaterialDialog.Builder builder = new MaterialDialog.Builder(context); builder.content(R.string.report_bugs_building).progress(true, 0).progressIndeterminateStyle(true); dialog = builder.build(); dialog.show(); } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); SparseArrayCompat<String> files = new SparseArrayCompat<>(); sb.append(DeviceHelper.getDeviceInfo(context)); String brokenAppFilter = buildBrokenAppFilter(context, folder); if (brokenAppFilter != null) files.append(files.size(), brokenAppFilter); String activityList = buildActivityList(context, folder); if (activityList != null) files.append(files.size(), activityList); String stackTrace = Preferences.getPreferences(context).getLatestCrashLog(); String crashLog = buildCrashLog(context, folder, stackTrace); if (crashLog != null) files.append(files.size(), crashLog); FileHelper.createZip(files, file); return true; } catch (Exception e) { Log.d(Tag.LOG_TAG, Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); dialog.dismiss(); if (aBoolean) { File zip = new File(file); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { context.getResources().getString(R.string.dev_email) }); intent.putExtra(Intent.EXTRA_SUBJECT, "Report Bugs " + (context.getString(R.string.app_name))); intent.putExtra(Intent.EXTRA_TEXT, sb.toString()); Uri uri = FileHelper.getUriFromFile(context, context.getPackageName(), zip); intent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity( Intent.createChooser(intent, context.getResources().getString(R.string.email_client))); } else { Toast.makeText(context, R.string.report_bugs_failed, Toast.LENGTH_LONG).show(); } dialog = null; sb.setLength(0); } }.execute(); }
From source file:com.dm.material.dashboard.candybar.databases.Database.java
private void resetDatabase(SQLiteDatabase db) { Cursor cursor = db.rawQuery("SELECT name FROM sqlite_master WHERE type=\'table\'", null); SparseArrayCompat<String> tables = new SparseArrayCompat<>(); if (cursor.moveToFirst()) { do {/*from w ww . j a va2s . c o m*/ tables.append(tables.size(), cursor.getString(0)); } while (cursor.moveToNext()); } cursor.close(); for (int i = 0; i < tables.size(); i++) { try { String dropQuery = "DROP TABLE IF EXISTS " + tables.get(i); if (!tables.get(i).equalsIgnoreCase("SQLITE_SEQUENCE")) db.execSQL(dropQuery); } catch (Exception ignored) { } } onCreate(db); }
From source file:com.dm.material.dashboard.candybar.adapters.RequestAdapter.java
public SparseArrayCompat<Integer> getSelectedItems() { SparseArrayCompat<Integer> selected = new SparseArrayCompat<>(); for (int i = 0; i < mSelectedItems.size(); i++) { selected.append(selected.size(), mSelectedItems.keyAt(i)); }//from w w w . j av a2 s . c om return selected; }
From source file:com.dm.material.dashboard.candybar.helpers.MuzeiHelper.java
@Nullable public Wallpaper getRandomDownloadedWallpaper() throws Exception { SparseArrayCompat<Wallpaper> downloaded = new SparseArrayCompat<>(); List<Wallpaper> wallpapers = mDatabase.getWallpapers(); for (Wallpaper wallpaper : wallpapers) { File file = new File(mDirectory + File.separator + wallpaper.getName() + FileHelper.IMAGE_EXTENSION); if (file.exists()) { downloaded.append(downloaded.size(), wallpaper); }//from w w w . ja va 2s. c om } wallpapers.clear(); int size = downloaded.size(); if (size > 0) { int position = getRandomInt(size); return new Wallpaper(downloaded.get(position).getName(), downloaded.get(position).getAuthor(), downloaded.get(position).getURL(), downloaded.get(position).getThumbUrl()); } return null; }
From source file:com.dm.material.dashboard.candybar.adapters.RequestAdapter.java
private SparseArrayCompat<Request> getSelectedApps() { SparseArrayCompat<Request> items = new SparseArrayCompat<>(mSelectedItems.size()); for (int i = 0; i < mSelectedItems.size(); i++) { int position = mSelectedItems.keyAt(i); if (position >= 0 && position < mRequests.size()) { Request request = mRequests.get(mSelectedItems.keyAt(i)); items.append(items.size(), request); }/*from ww w .j a v a 2 s .co m*/ } return items; }
From source file:com.dm.material.dashboard.candybar.databases.Database.java
public SparseArrayCompat<Wallpaper> getWallpaperAddedOn() { SparseArrayCompat<Wallpaper> dates = new SparseArrayCompat<>(); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_WALLPAPERS, new String[] { KEY_URL, KEY_ADDED_ON }, null, null, null, null, null);//from w w w. jav a 2 s. co m if (cursor.moveToFirst()) { do { Wallpaper item = new Wallpaper(cursor.getString(0), cursor.getString(1)); dates.append(dates.size(), item); } while (cursor.moveToNext()); } cursor.close(); db.close(); return dates; }
From source file:com.dm.material.dashboard.candybar.databases.Database.java
public SparseArrayCompat<Request> getPremiumRequest() { SparseArrayCompat<Request> requests = new SparseArrayCompat<>(); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_PREMIUM_REQUEST, null, null, null, null, null, null); if (cursor.moveToFirst()) { do {//from ww w. ja v a 2s . c om Request request = new Request(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4)); requests.append(requests.size(), request); } while (cursor.moveToNext()); } cursor.close(); db.close(); return requests; }
From source file:com.dm.material.dashboard.candybar.databases.Database.java
public SparseArrayCompat<Wallpaper> getWallpapers() { SparseArrayCompat<Wallpaper> wallpapers = new SparseArrayCompat<>(); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_WALLPAPERS, null, null, null, null, null, KEY_ADDED_ON + " DESC, " + KEY_ID); if (cursor.moveToFirst()) { do {//from www . j a v a 2 s. c o m Wallpaper wallpaper = new Wallpaper(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4)); wallpapers.append(wallpapers.size(), wallpaper); } while (cursor.moveToNext()); } cursor.close(); db.close(); return wallpapers; }
From source file:com.bmd.android.collection.internal.SparseArrayCompatIterableImpl.java
@Override public SparseArrayCompatIterable<V> appendTo(final SparseArrayCompat<V> other) { for (final SparseArrayEntry<V> entry : this) { other.append(entry.getKey(), entry.getValue()); }//from ww w .j a v a 2 s . c o m return this; }
From source file:com.bmd.android.collection.internal.SparseArrayCompatIterableImpl.java
@Override public SparseArrayCompatIterable<V> replaceValues(final Translator<V, V> translator) { final SparseArrayCompat<V> array = mArray; for (final SparseArrayEntry<V> entry : this) { array.append(entry.getKey(), translator.translate(entry.getValue())); }/*from w w w .jav a 2s. c o m*/ return this; }