Java Code Examples for com.orhanobut.logger.Logger#w()

The following examples show how to use com.orhanobut.logger.Logger#w() . 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: StorageUtils.java    From MaterialCalendar with Apache License 2.0 6 votes vote down vote up
private static File getExternalCacheDir(Context context, String type) {
    File appCacheDir =
            new File(new File(Environment.getExternalStorageDirectory(), "tifen"), type);
    if (!appCacheDir.exists()) {
        if (!appCacheDir.mkdirs()) {
            Logger.w("Unable to create external cache directory");
            return null;
        }
        try {
            new File(appCacheDir, ".nomedia").createNewFile();
        } catch (IOException e) {
            Logger.i("Can't create \".nomedia\" file in application external cache directory");
        }
    }
    return appCacheDir;
}
 
Example 2
Source File: RingerModeLoader.java    From Easer with GNU General Public License v3.0 6 votes vote down vote up
private static boolean amSetMode(AudioManager audioManager, RingerMode mode) {
    int am_mode;
    switch (mode) {
        case silent:
            am_mode = AudioManager.RINGER_MODE_SILENT;
            break;
        case vibrate:
            am_mode = AudioManager.RINGER_MODE_VIBRATE;
            break;
        case normal:
            am_mode = AudioManager.RINGER_MODE_NORMAL;
            break;
        default:
            Logger.w("Running on below Lollipop, but ringer mode %s found", mode);
            return false;
    }
    audioManager.setRingerMode(am_mode);
    if (audioManager.getRingerMode() == am_mode) {
        return true;
    } else {
        Logger.e("not properly set ringer mode :: expected <%s> got <%s>", mode, audioManager.getRingerMode());
        return false;
    }
}
 
Example 3
Source File: CycledLeScanner.java    From AndroidBleManager with Apache License 2.0 6 votes vote down vote up
private void stopScan(){
    if (mScanning) {
        BluetoothAdapter mAdapter = mBluetoothUtils.getBluetoothAdapter();
        if (mAdapter != null && mBluetoothUtils.isBluetoothIsEnable()) {
            try {
                BluetoothLeScannerCompat.stopScan(mAdapter, scanCallbackCompat);
                lastScanEndTime = SystemClock.elapsedRealtime();
                Logger.d("stopping bluetooth le scan "+lastScanEndTime);
            } catch (Exception e) {
                Logger.w("Internal Android exception scanning for beacons "+e.toString());
            }
        } else {
            Logger.d("Bluetooth is disabled.  Cannot scan for beacons.");
        }
        nextScanStartTime = SystemClock.elapsedRealtime() + betweenScanPeriod;
        //start next scan cycle
        if (!isPauseScan){
            scanLeDevice(true);
        }
    }
    mScanning = false;
    //// FIXME: 2017/6/22 将其调整到mScanning后面
    if (scanOverListener != null){
        scanOverListener.onScanOver();
    }
}
 
Example 4
Source File: NotificationEventListenerService.java    From Easer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroy() {
    Logger.i("NotificationEventListenerService onDestroy()");
    super.onDestroy();
    LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(mReceiver);
    if (dataList.size() > 0) {
        Logger.w("Listener to notifications not cleaned up completely: %d left",
                dataList.size());
    }
}
 
Example 5
Source File: BluetoothConnectManager.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (!mBluetoothUtils.isBluetoothIsEnable()){
        Logger.w("Fail to connect device! Bluetooth is not enable!");
        closeAll();
    }
}
 
Example 6
Source File: BluetoothConnectManager.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
/**
 * close bluetooth, release resource
 * @param address
 */
public boolean close(String address) {
    if (!isEmpty(address) && gattMap.containsKey(address)){
        Logger.w("close gatt server " + address);
        BluetoothGatt mBluetoothGatt = gattMap.get(address);
        mBluetoothGatt.close();
        gattMap.remove(address);
        updateConnectStateListener(address, ConnectState.NORMAL);
        return true;
    }
    return false;
}
 
Example 7
Source File: ConnectRequestQueue.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
/**
 * 关闭蓝牙连接,会释放BluetoothGatt持有的所有资源
 * @param address
 */
public boolean close(String address) {
    if (!isEmpty(address) && gattMap.containsKey(address)){
        Logger.w( "close gatt server " + address);
        BluetoothGatt mBluetoothGatt = gattMap.get(address);
        mBluetoothGatt.close();
        gattMap.remove(address);
        updateConnectState(address, ConnectState.NORMAL);
        return true;
    }
    return false;
}
 
Example 8
Source File: ConnectRequestQueue.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
/**
 * reconnect device
 * @param address
 */
private synchronized void reconnectDevice(final String address){
    if (macMap.containsKey(address)){
        ReconnectParamsBean bean = reconnectMap.get(address);
        if (mBluetoothUtils.isBluetoothIsEnable()) {
            if (bean == null){
                reconnectMap.put(address, new ReconnectParamsBean(address));
            }

            //check is connected or connectting
            ConnectState state = macMap.get(address);
            if (state == ConnectState.NORMAL){
                Logger.d( "Start reconnect device "+address+" reconnect number is "+bean.getNumber());
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        connect(address);
                    }
                });
            }else{
                Logger.w( "Fail to reconnect device! "+address+" state is "+state);
            }
        }else {
            closeAll();
            Logger.w( "Fail to reconnect device! Bluetooth is not enable!");
        }
    }else{
        Logger.w("Fail to reconnect device! "+address+" is remove from reconnectMap");
        reconnectMap.remove(address);
    }
}
 
Example 9
Source File: ConnectRequestQueue.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (!mBluetoothUtils.isBluetoothIsEnable()){
        Logger.w( "Fail to connect device! Bluetooth is not enable!");
        closeAll();
    }
}
 
Example 10
Source File: CharacteristicDetailActivity.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
public void setCharacteristicNotification(final BluetoothGattCharacteristic characteristic, final boolean enabled) {
    if (gatt == null) {
        Logger.w("CharacteristicDetailActivity", "BluetoothAdapter not initialized");
        return;
    }
    gatt.setCharacteristicNotification(characteristic, enabled);
    if (enabled){
        for (BluetoothGattDescriptor descriptor:characteristic.getDescriptors()){
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            gatt.writeDescriptor(descriptor);
        }
    }

}
 
Example 11
Source File: WriteLogUtil.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
/**
 * 警告信息
 *
 * @param TAG
 * @param msg
 */
public final static void w(String TAG, String msg) {
    if(!isWShow){
        return;
    }
    Logger.w(TAG, msg);
    if (LOG_WRITE_TO_FILE)
        writeLogtoFile("w", TAG, msg);
}
 
Example 12
Source File: GankIoFragment.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
@Override
public void showTabList(String[] tabs) {
    Logger.w(Arrays.toString(tabs));
    for (int i = 0; i < tabs.length; i++) {
        tlTabs.addTab(tlTabs.newTab().setText(tabs[i]));
        switch (i) {
            case TabFragmentIndex.TAB_GANK_DAY_INDEX:
                fragments.add(GankIoDayFragment.newInstance());
                break;
            case TabFragmentIndex.TAB_GANK_CUSTOM_INDEX:
                fragments.add(GankIoCustomFragment.newInstance());
                break;
            case TabFragmentIndex.TAB_GANK_WELFARE_INDEX:
                fragments.add(GankIoWelfareFragment.newInstance());
                break;
            default:
                fragments.add(GankIoDayFragment.newInstance());
                break;
        }
    }
    vpFragment.setAdapter(new FragmentAdapter(getChildFragmentManager(), fragments));
    vpFragment.setCurrentItem(TabFragmentIndex.TAB_GANK_DAY_INDEX);//要设置到viewpager
    // .setAdapter后才起作用
    tlTabs.setupWithViewPager(vpFragment);
    tlTabs.setVerticalScrollbarPosition(TabFragmentIndex.TAB_GANK_DAY_INDEX);
    //tlTabs.setupWithViewPager方法内部会remove所有的tabs,这里重新设置一遍tabs的text,否则tabs的text不显示
    for (int i = 0; i < tabs.length; i++) {
        tlTabs.getTabAt(i).setText(tabs[i]);
    }
}
 
Example 13
Source File: Print.java    From BaseUIFrame with MIT License 4 votes vote down vote up
public static void w(Object log, Throwable tr) {
    Logger.w(String.valueOf(log), tr);
}
 
Example 14
Source File: AFLog.java    From AFBaseLibrary with Apache License 2.0 4 votes vote down vote up
public static void w(String message) {
    if (!DEBUG) {
        return;
    }
    Logger.w(message);
}
 
Example 15
Source File: LogUtil.java    From AcgClub with MIT License 4 votes vote down vote up
public static void w(String tag, Object o) {
  Logger.w(tag, o);
}
 
Example 16
Source File: CycledLeScanner.java    From AndroidBleManager with Apache License 2.0 4 votes vote down vote up
/**
 * Tells the cycler the scan rate and whether it is in operating in background mode.
 * Background mode flag  is used only with the Android 5.0 scanning implementations to switch
 * between LOW_POWER_MODE vs. LOW_LATENCY_MODE
 * @param backgroundFlag is running background
 */
public void setBackgroundMode(long scanPeriod, long betweenScanPeriod, boolean backgroundFlag) {
    if (android.os.Build.VERSION.SDK_INT < 18) {
        Logger.w("Not supported prior to API 18.  Method invocation will be ignored");
        return;
    }

    this.scanPeriod = scanPeriod;
    this.betweenScanPeriod = betweenScanPeriod;
    if (backgroundFlag != mBackgroundFlag) {
        Logger.d("restart polling task scanPeriod:" + scanPeriod + " betweenScanPeriod:" + betweenScanPeriod + " backgroundFlag:" + backgroundFlag + " mode:" + mBackgroundFlag);
        mBackgroundFlag = backgroundFlag;
        long now = SystemClock.elapsedRealtime();

        //update next scan start time(在等待开始扫描时修正下一次开始时间,提前开始)
        if (nextScanStartTime > now){
            long proposedNextScanStartTime = lastScanEndTime + betweenScanPeriod;
            if (proposedNextScanStartTime < nextScanStartTime){
                Logger.d("Waiting...Adjusted nextScanStartTime to be" + (proposedNextScanStartTime - now) + " old:" + (nextScanStartTime - now));
                nextScanStartTime = proposedNextScanStartTime;
            }
        }

        //update current scan stop time(如果在扫描中则修正本次的结束时间,提前结束)
        if (scanStopTime > now){
            long proposedStopTime = nextScanStartTime + scanPeriod;
            if (proposedStopTime < scanStopTime){
                Logger.d("Scanning...Adjusted scanStopTime to be " + (proposedStopTime - now) + " old:" + (scanStopTime - now));
                scanStopTime = proposedStopTime;
            }
        }

        //set scan setting params
        if (!isSetScanSetting || scanSettings == null){
            if (mBackgroundFlag) {
                Logger.d("starting filtered scan in SCAN_MODE_LOW_POWER");
                scanSettings = (new ScanSettingsCompat.Builder().setScanMode(ScanSettingsCompat.SCAN_MODE_LOW_POWER)).build();
            } else {
                Logger.d("starting non-filtered scan in SCAN_MODE_LOW_LATENCY");
                scanSettings = (new ScanSettingsCompat.Builder().setScanMode(ScanSettingsCompat.SCAN_MODE_LOW_LATENCY)).build();
            }
        }
    }
}
 
Example 17
Source File: AgentHandler.java    From landlord_client with Apache License 2.0 4 votes vote down vote up
@Override
public void onSocketIOThreadShutdown(String action, Exception e) {
    Logger.w("Request发送失败");
}
 
Example 18
Source File: JLog.java    From Elephant with Apache License 2.0 4 votes vote down vote up
public static void logw(String tag, String message) {
    if(DEBUG) {
        Logger.init(tag);
        Logger.w(message);
    }
}
 
Example 19
Source File: BluetoothScanManager.java    From AndroidBleManager with Apache License 2.0 3 votes vote down vote up
/**
 * This method notifies the beacon service that the application is either moving to background
 * mode or foreground mode.  When in background mode, BluetoothLE scans to look for beacons are
 * executed less frequently in order to save battery life. The specific scan rates for
 * background and foreground operation are set by the defaults below, but may be customized.
 * When ranging in the background, the time between updates will be much less frequent than in
 * the foreground.  Updates will come every time interval equal to the sum total of the
 * BackgroundScanPeriod and the BackgroundBetweenScanPeriod.
 *
 * @param backgroundMode true indicates the app is in the background
 */
public void setBackgroundMode(boolean backgroundMode) {
    if (android.os.Build.VERSION.SDK_INT < 18) {
        Logger.w("Not supported prior to API 18.  Method invocation will be ignored");
    }
    if (backgroundMode != this.backgroundMode) {
        this.backgroundMode = backgroundMode;
        cycledLeScanner.setBackgroundMode(mPowerSaver.getScanPeriod(), mPowerSaver.getBetweenScanPeriod(), backgroundMode);
    }
}
 
Example 20
Source File: Print.java    From BaseUIFrame with MIT License votes vote down vote up
public static void w(Object log) {Logger.w(String.valueOf(log));}