com.apkfuns.logutils.LogUtils Java Examples

The following examples show how to use com.apkfuns.logutils.LogUtils. 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: MeFragment.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
private void queryBasicInfo(){
    factory.getBasicInfo(new Observer<BasicInfo>() {
        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onNext(BasicInfo value) {
            DataSupport.deleteAll(BasicInfo.class);
            value.save();
            setBasicInfo4View(value);
        }
        @Override
        public void onError(Throwable e) {
            if(e != null && !TextUtils.isEmpty(e.getMessage())) {
                LogUtils.e(e.toString());
                Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
        @Override
        public void onComplete() {

        }
    });
}
 
Example #2
Source File: QupaiAuth.java    From CoolChat with Apache License 2.0 6 votes vote down vote up
/**
 * 鉴权 建议只调用一次,在demo里面为了测试调用了多次 得到accessToken,通常一个用户对应一个token
 *
 * @param context 上下文
 */
public void initAuth(final Context context) {
    AuthService service = AuthService.getInstance();
    service.setQupaiAuthListener(new QupaiAuthListener() {
        @Override
        public void onAuthError(int errorCode, String message) {
            LogUtils.e("趣拍云认证失败:" + "ErrorCode" + errorCode + ";message" + message);
        }

        @Override
        public void onAuthComplte(int responseCode, String responseMessage) {
            LogUtils.e("趣拍云认证成功:" + "responseCode" + responseCode + ";message" + responseMessage);
            AppConfig.setQupaiToken(context, responseMessage);
        }
    });
    String appKey = "20c8241fb3e0c95";
    String appSecret = "149edead851b4331a0eb4207542a9a3e";
    String space = String.valueOf(AppConfig.getUserId(context));
    service.startAuth(context, appKey, appSecret, space);
}
 
Example #3
Source File: UserProfileActivity.java    From CoolChat with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == NameActivity.REQUEST_REMARK_NAME && resultCode == NameActivity.REQUEST_REMARK_NAME) {
        LogUtils.e("修改后的备注名为", data.getStringExtra("name"));
        String name = data.getStringExtra("name");
        contact.setRemarkName(name);
        contactDao.update(contact);
        initData();

        //通知主页聊天页面用户昵称更新
        EventBus.getDefault().post(new Conversation());
    } else {
        LogUtils.e("修改后的备注名为", "未修改");
    }
}
 
Example #4
Source File: ChatActivity.java    From CoolChat with Apache License 2.0 6 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    LogUtils.e("dispatchTouchEvent" + ",当前点击高度" + ev.getY());
    LogUtils.e("dispatchTouchEvent" + ",当前无效区域高度" + (DisplayUtils.getScreenHeight(this) - DisplayUtils.dp2px(this, 120)));
    if (ev.getY() < DisplayUtils.getScreenHeight(this) - AppConfig.getKeyboardHeight(this) - DisplayUtils.dp2px(this, 120)) {
        if (isKeyboardShowing) {
            LogUtils.e("点击事件" + "键盘在展示,要隐藏");
            KeyboardUtils.updateSoftInputMethod(this, WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
            KeyboardUtils.hideKeyboard(getCurrentFocus());
        }
        if (isMultiLayoutShowing) {
            hideMultiLayout();
        }
    }
    return super.dispatchTouchEvent(ev);
}
 
Example #5
Source File: RecordButton.java    From CoolChat with Apache License 2.0 6 votes vote down vote up
private void init() {

        //如果文件夹不创建的话那么执行到recorder.prepare()就会报错
        File dir = new File(audioPath);
        if (!dir.exists()) {
            dir.mkdirs();
        }

        recorder = new MediaRecorder();
        recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        recorder.setMaxDuration(MAX_LENGTH);
        recorder.setOutputFile(audioFileName);
        try {
            recorder.prepare();
        } catch (IOException e) {
            e.printStackTrace();
            LogUtils.e("MediaRecorder prepare()报错");
        }
    }
 
Example #6
Source File: MyApplication.java    From CoolChat with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    context = getApplicationContext();

    Intent i = new Intent(context, MyService.class);
    startService(i);

    LogUtils.getLogConfig()
            .configAllowLog(true)
            .configTagPrefix("CoolChat")
            .configShowBorders(true)
            .configFormatTag("%d{HH:mm:ss:SSS} %t %c{-5}")
            .configLevel(LogLevel.TYPE_VERBOSE);

    //MultiDex.install(this);
    initClient();
    initQupaiAuth();
    initQupaiSetting();

    sendLoginMsg();
}
 
Example #7
Source File: ChatPresenter.java    From TouchNews with Apache License 2.0 6 votes vote down vote up
private void onRequestMessage(String message) {
            /*“key”: “APIKEY”,
            “info”: “今天天气怎么样”,
            “loc”:“北京市中关村”,
            “userid”:“12345678”*/

    param.put(Keys.INFO, EncodeString(message));
    param.put("userid", "12345678");
    NetRequestUtil.getInstance().getJson(UrlUtil.URL_CHAT, param, new NetRequestUtil.RequestListener() {
        @Override
        public void onResponse(JSONObject response) {
            LogUtils.i(response);
            try {
                if (response.getString("code").equals("100000")) {
                    mView.onReceiveRespond(response.getString("text"));
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(VolleyError error) {
        }
    });
}
 
Example #8
Source File: AppContext.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    ButterKnife.setDebug(BuildConfig.DEBUG);
    LogUtils.configAllowLog = BuildConfig.DEBUG;
    LitePal.initialize(this);
    //友盟
    MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);

    //自动更新
    UpdateConfig.getConfig()
            .init(this)
            // 数据更新接口数据,此时默认为使用GET请求
            .url(AppConfig.BASE_URL+AppConfig.Url.updateURL)
            // 必填:用于从数据更新接口获取的数据response中。解析出Update实例。以便框架内部处理
            .jsonParser(new UpdateParser() {
                @Override
                public Update parse(String response) {
                    // 此处根据上面url接口返回的数据response进行update类组装。框架内部会使用此
                    // 组装的update实例判断是否需要更新以做进一步工作
                    Update update = new Gson().fromJson(response,Update.class);
                    return update;
                }
            });
}
 
Example #9
Source File: CourseAppWidgetProvider.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    LogUtils.i(intent.getAction());
    String currentWeek = FileUtils.getCurrentWeek(context);

    //更换日期且更新对应数据
    if (intent.getAction().equals(WidgetCommonUtil.WidgetConstant.INTENT_NEXTDAY)){
        currentDay = WidgetCommonUtil.getNextDay(currentDay);
        WidgetListProviderFactory.refreshData(currentDay,currentWeek);
        setDepartmentOrWeek(context);
    }else if (intent.getAction().equals(WidgetCommonUtil.WidgetConstant.INTENT_PREDAY)) {
        currentDay = WidgetCommonUtil.getPreDay(currentDay);
        WidgetListProviderFactory.refreshData(currentDay,currentWeek);
        setDepartmentOrWeek(context);
    }else{ //其他广播不需要处理
    }
    LogUtils.i("after change currentDay:"+currentDay + " "+ "星期" + weekName[currentDay]);

    //更新 星期几 的文字说明
    setRemoteView(context);
    remoteViews.setTextViewText(R.id.widget_tv_weekday,"星期" + weekName[currentDay]);
    notifyUpdateUI(context);
    notifyListUpdateUI(context);

}
 
Example #10
Source File: CourseAppWidgetProvider.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        super.onUpdate(context, appWidgetManager, appWidgetIds);
        LogUtils.i("====onUpdate");

        setRemoteView(context);
        currentDay = WidgetCommonUtil.getTodayInWeek();
        updateDataView(context, appWidgetIds[0]);   //固定[0]

        //添加点击事件
        SetOnClickPendingIntent(context,R.id.widget_btn_nextday, WidgetCommonUtil.WidgetConstant.INTENT_NEXTDAY);
        SetOnClickPendingIntent(context,R.id.widget_btn_preday, WidgetCommonUtil.WidgetConstant.INTENT_PREDAY);
        SetOnClickPendingIntent(context,R.id.widget_tv_weekday, WidgetCommonUtil.WidgetConstant.INTENT_NEXTDAY); //点击星期几也显示明天的

//        //更新全部widget的界面,这个代码没效果,不过以后如果有遇到其他代码更新无效的情况可以试试
//        for (int widgetId : appWidgetIds) {
//            appWidgetManager.updateAppWidget(widgetId, remoteViews);
//        }

        //  item点击事件调到app,与WidgetListProviderFactory的setOnClickFillInIntent()共同使用
        Intent clickIntent = new Intent(context, MainActivity.class);
        PendingIntent clickPI = PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        remoteViews.setPendingIntentTemplate(R.id.desktop_widget_list, clickPI);
    }
 
Example #11
Source File: SearchBookStoreActivity.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void loadData() {

    factory.getBookStoreDetail(mMacNo, new Observer<List<SearchBookStoreItem>>() {
        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onNext(List<SearchBookStoreItem> value) {
            mAdapter.addData(value);
            mAdapter.notifyDataSetChanged();
        }
        @Override
        public void onError(Throwable e) {
            LogUtils.e(e.getMessage());
            Toast.makeText(SearchBookStoreActivity.this, "获取详情失败:"+e.getMessage(), Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onComplete() {

        }
    });
}
 
Example #12
Source File: CalcUtils.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 获取当前登陆学号的大一那年的年份,如2013级则返回13(即使现在是2017年),从而构造2013-2014(大一) 这种选择框
 * @return int 13
 */
public static int getFirstYear(){
    int firstYear = 13; //校友则学年根据个人信息的班级获取,正常账号直接截学号
    if(AppConfig.schoolmateSno.equals(AppConfig.sno)) {
        BasicInfo basicInfo = DataSupport.findFirst(BasicInfo.class);
        if(basicInfo == null){
            LogUtils.e("校友学年获取失败");
        }
        firstYear = Integer.parseInt(basicInfo != null ? basicInfo.getClassroom().substring(2, 4) : "13");
    }else {
        firstYear = Integer.parseInt(AppConfig.sno.substring(0, 2));
    }
    return firstYear;
}
 
Example #13
Source File: HomeFragment.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
private void realQuerySchedule(String studyTime){
    factory.getSchedule(studyTime,JwApiFactory.MERGE_SCHEDULE, new Observer<List<Schedule>>() {
        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onNext(List<Schedule> value) {
            if(value.size()==0){
                Toast.makeText(getActivity(), "没有喔", Toast.LENGTH_SHORT).show();
                return;
            }
            mScheduleView.cleanScheduleData();
            mScheduleView.setScheduleData(value);
            DataSupport.deleteAll(Schedule.class);
            DataSupport.saveAll(value);
        }

        @Override
        public void onError(Throwable e) {
            LogUtils.e(e.getMessage());
            Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onComplete() {
        }
    });
}
 
Example #14
Source File: QupaiUpload.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
/**
 * 开始上传
 *
 * @param data 上传任务的task
 */
public static void startUpload(QupaiUploadTask data) {
    try {
        UploadService uploadService = UploadService.getInstance();
        uploadService.startUpload(data);
    } catch (IllegalArgumentException exc) {
        LogUtils.e("趣拍云上传错误:" + "Missing some arguments. " + exc.getMessage());
    }
}
 
Example #15
Source File: GroupProfileActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == NameActivity.REQUEST_CHANGE_GROUP_NAME && resultCode == NameActivity.REQUEST_CHANGE_GROUP_NAME) {
        if (data.hasExtra("name")) {
            LogUtils.e("修改的后的群组名", data.getStringExtra("name"));
        }
    } else {
        LogUtils.e("修改的后的群组名", "未修改");
    }

}
 
Example #16
Source File: MeFragment.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
private void queryCurrentCash(){
    cardFactory.getCurrentCash(new Observer<CardBasic>() {
        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onNext(CardBasic value) {
            if(null != value && !TextUtils.isEmpty(value.getCash())) {
                tvMeCash.setText("¥" + value.getCash());
                mCardNum = value.getCardNum();
            }else{
                tvMeCash.setText("获取失败");
            }
        }
        @Override
        public void onError(Throwable e) {
            if(e != null && !TextUtils.isEmpty(e.getMessage())) {
                LogUtils.e(e.toString());
                Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
            }
            tvMeCash.setText("获取失败");
        }
        @Override
        public void onComplete() {
        }
    });
}
 
Example #17
Source File: ChatActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
/**
 * 下拉加载更多聊天信息
 */
private void initMoreChatData(String chatType, int chatId) {
    ChatDao chatDao = GreenDAOUtils.getInstance(ChatActivity.this).getChatDao();
    List<Chat> chats;
    //从Id最大的往小查
    if ("friend".equals(chatType)) {
        chats = chatDao.queryBuilder()
                .where(ChatDao.Properties.ChatType.eq(chatType), ChatDao.Properties.Id.lt(latestId))
                .whereOr(ChatDao.Properties.FromId.eq(chatId), ChatDao.Properties.ToId.eq(chatId))
                .limit(10)
                .orderDesc(ChatDao.Properties.Time)
                .build()
                .list();
    } else {
        chats = chatDao.queryBuilder()
                .where(ChatDao.Properties.ChatType.eq(chatType), ChatDao.Properties.Id.lt(latestId), ChatDao.Properties.ToId.eq(chatId))
                .limit(10)
                .orderDesc(ChatDao.Properties.Time)
                .build()
                .list();
    }
    if (!chats.isEmpty()) {
        latestId = chats.get(chats.size() - 1).getId();
        LogUtils.e("数据的索引" + latestId);
        Collections.reverse(chats);
        chatListData.addAll(0, chats);
        adapter.notifyDataSetChanged();
    } else {
        ToastUtils.showShort(ChatActivity.this, "没有更多数据了");
    }
    swipeRefreshLayout.setRefreshing(false);
}
 
Example #18
Source File: ChatActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
/**
 * 加载最近的聊天消息,默认5条(QQ是15条)
 */
private void initRecentChatData(String chatType, int chatId) {
    ChatDao chatDao = GreenDAOUtils.getInstance(ChatActivity.this).getChatDao();
    List<Chat> chats;

    //从Id最大的往小查
    if ("friend".equals(chatType)) {
        chats = chatDao.queryBuilder()
                .where(ChatDao.Properties.ChatType.eq(chatType))
                .whereOr(ChatDao.Properties.FromId.eq(chatId), ChatDao.Properties.ToId.eq(chatId))
                .limit(5)
                .orderDesc(ChatDao.Properties.Time)
                .build()
                .list();
    } else {
        chats = chatDao.queryBuilder()
                .where(ChatDao.Properties.ChatType.eq(chatType), ChatDao.Properties.ToId.eq(chatId))
                .limit(5)
                .orderDesc(ChatDao.Properties.Time)
                .build()
                .list();
    }

    if (!chats.isEmpty()) {
        latestId = chats.get(chats.size() - 1).getId();
        LogUtils.e("数据的索引" + latestId);
        //倒序排列下
        Collections.reverse(chats);
        //为了加载和其他人聊天信息的时候清空屏幕
        chatListData.clear();
        chatListData.addAll(chats);

        adapter.notifyDataSetChanged();
        int itemCount = adapter.getItemCount() - 1;
        if (itemCount > 0) {
            recyclerView.smoothScrollToPosition(itemCount);
        }
    }
}
 
Example #19
Source File: ChatActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void getData() {
    Intent intent = getIntent();
    chatId = intent.getIntExtra("chatId", 0);                       //好友或者群组的ID
    chatType = intent.getStringExtra("chatType");                   //群组还是好友
    chatName = intent.getStringExtra("chatName");                   //群组名或者好友名
    LogUtils.e("聊天信息" + "当前在跟" + chatType + ":ID为" + chatId + "的" + chatName + "聊天");
    initToolbar(chatName);

    //保存当前聊天对象的信息
    AppConfig.setUserCurrentChatId(ChatActivity.this, chatId);
    AppConfig.setUserCurrentChatType(ChatActivity.this, chatType);
}
 
Example #20
Source File: OkHttpTask.java    From ZhiHu-TopAnswer with Apache License 2.0 5 votes vote down vote up
private OkHttpTask(OkHttpClient okHttpClient) {
    if (okHttpClient == null) {
        OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
        //cookie enabled
        okHttpClientBuilder.cookieJar(new CookieJarImpl(new MemoryCookieStore()));
        okHttpClientBuilder.hostnameVerifier(new HostnameVerifier() {
            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });

        if (isDebug) {
            HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
                @Override
                public void log(String message, String json) {
                    LogUtils.i(message);
                    if (!TextUtils.isEmpty(json)) {
                        LogUtils.i("--------json---------\n");
                        LogUtils.json(json);
                        LogUtils.i("--------end----------\n");
                    }
                }

            });
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            okHttpClientBuilder.addInterceptor(loggingInterceptor);
        }
        mOkHttpClient = okHttpClientBuilder.build();
    } else {
        mOkHttpClient = okHttpClient;
    }


    init();
}
 
Example #21
Source File: ApiUtils.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public T apply(HttpResult<T> httpResult) throws Exception {
    if (!httpResult.isSuccess()) {  //业务错误到onError里获取
        LogUtils.e("httpres "+httpResult.getMsg());
        throw new ApiException(httpResult.getCode(),httpResult.getMsg());
    }
    return httpResult.getData();
}
 
Example #22
Source File: MyEditText.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
    if (event.getAction() == KeyEvent.KEYCODE_SOFT_LEFT) {
        LogUtils.e("dispatchKeyEventPreIme", "按下了返回键");
        if (mOnCancelInputLayout != null) {
            mOnCancelInputLayout.onCancelInputLayout();
        }
        return false;
    }
    return super.dispatchKeyEventPreIme(event);
}
 
Example #23
Source File: ConversationFragment.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
/**
 * 将数据从数据库删除
 */
private void deleteFromDB(Conversation conversation) {
    LogUtils.e("要删除的ID:" + conversation.getId() + "");
    conversationDao.delete(conversation);
    //更新页面
    handleConversation.sendEmptyMessage(0);
}
 
Example #24
Source File: RecordFragment.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void initViews(View rootView) {
    RecordButton recordButton = (RecordButton) rootView.findViewById(R.id.btn_record);
    ImageView img_play = (ImageView) rootView.findViewById(R.id.img_play);
    ExpectAnim expectAnim = new ExpectAnim()
            .expect(img_play)
            .toBe(
                    width(180).toDp().keepRatio()
            )
            .toAnimation()
            .setDuration(250)
            .start();
    expectAnim.reset();

    recordButton.setOnFinishRecordListener(new RecordButton.OnFinishedRecordListener() {

        @Override
        public void onFinishedRecord(String audioFilePath, String audioLength) {
            LogUtils.e("录音位置完成:位置:" + audioFilePath + ";长度:" + audioLength);
            SendMessageUtils.sendAudioMessage(getActivity(), new File(audioFilePath), audioLength);
        }

        @Override
        public void onCancelRecord(String msg) {
            //ToastUtils.showShort(getActivity(), "录音取消");
            LogUtils.e("录音取消");
        }
    });
}
 
Example #25
Source File: CardHistoryActivity.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 当日消费记录
 * @param cardNum string
 */
private void getCardConsumeToday(String cardNum){
    factory.getCardConsumeToday(cardNum,new Observer<List<CardConsumeItem>>() {
        @Override
        public void onSubscribe(Disposable d) {
            startLoadingProgess();
        }
        @Override
        public void onNext(List<CardConsumeItem> value) {
            if(value.size() == 0){
                Toast.makeText(CardHistoryActivity.this, "你今天没有校园卡交易喔", Toast.LENGTH_SHORT).show();
                return;
            }
            LogUtils.w(value);
            mAdapter.cleanData();
            mAdapter.addData(value);
            mAdapter.notifyDataSetChanged();
        }

        @Override
        public void onError(Throwable e) {
            LogUtils.e(e.getMessage());
            Toast.makeText(CardHistoryActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
            finish();
        }

        @Override
        public void onComplete() {
            mAdapter.isUseEmpty(true);
            stopLoadingProgess();
        }
    });
}
 
Example #26
Source File: MyService.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void updateChatData(int deleteMsgId) {
    ChatDao chatDao = GreenDAOUtils.getInstance(this).getChatDao();
    Chat deleteChat = chatDao.queryBuilder().where(ChatDao.Properties.MsgId.eq(deleteMsgId)).build().unique();
    if (null != deleteChat) {
        LogUtils.e("查到的信息:", deleteChat.getMsgId());
        deleteChat.setContentType("delete");
        chatDao.update(deleteChat);
    }
}
 
Example #27
Source File: MyService.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
/**
     * 通知栏展示消息
     *
     * @param avatar  头像URL
     * @param title   标题(好友名、群组名)
     * @param content 内容
     */
    private void showNotification(String avatar, String title, String content) {
        LogUtils.d("通知栏提示", content);

        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.item_conversation);
        remoteViews.setImageViewResource(R.id.conversation_avatar, R.mipmap.ic_launcher);

        final int NOTIFICATION_ID = 1993;
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher) // Needed for the notification to work/show!!
                .setContentTitle(title)
                .setContentText(content)
                //.setContent(remoteViews)
                .setDefaults(Notification.DEFAULT_ALL);

//        if (Build.VERSION.SDK_INT > 16) {
//            notification.bigContentView = remoteViews;
//        }

        Notification notification = builder.build();

        NotificationManager notificationManager = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE);
        notificationManager.notify(NOTIFICATION_ID, notification);

        Picasso.with(this).load(ImgUrlUtils.getUrl(avatar))
                .into(remoteViews, R.id.conversation_avatar, NOTIFICATION_ID, notification);

    }
 
Example #28
Source File: MusicPresenter.java    From TouchNews with Apache License 2.0 5 votes vote down vote up
/**
     * 获取专辑头像
     *
     * @param musicInfo mu
     */
    private void getSingerAlbum(Data musicInfo, final MusicEntity musicEntity, final int i) {
                /*BaseApplication.mBaiDuApiService.getSinger ( Keys.BAI_DU_API_KEY, musicInfo.getSingername ( ) )
                        .subscribeOn ( Schedulers.newThread ( ) )
                        .observeOn ( AndroidSchedulers.mainThread ( ) )
                        .subscribe ( new Action1< MusicSingerRoot > ( ) {
                                @Override
                                public void call ( MusicSingerRoot musicSingerRoot ) {
                                        if ( musicSingerRoot.getCode ( ) == 0 ) {
//                                                                mMusicPresenter.addMusic ( musicInfoRoot.getData ( ) );
                                                musicEntity.setMusicSinger ( musicSingerRoot.getData ( ) );
                                                if ( i == 0 ) {
                                                        mMusicView.setAlbum ( );
                                                }
                                        }
                                }
                        } );
                        */
        param.clear();
        param.put("name", musicInfo.getSingername());
        NetRequestUtil.getInstance().getJsonWithHeaders(UrlUtil.URL_MUSIC_SINGER, param, headers, new NetRequestUtil.RequestListener() {
            @Override
            public void onResponse(JSONObject response) {
                LogUtils.i(response.toString());
                MusicSingerRoot musicSingerRoot = mGson.fromJson(response.toString(), MusicSingerRoot.class);
                if (musicSingerRoot.getCode() == 0) {
//                                                                mMusicPresenter.addMusic ( musicInfoRoot.getData ( ) );
                    musicEntity.setMusicSinger(musicSingerRoot.getData());
                    if (i == 0) {
                        mMusicView.setAlbum();
                    }
                }
            }

            @Override
            public void onError(VolleyError error) {
            }
        });
    }
 
Example #29
Source File: BaseApplication.java    From TouchNews with Apache License 2.0 5 votes vote down vote up
/**
 * 设置LogUtil
 */
private void setupLogUtils() {
    LogUtils.getLogConfig()
        .configAllowLog(true)
        .configTagPrefix("TouchNews")
        .configShowBorders(true)
        .configLevel(LogLevel.TYPE_VERBOSE);
}
 
Example #30
Source File: MainActivity.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    AppConfig.appVer = CalcUtils.getVersionName(this);
    isAlpha = FileUtils.getIsAlphaTest(this);
    LogUtils.e("内测Ing");

    //未登录跳转登陆页
    if(!FileUtils.getStoredAccountAndSetApp(this) || TextUtils.isEmpty(AppConfig.sno) || TextUtils.isEmpty(AppConfig.idsPwd)){
        startActivity(new Intent(this, LoginActivity.class));
        this.finish();return; //没这个居然会往下跑!
    }
    //默认页为drcom的话就跳转到drcom页且关闭当前的(特例:从drcom回到main的情况不跳转,不然就死循环跳转了)
    AppConfig.defaultPage = FileUtils.getStoredDefaultPage(this);
    if(AppConfig.defaultPage == AppConfig.DefaultPage.DRCOM
            && !getIntent().getBooleanExtra(DrcomActivity.INTENT_DRCOM_TO_MAIN,false) ) {
        startActivity(new Intent(this, DrcomActivity.class));
        this.finish();return;
    }

    setTitle(R.string.app_name);
    initFragment();
    UpdateBuilder.create().check();

    checkAppTips();
}