Java Code Examples for android.support.annotation.Keep

The following are top voted examples for showing how to use android.support.annotation.Keep. 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: android_ui   File: SeekBarWidget.java   View source code 6 votes vote down vote up
/**
 * Specifies a transformation for the discrete components. Depends on the implementation,
 * this can change alpha value of some discrete components or theirs current scale for example.
 * <p>
 * This method can be used to animate revealing/concealing of the discrete components or theirs
 * immediate hiding/showing.
 *
 * @param transformation The desired transformation from the range {@code [0.0, 1.0]}.
 *                       Transformation {@code 0.0} means that discrete components will be
 *                       hided, {@code 1.0} means that they will be visible.
 */
@Keep
void setDiscreteTransformation(float transformation) {
	if (this.transformation != transformation) {
		this.transformation = transformation;
		// Scale up/down the discrete indicator and the thumb in a way when one is fully scaled
		// up the other is fully scaled down and reversed.
		setThumbScale(1 - transformation);
		setDiscreteIndicatorScale(transformation);

		// Fade in/out the text of discrete indicator during the indicator is at least 75% transformed/visible.
		if (transformation > 0.75) {
			final int alpha = Math.round((transformation - 0.75f) / 0.25f * 255);
			setDiscreteIndicatorTextAlpha(alpha);
		} else {
			setDiscreteIndicatorTextAlpha(0);
		}

		// Fade in/out discrete interval.
		setDiscreteIntervalAlpha(Math.round(transformation * 255));
		invalidate();
	}
}
 
Example 2
Project: usb-with-serial-port   File: UsbSerialProber.java   View source code 6 votes vote down vote up
/**
 * Probes a single device for a compatible driver.
 *
 * @param usbDevice the usb device to probe
 *
 * @return a new {@link UsbSerialDriver} compatible with this device, or
 * {@code null} if none available.
 */
@Keep
public UsbSerialDriver probeDevice(final UsbDevice usbDevice) {
    final int vendorId = usbDevice.getVendorId();
    final int productId = usbDevice.getProductId();
    final Class<? extends UsbSerialDriver> driverClass = mProbeTable.findDriver(vendorId, productId);
    if (driverClass != null) {
        final UsbSerialDriver driver;
        try {
            final Constructor<? extends UsbSerialDriver> constructor = driverClass.getConstructor(UsbDevice.class);
            driver = constructor.newInstance(usbDevice);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return driver;
    }
    return null;
}
 
Example 3
Project: Pioneer   File: DataInitializer.java   View source code 6 votes vote down vote up
@Subscribe @Keep
public void onAppInitializeRequest(AppInitializeRequestEvent event) {
    // 构造的时候无法执行注入, 推迟到需要的时候再注入
    initialize();

    File dbInCache = new File(cacheDir, "db/store.db");
    if (cacheDir != null && !dbInCache.exists()) {
        appBus.post(new AppInitializeReportEvent("正在缓存数据库"));
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            return;
        }
        if (IoUtils.ensureDirsExist(dbInCache.getParentFile())) {
            IoUtils.copyAssets(AppMain.app().getAssets(), Assets.STORE_DB, dbInCache);
        } else {
            Timber.w("Can't ensure cache dir");
        }
    }
}
 
Example 4
Project: Pioneer   File: DataInitializer.java   View source code 6 votes vote down vote up
@Subscribe @Keep
public void onAppInitializeRequest(AppInitializeRequestEvent event) {
    // 构造的时候无法执行注入, 推迟到需要的时候再注入
    initialize();

    File dbInCache = new File(cacheDir, "db/store.db");
    if (cacheDir != null && !dbInCache.exists()) {
        appBus.post(new AppInitializeReportEvent("正在缓存数据库"));
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            return;
        }
        if (IoUtils.ensureDirsExist(dbInCache.getParentFile())) {
            IoUtils.copyAssets(AppMain.app().getAssets(), Assets.STORE_DB, dbInCache);
        } else {
            Timber.w("Can't ensure cache dir");
        }
    }
}
 
Example 5
Project: appcan-android   File: EUExBase.java   View source code 6 votes vote down vote up
/**
 * 获取callbackId ,-1为无效值
 * @param callbackIdStr
 * @return 为空或转换失败时返回-1
 */
@Keep
int valueOfCallbackId(String callbackIdStr){
    int callbackId=-1;
    if (TextUtils.isEmpty(callbackIdStr)||callbackIdStr.equals("null")){
        return callbackId;
    }
    try{
        callbackId=Integer.parseInt(callbackIdStr);
    }catch (Exception e){
        if (BDebug.DEBUG){
            e.printStackTrace();
        }
    }
    return callbackId;
}
 
Example 6
Project: android-state   File: TestProguard.java   View source code 5 votes vote down vote up
@Keep
public void verifyValue(int value) {
    if (test1 != value) {
        throw new IllegalStateException();
    }
    if (getTest2() != value) {
        throw new IllegalStateException();
    }
    if (test3 != value) {
        throw new IllegalStateException();
    }
}
 
Example 7
Project: android-state   File: TestProguardBundler.java   View source code 5 votes vote down vote up
@Keep
public void setValue(int value) {
    mData2.int1 = value;
    mData2.int2 = value;
    mDataReflOtherName.int1 = value;
    mDataReflOtherName.int2 = value;
}
 
Example 8
Project: android-state   File: TestProguardBundler.java   View source code 5 votes vote down vote up
@Keep
public void verifyValue(int value) {
    if (mData2.int1 != value) {
        throw new IllegalStateException();
    }
    if (mData2.int2 != value) {
        throw new IllegalStateException();
    }
    if (mDataReflOtherName.int1 != value) {
        throw new IllegalStateException();
    }
    if (mDataReflOtherName.int2 != value) {
        throw new IllegalStateException();
    }
}
 
Example 9
Project: LaunchEnr   File: AllAppsBackgroundDrawable.java   View source code 5 votes vote down vote up
@Override
@Keep
public void setAlpha(int alpha) {
    mHand.setAlpha(alpha);
    for (int i = 0; i < mIcons.length; i++) {
        mIcons[i].setAlpha(alpha);
    }
    invalidateSelf();
}
 
Example 10
Project: Chidori   File: MainActivity.java   View source code 5 votes vote down vote up
@Keep
public void onEvent(String action) {
    // 垃圾小米 rom 里把 append 方法给删了
    // mTextView.append("接收到消息:" + t + "\n");

    mTextView.setText(null);
    String str = mTextView.getText().toString();
    mTextView.setText(str + "接收到:" + action + "\n");

    Log.d("kymjs", "kymjs=======demo=====" + action);
}
 
Example 11
Project: Chidori   File: MainActivity.java   View source code 5 votes vote down vote up
@Keep
public void onEvent(String action) {
    // 垃圾小米 rom 里把 append 方法给删了
    // mTextView.append("接收到消息:" + t + "\n");
    String str = mTextView.getText().toString();
    mTextView.setText(str + "接收到:" + action + "\n");
    
    Log.d("kymjs", "kymjs======sample======" + action);
}
 
Example 12
Project: EpubReaderAndroid   File: InternalEpubBridge.java   View source code 5 votes vote down vote up
@Keep
@JavascriptInterface
public void onLocationChanged(String xPath) {
    if (xPath == null) {
        return;
    }
    xPathSubject.onNext(xPath);
}
 
Example 13
Project: Tangram-Android   File: SlideCard.java   View source code 5 votes vote down vote up
@Keep
public void parseMeta(Event event) {
    try {
        if (mTotalPageCount != Integer.MAX_VALUE) {
            storeCache();
        }
        mIndex = Integer.parseInt(event.args.get(KEY_INDEX));
        mTotalPageCount = Integer.parseInt(event.args.get(KEY_PAGE_COUNT));
    } catch (Exception e) {
    }
}
 
Example 14
Project: OpenYOLO-Android   File: LoginViewModel.java   View source code 5 votes vote down vote up
/**
 * Creates the view model, with the required application reference.
 */
@Keep
public LoginViewModel(Application application) {
    super(application);
    mApplication = OpenYoloDemoApplication.getInstance(application);
    mUserDataSource = mApplication.getUserRepository();
    mCredentialClient = CredentialClient.getInstance(mApplication);
}
 
Example 15
Project: Here   File: SpannedGridLayoutManager.java   View source code 5 votes vote down vote up
@Keep /* XML constructor, see RecyclerView#createLayoutManager */
public SpannedGridLayoutManager(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.SpannedGridLayoutManager, defStyleAttr, defStyleRes);
    columns = a.getInt(R.styleable.SpannedGridLayoutManager_spanCount, 1);
    parseAspectRatio(a.getString(R.styleable.SpannedGridLayoutManager_aspectRatio));
    // TODO use this!
    int orientation = a.getInt(
            R.styleable.SpannedGridLayoutManager_android_orientation, RecyclerView.VERTICAL);
    a.recycle();
    setAutoMeasureEnabled(true);
}
 
Example 16
Project: RetroMusicPlayer   File: SpannedGridLayoutManager.java   View source code 5 votes vote down vote up
@Keep /* XML constructor, see RecyclerView#createLayoutManager */
public SpannedGridLayoutManager(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.SpannedGridLayoutManager, defStyleAttr, defStyleRes);
    columns = a.getInt(R.styleable.SpannedGridLayoutManager_spanCount, 1);
    parseAspectRatio(a.getString(R.styleable.SpannedGridLayoutManager_aspectRatio));
    // TODO use this!
    int orientation = a.getInt(
            R.styleable.SpannedGridLayoutManager_android_orientation, RecyclerView.VERTICAL);
    a.recycle();
    setAutoMeasureEnabled(true);
}
 
Example 17
Project: Android-Migrator   File: SQLiteMigrations.java   View source code 5 votes vote down vote up
/**
 * New migrations from default assets folder.
 *
 * @param context current application context.
 */
@Keep
public SQLiteMigrations(
    @NonNull final Context context
) {
    this(context, DEFAULT_FOLDER);
}
 
Example 18
Project: Android-Migrator   File: SQLiteMigrations.java   View source code 5 votes vote down vote up
/**
 * New migrations from custom assets folder.
 *
 * @param context current application content.
 * @param folder  custom folder.
 */
@Keep
public SQLiteMigrations(
    @NonNull final Context context,
    @NonNull final String folder
) {
    this.context = context;
    this.folder = folder;
}
 
Example 19
Project: BizareChat   File: ChatRoomFragment.java   View source code 5 votes vote down vote up
@Subscribe(threadMode = ThreadMode.MAIN)
@Keep
public void onPrivateMessageEvent(PrivateMessageEvent event) {
    if (presenter.getType() == DialogsType.PRIVATE_CHAT) {
        presenter.processPrivateMessage(event.getMessage());
    }
}
 
Example 20
Project: BizareChat   File: ChatRoomFragment.java   View source code 5 votes vote down vote up
@Subscribe(threadMode = ThreadMode.MAIN)
@Keep
public void onPublicMessageEvent(PublicMessageEvent event) {
    if (presenter.getType() != DialogsType.PRIVATE_CHAT) {
        presenter.processPublicMessage(event.getMessage());
    }
}
 
Example 21
Project: android-recaptcha   File: RecaptchaV1Task.java   View source code 5 votes vote down vote up
@Keep
@JavascriptInterface
public void onGetChallenge(String challenge) {
  if (failureRunnable != null) {
    handler.removeCallbacks(failureRunnable);
    failureRunnable = null;
  } else {
    // FailureRunnable has run
    return;
  }

  final String finalChallenge = challenge;
  final String finalImage = image;
  final boolean success = !TextUtils.isEmpty(challenge) || !TextUtils.isEmpty(image);

  handler.post(new Runnable() {
    @Override
    public void run() {
      if (!destroyed) {
        destroyed = true;
        webView.destroy();
        if (success) {
          callback.onSuccess(finalChallenge, finalImage);
        } else {
          callback.onFailure();
        }
      }
    }
  });
}
 
Example 22
Project: usb-with-serial-port   File: UsbSerialProber.java   View source code 5 votes vote down vote up
/**
 * Finds and builds all possible {@link UsbSerialDriver UsbSerialDrivers}
 * from the currently-attached {@link UsbDevice} hierarchy. This method does
 * not require permission from the Android USB system, since it does not
 * open any of the devices.
 *
 * @param usbManager
 * @return a list, possibly empty, of all compatible drivers
 */
@Keep
public List<UsbSerialDriver> findAllDrivers(final UsbManager usbManager) {
    final List<UsbSerialDriver> result = new ArrayList<UsbSerialDriver>();
    HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
    Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
    while (deviceIterator.hasNext()) {
        UsbDevice usbDevice = deviceIterator.next();
        UsbSerialDriver driver = probeDevice(usbDevice);
        if (driver != null) {
            result.add(driver);
        }
    }
    return result;
}
 
Example 23
Project: android-multipleGridRecyclerView-library   File: SpannedGridLayoutManager.java   View source code 5 votes vote down vote up
@Keep /* XML constructor, see RecyclerView#createLayoutManager */
public SpannedGridLayoutManager(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.SpannedGridLayoutManager, defStyleAttr, defStyleRes);
    columns = a.getInt(R.styleable.SpannedGridLayoutManager_spanCount, 1);
    parseAspectRatio(a.getString(R.styleable.SpannedGridLayoutManager_aspectRatio));
    // TODO use this!
    int orientation = a.getInt(
            R.styleable.SpannedGridLayoutManager_android_orientation, RecyclerView.VERTICAL);
    a.recycle();
    setAutoMeasureEnabled(true);
}
 
Example 24
Project: ocreader   File: FABLayout.java   View source code 5 votes vote down vote up
@Keep
public void setFabBackgroundColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ColorStateList colorStateList = ColorStateList.valueOf(color);
        for (int i = 0; i < getChildCount(); i++) {
            View view = getChildAt(i);
            if (view instanceof FloatingActionButton)
                view.setBackgroundTintList(colorStateList);
        }
    }
}
 
Example 25
Project: ocreader   File: ItemPagerActivity.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Keep
@Override
void setStatusBarColor(int backgroundColor) {
    int statusbarColor = changeLightness(backgroundColor, 0.7f);
    getWindow().setStatusBarColor(statusbarColor);
    super.setStatusBarColor(backgroundColor);
}
 
Example 26
Project: react-native-navigation   File: SharedElementTransition.java   View source code 5 votes vote down vote up
@Keep
public void setTextColor(double[] color) {
    if (child instanceof TextView) {
        ViewUtils.setSpanColor(spannableText, ColorUtils.labToColor(color));
        ((TextView) child).setText(spannableText);
    }
}
 
Example 27
Project: android-proguards   File: StaggeredDistanceSlide.java   View source code 5 votes vote down vote up
@Keep
public StaggeredDistanceSlide(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray a =
            context.obtainStyledAttributes(attrs, R.styleable.StaggeredDistanceSlide);
    spread = a.getInteger(R.styleable.StaggeredDistanceSlide_spread, spread);
    a.recycle();
}
 
Example 28
Project: kits   File: SpannedGridLayoutManager.java   View source code 5 votes vote down vote up
@Keep /* XML constructor, see RecyclerView#createLayoutManager */
public SpannedGridLayoutManager(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.SpannedGridLayoutManager, defStyleAttr, defStyleRes);
    columns = a.getInt(R.styleable.SpannedGridLayoutManager_spanCount, 1);
    parseAspectRatio(a.getString(R.styleable.SpannedGridLayoutManager_aspectRatio));
    // TODO use this!
    int orientation = a.getInt(
            R.styleable.SpannedGridLayoutManager_android_orientation, RecyclerView.VERTICAL);
    a.recycle();
    setAutoMeasureEnabled(true);
}
 
Example 29
Project: DrawerBehavior   File: DrawerBehavior.java   View source code 5 votes vote down vote up
@Keep @SuppressWarnings("unused") // Instantiated reflectively from layout XML.
public DrawerBehavior(Context context, AttributeSet attrs) {
  super(context, attrs);
  TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawerBehavior);
  int gravity =
      a.getInteger(R.styleable.DrawerBehavior_android_layout_gravity, GravityCompat.END);
  a.recycle();

  validateGravity(gravity);
  this.gravity = gravity;
}
 
Example 30
Project: bachamada   File: MainActivity.java   View source code 5 votes vote down vote up
@Keep
public void onEvent(final OnDeleteFCEvent deleteFCEvent) {

    mDbHelper.deleteFC(deleteFCEvent.getId());
    updateBpmMinMax();
    mZoneBPMFrag.updateZone();

}
 
Example 31
Project: Jockey   File: GestureView.java   View source code 5 votes vote down vote up
/**
 * Sets the current radius of the overlay background. This method is used by an
 * {@link ObjectAnimator} to animate completion events and shouldn't be used by external
 * classes because it will be overwritten.
 * @param radius The new radius of the background overlay
 */
@Keep
@SuppressWarnings("unused")
public void setRadius(int radius) {
    if (mOverlayEdge != null && mOverlayOrigin != null) {
        mOverlayEdge.x = mOverlayOrigin.x + radius;
        invalidate();
    }
}
 
Example 32
Project: plaid   File: StaggeredDistanceSlide.java   View source code 5 votes vote down vote up
@Keep
public StaggeredDistanceSlide(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray a =
            context.obtainStyledAttributes(attrs, R.styleable.StaggeredDistanceSlide);
    spread = a.getInteger(R.styleable.StaggeredDistanceSlide_spread, spread);
    a.recycle();
}
 
Example 33
Project: appcan-android   File: BDebug.java   View source code 5 votes vote down vote up
@Keep
public static void sendUDPLog(String log){
    if (WDataManager.sRootWgt==null||WDataManager.sRootWgt.m_appdebug==0|| TextUtils.isEmpty(WDataManager.sRootWgt.m_logServerIp)){
        return;
    }
    Intent intent=new Intent(BConstant.app,DebugService.class);
    intent.putExtra(DebugService.KEY_TYPE_DEBUG,DebugService.TYPE_LOG);
    intent.putExtra(DebugService.KEY_LOG_DATA,log);
    BConstant.app.startService(intent);
}
 
Example 34
Project: appcan-android   File: BUtility.java   View source code 5 votes vote down vote up
/**
 * 获取真实的路径,同时拷贝res协议文件到sd卡缓存目录
 *
 * @param mBrwView
 * @param url      AppCan协议路径
 * @return
 */
@Keep
public static String getRealPathWithCopyRes(EBrowserView mBrwView, String url) {
    String realPath = makeRealPath(url, mBrwView);
    if (realPath.startsWith("/") && !realPath.startsWith("/data")) {
        return realPath;
    }
    return getResLocalPath(mBrwView.getContext(), realPath);
}
 
Example 35
Project: appcan-android   File: EUExBase.java   View source code 5 votes vote down vote up
@Keep
public static void callBackJs(EBrowserView eBrowserView,String methodName, String jsonData){
    if (eBrowserView == null) {
        BDebug.e("mBrwView is null...");
        return;
    }
    String js = SCRIPT_HEADER + "if(" + methodName + "){"
            + methodName + "('" + jsonData + "');}else{console.log('function "+methodName +" not found.')}";
    callbackToJs(eBrowserView,js);
}
 
Example 36
Project: appcan-android   File: EUExBase.java   View source code 5 votes vote down vote up
@Keep
public static void callBackJsObject(EBrowserView eBrowserView,String methodName, Object value){
    if (eBrowserView == null) {
        BDebug.e("mBrwView is null...");
        return;
    }
    String js = SCRIPT_HEADER + "if(" + methodName + "){"
            + methodName + "(" + value + ");}else{console.log('function "+methodName +" not found.')}";
    callbackToJs(eBrowserView,js);
}
 
Example 37
Project: appcan-android   File: EUExBase.java   View source code 5 votes vote down vote up
/**
 * 异步回调到JS
 * @param callbackId 回调ID,该值由插件接口被调用时传入
 * @param hasNext 是否有下一次回调。没有传false ,有传true
 * @param args 参数可以是任何对象,直接回调对象可使用DataHelper.gson.toJsonTree()方法
 */
@Keep
public void callbackToJs(int callbackId,boolean hasNext,Object... args){
    if (null != mBrwView) {

        int flag=hasNext?1:0;
        final StringBuilder sb=new StringBuilder("javascript:uexCallback.callback(");
        sb.append(callbackId).append(",").append(flag);
        for (Object obj:args){
            sb.append(",");
            boolean isStrArg = obj instanceof String;
            if (isStrArg) {
                sb.append("\'");
            }
            sb.append(String.valueOf(obj));
            if (isStrArg) {
                sb.append("\'");
            }
         }
        sb.append(");");
        BDebug.i(sb.toString());
        //在主线程回调
        if (mContext!=null&&mContext instanceof Activity){
            ((Activity)mContext).runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (null != mBrwView) {
                        mBrwView.loadUrl(sb.toString());
                    }
                }
            });
        }else{
            callbackToJs(mBrwView,sb.toString());
        }
     }
}
 
Example 38
Project: appcan-android   File: EUExBase.java   View source code 5 votes vote down vote up
/**
 * 区分接口收到的参数,简单判断字符串是否是json格式的String,没有必要完整校验一遍
 * @param str
 * @return
 */
@Keep
boolean isJsonString(String str){
    if (TextUtils.isEmpty(str)){
        return false;
    }
    return str.startsWith("{") && str.endsWith("}")||
            str.startsWith("[") && str.endsWith("]");
}
 
Example 39
Project: appcan-android   File: EUExBase.java   View source code 5 votes vote down vote up
/**
 * 判断数组的第一个是否存在并且是Json格式
 * @param params
 * @return
 */
@Keep
boolean isFirstParamExistAndIsJson(String[] params){
    if (params==null||params.length==0){
        return false;
    }
    return isJsonString(params[0]);
}
 
Example 40
Project: sketch   File: Sketch.java   View source code 5 votes vote down vote up
/**
 * 修整内存缓存,4.0 以下你需要重写 {@link Application#onTrimMemory(int)} 方法,然后调用这个方法
 *
 * @param level 修剪级别,对应 APP 的不同状态,对应 {@link ComponentCallbacks2} 里的常量
 */
@Keep
public void onTrimMemory(int level) {
    SLog.w(null, "Trim of memory, level= %s", SketchUtils.getTrimLevelName(level));

    configuration.getMemoryCache().trimMemory(level);
    configuration.getBitmapPool().trimMemory(level);
}