List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:com.mobiletin.inputmethod.indic.LatinIME.java
private void showSubtypeSelectorAndSettings() { final CharSequence title = getString(R.string.english_ime_input_options); // TODO: Should use new string "Select active input modes". final CharSequence languageSelectionTitle = getString(R.string.language_selection_title); final CharSequence[] items = new CharSequence[] { languageSelectionTitle, getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class)) }; final OnClickListener listener = new OnClickListener() { @Override/*from w w w. ja va 2s .co m*/ public void onClick(DialogInterface di, int position) { di.dismiss(); switch (position) { case 0: final Intent intent = IntentUtils.getInputLanguageSelectionIntent( mRichImm.getInputMethodIdOfThisIme(), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle); startActivity(intent); break; case 1: launchSettings(); break; } } }; final AlertDialog.Builder builder = new AlertDialog.Builder( DialogUtils.getPlatformDialogThemeContext(this)); builder.setItems(items, listener).setTitle(title); final AlertDialog dialog = builder.create(); dialog.setCancelable(true /* cancelable */); dialog.setCanceledOnTouchOutside(true /* cancelable */); showOptionDialog(dialog); }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
@Override public void onBackPressed() { if (flagRecord) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 0); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutTalk.setLayoutParams(params); layoutTalk.setGravity(Gravity.CENTER); flagRecord = false;//from ww w . jav a2 s . co m } else if (noti) { Intent intent = new Intent("com.arctech.BROWSEACTIVITY"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } else { super.onBackPressed(); StikyChatMoreActivity.flagStart = false; finish(); } }
From source file:com.hichinaschool.flashcards.anki.DeckPicker.java
/** * Creates an intent to load a deck given the full pathname of it. The constructed intent is equivalent (modulo the * extras) to the open used by the launcher shortcut, which means it will not open a new study options window but * bring the existing one to the front.//from ww w.ja v a 2 s .c o m */ public static Intent getLoadDeckIntent(Context context, long deckId) { Intent loadDeckIntent = new Intent(context, DeckPicker.class); loadDeckIntent.setAction(Intent.ACTION_MAIN); loadDeckIntent.addCategory(Intent.CATEGORY_LAUNCHER); loadDeckIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); loadDeckIntent.putExtra(EXTRA_DECK_ID, deckId); return loadDeckIntent; }
From source file:com.irccloud.android.activity.MainActivity.java
public void onIRCEvent(int what, Object obj) { super.onIRCEvent(what, obj); Integer event_bid = 0;//from w w w . j a v a 2s. co m final IRCCloudJSONObject event; final Object o = obj; switch (what) { case NetworkConnection.EVENT_DEBUG: runOnUiThread(new Runnable() { @Override public void run() { errorMsg.setVisibility(View.VISIBLE); errorMsg.setText(o.toString()); } }); break; case NetworkConnection.EVENT_PROGRESS: final float progress = (Float) obj; if (progressBar.getProgress() < progress) { runOnUiThread(new Runnable() { @Override public void run() { progressBar.setIndeterminate(false); progressBar.setProgress((int) progress); } }); } break; case NetworkConnection.EVENT_BACKLOG_START: runOnUiThread(new Runnable() { @Override public void run() { progressBar.setProgress(0); } }); break; case NetworkConnection.EVENT_RENAMECONVERSATION: if (buffer != null && (Integer) obj == buffer.bid) { runOnUiThread(new Runnable() { @Override public void run() { update_subtitle(); } }); } break; case NetworkConnection.EVENT_CHANNELTOPICIS: event = (IRCCloudJSONObject) obj; if (buffer != null && buffer.cid == event.cid() && buffer.name.equalsIgnoreCase(event.getString("chan"))) { runOnUiThread(new Runnable() { @Override public void run() { update_subtitle(); show_topic_popup(); } }); } break; case NetworkConnection.EVENT_LINKCHANNEL: event = (IRCCloudJSONObject) obj; if (event != null && cidToOpen == event.cid() && event.has("invalid_chan") && event.has("valid_chan") && event.getString("invalid_chan").equalsIgnoreCase(bufferToOpen)) { bufferToOpen = event.getString("valid_chan"); obj = BuffersDataSource.getInstance().getBuffer(event.bid()); } else { bufferToOpen = null; return; } case NetworkConnection.EVENT_MAKEBUFFER: BuffersDataSource.Buffer b = (BuffersDataSource.Buffer) obj; if (cidToOpen == b.cid && (bufferToOpen == null || (b.name.equalsIgnoreCase(bufferToOpen) && (buffer == null || !bufferToOpen.equalsIgnoreCase(buffer.name))))) { server = null; final int bid = b.bid; runOnUiThread(new Runnable() { @Override public void run() { onBufferSelected(bid); } }); bufferToOpen = null; cidToOpen = -1; } break; case NetworkConnection.EVENT_OPENBUFFER: event = (IRCCloudJSONObject) obj; try { bufferToOpen = event.getString("name"); cidToOpen = event.cid(); b = BuffersDataSource.getInstance().getBufferByName(cidToOpen, bufferToOpen); if (b != null && !bufferToOpen.equalsIgnoreCase(buffer.name)) { server = null; bufferToOpen = null; cidToOpen = -1; final int bid = b.bid; runOnUiThread(new Runnable() { @Override public void run() { onBufferSelected(bid); } }); } } catch (Exception e2) { e2.printStackTrace(); } break; case NetworkConnection.EVENT_CONNECTIVITY: runOnUiThread(new Runnable() { @Override public void run() { updateReconnecting(); } }); if (conn != null) { if (conn.getState() == NetworkConnection.STATE_CONNECTED) { for (EventsDataSource.Event e : pendingEvents.values()) { try { e.expiration_timer.cancel(); } catch (Exception ex) { //Task already cancellled } e.expiration_timer = null; e.failed = true; e.bg_color = R.color.error; } if (drawerLayout != null && NetworkConnection.getInstance().ready) { runOnUiThread(new Runnable() { @Override public void run() { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); getSupportActionBar().setHomeButtonEnabled(true); updateUsersListFragmentVisibility(); } }); } if (server != null && messageTxt.getText() != null && messageTxt.getText().length() > 0) { runOnUiThread(new Runnable() { @Override public void run() { sendBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(1); } }); } } else { runOnUiThread(new Runnable() { @Override public void run() { if (drawerLayout != null && !NetworkConnection.getInstance().ready) { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); getSupportActionBar().setHomeButtonEnabled(false); } sendBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(0.5f); photoBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) photoBtn.setAlpha(0.5f); } }); } } break; case NetworkConnection.EVENT_BANLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { if (event != null && event.cid() == buffer.cid) { Bundle args = new Bundle(); args.putInt("cid", event.cid()); BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(), event.getString("channel")); if (b != null) args.putInt("bid", b.bid); args.putString("mode", "b"); args.putString("placeholder", "No bans in effect.\n\nYou can ban someone by tapping their nickname in the user list, long-pressing a message, or by using /ban."); args.putString("mask", "mask"); args.putString("list", "bans"); args.putString("title", "Ban list for " + event.getString("channel")); args.putString("event", event.toString()); ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager() .findFragmentByTag("banlist"); if (channelModeList == null) { channelModeList = new ChannelModeListFragment(); channelModeList.setArguments(args); try { channelModeList.show(getSupportFragmentManager(), "banlist"); } catch (IllegalStateException e) { //App lost focus already } } else { channelModeList.setArguments(args); } } } }); break; case NetworkConnection.EVENT_QUIETLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { if (event != null && event.cid() == buffer.cid) { Bundle args = new Bundle(); args.putInt("cid", event.cid()); BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(), event.getString("channel")); if (b != null) args.putInt("bid", b.bid); args.putString("mode", "q"); args.putString("placeholder", "Empty quiet list."); args.putString("mask", "quiet_mask"); args.putString("list", "list"); args.putString("title", "Quiet list for " + event.getString("channel")); args.putString("event", event.toString()); ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager() .findFragmentByTag("quietlist"); if (channelModeList == null) { channelModeList = new ChannelModeListFragment(); channelModeList.setArguments(args); try { channelModeList.show(getSupportFragmentManager(), "quietlist"); } catch (IllegalStateException e) { //App lost focus already } } else { channelModeList.setArguments(args); } } } }); break; case NetworkConnection.EVENT_BANEXCEPTIONLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { if (event != null && event.cid() == buffer.cid) { Bundle args = new Bundle(); args.putInt("cid", event.cid()); BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(), event.getString("channel")); if (b != null) args.putInt("bid", b.bid); args.putString("mode", "e"); args.putString("placeholder", "Empty exception list."); args.putString("mask", "mask"); args.putString("list", "exceptions"); args.putString("title", "Exception list for " + event.getString("channel")); args.putString("event", event.toString()); ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager() .findFragmentByTag("exceptionlist"); if (channelModeList == null) { channelModeList = new ChannelModeListFragment(); channelModeList.setArguments(args); try { channelModeList.show(getSupportFragmentManager(), "exceptionlist"); } catch (IllegalStateException e) { //App lost focus already } } else { channelModeList.setArguments(args); } } } }); break; case NetworkConnection.EVENT_INVITELIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { if (event != null && event.cid() == buffer.cid) { Bundle args = new Bundle(); args.putInt("cid", event.cid()); BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(), event.getString("channel")); if (b != null) args.putInt("bid", b.bid); args.putString("mode", "I"); args.putString("placeholder", "Empty invite list"); args.putString("mask", "mask"); args.putString("list", "list"); args.putString("title", "Invite list for " + event.getString("channel")); args.putString("event", event.toString()); ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager() .findFragmentByTag("invitelist"); if (channelModeList == null) { channelModeList = new ChannelModeListFragment(); channelModeList.setArguments(args); try { channelModeList.show(getSupportFragmentManager(), "invitelist"); } catch (IllegalStateException e) { //App lost focus already } } else { channelModeList.setArguments(args); } } } }); break; case NetworkConnection.EVENT_ACCEPTLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { if (event != null && event.cid() == buffer.cid) { Bundle args = new Bundle(); args.putInt("cid", buffer.cid); args.putString("event", event.toString()); AcceptListFragment acceptList = (AcceptListFragment) getSupportFragmentManager() .findFragmentByTag("acceptlist"); if (acceptList == null) { acceptList = new AcceptListFragment(); acceptList.setArguments(args); try { acceptList.show(getSupportFragmentManager(), "acceptlist"); } catch (IllegalStateException e) { //App lost focus already } } else { acceptList.setArguments(args); } } } }); break; case NetworkConnection.EVENT_WHOLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { Bundle args = new Bundle(); args.putString("event", event.toString()); WhoListFragment whoList = (WhoListFragment) getSupportFragmentManager() .findFragmentByTag("wholist"); if (whoList == null) { whoList = new WhoListFragment(); whoList.setArguments(args); try { whoList.show(getSupportFragmentManager(), "wholist"); } catch (IllegalStateException e) { //App lost focus already } } else { whoList.setArguments(args); } } }); break; case NetworkConnection.EVENT_NAMESLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { Bundle args = new Bundle(); args.putString("event", event.toString()); NamesListFragment namesList = (NamesListFragment) getSupportFragmentManager() .findFragmentByTag("nameslist"); if (namesList == null) { namesList = new NamesListFragment(); namesList.setArguments(args); try { namesList.show(getSupportFragmentManager(), "nameslist"); } catch (IllegalStateException e) { //App lost focus already } } else { namesList.setArguments(args); } } }); break; case NetworkConnection.EVENT_SERVERMAPLIST: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { Bundle args = new Bundle(); args.putString("event", event.toString()); ServerMapListFragment serversList = (ServerMapListFragment) getSupportFragmentManager() .findFragmentByTag("serverslist"); if (serversList == null) { serversList = new ServerMapListFragment(); serversList.setArguments(args); try { serversList.show(getSupportFragmentManager(), "serverslist"); } catch (IllegalStateException e) { //App lost focus already } } else { serversList.setArguments(args); } } }); break; case NetworkConnection.EVENT_WHOIS: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { Bundle args = new Bundle(); args.putString("event", event.toString()); WhoisFragment whois = (WhoisFragment) getSupportFragmentManager().findFragmentByTag("whois"); if (whois == null) { whois = new WhoisFragment(); whois.setArguments(args); try { whois.show(getSupportFragmentManager(), "whois"); } catch (IllegalStateException e) { //App lost focus already } } else { whois.setArguments(args); } } }); break; case NetworkConnection.EVENT_LISTRESPONSEFETCHING: event = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { String dialogtitle = "List of channels on " + ServersDataSource.getInstance().getServer(event.cid()).hostname; if (channelsListDialog == null) { Context ctx = MainActivity.this; final AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); builder.setView(getLayoutInflater().inflate(R.layout.dialog_channelslist, null)); builder.setTitle(dialogtitle); builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); channelsListDialog = builder.create(); channelsListDialog.setOwnerActivity(MainActivity.this); } else { channelsListDialog.setTitle(dialogtitle); } try { channelsListDialog.show(); } catch (IllegalStateException e) { //App lost focus already } ChannelListFragment channels = (ChannelListFragment) getSupportFragmentManager() .findFragmentById(R.id.channelListFragment); Bundle args = new Bundle(); args.putInt("cid", event.cid()); channels.setArguments(args); } }); break; case NetworkConnection.EVENT_USERINFO: runOnUiThread(new Runnable() { @Override public void run() { updateUsersListFragmentVisibility(); supportInvalidateOptionsMenu(); if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } }); if (launchBid == -1 && server == null && conn != null && conn.getUserInfo() != null) launchBid = conn.getUserInfo().last_selected_bid; break; case NetworkConnection.EVENT_STATUSCHANGED: try { event = (IRCCloudJSONObject) obj; if (event != null && server != null && event.cid() == server.cid) { runOnUiThread(new Runnable() { @Override public void run() { supportInvalidateOptionsMenu(); } }); } } catch (Exception e1) { e1.printStackTrace(); } break; case NetworkConnection.EVENT_MAKESERVER: ServersDataSource.Server s = (ServersDataSource.Server) obj; if (server != null && s != null && s.cid == server.cid) { runOnUiThread(new Runnable() { @Override public void run() { supportInvalidateOptionsMenu(); update_subtitle(); } }); } else { cidToOpen = s.cid; bufferToOpen = "*"; } break; case NetworkConnection.EVENT_BUFFERARCHIVED: case NetworkConnection.EVENT_BUFFERUNARCHIVED: event_bid = (Integer) obj; if (buffer != null && event_bid == buffer.bid) { runOnUiThread(new Runnable() { @Override public void run() { update_subtitle(); } }); } if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); break; case NetworkConnection.EVENT_JOIN: event = (IRCCloudJSONObject) obj; if (event != null && buffer != null && event.bid() == buffer.bid && event.type().equals("you_joined_channel")) { runOnUiThread(new Runnable() { @Override public void run() { supportInvalidateOptionsMenu(); updateUsersListFragmentVisibility(); } }); } break; case NetworkConnection.EVENT_PART: case NetworkConnection.EVENT_KICK: event = (IRCCloudJSONObject) obj; if (event != null && buffer != null && event.bid() == buffer.bid && event.type().toLowerCase().startsWith("you_")) { runOnUiThread(new Runnable() { @Override public void run() { supportInvalidateOptionsMenu(); updateUsersListFragmentVisibility(); } }); } break; case NetworkConnection.EVENT_CHANNELINIT: ChannelsDataSource.Channel channel = (ChannelsDataSource.Channel) obj; if (channel != null && buffer != null && channel.bid == buffer.bid) { runOnUiThread(new Runnable() { @Override public void run() { update_subtitle(); supportInvalidateOptionsMenu(); updateUsersListFragmentVisibility(); } }); } break; case NetworkConnection.EVENT_BACKLOG_END: runOnUiThread(new Runnable() { @Override public void run() { errorMsg.setVisibility(View.GONE); error = null; if (progressBar.getVisibility() == View.VISIBLE) { if (Build.VERSION.SDK_INT >= 16) { progressBar.animate().alpha(0).setDuration(200).withEndAction(new Runnable() { @Override public void run() { progressBar.setVisibility(View.GONE); } }); } else { progressBar.setVisibility(View.GONE); } } getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); if (drawerLayout != null) { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); getSupportActionBar().setHomeButtonEnabled(true); updateUsersListFragmentVisibility(); } if (ServersDataSource.getInstance().count() < 1) { Crashlytics.log(Log.DEBUG, "IRCCloud", "No servers configured, launching add dialog"); addNetwork(); } else { if (server == null || launchURI != null || launchBid != -1) { Crashlytics.log(Log.DEBUG, "IRCCloud", "Backlog loaded and we're waiting for a buffer, switching now"); if (launchURI == null || !open_uri(launchURI)) { if (launchBid == -1 || !open_bid(launchBid)) { if (conn == null || conn.getUserInfo() == null || !open_bid(conn.getUserInfo().last_selected_bid)) { if (!open_bid(BuffersDataSource.getInstance().firstBid())) { if (drawerLayout != null && NetworkConnection.getInstance().ready && findViewById(R.id.usersListFragment2) == null) { drawerLayout.openDrawer(Gravity.LEFT); } } } } } } update_subtitle(); } if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); photoBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) photoBtn.setAlpha(1); } }); //TODO: prune and pop the back stack if the current BID has disappeared break; case NetworkConnection.EVENT_CONNECTIONDELETED: case NetworkConnection.EVENT_DELETEBUFFER: Integer id = (Integer) obj; if (what == NetworkConnection.EVENT_DELETEBUFFER) { synchronized (backStack) { for (int i = 0; i < backStack.size(); i++) { if (backStack.get(i).equals(id)) { backStack.remove(i); i--; } } } } if (buffer != null && id == ((what == NetworkConnection.EVENT_CONNECTIONDELETED) ? buffer.cid : buffer.bid)) { synchronized (backStack) { while (backStack != null && backStack.size() > 0) { final Integer bid = backStack.get(0); backStack.remove(0); b = BuffersDataSource.getInstance().getBuffer(bid); if (b != null) { runOnUiThread(new Runnable() { @Override public void run() { onBufferSelected(bid); if (backStack.size() > 0) backStack.remove(0); } }); return; } } } runOnUiThread(new Runnable() { @Override public void run() { if (BuffersDataSource.getInstance().count() == 0) { startActivity(new Intent(MainActivity.this, EditConnectionActivity.class)); finish(); } else { if ((NetworkConnection.getInstance().getUserInfo() == null || !open_bid(NetworkConnection.getInstance().getUserInfo().last_selected_bid)) && !open_bid(BuffersDataSource.getInstance().firstBid())) finish(); } } }); } runOnUiThread(new Runnable() { @Override public void run() { if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } }); break; case NetworkConnection.EVENT_CHANNELMODE: case NetworkConnection.EVENT_CHANNELTOPIC: event = (IRCCloudJSONObject) obj; if (event != null && buffer != null && event.bid() == buffer.bid) { runOnUiThread(new Runnable() { @Override public void run() { update_subtitle(); } }); } break; case NetworkConnection.EVENT_SELFBACK: case NetworkConnection.EVENT_AWAY: try { event = (IRCCloudJSONObject) obj; if (event != null && buffer != null && event.cid() == buffer.cid && event.getString("nick").equalsIgnoreCase(buffer.name)) { runOnUiThread(new Runnable() { @Override public void run() { update_subtitle(); } }); } } catch (Exception e1) { e1.printStackTrace(); } break; case NetworkConnection.EVENT_HEARTBEATECHO: boolean shouldRefresh = false; event = (IRCCloudJSONObject) obj; JsonNode seenEids = event.getJsonNode("seenEids"); Iterator<Map.Entry<String, JsonNode>> iterator = seenEids.fields(); while (iterator.hasNext()) { Map.Entry<String, JsonNode> entry = iterator.next(); JsonNode eids = entry.getValue(); Iterator<Map.Entry<String, JsonNode>> j = eids.fields(); while (j.hasNext()) { Map.Entry<String, JsonNode> eidentry = j.next(); Integer bid = Integer.valueOf(eidentry.getKey()); if (buffer != null && bid != buffer.bid) { shouldRefresh = true; } } } if (shouldRefresh) { runOnUiThread(new Runnable() { @Override public void run() { if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } }); } break; case NetworkConnection.EVENT_FAILURE_MSG: event = (IRCCloudJSONObject) obj; if (event != null && event.has("_reqid")) { int reqid = event.getInt("_reqid"); if (pendingEvents.containsKey(reqid)) { EventsDataSource.Event e = pendingEvents.get(reqid); EventsDataSource.getInstance().deleteEvent(e.eid, e.bid); pendingEvents.remove(event.getInt("_reqid")); e.failed = true; e.bg_color = R.color.error; if (e.expiration_timer != null) e.expiration_timer.cancel(); conn.notifyHandlers(NetworkConnection.EVENT_BUFFERMSG, e); } } else { if (event.getString("message").equalsIgnoreCase("auth")) { conn.logout(); Intent i = new Intent(MainActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } if (event.getString("message").equalsIgnoreCase("set_shard")) { NetworkConnection.getInstance().disconnect(); NetworkConnection.getInstance().ready = false; SharedPreferences.Editor editor = getSharedPreferences("prefs", 0).edit(); editor.putString("session_key", event.getString("cookie")); if (event.has("websocket_host")) { NetworkConnection.IRCCLOUD_HOST = event.getString("websocket_host"); NetworkConnection.IRCCLOUD_PATH = event.getString("websocket_path"); } editor.putString("host", NetworkConnection.IRCCLOUD_HOST); editor.putString("path", NetworkConnection.IRCCLOUD_PATH); editor.commit(); NetworkConnection.getInstance().connect(event.getString("cookie")); } } try { error = event.getString("message"); if (error.equals("temp_unavailable")) error = "Your account is temporarily unavailable"; runOnUiThread(new Runnable() { @Override public void run() { updateReconnecting(); } }); } catch (Exception ex) { ex.printStackTrace(); } break; case NetworkConnection.EVENT_BUFFERMSG: try { EventsDataSource.Event e = (EventsDataSource.Event) obj; if (e != null && buffer != null) { if (e.bid != buffer.bid && upDrawable != null) { BuffersDataSource.Buffer buf = BuffersDataSource.getInstance().getBuffer(e.bid); if (e.isImportant(buf.type)) { if (upDrawable.getColor() != redColor && (e.highlight || buf.type.equals("conversation"))) { runOnUiThread(new Runnable() { @Override public void run() { upDrawable.setColor(redColor); } }); } else if (upDrawable.getColor() == greyColor) { JSONObject channelDisabledMap = null; JSONObject bufferDisabledMap = null; if (NetworkConnection.getInstance().getUserInfo() != null && NetworkConnection.getInstance().getUserInfo().prefs != null) { try { if (NetworkConnection.getInstance().getUserInfo().prefs .has("channel-disableTrackUnread")) channelDisabledMap = NetworkConnection.getInstance().getUserInfo().prefs .getJSONObject("channel-disableTrackUnread"); if (NetworkConnection.getInstance().getUserInfo().prefs .has("buffer-disableTrackUnread")) bufferDisabledMap = NetworkConnection.getInstance().getUserInfo().prefs .getJSONObject("buffer-disableTrackUnread"); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } if (buf.type.equalsIgnoreCase("channel") && channelDisabledMap != null && channelDisabledMap.has(String.valueOf(buf.bid)) && channelDisabledMap.getBoolean(String.valueOf(buf.bid))) break; else if (bufferDisabledMap != null && bufferDisabledMap.has(String.valueOf(buf.bid)) && bufferDisabledMap.getBoolean(String.valueOf(buf.bid))) break; runOnUiThread(new Runnable() { @Override public void run() { upDrawable.setColor(blueColor); } }); } } } if (e.from.equalsIgnoreCase(buffer.name)) { pendingEvents.clear(); } else if (pendingEvents.containsKey(e.reqid)) { pendingEvents.remove(e.reqid); } } } catch (Exception e1) { } break; } }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void showAlert(final String title, final String message, boolean OKOnly) { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setCancelable(false);/* w ww .jav a2 s . com*/ dialog.setTitle(title); dialog.setMessage(message); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int place) { //if device not registered go straight to scan screen if (!Utility.deviceRegistered()) scan_click(false); //if OK entered from updateSync then reboot if (restartsyncTimer) { Intent restartIntent = getPackageManager().getLaunchIntentForPackage(getPackageName()); PendingIntent intent = PendingIntent.getActivity(HomeScreen.this, 0, restartIntent, Intent.FLAG_ACTIVITY_CLEAR_TOP); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); manager.set(AlarmManager.RTC, System.currentTimeMillis() + 500, intent); System.exit(2); } if (taa == 5) { taa = 3; //when returning to onResume from signature screen this will execute specific code inside onResume signaturefileName = Utility.createSignatureFileName(); Intent intent = new Intent(); intent.setClass(HomeScreen.this, SignatureScreen.class); intent.putExtra("file_name", Utility.getsharedPreference(HomeScreen.this, "signaturefileName")); startActivity(intent); } } }); if (!OKOnly) { dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int place) { if (taa == 5) { taa = 3; //tells onResume to execute end shift code onResume(); } } }); } dialog.show(); }
From source file:android.app.Activity.java
/** * execute migration immediately with file(s) * NOTE: if you call this method, Activity will perform finish() * @param paths Absolute filepaths you want to migrate *///from w ww . jav a2 s .c o m public void migrate(String[] paths) { boolean result = false; Bundle savedBundle; if (paths != null) { FileWorker fw = new FileWorker(paths, FileWorker.READ_MODE); fw.start(); } Intent intent = new Intent(); intent.setClassName("com.android.migrationmanager", "com.android.migrationmanager.DeviceListDialog"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); }
From source file:android.app.Activity.java
/** * @hide// www . j a va 2s. co m */ private void showMigrateNotification() { boolean flag = false; if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } try { /* judge whether this App can migrate */ flag = mMigrator.checkMigratableApp(); } catch (RemoteException e) { Log.d(TAG, "Migrate failed in Dialog"); } if (flag) { Intent intent = new Intent(); intent.setClassName("com.android.migrationmanager", "com.android.migrationmanager.DeviceListDialog"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); /* on tapping, show dialog Activity */ Notification notification = new Notification.Builder(this) .setContentTitle("Migrator in " + getAppName()) .setContentText("start Migration: " + getLocalClassName()) .setSmallIcon(com.android.internal.R.drawable.ic_menu_send).setAutoCancel(true) .setContentIntent(pi).build(); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(Process.myUid(), notification); } }
From source file:carnero.cgeo.original.libs.Base.java
public void goHome(Activity activity) { final Intent intent = new Intent(activity, main.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.startActivity(intent);// ww w .j a va 2 s. c o m activity.finish(); }
From source file:carnero.cgeo.cgBase.java
public void goHome(Activity activity) { final Intent intent = new Intent(activity, cgeo.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.startActivity(intent);//from w w w .j a v a 2s. c om activity.finish(); }