com.danimahardhika.android.helpers.core.utils.LogUtil Java Examples
The following examples show how to use
com.danimahardhika.android.helpers.core.utils.LogUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PremiumRequestBuilderTask.java From candybar-library with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); if (mContext.get() == null) return; if (((AppCompatActivity) mContext.get()).isFinishing()) return; if (aBoolean) { try { if (mCallback != null && mCallback.get() != null) { mCallback.get().onFinished(); } RequestListener listener = (RequestListener) mContext.get(); listener.onRequestBuilt(getIntent(CandyBarApplication.sRequestProperty.getComponentName(), mEmailBody), IntentChooserFragment.REBUILD_ICON_REQUEST); } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } } else { if (mError != null) { LogUtil.e(mError.getMessage()); mError.showToast(mContext.get()); } } }
Example #2
Source File: Database.java From candybar with Apache License 2.0 | 6 votes |
public void addRequest(@Nullable SQLiteDatabase db, Request request) { SQLiteDatabase database = db; if (database == null) { if (!openDatabase()) { LogUtil.e("Database error: addRequest() failed to open database"); return; } database = mDatabase.get().mSQLiteDatabase; } ContentValues values = new ContentValues(); values.put(KEY_NAME, request.getName()); values.put(KEY_ACTIVITY, request.getActivity()); String requestedOn = request.getRequestedOn(); if (requestedOn == null) requestedOn = TimeHelper.getLongDateTime(); values.put(KEY_REQUESTED_ON, requestedOn); database.insert(TABLE_REQUEST, null, values); }
Example #3
Source File: JsonHelper.java From candybar-library with Apache License 2.0 | 6 votes |
@Nullable public static List parseList(@NonNull InputStream stream) { List list = null; JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure(); try { if (jsonStructure.getArrayName() == null) { list = LoganSquare.parseList(stream, Map.class); } else { Map<String, List> map = LoganSquare.parseMap(stream, List.class); list = map.get(jsonStructure.getArrayName()); } } catch (IOException e) { LogUtil.e(Log.getStackTraceString(e)); } return list; }
Example #4
Source File: CategoriesFragment.java From wallpaperboard with Apache License 2.0 | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); mCategories = Database.get(getActivity()).getCategories(); for (Category category : mCategories) { category = Database.get(getActivity()).getCategoryPreview(category); publishProgress(category); } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #5
Source File: JsonHelper.java From candybar with Apache License 2.0 | 6 votes |
@Nullable public static List parseList(@NonNull InputStream stream) { List list = null; JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure(); try { if (jsonStructure.getArrayName() == null) { list = LoganSquare.parseList(stream, Map.class); } else { Map<String, List> map = LoganSquare.parseMap(stream, List.class); list = map.get(jsonStructure.getArrayName()); } } catch (IOException e) { LogUtil.e(Log.getStackTraceString(e)); } return list; }
Example #6
Source File: LocaleHelper.java From candybar with Apache License 2.0 | 6 votes |
@Nullable public static String getOtherAppLocaleName(@NonNull Context context, @NonNull Locale locale, @NonNull String fullComponentName) { try { int slashIndex = fullComponentName.indexOf("/"); String activityName = fullComponentName.substring(slashIndex).replace("/", ""); String packageName = fullComponentName.replace("/" + activityName, ""); ComponentName componentName = new ComponentName(packageName, activityName); PackageManager packageManager = context.getPackageManager(); ActivityInfo info = packageManager.getActivityInfo(componentName, PackageManager.GET_META_DATA); Resources res = packageManager.getResourcesForActivity(componentName); Configuration configuration = new Configuration(); configuration.locale = locale; res.updateConfiguration(configuration, context.getResources().getDisplayMetrics()); return info.loadLabel(packageManager).toString(); } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }
Example #7
Source File: Database.java From candybar with Apache License 2.0 | 6 votes |
public void addPremiumRequest(@Nullable SQLiteDatabase db, Request request) { SQLiteDatabase database = db; if (database == null) { if (!openDatabase()) { LogUtil.e("Database error: addPremiumRequest() failed to open database"); return; } database = mDatabase.get().mSQLiteDatabase; } ContentValues values = new ContentValues(); values.put(KEY_ORDER_ID, request.getOrderId()); values.put(KEY_PRODUCT_ID, request.getProductId()); values.put(KEY_NAME, request.getName()); values.put(KEY_ACTIVITY, request.getActivity()); String requestedOn = request.getRequestedOn(); if (requestedOn == null) requestedOn = TimeHelper.getLongDateTime(); values.put(KEY_REQUESTED_ON, requestedOn); database.insert(TABLE_PREMIUM_REQUEST, null, values); }
Example #8
Source File: Database.java From wallpaperboard with Apache License 2.0 | 6 votes |
public void deleteCategories(@NonNull List<Category> categories) { if (!openDatabase()) { LogUtil.e("Database error: deleteCategories() failed to open database"); return; } String query = "DELETE FROM " +TABLE_CATEGORIES+ " WHERE " +KEY_NAME+ " = ?"; SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query); mDatabase.get().mSQLiteDatabase.beginTransaction(); for (Category category : categories) { statement.clearBindings(); statement.bindString(1, category.getName()); statement.execute(); } mDatabase.get().mSQLiteDatabase.setTransactionSuccessful(); mDatabase.get().mSQLiteDatabase.endTransaction(); }
Example #9
Source File: LocaleHelper.java From candybar-library with Apache License 2.0 | 6 votes |
@Nullable public static String getOtherAppLocaleName(@NonNull Context context, @NonNull Locale locale, @NonNull String packageName) { try { PackageManager packageManager = context.getPackageManager(); ApplicationInfo info = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Resources res = packageManager.getResourcesForApplication(packageName); Context otherAppContext = context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY); Configuration configuration = new Configuration(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { configuration = res.getConfiguration(); configuration.setLocale(locale); return otherAppContext.createConfigurationContext(configuration).getString(info.labelRes); } configuration.locale = locale; res.updateConfiguration(configuration, context.getResources().getDisplayMetrics()); return res.getString(info.labelRes); } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }
Example #10
Source File: LocalFavoritesBackupTask.java From wallpaperboard with Apache License 2.0 | 6 votes |
@Override protected void onPreExecute() { super.onPreExecute(); if (mIsStorageGranted) { File file = BackupHelper.getDefaultDirectory(mContext.get()); if (!file.exists()) { file.mkdirs(); } File nomedia = new File(file.getParent(), BackupHelper.NOMEDIA); if (!nomedia.exists()) { try { nomedia.createNewFile(); } catch (IOException e) { LogUtil.e(Log.getStackTraceString(e)); } } } }
Example #11
Source File: LanguagesFragment.java From candybar with Apache License 2.0 | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); languages = LocaleHelper.getAvailableLanguages(getActivity()); Locale locale = Preferences.get(getActivity()).getCurrentLocale(); for (int i = 0; i < languages.size(); i++) { Locale l = languages.get(i).getLocale(); if (l.toString().equals(locale.toString())) { index = i; break; } } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #12
Source File: LicensesFragment.java From candybar with Apache License 2.0 | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); InputStream rawResource = getResources().openRawResource(R.raw.licenses); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(rawResource)); String line; while ((line = bufferedReader.readLine()) != null) { sb.append(line); sb.append("\n"); } bufferedReader.close(); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #13
Source File: Database.java From candybar-library with Apache License 2.0 | 6 votes |
public void addRequest(@Nullable SQLiteDatabase db, Request request) { SQLiteDatabase database = db; if (database == null) { if (!openDatabase()) { LogUtil.e("Database error: addRequest() failed to open database"); return; } database = mDatabase.get().mSQLiteDatabase; } ContentValues values = new ContentValues(); values.put(KEY_NAME, request.getName()); values.put(KEY_ACTIVITY, request.getActivity()); String requestedOn = request.getRequestedOn(); if (requestedOn == null) requestedOn = TimeHelper.getLongDateTime(); values.put(KEY_REQUESTED_ON, requestedOn); database.insert(TABLE_REQUEST, null, values); }
Example #14
Source File: DrawableHelper.java From candybar-library with Apache License 2.0 | 6 votes |
@Nullable public static Drawable getHighQualityIcon(@NonNull Context context, String packageName) { try { PackageManager packageManager = context.getPackageManager(); ApplicationInfo info = packageManager.getApplicationInfo( packageName, PackageManager.GET_META_DATA); Resources resources = packageManager.getResourcesForApplication(packageName); int density = DisplayMetrics.DENSITY_XXHIGH; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { density = DisplayMetrics.DENSITY_XXXHIGH; } Drawable drawable = ResourcesCompat.getDrawableForDensity( resources, info.icon, density, null); if (drawable != null) return drawable; return info.loadIcon(packageManager); } catch (Exception | OutOfMemoryError e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }
Example #15
Source File: LanguagesFragment.java From candybar-library with Apache License 2.0 | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); languages = LocaleHelper.getAvailableLanguages(getActivity()); Locale locale = Preferences.get(getActivity()).getCurrentLocale(); for (int i = 0; i < languages.size(); i++) { Locale l = languages.get(i).getLocale(); if (l.toString().equals(locale.toString())) { index = i; break; } } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #16
Source File: IconRequestBuilderTask.java From candybar with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); if (aBoolean) { try { if (mCallback != null && mCallback.get() != null) mCallback.get().onFinished(); RequestListener listener = (RequestListener) mContext.get(); listener.onRequestBuilt(getIntent(CandyBarApplication.sRequestProperty .getComponentName(), mEmailBody), IntentChooserFragment.ICON_REQUEST); } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } } else { if (mError != null) { LogUtil.e(mError.getMessage()); mError.showToast(mContext.get()); } } }
Example #17
Source File: InAppBillingProcessor.java From candybar with Apache License 2.0 | 6 votes |
@Override public void onBillingError(int errorCode, Throwable error) { if (mInAppBilling == null || mInAppBilling.get() == null) { LogUtil.e("InAppBillingProcessor error: not initialized"); return; } if (errorCode == Constants.BILLING_RESPONSE_RESULT_USER_CANCELED) { if (Preferences.get(mInAppBilling.get().mContext).getInAppBillingType() == InAppBilling.PREMIUM_REQUEST) { Preferences.get(mInAppBilling.get().mContext).setPremiumRequestCount(0); Preferences.get(mInAppBilling.get().mContext).setPremiumRequestTotal(0); } Preferences.get(mInAppBilling.get().mContext).setInAppBillingType(-1); } else if (errorCode == Constants.BILLING_ERROR_FAILED_TO_INITIALIZE_PURCHASE) { mInAppBilling.get().mIsInitialized = false; } }
Example #18
Source File: IconShapeFragment.java From candybar with Apache License 2.0 | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); iconShapes = IconShapeHelper.getShapes(); int currentShape = Preferences.get(getActivity()).getIconShape(); for (int i = 0; i < iconShapes.size(); i++) { int shape = iconShapes.get(i).getShape(); if (shape == currentShape) { index = i; break; } } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #19
Source File: CandyBarMuzeiActivity.java From candybar-library with Apache License 2.0 | 6 votes |
private void setDividerColor (NumberPicker picker) { java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields(); for (java.lang.reflect.Field pf : pickerFields) { if (pf.getName().equals("mSelectionDivider")) { pf.setAccessible(true); try { pf.set(picker, ContextCompat.getDrawable(this, Preferences.get(this).isDarkTheme() ? R.drawable.numberpicker_divider_dark : R.drawable.numberpicker_divider)); } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } break; } } }
Example #20
Source File: Database.java From candybar-library with Apache License 2.0 | 5 votes |
public int getWallpapersCount() { if (!openDatabase()) { LogUtil.e("Database error: getWallpapersCount() failed to open database"); return 0; } Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_WALLPAPERS, null, null, null, null, null, null, null); int rowCount = cursor.getCount(); cursor.close(); return rowCount; }
Example #21
Source File: InAppBillingProcessor.java From candybar-library with Apache License 2.0 | 5 votes |
public BillingProcessor getProcessor() { if (mLicenseKey == null) { LogUtil.e("InAppBillingProcessor: license key is null, make sure to call InAppBillingProcessor.init() first"); } if (mInAppBilling.get().mBillingProcessor == null || !mInAppBilling.get().mIsInitialized) { mInAppBilling.get().mBillingProcessor = new BillingProcessor( mInAppBilling.get().mContext, mLicenseKey, mInAppBilling.get()); } return mInAppBilling.get().mBillingProcessor; }
Example #22
Source File: WallpaperBoardSplashActivity.java From wallpaperboard with Apache License 2.0 | 5 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(500); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return null; }
Example #23
Source File: RequestAdapter.java From candybar-library with Apache License 2.0 | 5 votes |
@Nullable private StaggeredGridLayoutManager.LayoutParams getLayoutParams(@Nullable View view) { if (view != null) { try { return (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams(); } catch (Exception e) { LogUtil.d(Log.getStackTraceString(e)); } } return null; }
Example #24
Source File: Database.java From wallpaperboard with Apache License 2.0 | 5 votes |
public void resetAutoIncrement() { if (!openDatabase()) { LogUtil.e("Database error: resetAutoIncrement() failed to open database"); return; } mSQLiteDatabase.delete("SQLITE_SEQUENCE", "NAME = ?", new String[]{TABLE_WALLPAPERS}); }
Example #25
Source File: CreditsAdapter.java From candybar with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View view, ViewGroup viewGroup) { ViewHolder holder; if (view == null) { view = View.inflate(mContext, R.layout.fragment_credits_item_list, null); holder = new ViewHolder(view); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } Credit credit = mCredits.get(position); holder.title.setText(credit.getName()); holder.subtitle.setText(credit.getContribution()); holder.container.setOnClickListener(view1 -> { String link = credit.getLink(); if (URLUtil.isValidUrl(link)) { try { mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } catch (ActivityNotFoundException e) { LogUtil.e(Log.getStackTraceString(e)); } } }); if (credit.getContribution().length() == 0) { holder.subtitle.setVisibility(View.GONE); } else { holder.subtitle.setVisibility(View.VISIBLE); } ImageLoader.getInstance().displayImage(credit.getImage(), new ImageViewAware(holder.image), mOptions.build(), new ImageSize(144, 144), null, null); return view; }
Example #26
Source File: Popup.java From candybar-library with Apache License 2.0 | 5 votes |
public void show() { if (mAdapter.getCount() == 0) { LogUtil.e("Popup size = 0, show() ignored"); return; } mPopupWindow.show(); }
Example #27
Source File: FilterFragment.java From wallpaperboard with Apache License 2.0 | 5 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); isAllSelected = mAdapter.selectAll(); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #28
Source File: CreditsFragment.java From candybar-library with Apache License 2.0 | 5 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); int res = getResource(mType); XmlPullParser xpp = getResources().getXml(res); while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) { if (xpp.getEventType() == XmlPullParser.START_TAG) { if (xpp.getName().equals("contributor")) { Credit credit = new Credit( xpp.getAttributeValue(null, "name"), xpp.getAttributeValue(null, "contribution"), xpp.getAttributeValue(null, "image"), xpp.getAttributeValue(null, "link")); credits.add(credit); } } xpp.next(); } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #29
Source File: CreditsFragment.java From wallpaperboard with Apache License 2.0 | 5 votes |
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); int res = getResource(mType); if (res == -1) return false; XmlPullParser xpp = getActivity().getResources().getXml(res); while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) { if (xpp.getEventType() == XmlPullParser.START_TAG) { if (xpp.getName().equals("contributor")) { Credit credit = new Credit( xpp.getAttributeValue(null, "name"), xpp.getAttributeValue(null, "contribution"), xpp.getAttributeValue(null, "image"), xpp.getAttributeValue(null, "link")); credits.add(credit); } } xpp.next(); } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
Example #30
Source File: CreditsAdapter.java From wallpaperboard with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View view, ViewGroup viewGroup) { ViewHolder holder; if (view == null) { view = View.inflate(mContext, R.layout.fragment_credits_item_list, null); holder = new ViewHolder(view); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } Credit credit = mCredits.get(position); holder.title.setText(credit.getName()); holder.subtitle.setText(credit.getContribution()); holder.container.setOnClickListener(view1 -> { String link = credit.getLink(); if (URLUtil.isValidUrl(link)) { try { mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } catch (ActivityNotFoundException e) { LogUtil.e(Log.getStackTraceString(e)); } } }); if (credit.getContribution().length() == 0) { holder.subtitle.setVisibility(View.GONE); } else { holder.subtitle.setVisibility(View.VISIBLE); } ImageLoader.getInstance().displayImage(credit.getImage(), new ImageViewAware(holder.image), mOptions.build(), new ImageSize(144, 144), null, null); return view; }