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

The following examples show how to use com.orhanobut.logger.Logger#e() . 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: MediaControlLoader.java    From Easer with GNU General Public License v3.0 8 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private boolean handleOnApi21(@ValidData @NonNull MediaControlOperationData data) {
    int keyCode = toKeyCode(data.choice);
    KeyEvent keyEvent_down = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
    KeyEvent keyEvent_up = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
    ComponentName myNotificationListenerComponent = new ComponentName(context, MediaControlHelperNotificationListenerService.class);
    MediaSessionManager mediaSessionManager = ((MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE));
    if (mediaSessionManager == null) {
        Logger.e("MediaSessionManager is null.");
        return false;
    }
    List<MediaController> activeSessions = mediaSessionManager.getActiveSessions(myNotificationListenerComponent);
    if (activeSessions.size() > 0) {
        MediaController mediaController = activeSessions.get(0);
        mediaController.dispatchMediaButtonEvent(keyEvent_down);
        mediaController.dispatchMediaButtonEvent(keyEvent_up);
    }
    return true;
}
 
Example 2
Source File: SmsOperationData.java    From Easer with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public String serialize(@NonNull PluginDataFormat format) {
    String res;
    switch (format) {
        default:
            try {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(K_DEST, destination);
                jsonObject.put(K_CONTENT, content);
                res = jsonObject.toString();
            } catch (JSONException e) {
                Logger.e(e, "error");
                throw new IllegalStateException(e);
            }
    }
    return res;
}
 
Example 3
Source File: RingerModeConditionData.java    From Easer with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public String serialize(@NonNull PluginDataFormat format) {
    String res;
    switch (format) {
        default:
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put(T_ringerMode, ringerMode);
                jsonObject.put(T_ringerLevel, ringerLevel);
                jsonObject.put(T_compareMode, compareMode);
            } catch (JSONException e) {
                Logger.e(e, "Error putting %s data", getClass().getSimpleName());
                e.printStackTrace();
            }
            res = jsonObject.toString();
    }
    return res;
}
 
Example 4
Source File: ManagerHolder.java    From landlord_client with Apache License 2.0 6 votes vote down vote up
public IServerManager getServer(int localPort) {
    IServerManagerPrivate manager = (IServerManagerPrivate)mServerManagerMap.get(localPort);
    if (manager == null) {
        manager = (IServerManagerPrivate) SPIUtils.load(IServerManager.class);
        if (manager == null) {
            String err = "Oksocket.Server() load error. Server plug-in are required! For details link to https://github.com/xuuhaoo/OkSocket";
            Logger.e(err);
            throw new IllegalStateException(err);
        } else {
            synchronized(mServerManagerMap) {
                mServerManagerMap.put(localPort, manager);
            }

            manager.initServerPrivate(localPort);
            return manager;
        }
    } else {
        return manager;
    }
}
 
Example 5
Source File: AbstractEditDataActivity.java    From Easer with GNU General Public License v3.0 6 votes vote down vote up
protected void persistChange() {
    Exception e = tryPersistChange();
    if (e == null) {
        setResult(RESULT_OK);
        finish();
        return;
    }
    if (e instanceof ItemBeingUsedException) {
        Logger.d(e);
        Toast.makeText(this, getString(R.string.prompt_delete_failed), Toast.LENGTH_SHORT).show();
    } else if (e instanceof InvalidDataInputException) {
        Logger.d(e);
        Toast.makeText(this, getString(R.string.prompt_data_illegal), Toast.LENGTH_LONG).show();
    } else if (e instanceof DataSavingFailedException) {
        Logger.d(e);
        Toast.makeText(this, getString(R.string.prompt_data_clash), Toast.LENGTH_LONG).show();
    } else if (e instanceof IOException) {
        Logger.d(e);
        Toast.makeText(this, getString(R.string.prompt_data_save_io_exception), Toast.LENGTH_LONG).show();
    } else {
        Logger.e(e, "Unknown exception happened in persistChange()");
        throw new RuntimeException(e);
    }
}
 
Example 6
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 7
Source File: HotspotHelper.java    From Easer with GNU General Public License v3.0 6 votes vote down vote up
boolean setTethering(boolean enable){
    boolean apStatus = false;
    try {
        Class<ConnectivityManager> connectivityClass = ConnectivityManager.class;
        if (enable) {
            Field internalConnectivityManagerField = ConnectivityManager.class.getDeclaredField("mService");
            internalConnectivityManagerField.setAccessible(true);
            callStartTethering(internalConnectivityManagerField.get(connectivityManager));
        } else {
            Method stopTetheringMethod = connectivityClass.getDeclaredMethod("stopTethering", int.class);
            stopTetheringMethod.invoke(connectivityManager, 0);
        }
        apStatus = true;
    } catch (Exception e) {
        apStatus = false;
        Logger.e(e,"Error while changing hotspot state in Tethering method");
    }
    return apStatus;
}
 
Example 8
Source File: ConvListFragment.java    From PlayTogether with Apache License 2.0 6 votes vote down vote up
/**
	 * 收到了消息,根据情况判断是否需要更新未读数量。
	 * 如果是在聊天的界面发送的event,则不需要增加未读数量
	 */
	public void onEvent(EventHomeConversationChange event)
	{
		String conversationId = event.conversation.getConversationId();
		if (event.isUpdateUnreadCount)
			SpUtils.increment(getActivity(), conversationId, 1);
		int pos = getConvPos(conversationId);
		if (pos != -1)
		{
			mAdapter.notifyItemChanged(pos);
		} else//证明还没有这条会话,手动从服务器拉取数据
		{
			Logger.e("refresh conversations");
			// TODO: 2016/2/5 第一次接收这条会话的时候 conversation 的 attr 没有值,只能强制重新拉取 conversation了
//			mAdapter.addConversation(event.conversation);
			mController.getConversations(AVUser.getCurrentUser(User.class).getUsername());
		}
	}
 
Example 9
Source File: LoginComplateManager.java    From imsdk-android with MIT License 5 votes vote down vote up
private static void updateMyCard() {
    String userId = IMLogicManager.getInstance().getMyself().bareJID().fullname();

    try {
        IMUserCardManager.getInstance().updateUserCard(userId, true);
        //原本在这里设置自身名字,现在更改位置 改为获取body后也获取一次
        String myNickName = IMDatabaseManager.getInstance().selectUserByJID(userId).optString("Name");
        CurrentPreference.getInstance().setUserName(myNickName);
        IMNotificaitonCenter.getInstance().postMainThreadNotificationName(QtalkEvent.SHOW_MY_INFO, "");
    } catch (JSONException e) {
        Logger.e(e, "updateMyCard failed.");
    }
}
 
Example 10
Source File: IMMessageManager.java    From imsdk-android with MIT License 5 votes vote down vote up
@Nullable
public String getGroupNickNameByGroupId(String groupId) {
    JSONObject userInfo = IMLogicManager.getInstance().getUserInfoByUserId(IMLogicManager.getInstance().getMyself());
    if (userInfo != null) {

        try {
            String name = userInfo.has("Name") ? userInfo.getString("Name") : (userInfo.has("UserId") ? userInfo.getString("UserId") : "");

            return name;
        } catch (JSONException e) {
            Logger.e(e, "getGroupNickNameByGroupId crashed");
        }
    }
    return null;
}
 
Example 11
Source File: ConvListFragment.java    From PlayTogether with Apache License 2.0 5 votes vote down vote up
public void onEvent(EventMemberLeft event)
{
	//member left
	AVIMConversation conversation = event.conversation;
	//如果成员数小于2,则删除该会话
	if (conversation.getMembers().size() < 2)
	{
		Logger.e("del conv");
		mAdapter.removeConversation(conversation);
		mController.delConversation(conversation);
	}
}
 
Example 12
Source File: MyConversationEventHandler.java    From PlayTogether with Apache License 2.0 5 votes vote down vote up
@Override
public void onMemberLeft(AVIMClient avimClient, AVIMConversation avimConversation,
												 List<String> list, String s)
{
	Logger.e("member left");
	EventBus.getDefault().post(new EventMemberLeft(avimConversation));
}
 
Example 13
Source File: EditUserProfileActivity.java    From phphub-android with Apache License 2.0 5 votes vote down vote up
public void onNetWorkError(Throwable throwable) {
    Logger.e(throwable.getMessage());
    SweetAlertDialog errorDialog = new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE);
    errorDialog.setTitleText("Oops...");
    errorDialog.setContentText(getString(R.string.publish_error));
    errorDialog.show();
}
 
Example 14
Source File: BaseWebViewLoadActivity.java    From YiZhi with Apache License 2.0 4 votes vote down vote up
@Override
public void showNetworkError() {
    Logger.e("Network error.");
    vNetworkError.setVisibility(View.VISIBLE);
}
 
Example 15
Source File: BadTokenBeforeActy.java    From DialogUtil with Apache License 2.0 4 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    Logger.e("onStart---time:" + (System.currentTimeMillis() - startTime));
    takeTime();
}
 
Example 16
Source File: TimetableActivity.java    From Sunshine with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabSelected(TabLayout.Tab tab) {
    Logger.e("点击了周" + (tab.getPosition() + 1));
    viewModel.setDay(tab.getPosition() + 1);
    viewModel.init();
}
 
Example 17
Source File: LogUtils.java    From youqu_master with Apache License 2.0 4 votes vote down vote up
public static void loge(Throwable throwable, String message, Object... args) {
    if (DEBUG_ENABLE) {
        Logger.e(throwable, message, args);
    }
}
 
Example 18
Source File: Print.java    From BaseUIFrame with MIT License 4 votes vote down vote up
public static void e(Object log, Throwable tr) {
    Logger.e(String.valueOf(log), tr);
}
 
Example 19
Source File: ExceptionHandle.java    From xifan with Apache License 2.0 4 votes vote down vote up
public static ApiException handleException(Throwable e) {
    e.printStackTrace();
    Logger.e("http request error result:\n" + e.fillInStackTrace());
    Context context = App.getInstance().getApplicationContext();

    if (e instanceof HttpException) {
        ApiException apiException = null;
        HttpException httpException = (HttpException) e;
        String errorMessage = null;
        switch (httpException.code()) {
            case UNAUTHORIZED:
                errorMessage = context.getString(R.string.http_unauthorized_error);
                break;
            case FORBIDDEN:
            case NOT_FOUND:
            case REQUEST_TIMEOUT:
            case RANGE_NOT_SATISFIABLE:
            case INTERNAL_SERVER_ERROR:
            case BAD_GATEWAY:
            case SERVICE_UNAVAILABLE:
            case GATEWAY_TIMEOUT:
                errorMessage = context.getString(R.string.http_service_error);
                break;
        }

        try {
            String errorBody = httpException.response().errorBody().string();
            if (!TextUtils.isEmpty(errorBody)) {
                errorMessage = errorBody;
            }
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        apiException = new ApiException(ErrorCode.ERROR_UNAUTHORIZED, errorMessage);
        return apiException;
    }

    if (e instanceof ConnectException) {
        return new ApiException(ErrorCode.ERROR_NO_CONNECT,
                context.getString(R.string.http_connect_error));
    }

    if (e instanceof JsonParseException || e instanceof JsonSyntaxException) {
        return new ApiException(ErrorCode.ERROR_PARSE,
                context.getString(R.string.http_data_parse_error));
    }

    if (e instanceof SocketTimeoutException) {
        return new ApiException(ErrorCode.ERROR_NET_TIMEOUT,
                context.getString(R.string.http_connect_timeout));
    }
    return new ApiException(ErrorCode.ERROR_UNKNOWN,
            context.getString(R.string.http_unknow_error));
}
 
Example 20
Source File: L.java    From Conquer with Apache License 2.0 4 votes vote down vote up
public static void e(String msg) {
        if (isDebug) {
//			Log.e(TAG, "........................" + msg);
            Logger.e(msg);
        }
    }