Java Code Examples for android.annotation.SuppressLint

The following are top voted examples for showing how to use android.annotation.SuppressLint. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Ghost-Android   File: DateDeserializer.java   View source code 9 votes vote down vote up
@Override
public Date deserialize(JsonElement element, Type type, JsonDeserializationContext context)
        throws JsonParseException {
    String date = element.getAsString();

    @SuppressLint("SimpleDateFormat")
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));

    try {
        return formatter.parse(date);
    } catch (ParseException e) {
        Log.e(TAG, "Date parsing failed");
        Log.exception(e);
        return new Date();
    }
}
 
Example 2
Project: ITagAntiLost   File: DevicesActivity.java   View source code 7 votes vote down vote up
@Override
public void onRename(Device device) {
  @SuppressLint("InflateParams")
  EditText edit = (EditText) LayoutInflater.from(this).inflate(R.layout.layout_edit_name, null);
  new AlertDialog.Builder(this)
      .setTitle(R.string.change_name)
      .setView(edit)
      .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss())
      .setPositiveButton(android.R.string.ok, (dialog, which) -> {
        if (edit.getText().toString().trim().length() > 0) {
          device.setName(edit.getText().toString().trim());
          updateDeviceSubject.onNext(device);
        }
        dialog.dismiss();
      })
      .show();
}
 
Example 3
Project: RxUploader   File: SimpleUploadDataStoreTest.java   View source code 7 votes vote down vote up
@SuppressLint("ApplySharedPref")
@Test
public void testGetInvalidJobId() throws Exception {
    final Job test = createTestJob();
    final String json = gson.toJson(test);
    final String key = SimpleUploadDataStore.jobIdKey(test.id());
    final Set<String> keys = new HashSet<>();
    keys.add(key);

    final SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putStringSet(SimpleUploadDataStore.KEY_JOB_IDS, keys);
    editor.putString(key, json);
    editor.commit();

    final TestSubscriber<Job> ts = TestSubscriber.create();
    dataStore.get("bad_id").subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertNoErrors();
    ts.assertValueCount(1);
    ts.assertValue(Job.INVALID_JOB);
}
 
Example 4
Project: exciting-app   File: AbsHListView.java   View source code 7 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@SuppressLint("Override")
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
	super.onInitializeAccessibilityNodeInfo(info);

	info.setClassName(AbsHListView.class.getName());
	if (isEnabled()) {
		if (getFirstVisiblePosition() > 0) {
			info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
		}
		if (getLastVisiblePosition() < getCount() - 1) {
			info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
		}
	}
}
 
Example 5
Project: XERUNG   File: AddPrefixMemberAdapter.java   View source code 7 votes vote down vote up
/**
 * Main mathod used to display view in list
 */
@SuppressLint("InflateParams")
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
	// TODO Auto-generated method stub
	ViewHolder viewHolder = null;
	LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	final ContactBean tb = data.get(position);
	if(convertView == null){

		viewHolder = new ViewHolder();
		convertView = inflate.inflate(R.layout.add_prefix_member_list_item, null);
		viewHolder.txtName = (TextView)convertView.findViewById(R.id.txtContactName);
		viewHolder.spCountry = (MaterialSpinner)convertView.findViewById(R.id.spCountry);
		viewHolder.txtName.setTypeface(ManagerTypeface.getTypeface(context, R.string.typeface_roboto_regular));
		convertView.setTag(viewHolder);
		convertView.setTag(R.id.txtContactName, viewHolder.txtName);
	}else{
		viewHolder = (ViewHolder)convertView.getTag();
	}
	viewHolder.txtName.setTypeface(fontBauhus);
	viewHolder.txtName.setText(tb.getName());
	return convertView;

}
 
Example 6
Project: GongXianSheng   File: UnlockDeviceAndroidJUnitRunner.java   View source code 7 votes vote down vote up
@SuppressLint("MissingPermission")
@Override
public void onStart() {
    Application application = (Application) getTargetContext().getApplicationContext();
    String simpleName = UnlockDeviceAndroidJUnitRunner.class.getSimpleName();
    // Unlock the device so that the tests can input keystrokes.
    ((KeyguardManager) application.getSystemService(KEYGUARD_SERVICE))
            .newKeyguardLock(simpleName)
            .disableKeyguard();
    // Wake up the screen.
    PowerManager powerManager = ((PowerManager) application.getSystemService(POWER_SERVICE));
    mWakeLock = powerManager.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP |
            ON_AFTER_RELEASE, simpleName);
    mWakeLock.acquire();
    super.onStart();
}
 
Example 7
Project: qmui   File: QMUILinkTextView.java   View source code 7 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            boolean hasSingleTap = mSingleTapConfirmedHandler.hasMessages(MSG_CHECK_DOUBLE_TAP_TIMEOUT);
            Log.w(TAG, "onTouchEvent hasSingleTap: " + hasSingleTap);
            if (!hasSingleTap) {
                mDownMillis = SystemClock.uptimeMillis();
            } else {
                Log.w(TAG, "onTouchEvent disallow onSpanClick mSingleTapConfirmedHandler because of DOUBLE TAP");
                disallowOnSpanClickInterrupt();
            }
            break;
    }
    boolean ret = super.onTouchEvent(event);
    if (mNeedForceEventToParent) {
        return mTouchSpanHit;
    }
    return ret;
}
 
Example 8
Project: boohee_v5.6   File: SwipeBackActivityHelper.java   View source code 7 votes vote down vote up
@SuppressLint({"NewApi"})
public void convertActivityToTranslucent() {
    try {
        Class<?> translucentConversionListenerClazz = null;
        for (Class<?> clazz : Activity.class.getDeclaredClasses()) {
            if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
                translucentConversionListenerClazz = clazz;
            }
        }
        Method method;
        if (VERSION.SDK_INT > 19) {
            method = Activity.class.getDeclaredMethod("convertToTranslucent", new
                    Class[]{translucentConversionListenerClazz, ActivityOptions.class});
            method.setAccessible(true);
            method.invoke(this.mActivity, new Object[]{null, null});
            return;
        }
        method = Activity.class.getDeclaredMethod("convertToTranslucent", new
                Class[]{translucentConversionListenerClazz});
        method.setAccessible(true);
        method.invoke(this.mActivity, new Object[]{null});
    } catch (Throwable th) {
    }
}
 
Example 9
Project: nongbeer-mvp-android-demo   File: BeerProductHolder.java   View source code 7 votes vote down vote up
@SuppressLint( "SetTextI18n" )
public void onBind( BeerProductItem item ){
    setBeerImage( item.getImage() );
    tvBeerName.setText( item.getName() );
    tvBeerPercent.setText( item.getAlcohol() );
    tvBeerVolume.setText( item.getVolume() );
    tvBeerPrice.setText( StringUtils.getCommaPriceWithBaht( getContext(), item.getPrice() ) );

    if( item.isAdded() ){
        btnAdded.setVisibility( View.VISIBLE );
        btnAddToCart.setVisibility( View.GONE );
    }else{
        btnAdded.setVisibility( View.GONE );
        btnAddToCart.setVisibility( View.VISIBLE );
    }
}
 
Example 10
Project: Utils   File: FileUtil.java   View source code 7 votes vote down vote up
/**
 * 获取磁盘可用空间.
 */
@SuppressWarnings("deprecation")
@SuppressLint({"NewApi", "ObsoleteSdkInt"})
public static long getSDCardAvailaleSize() {
    File path = getRootPath();
    StatFs stat = new StatFs(path.getPath());
    long blockSize, availableBlocks;
    if (Build.VERSION.SDK_INT >= 18) {
        blockSize = stat.getBlockSizeLong();
        availableBlocks = stat.getAvailableBlocksLong();
    } else {
        blockSize = stat.getBlockSize();
        availableBlocks = stat.getAvailableBlocks();
    }
    return availableBlocks * blockSize;
}
 
Example 11
Project: face-landmark-android   File: CameraConnectionFragment.java   View source code 7 votes vote down vote up
/**
 * Stops the background thread and its {@link Handler}.
 */
@SuppressLint("LongLogTag")
@DebugLog
private void stopBackgroundThread() {
    backgroundThread.quitSafely();
    inferenceThread.quitSafely();
    try {
        backgroundThread.join();
        backgroundThread = null;
        backgroundHandler = null;

        inferenceThread.join();
        inferenceThread = null;
        inferenceThread = null;
    } catch (final InterruptedException e) {
        Log.e(TAG, "error" ,e );
    }
}
 
Example 12
Project: Go-RxJava   File: ChildViewHolder.java   View source code 7 votes vote down vote up
@SuppressLint("DefaultLocale")
private String fileExt(String url) {
    if (url.indexOf("?") > -1) {
        url = url.substring(0, url.indexOf("?"));
    }
    if (url.lastIndexOf(".") == -1) {
        return null;
    } else {
        String ext = url.substring(url.lastIndexOf("."));
        if (ext.indexOf("%") > -1) {
            ext = ext.substring(0, ext.indexOf("%"));
        }
        if (ext.indexOf("/") > -1) {
            ext = ext.substring(0, ext.indexOf("/"));
        }
        return ext.toLowerCase();
    }
}
 
Example 13
Project: Hitalk   File: FloatingActionButton.java   View source code 7 votes vote down vote up
@SuppressLint("NewApi")
private void init(Context context, AttributeSet attributeSet) {
    mVisible = true;
    mColorNormal = getColor(R.color.material_blue_500);
    mColorPressed = darkenColor(mColorNormal);
    mColorRipple = lightenColor(mColorNormal);
    mColorDisabled = getColor(android.R.color.darker_gray);
    mType = TYPE_NORMAL;
    mShadow = true;
    mScrollThreshold = getResources().getDimensionPixelOffset(R.dimen.fab_scroll_threshold);
    mShadowSize = getDimension(R.dimen.fab_shadow_size);
    if (hasLollipopApi()) {
        StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(context,
                R.animator.fab_press_elevation);
        setStateListAnimator(stateListAnimator);
    }
    if (attributeSet != null) {
        initAttributes(context, attributeSet);
    }
    updateBackground();
}
 
Example 14
Project: Espresso   File: AutoFocusManager.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
private synchronized void autoFocusAgainLater() {
	if (!stopped && outstandingTask == null) {
		AutoFocusTask newTask = new AutoFocusTask();
		try {
			// Unnecessary, our app's min sdk is higher than 11.
			// if (Build.VERSION.SDK_INT >= 11) {
			// 	newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			// } else {
			//
			// }
			newTask.execute();
			outstandingTask = newTask;
		} catch (RejectedExecutionException ree) {
			Log.w(TAG, "Could not request auto focus", ree);
		}
	}
}
 
Example 15
Project: cordova-plugin-themeablebrowser-diy   File: InAppBrowser.java   View source code 6 votes vote down vote up
/**
 * Inject an object (script or style) into the InAppBrowser AmazonWebView.
 *
 * This is a helper method for the inject{Script|Style}{Code|File} API calls, which
 * provides a consistent method for injecting JavaScript code into the document.
 *
 * If a wrapper string is supplied, then the source string will be JSON-encoded (adding
 * quotes) and wrapped using string formatting. (The wrapper string should have a single
 * '%s' marker)
 *
 * @param source      The source object (filename or script/style text) to inject into
 *                    the document.
 * @param jsWrapper   A JavaScript string to wrap the source string in, so that the object
 *                    is properly injected, or null if the source string is JavaScript text
 *                    which should be executed directly.
 */
private void injectDeferredObject(String source, String jsWrapper) {
    final String scriptToInject;
    if (jsWrapper != null) {
        org.json.JSONArray jsonEsc = new org.json.JSONArray();
        jsonEsc.put(source);
        String jsonRepr = jsonEsc.toString();
        String jsonSourceString = jsonRepr.substring(1, jsonRepr.length()-1);
        scriptToInject = String.format(jsWrapper, jsonSourceString);
    } else {
        scriptToInject = source;
    }
    final String finalScriptToInject = scriptToInject;
    this.cordova.getActivity().runOnUiThread(new Runnable() {
        @SuppressLint("NewApi")
        @Override
        public void run() {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
                // This action will have the side-effect of blurring the currently focused element
                inAppWebView.loadUrl("javascript:" + finalScriptToInject);
            } /*else {
                inAppWebView.evaluateJavascript(finalScriptToInject, null);
            }*/
        }
    });
}
 
Example 16
Project: airgram   File: MediaController.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
public static MediaCodecInfo selectCodec(String mimeType) {
    int numCodecs = MediaCodecList.getCodecCount();
    MediaCodecInfo lastCodecInfo = null;
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
        if (!codecInfo.isEncoder()) {
            continue;
        }
        String[] types = codecInfo.getSupportedTypes();
        for (String type : types) {
            if (type.equalsIgnoreCase(mimeType)) {
                lastCodecInfo = codecInfo;
                if (!lastCodecInfo.getName().equals("OMX.SEC.avc.enc")) {
                    return lastCodecInfo;
                } else if (lastCodecInfo.getName().equals("OMX.SEC.AVC.Encoder")) {
                    return lastCodecInfo;
                }
            }
        }
    }
    return lastCodecInfo;
}
 
Example 17
Project: PeSanKita-android   File: ContactIdentityManagerICS.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
Example 18
Project: Swface   File: StickyListHeadersListView.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
private void setHeaderOffet(int offset) {
    if (mHeaderOffset == null || mHeaderOffset != offset) {
        mHeaderOffset = offset;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mHeader.setTranslationY(mHeaderOffset);
        } else {
            MarginLayoutParams params = (MarginLayoutParams) mHeader.getLayoutParams();
            params.topMargin = mHeaderOffset;
            mHeader.setLayoutParams(params);
        }
        if (mOnStickyHeaderOffsetChangedListener != null) {
            mOnStickyHeaderOffsetChangedListener.onStickyHeaderOffsetChanged(this, mHeader, -mHeaderOffset);
        }
    }
}
 
Example 19
Project: tuxguitar   File: TGToolbarPlayRateDialog.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
public Dialog onCreateDialog() {
    tgPlayRateList = generatePercent();

    final View view = getActivity().getLayoutInflater().inflate(R.layout.view_toolbar_playrate_dialog, null);
    this.seekBar = (SeekBar) view.findViewById(R.id.toolbar_percent_seekbar);
    this.textView = (TextView) view.findViewById(R.id.toolbar_percent_textview);

    this.seekBar.setMax(tgPlayRateList.size() - 1);
    this.initPlayRate();
    this.appendListeners(seekBar);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.toolbar_playrate_dlg_title);
    builder.setView(view);
    return builder.create();
}
 
Example 20
Project: GCSApp   File: SearChContactListFragment.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
    @Override
    protected void initView() {
        super.initView();
//        @SuppressLint("InflateParams")
//        View headerView = LayoutInflater.from(getActivity()).inflate(R.layout.em_contacts_header, null);
//        HeaderItemClickListener clickListener = new HeaderItemClickListener();
//        applicationItem = (ContactItemView) headerView.findViewById(R.id.application_item);
//        applicationItem.setVisibility(View.GONE);
//        applicationItem.setOnClickListener(clickListener);
//        headerView.findViewById(R.id.group_item).setOnClickListener(clickListener);
//        headerView.findViewById(R.id.chat_room_item).setOnClickListener(clickListener);
//        headerView.findViewById(R.id.robot_item).setOnClickListener(clickListener);
//        listView.addHeaderView(headerView);
        //add loading view
        loadingView = LayoutInflater.from(getActivity()).inflate(R.layout.em_layout_loading_data, null);
        contentContainer.addView(loadingView);
//        getView().findViewById(R.id.search_bar_view).setVisibility(View.GONE);
        registerForContextMenu(listView);
    }
 
Example 21
Project: Exoplayer2Radio   File: AudioCapabilities.java   View source code 6 votes vote down vote up
@SuppressLint("InlinedApi")
/* package */ static AudioCapabilities getCapabilities(Intent intent) {
  if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) {
    return DEFAULT_AUDIO_CAPABILITIES;
  }
  return new AudioCapabilities(intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS),
      intent.getIntExtra(AudioManager.EXTRA_MAX_CHANNEL_COUNT, 0));
}
 
Example 22
Project: PokerBankroll   File: adpDrawerPrincipal.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        convertView = mInflater.inflate(R.layout.list_drawer_principal, null);
    }

    ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
    TextView txtTitle = (TextView) convertView.findViewById(R.id.txtTitulo);

    imgIcon.setImageResource(navDrawerItems.get(position).getIcon());
    txtTitle.setText(navDrawerItems.get(position).getTitle());

    return convertView;
}
 
Example 23
Project: LucaHome-AndroidApplication   File: MoneyMeterListViewAdapter.java   View source code 6 votes vote down vote up
@SuppressLint({"InflateParams", "ViewHolder"})
@Override
public View getView(final int index, View convertView, ViewGroup parent) {
    final Holder holder = new Holder();

    View rowView = _inflater.inflate(R.layout.listview_card_moneymeterdata, null);

    holder._dateText = rowView.findViewById(R.id.moneymeterdata_date_text_view);
    holder._valueText = rowView.findViewById(R.id.moneymeterdata_value_text_view);
    holder._unitText = rowView.findViewById(R.id.moneymeterdata_unit_text_view);
    holder._updateButton = rowView.findViewById(R.id.moneymeterdata_card_update_button);
    holder._deleteButton = rowView.findViewById(R.id.moneymeterdata_card_delete_button);

    final MoneyMeterData moneyMeterData = _listViewItems.getValue(index);

    holder._dateText.setText(moneyMeterData.GetSaveDate().DDMMYYYY());
    holder._valueText.setText(String.valueOf(moneyMeterData.GetAmount()));
    holder._unitText.setText(moneyMeterData.GetUnit());

    holder._updateButton.setOnClickListener(view -> holder.navigateToEditActivity(moneyMeterData));
    holder._deleteButton.setOnClickListener(view -> holder.displayDeleteDialog(moneyMeterData));

    rowView.setVisibility((moneyMeterData.GetServerDbAction() == ILucaClass.LucaServerDbAction.Delete) ? View.GONE : View.VISIBLE);

    return rowView;
}
 
Example 24
Project: android-mobile-engage-sdk   File: IamWebViewProvider.java   View source code 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public void loadMessageAsync(final String html, final IamJsBridge jsBridge, final MessageLoadedListener messageLoadedListener) {
    Assert.notNull(html, "Html must not be null!");
    Assert.notNull(messageLoadedListener, "MessageLoadedListener must not be null!");
    Assert.notNull(jsBridge, "JsBridge must not be null!");

    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @SuppressLint({"JavascriptInterface", "AddJavascriptInterface"})
        @Override
        public void run() {
            Context context = MobileEngage.getConfig().getApplication();
            webView = new WebView(context);

            jsBridge.setWebView(webView);

            webView.getSettings().setJavaScriptEnabled(true);
            webView.addJavascriptInterface(jsBridge, "Android");
            webView.setBackgroundColor(Color.TRANSPARENT);
            webView.setWebViewClient(new IamWebViewClient(messageLoadedListener));

            webView.loadData(html, "text/html", "UTF-8");
        }
    });
}
 
Example 25
Project: AllHuaji   File: MainActivity.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_demo);
	setting = new Settings(this);
	s = (Switch) findViewById(R.id.switch1);
	s.setChecked(setting.isStarted());
	s.setOnCheckedChangeListener(new OnCheckedChangeListener() {
		
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			// TODO 自动生成的方法存根
			setting.setStarted(isChecked);
		}
	});
	
}
 
Example 26
Project: Toodoo   File: ToodooCamera.java   View source code 6 votes vote down vote up
/**
 * Creates and starts the camera.  Note that this uses a higher resolution in comparison
 * to other detection examples to enable the ocr detector to detect small text samples
 * at long distances.
 *
 * Suppressing InlinedApi since there is a check that the minimum version is met before using
 * the constant.
 */
@SuppressLint("InlinedApi")
private void createCameraSource(boolean autoFocus, boolean useFlash) {
    Context context = getApplicationContext();

    // A text recognizer is created to find text.  An associated multi-processor instance
    // is set to receive the text recognition results, track the text, and maintain
    // graphics for each text block on screen.  The factory is used by the multi-processor to
    // create a separate tracker instance for each text block.
    TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();
    textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay));

    if (!textRecognizer.isOperational()) {
        // Note: The first time that an app using a Vision API is installed on a
        // device, GMS will download a native libraries to the device in order to do detection.
        // Usually this completes before the app is run for the first time.  But if that
        // download has not yet completed, then the above call will not detect any text,
        // barcodes, or faces.
        //
        // isOperational() can be used to check if the required native libraries are currently
        // available.  The detectors will automatically become operational once the library
        // downloads complete on device.
        Log.w(TAG, "Detector dependencies are not yet available.");

        // Check for low storage.  If there is low storage, the native library will not be
        // downloaded, so detection will not become operational.
        IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
        boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;

        if (hasLowStorage) {
            Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }

    // Creates and starts the camera.  Note that this uses a higher resolution in comparison
    // to other detection examples to enable the text recognizer to detect small pieces of text.
    mCameraSource =
            new CameraSource.Builder(getApplicationContext(), textRecognizer)
                    .setFacing(CameraSource.CAMERA_FACING_BACK)
                    .setRequestedPreviewSize(1280, 1024)
                    .setRequestedFps(2.0f)
                    .setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
                    .setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null)
                    .build();
}
 
Example 27
Project: PlusGram   File: CameraController.java   View source code 6 votes vote down vote up
public void startPreview(final CameraSession session) {
    if (session == null) {
        return;
    }
    threadPool.execute(new Runnable() {
        @SuppressLint("NewApi")
        @Override
        public void run() {
            Camera camera = session.cameraInfo.camera;
            try {
                if (camera == null) {
                    camera = session.cameraInfo.camera = Camera.open(session.cameraInfo.cameraId);
                }
                camera.startPreview();
            } catch (Exception e) {
                session.cameraInfo.camera = null;
                if (camera != null) {
                    camera.release();
                }
                FileLog.e("tmessages", e);
            }
        }
    });
}
 
Example 28
Project: GitHub   File: MessageDialog.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
	View dialogView = LayoutInflater.from(getActivity())
			.inflate(R.layout.dialog_message, null);

	TextView messageView = (TextView) dialogView.findViewById(R.id.message);
	messageView.setMovementMethod(LinkMovementMethod.getInstance());
	messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));

	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
	builder.setTitle(getArguments().getString(ARG_TITLE))
			.setIcon(getArguments().getInt(ARG_ICON))
			.setView(dialogView)
			.setPositiveButton(R.string.OK, new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
			});

	return builder.create();
}
 
Example 29
Project: letv   File: TDialog.java   View source code 5 votes vote down vote up
@SuppressLint({"SetJavaScriptEnabled"})
private void b() {
    this.i.setVerticalScrollBarEnabled(false);
    this.i.setHorizontalScrollBarEnabled(false);
    this.i.setWebViewClient(new FbWebViewClient());
    this.i.setWebChromeClient(this.mChromeClient);
    this.i.clearFormData();
    WebSettings settings = this.i.getSettings();
    settings.setSavePassword(false);
    settings.setSaveFormData(false);
    settings.setCacheMode(-1);
    settings.setNeedInitialFocus(false);
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(true);
    settings.setRenderPriority(RenderPriority.HIGH);
    settings.setJavaScriptEnabled(true);
    if (!(this.c == null || this.c.get() == null)) {
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(((Context) this.c.get()).getApplicationContext().getDir("databases", 0).getPath());
    }
    settings.setDomStorageEnabled(true);
    this.jsBridge.a(new JsListener(), "sdk_js_if");
    this.i.loadUrl(this.e);
    this.i.setLayoutParams(a);
    this.i.setVisibility(4);
    this.i.getSettings().setSavePassword(false);
}
 
Example 30
Project: GitHub   File: PrefStore.java   View source code 5 votes vote down vote up
/**
 * Get height of device screen
 *
 * @param c context
 * @return screen height
 */
@SuppressLint("NewApi")
static Integer getScreenHeight(Context c) {
    int height = 0;
    WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    if (Build.VERSION.SDK_INT > 12) {
        Point size = new Point();
        display.getSize(size);
        height = size.y;
    } else {
        height = display.getHeight(); // deprecated
    }
    return height;
}
 
Example 31
Project: APIJSON-Android-RxJava   File: GridAdapter.java   View source code 5 votes vote down vote up
/**标记List<String>中的值是否已被选中。
 * 不需要可以删除,但“this.list = list;”这句
 * 要放到constructor【这个adapter只有ModleAdapter(Context context, List<Object> list)这一个constructor】里去
 * @param list
 * @return
 */
@SuppressLint("UseSparseArrays")
private void initList(List<Entry<String, String>> list) {
	this.list = list;
	if (hasCheck) {
		hashMap = new HashMap<Integer, Boolean>();
		if (list != null) {
			for (int i = 0; i < list.size(); i++) {
				hashMap.put(i, false);
			}
		}
	}
}
 
Example 32
Project: LeCatApp   File: InactivityTimer.java   View source code 5 votes vote down vote up
/**
 * 首先终止之前的监控任务,然后新起一个监控任务
 */
@SuppressWarnings("unchecked")
@SuppressLint("NewApi")
public synchronized void onActivity() {
	cancel();
	inactivityTask = new InactivityAsyncTask();
	inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 33
Project: orgzly-android   File: SyncFragment.java   View source code 5 votes vote down vote up
@SuppressLint("StaticFieldLeak")
public void createFilter(final Filter filter) {
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            mShelf.createFilter(filter);
            return null;
        }
    }.execute();
}
 
Example 34
Project: AndiCar   File: BaseEditFragment.java   View source code 5 votes vote down vote up
@SuppressLint("WrongConstant")
void initDateTimeFields() {
    mDateTimeCalendar.setTimeInMillis(mlDateTimeInMillis);
    if (isTimeOnly) {
        mDateTimeCalendar.set(1970, Calendar.JANUARY, 1);
    }
    mYear = mDateTimeCalendar.get(Calendar.YEAR);
    mMonth = mDateTimeCalendar.get(Calendar.MONTH);
    mDay = mDateTimeCalendar.get(Calendar.DAY_OF_MONTH);
    mHour = mDateTimeCalendar.get(Calendar.HOUR_OF_DAY);
    mMinute = mDateTimeCalendar.get(Calendar.MINUTE);
    mDateTimeCalendar.set(mYear, mMonth, mDay, mHour, mMinute, 0); //reset seconds to 0
    mlDateTimeInMillis = mDateTimeCalendar.getTimeInMillis();
}
 
Example 35
Project: ObjectBoxDebugBrowser   File: NetworkUtils.java   View source code 5 votes vote down vote up
public static String getAddressLog(Context context, int port) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
    @SuppressLint("DefaultLocale")
    final String formattedIpAddress = String.format("%d.%d.%d.%d",
            (ipAddress & 0xff),
            (ipAddress >> 8 & 0xff),
            (ipAddress >> 16 & 0xff),
            (ipAddress >> 24 & 0xff));
    return "Open http://" + formattedIpAddress + ":" + port + " in your browser";
}
 
Example 36
Project: encryptedprefs   File: SecureSharedPreferencesTest.java   View source code 5 votes vote down vote up
@SuppressLint("CommitPrefEdits")
@Test
public void secureEditor_putFloat_ShouldStoreToBackingEditor() {

    SharedPreferences.Editor editor = mockPutValue(String.valueOf(Float.MAX_VALUE));

    EncryptedSharedPreferences.SecureEditor secureEditor = (EncryptedSharedPreferences.SecureEditor) prefs.edit();
    SharedPreferences.Editor returnedEditor = secureEditor.putFloat(KEY, Float.MAX_VALUE);

    secureEditor_verifyPutValue(editor, secureEditor, returnedEditor);
}
 
Example 37
Project: OSchina_resources_android   File: ShareNewsActivity.java   View source code 5 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
protected void initData() {
    super.initData();
    mTextTitle.setText(mBean.getTitle());
    mTextPubDate.setText("发布于 " + StringUtils.formatYearMonthDay(mBean.getPubDate()));
    Author author = mBean.getAuthor();
    if (author != null) {
        mTextAuthor.setText("@" + author.getName());
    }
}
 
Example 38
Project: letv   File: SyncUserStateUtil.java   View source code 5 votes vote down vote up
@SuppressLint({"AddJavascriptInterface"})
public synchronized void syncUserStateByAsync(Context context) {
    LogInfo.log("wlx", "通知WebView客户端登录登出状态");
    mIsSyncUserStateSuccessWithH5 = false;
    WebView webView = new WebView(context);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.addJavascriptInterface(new JSHandler(), "jshandler");
    webView.setVisibility(8);
    webView.loadUrl(getSyncUserStateUrl());
    webView.setWebViewClient(new 1(this));
}
 
Example 39
Project: simplewallet-api-java   File: SimpleWallet.java   View source code 5 votes vote down vote up
@SuppressLint("DefaultLocale")
public static String AmountToString(long amount){
  String res = "";
  DecimalFormat df = new DecimalFormat("#.00##########");
  res = df.format(amount * 0.000000000001);
  return res;
}
 
Example 40
Project: UpdateLibrary   File: X5WebView.java   View source code 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public X5WebView(Context arg0, AttributeSet arg1) {
    super(arg0, arg1);
    this.setWebViewClient(client);
    initWebViewSettings();
    this.getView().setClickable(true);
}