List of usage examples for android.content Context POWER_SERVICE
String POWER_SERVICE
To view the source code for android.content Context POWER_SERVICE.
Click Source Link
From source file:com.grass.caishi.cc.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from w w w.j a v a 2s.c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); if (toChatUsername.equals("admin")) { ((TextView) findViewById(R.id.name)).setText(""); } else { UserDao userdao = new UserDao(this); User user = userdao.getUser(toChatUsername, false); usernick = getIntent().getStringExtra("nickname"); userlogo = getIntent().getStringExtra("headurl"); if (user == null || CommonUtils.isNullOrEmpty(user.getNick())) { ((TextView) findViewById(R.id.name)).setText(""); } else { ((TextView) findViewById(R.id.name)).setText(user.getNick()); } } } else if (chatType == 0) { // ? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText("?"); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? // receiver = new NewMessageBroadcastReceiver(); // IntentFilter intentFilter = new // IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // // Mainacitivity,??chat?????? // intentFilter.setPriority(5); // registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver // IntentFilter ackMessageIntentFilter = new // IntentFilter(EMChatManager.getInstance().getAckMessageBroadcastAction()); // ackMessageIntentFilter.setPriority(5); // registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.app.khclub.base.easeim.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???// w w w . j a v a 2 s .com chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((KHHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { ((TextView) findViewById(R.id.name)).setText(nick); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } } else { UserUtils.setUserNick(toChatUsername, (TextView) findViewById(R.id.name)); } //? if (toChatUsername.equals(KHConst.KH_ROBOT)) { ((TextView) findViewById(R.id.name)) .setText(getString(R.string.personal_official_business_manager)); } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_resume).setVisibility(View.GONE); // findViewById(R.id.container_voice_call).setVisibility(View.GONE); // findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } //???? if (getIntent().hasExtra(ShareContactsActivity.INTENT_CARD_KEY)) { sendText("###card" + getIntent().getStringExtra(ShareContactsActivity.INTENT_CARD_KEY) + "card###"); } }
From source file:cn.gen.superwechat.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from ww w . ja v a 2 s . c o m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { ((TextView) findViewById(cn.gen.superwechat.R.id.name)).setText(nick); } else { ((TextView) findViewById(cn.gen.superwechat.R.id.name)).setText(toChatUsername); } } else { UserUtils.setUserBeanNick(toChatUsername, (TextView) findViewById(cn.gen.superwechat.R.id.name)); } } else { // ? findViewById(cn.gen.superwechat.R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(cn.gen.superwechat.R.id.container_remove).setVisibility(View.GONE); findViewById(cn.gen.superwechat.R.id.container_voice_call).setVisibility(View.GONE); findViewById(cn.gen.superwechat.R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.entertailion.android.slideshow.utils.Utils.java
/** * Prevent the screensave from activating on Google TV devices. * //from w w w . j a v a 2 s . c o m * @param context */ public static void wakeUp(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "tag"); wl.acquire(); wl.release(); }
From source file:com.aidigame.hisun.imengstar.huanxin.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//w w w . ja v a 2 s . c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = "" + other.userId; conversation = EMChatManager.getInstance().getConversation(toChatUsername); EMMessage m = conversation.getLastMessage(); ((TextView) findViewById(R.id.name)).setText(other.u_nick); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.example.fertilizercrm.easemob.chatuidemo.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*www .j av a2 s . co m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); //TODO Role role = getRoleByUsername(getIntent().getStringExtra("userId")); if (role != null) { tv_name = (TextView) findViewById(R.id.name2); tv_name.setVisibility(View.VISIBLE); TextView tv_role = (TextView) findViewById(R.id.tv_role); tv_role.setVisibility(View.VISIBLE); tv_role.setText(" (" + role.getDescription() + ")"); } else { tv_name.setVisibility(View.VISIBLE); } if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { tv_name.setText(nick); } else { tv_name.setText(toChatUsername); } } else { UserUtils.setUserNick(toChatUsername, tv_name); } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.parttime.IM.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); btnMore.setOnClickListener(this); nameVeiw = (TextView) findViewById(R.id.name); memberNum = (TextView) findViewById(R.id.number); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from ww w .j a va2 s .co m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); //chatBottomBarHelper = new ChatBottomBarHelper(this); if (toChatUsername != null && !"".equals(toChatUsername)) { if (ApplicationConstants.JZDR.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.JZDR + "realname", "?"); } else if (ApplicationConstants.CAIWU.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.CAIWU + "realname", "?"); } else if (ApplicationConstants.DINGYUE.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.DINGYUE + "realname", "?"); } else if (ApplicationConstants.KEFU.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.KEFU + "realname", "??"); chatBottomBarHelper = new ChatBottomBarHelper(this); } else if (ApplicationConstants.TONGZHI.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.TONGZHI + "realname", ""); } } // ?? // ???,??? String chatName = sp.loadStringSharedPreference(toChatUsername + "realname", ""); if (!"".equals(chatName)) { nameVeiw.setText(chatName); } else { getNick(toChatUsername, nameVeiw); } } else { // ? findViewById(R.id.container_right2_image).setVisibility(View.VISIBLE); findViewById(R.id.container_group_notice).setVisibility(View.VISIBLE); findViewById(R.id.container_contact_detail).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); new Thread(new Runnable() { @Override public void run() { try { EMGroup returnGroup = EMGroupManager.getInstance().getGroupFromServer(toChatUsername); // ? EMGroupManager.getInstance().createOrUpdateLocalGroup(returnGroup); if (group != null) { setGroupChatTitle(); } } catch (Exception ignore) { } } }).start(); if (group != null) { setGroupChatTitle(); } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); // 2015-4-7? // ************************************************************** // ?db?conversationgetChatOptions().getNumberOfMessagesLoaded // ??? final List<EMMessage> msgs = conversation.getAllMessages(); int msgCount = msgs != null ? msgs.size() : 0; if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) { String msgId = null; if (msgs != null && msgs.size() > 0) { msgId = msgs.get(0).getMsgId(); } if (chatType == CHATTYPE_SINGLE) { conversation.loadMoreMsgFromDB(msgId, pagesize); } else { conversation.loadMoreGroupMsgFromDB(msgId, pagesize); } } // ************************************************************** adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); // ==================?================== listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMConversation conversation = adapter.getEMConversationItem(); String username = conversation.getUserName(); if (username.equals(ApplicationControl.getInstance().getUserName())) Toast.makeText(ChatActivity.this, "", Toast.LENGTH_SHORT).show(); else { // Intent intent = new Intent(ChatActivity.this, UserInfo.class); // startActivity(intent); } } }); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); moreGone(); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.ternup.caddisfly.fragment.DetailsFragment.java
public void postResult(String folderName) { RequestParams params = new RequestParams(); TimeZone tz = TimeZone.getTimeZone("UTC"); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(tz);//from ww w.j ava 2s .c o m final ArrayList<String> filePaths = FileUtils.getFilePaths(getActivity(), folderName, "/small/", mLocationId); File myFile = new File(filePaths.get(0)); String date = df.format(DateUtils.getDateFromFilename(myFile.getName())); params.put("date", date); String deviceId = Build.MANUFACTURER + " " + Build.MODEL; if (deviceId.length() > 32) { deviceId = deviceId.substring(1, 32); } params.put("deviceId", deviceId); params.put("type", String.valueOf(mTestTypeId + 1)); if (wakeLock == null || !wakeLock.isHeld()) { PowerManager pm = (PowerManager) getActivity().getApplicationContext() .getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyWakeLock"); wakeLock.acquire(); } WebClient.post("tests", params, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { String response = responseBody == null ? null : new String(responseBody); try { JSONObject json = new JSONObject(response); final int newId = json.getInt("id"); if (filePaths.size() > 0) { count = 0; totalCount = filePaths.size(); postItem(newId, filePaths); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, final Throwable error) { Log.d(Globals.DEBUG_TAG, "fail: " + error.getMessage()); getActivity().runOnUiThread(new Runnable() { public void run() { if (progressDialog != null) { progressDialog.dismiss(); } if (wakeLock != null && wakeLock.isHeld()) { wakeLock.release(); } AlertUtils.showAlert(getActivity(), R.string.error, error.getMessage(), R.string.ok, null, null); } }); } }); }
From source file:com.sxt.superqq.activity.ChatActivity.java
private void setUpView() { // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from w ww . ja v a 2 s . com*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); if (group != null) ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); else ((TextView) findViewById(R.id.name)).setText(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); // ?db?conversationgetChatOptions().getNumberOfMessagesLoaded // ??? final List<EMMessage> msgs = conversation.getAllMessages(); int msgCount = msgs != null ? msgs.size() : 0; if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) { String msgId = null; if (msgs != null && msgs.size() > 0) { msgId = msgs.get(0).getMsgId(); } if (chatType == CHATTYPE_SINGLE) { conversation.loadMoreMsgFromDB(msgId, pagesize); } else { conversation.loadMoreGroupMsgFromDB(msgId, pagesize); } } adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); adapter.refreshSelectLast(); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.bonsai.btcreceive.WalletService.java
@Override public void onCreate() { mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mLBM = LocalBroadcastManager.getInstance(this); mLogger.info("WalletService created"); mContext = getApplicationContext();//from w w w . java 2 s .c o m mRes = mContext.getResources(); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String fiatRateSource = sharedPref.getString(SettingsActivity.KEY_FIAT_RATE_SOURCE, ""); setFiatRateSource(fiatRateSource); // Register for future preference changes. sharedPref.registerOnSharedPreferenceChangeListener(this); }