List of usage examples for android.os Bundle getLong
public long getLong(String key)
From source file:com.vuze.android.remote.fragment.OpenOptionsGeneralFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FragmentActivity activity = getActivity(); Intent intent = activity.getIntent(); if (AndroidUtils.DEBUG) { Log.d(TAG, activity + "] onCreateview " + this); }//from w ww . j a v a 2 s . c o m final Bundle extras = intent.getExtras(); if (extras == null) { Log.e(TAG, "No extras!"); } else { String remoteProfileID = extras.getString(SessionInfoManager.BUNDLE_KEY); if (remoteProfileID != null) { sessionInfo = SessionInfoManager.getSessionInfo(remoteProfileID, activity); } torrentID = extras.getLong("TorrentID"); } if (activity instanceof TorrentOpenOptionsActivity) { ourActivity = (TorrentOpenOptionsActivity) activity; } topView = inflater.inflate(R.layout.frag_openoptions_general, container, false); ImageButton btnEditDir = (ImageButton) topView.findViewById(R.id.openoptions_btn_editdir); ImageButton btnEditName = (ImageButton) topView.findViewById(R.id.openoptions_btn_editname); tvName = (TextView) topView.findViewById(R.id.openoptions_name); tvSaveLocation = (TextView) topView.findViewById(R.id.openoptions_saveloc); tvFreeSpace = (TextView) topView.findViewById(R.id.openoptions_freespace); CompoundButton btnPositionLast = (CompoundButton) topView.findViewById(R.id.openoptions_sw_position); CompoundButton btnStateQueued = (CompoundButton) topView.findViewById(R.id.openoptions_sw_state); if (ourActivity != null) { if (btnPositionLast != null) { btnPositionLast.setChecked(ourActivity.isPositionLast()); btnPositionLast.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ourActivity.setPositionLast(isChecked); } }); } if (btnStateQueued != null) { btnStateQueued.setChecked(ourActivity.isStateQueued()); btnStateQueued.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ourActivity.setStateQueued(isChecked); } }); } } final Map<?, ?> torrent = sessionInfo.getTorrent(torrentID); if (torrent == null) { getActivity().finish(); VuzeEasyTracker.getInstance(getActivity()).logError("Torrent doesn't exist", TAG); return topView; } if (torrent.containsKey(TransmissionVars.FIELD_TORRENT_DOWNLOAD_DIR)) { updateFields(torrent); } else { sessionInfo.executeRpc(new RpcExecuter() { @Override public void executeRpc(TransmissionRPC rpc) { rpc.getTorrent(TAG, torrentID, Collections.singletonList(TransmissionVars.FIELD_TORRENT_DOWNLOAD_DIR), new TorrentListReceivedListener() { @Override public void rpcTorrentListReceived(String callID, List<?> addedTorrentMaps, List<?> removedTorrentIDs) { AndroidUtils.runOnUIThread(OpenOptionsGeneralFragment.this, new Runnable() { @Override public void run() { updateFields(torrent); } }); } }); } }); } if (btnEditDir != null) { btnEditDir.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Map<?, ?> torrent = sessionInfo.getTorrent(torrentID); DialogFragmentMoveData.openMoveDataDialog(torrent, sessionInfo, getFragmentManager()); } }); } if (btnEditName != null) { if (sessionInfo.getSupportsTorrentRename()) { btnEditName.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Builder builder = new AlertDialog.Builder(getActivity()); final TextView textView = new EditText(getActivity()); textView.setText(tvName.getText()); textView.setSingleLine(); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { builder.setInverseBackgroundForced(true); } builder.setView(textView); builder.setTitle(R.string.change_name_title); builder.setMessage(R.string.change_name_message); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String newName = textView.getText().toString(); tvName.setText(newName); sessionInfo.executeRpc(new RpcExecuter() { @Override public void executeRpc(TransmissionRPC rpc) { rpc.setDisplayName(TAG, torrentID, newName); } }); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); } }); } else { btnEditName.setVisibility(View.GONE); } } return topView; }
From source file:com.example.bidisha.ace.ClueScan.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cluescan);/*from w w w . j ava 2s . c o m*/ /** * @mitra00 * receiving the values from the calling activity */ Bundle b1 = getIntent().getExtras(); if (b1 != null) { timeValue = b1.getLong("time"); i = b1.getInt("question_no"); } else { /** * @mitra00 * the limit for the time of the event */ timeValue = 7200000; } clues[0] = "Careers like rockets dont always take on time! The trick is to keep them running always."; clues[1] = "The place doesnt smell pleasant! A new journey starts and the Earth Feels Happy.."; clues[2] = "I am dark and produce light and i can make something or destroy everything. Inspite of that im used everywhere."; clues[3] = "akivuy is a place where everyone have their eyes on!"; clues[4] = "No one presses my first button now a days and im on top of all"; clues[5] = "Find me in the center of the place where sounds start and turn off"; clues[6] = "Take away standing infinity from Dhaku Mangal Singh"; clues[7] = "Under pressure is the only way i work and by myself is the only way im hurt and mysore express inaugurated me"; clues[8] = "Hercules has made his mark in sports"; // clue1="This app was recently inaugurated by Mysore MLA"; clues[10] = "Some like me hot, Some like me cold, Some like me mild,Some like me bold"; clues[11] = "All husbands want their wives to be this"; clues[12] = "The best solution to attract the girls"; clues[13] = "I can tell you where we stand in the country"; clues[14] = "I start when the VVCE fest stops"; clues[15] = "The lead executive"; clues[16] = "Im the lab which contains THINGS"; clues[17] = "Railway Workshop, BEML, Silk Factory and NIE have this incommon"; clues[18] = "Theres a place near by you will want to visit A portal place where people greet"; clues[9] = "Im the only place whose identity remains the same even after you flip me horizontally"; /** * @mitra00 * to call the random generator only when the value of i is zero */ if (i == 0) gen_clues(); /** * @mitra00 * updating the field of the textview */ String valueS = Integer.toString(i + 1); currQ = (TextView) findViewById(R.id.currentQ); question = (TextView) findViewById(R.id.clue); question.setText(rando[i]); currQ.setText(valueS); Button button = (Button) findViewById(R.id.scanQR); scanResults = (TextView) findViewById(R.id.scanResults); if (savedInstanceState != null) { imageUri = Uri.parse(savedInstanceState.getString(SAVED_INSTANCE_URI)); //scanResults.setText(savedInstanceState.getString(SAVED_INSTANCE_RESULT)); } button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(ClueScan.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(ClueScan.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_WRITE_PERMISSION); } else { takePicture(); } } }); /* TextView question=(TextView)findViewById(R.id.clue); switch (q) { case 1: question.setText(getString(R.string.clue1)); break; case 2: question.setText(getString(R.string.clue2)); break; case 3: question.setText(getString(R.string.clue3)); break; case 4: question.setText(getString(R.string.clue4)); break; case 5: question.setText(getString(R.string.clue5)); break; }*/ /*This is the code for timer*/ final TextView time_mins = (TextView) findViewById(R.id.time_mins); final TextView time_sec = (TextView) findViewById(R.id.time_sec); new CountDownTimer(timeValue, 1000) { public void onTick(long millisUntilFinished) { time_left = millisUntilFinished; sec = (millisUntilFinished / 1000) % 60; mins = millisUntilFinished / (1000 * 60); if (mins < 10) time_mins.setText("0" + millisUntilFinished / (1000 * 60)); else time_mins.setText("" + millisUntilFinished / (1000 * 60)); if (sec < 10) time_sec.setText(": 0" + (millisUntilFinished / 1000) % 60); else time_sec.setText(": " + (millisUntilFinished / 1000) % 60); } public void onFinish() { Intent i = new Intent(ClueScan.this, ScoreCal.class); /** * @mitra00 * setting the time left to zero */ ((StoreGlobal) getApplication()).setTimeToZero(); startActivity(i); ClueScan.this.finish(); } }.start(); detector = new BarcodeDetector.Builder(getApplicationContext()) .setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE | Barcode.ALL_FORMATS).build(); if (!detector.isOperational()) { scanResults.setText("Could not set up the detector!"); return; } }
From source file:com.android.calendar.month.SimpleDayPickerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_TIME)) { goTo(savedInstanceState.getLong(KEY_CURRENT_TIME), false, true, true); }//from w ww.ja v a2 s .c o m }
From source file:com.noshufou.android.su.AppDetailsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); FrameLayout fragmentContainer = (FrameLayout) getActivity().findViewById(R.id.fragment_container); if (fragmentContainer != null) { mDualPane = true;/* w ww . j a v a 2s . co m*/ } if (savedInstanceState != null && savedInstanceState.containsKey("mShownIndex")) { mShownIndex = savedInstanceState.getLong("mShownIndex"); } else if (getArguments() != null) { mShownIndex = getArguments().getLong("index", 0); } else { mShownIndex = 0; } setupListView(); getLoaderManager().initLoader(DETAILS_LOADER, null, this); getLoaderManager().initLoader(LOG_LOADER, null, this); }
From source file:com.mb.android.playbackmediator.utils.Utils.java
/** * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by * <code>fromMediaInfo</code>. * * @param wrapper/*from w ww .j a v a 2 s. co m*/ * @return * @see <code>fromMediaInfo()</code> */ public static MediaInfo toMediaInfo(Bundle wrapper) { if (null == wrapper) { return null; } MediaMetadata metaData = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE)); metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE)); metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO)); ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES); if (null != images && !images.isEmpty()) { for (String url : images) { Uri uri = Uri.parse(url); metaData.addImage(new WebImage(uri)); } } String customDataStr = wrapper.getString(KEY_CUSTOM_DATA); JSONObject customData = null; if (!TextUtils.isEmpty(customDataStr)) { try { customData = new JSONObject(customDataStr); } catch (JSONException e) { LOGE(TAG, "Failed to deserialize the custom data string: custom data= " + customDataStr); } } return new MediaInfo.Builder(wrapper.getString(KEY_URL)).setStreamType(wrapper.getInt(KEY_STREAM_TYPE)) .setContentType(wrapper.getString(KEY_CONTENT_TYPE)).setMetadata(metaData).setCustomData(customData) .setStreamDuration(wrapper.getLong(KEY_STREAM_DURATION)).build(); }
From source file:com.example.app_2.activities.ImageGridActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { actual_category_fk.setCategoryId(savedInstanceState.getLong("actual_category_fk")); }
From source file:com.ibm.pi.beacon.PIBeaconSensorService.java
private void handleCommands(Intent intent) { Bundle extras = intent.getExtras(); // check passed in intent for commands sent from Beacon Sensor wrapper class if (extras != null) { if (extras.containsKey(PIBeaconSensor.ADAPTER_KEY)) { mPiApiAdapter = (PIAPIAdapter) extras.get(PIBeaconSensor.ADAPTER_KEY); }/* w w w . ja v a 2s . c o m*/ if (extras.containsKey(PIBeaconSensor.SEND_INTERVAL_KEY)) { PILogger.d(TAG, "updating send interval to: " + mSendInterval); mSendInterval = extras.getLong(PIBeaconSensor.SEND_INTERVAL_KEY); } if (extras.containsKey(PIBeaconSensor.BEACON_LAYOUT_KEY)) { String beaconLayout = intent.getStringExtra(PIBeaconSensor.BEACON_LAYOUT_KEY); PILogger.d(TAG, "adding beacon layout: " + beaconLayout); mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(beaconLayout)); } if (extras.containsKey(PIBeaconSensor.BACKGROUND_SCAN_PERIOD_KEY)) { PILogger.d(TAG, "updating background scan period to: " + mBackgroundScanPeriod); mBackgroundScanPeriod = extras.getLong(PIBeaconSensor.BACKGROUND_SCAN_PERIOD_KEY); mBeaconManager.setBackgroundScanPeriod(mBackgroundScanPeriod); } if (extras.containsKey(PIBeaconSensor.BACKGROUND_BETWEEN_SCAN_PERIOD_KEY)) { PILogger.d(TAG, "updating background between scan period to: " + mBackgroundBetweenScanPeriod); mBackgroundBetweenScanPeriod = extras.getLong(PIBeaconSensor.BACKGROUND_BETWEEN_SCAN_PERIOD_KEY); mBeaconManager.setBackgroundBetweenScanPeriod(mBackgroundBetweenScanPeriod); } if (extras.containsKey(PIBeaconSensor.START_IN_BACKGROUND_KEY)) { PILogger.d(TAG, "service started up in the background, starting sensor in background mode"); mBeaconManager.setBackgroundMode(true); } } if (intent.getAction() != null) { String action = intent.getAction(); if (action.equals(PIBeaconSensor.INTENT_ACTION_START)) { PILogger.d(TAG, "Service has started scanning for beacons"); mBeaconManager.bind(this); } else if (action.equals(PIBeaconSensor.INTENT_ACTION_STOP)) { PILogger.d(TAG, "Service has stopped scanning for beacons"); mBeaconManager.unbind(this); stopSelf(); } } }
From source file:com.tune.news.fragment.EntriesListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { setHasOptionsMenu(true);/*w w w. j a va 2s. c o m*/ super.onCreate(savedInstanceState); if (savedInstanceState != null) { mUri = savedInstanceState.getParcelable(STATE_URI); mShowFeedInfo = savedInstanceState.getBoolean(STATE_SHOW_FEED_INFO); mListDisplayDate = savedInstanceState.getLong(STATE_LIST_DISPLAY_DATE); mEntriesCursorAdapter = new EntriesCursorAdapter(getActivity(), mUri, Constants.EMPTY_CURSOR, mShowFeedInfo); } mUri = getArguments() != null && getArguments().getInt(Constants.FEED_ID, -1) >= 0 ? EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(getArguments().getInt(Constants.FEED_ID, -1)) : EntryColumns.FAVORITES_CONTENT_URI; if (mUri != null) { mListDisplayDate = new Date().getTime(); mShowFeedInfo = true; mEntriesCursorAdapter = new EntriesCursorAdapter(getActivity(), mUri, Constants.EMPTY_CURSOR, mShowFeedInfo); setListAdapter(mEntriesCursorAdapter); } }
From source file:com.vuze.android.remote.fragment.OpenOptionsFilesFragment.java
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {/*from w w w .j a v a 2 s .c om*/ if (AndroidUtils.DEBUG) { Log.d(TAG, "onCreateview " + this); } FragmentActivity activity = getActivity(); Intent intent = activity.getIntent(); final Bundle extras = intent.getExtras(); if (extras == null) { Log.e(TAG, "No extras!"); } else { String remoteProfileID = extras.getString(SessionInfoManager.BUNDLE_KEY); if (remoteProfileID != null) { sessionInfo = SessionInfoManager.getSessionInfo(remoteProfileID, activity); } torrentID = extras.getLong("TorrentID"); } Map<?, ?> torrent = sessionInfo.getTorrent(torrentID); if (torrent == null) { // In theory TorrentOpenOptionsActivity handled this NPE already return null; } View topView = inflater.inflate(R.layout.frag_fileselection, container, false); tvScrollTitle = (TextView) topView.findViewById(R.id.files_scrolltitle); tvSummary = (TextView) topView.findViewById(R.id.files_summary); listview = (RecyclerView) topView.findViewById(R.id.files_list); listview.setLayoutManager(new PreCachingLayoutManager(getContext())); listview.setAdapter(adapter); FlexibleRecyclerSelectionListener rs = new FlexibleRecyclerSelectionListener<FilesTreeAdapter, FilesAdapterDisplayObject>() { @Override public void onItemClick(FilesTreeAdapter adapter, int position) { if (AndroidUtils.usesNavigationControl()) { FilesAdapterDisplayObject oItem = adapter.getItem(position); if (adapter.isInEditMode()) { adapter.flipWant(oItem); return; } if (oItem instanceof FilesAdapterDisplayFolder) { FilesAdapterDisplayFolder oFolder = (FilesAdapterDisplayFolder) oItem; oFolder.expand = !oFolder.expand; adapter.getFilter().filter(""); } } } @Override public boolean onItemLongClick(FilesTreeAdapter adapter, int position) { return false; } @Override public void onItemSelected(FilesTreeAdapter adapter, int position, boolean isChecked) { } @Override public void onItemCheckedChanged(FilesTreeAdapter adapter, FilesAdapterDisplayObject item, boolean isChecked) { } }; adapter = new FilesTreeAdapter(this.getActivity(), rs); adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeChanged(int positionStart, int itemCount) { if (tvSummary != null) { tvSummary.setText(DisplayFormatters.formatByteCountToKiBEtc(adapter.getTotalSizeWanted())); } } @Override public void onChanged() { super.onChanged(); if (tvSummary != null) { tvSummary.setText(DisplayFormatters.formatByteCountToKiBEtc(adapter.getTotalSizeWanted())); } } }); adapter.setInEditMode(true); adapter.setSessionInfo(sessionInfo); adapter.setCheckOnSelectedAfterMS(0); listview.setAdapter(adapter); listview.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_RIGHT: { // expand int i = adapter.getSelectedPosition(); FilesAdapterDisplayObject item = adapter.getItem(i); if (item instanceof FilesAdapterDisplayFolder) { if (!((FilesAdapterDisplayFolder) item).expand) { ((FilesAdapterDisplayFolder) item).expand = true; adapter.getFilter().filter(""); return true; } } break; } case KeyEvent.KEYCODE_DPAD_LEFT: { // collapse int i = adapter.getSelectedPosition(); FilesAdapterDisplayObject item = adapter.getItem(i); if (item instanceof FilesAdapterDisplayFolder) { if (((FilesAdapterDisplayFolder) item).expand) { ((FilesAdapterDisplayFolder) item).expand = false; adapter.getFilter().filter(""); return true; } } break; } } return false; } } }); listview.setOnScrollListener(new RecyclerView.OnScrollListener() { int firstVisibleItem = 0; @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LinearLayoutManager lm = (LinearLayoutManager) listview.getLayoutManager(); int firstVisibleItem = lm.findFirstCompletelyVisibleItemPosition(); if (firstVisibleItem != this.firstVisibleItem) { this.firstVisibleItem = firstVisibleItem; FilesAdapterDisplayObject itemAtPosition = adapter.getItem(firstVisibleItem); if (itemAtPosition == null) { return; } if (itemAtPosition.parent != null) { if (tvScrollTitle != null) { tvScrollTitle.setText(itemAtPosition.parent.folder); } } else { if (tvScrollTitle != null) { tvScrollTitle.setText(""); } } } } }); if (torrent.containsKey("files")) { adapter.setTorrentID(torrentID); } else { sessionInfo.executeRpc(new RpcExecuter() { @Override public void executeRpc(TransmissionRPC rpc) { rpc.getTorrentFileInfo(TAG, torrentID, null, new TorrentListReceivedListener() { @Override public void rpcTorrentListReceived(String callID, List<?> addedTorrentMaps, List<?> removedTorrentIDs) { AndroidUtils.runOnUIThread(OpenOptionsFilesFragment.this, new Runnable() { @Override public void run() { adapter.setTorrentID(torrentID); } }); } }); } }); } if (AndroidUtils.DEBUG) { Log.d(TAG, "set " + adapter + " for " + listview + " to " + sessionInfo + "/" + torrentID); } return topView; }
From source file:com.chess.genesis.engine.GameState.java
@Override public boolean handleMessage(final Message msg) { try {/*from w ww .j a va 2 s .co m*/ switch (msg.what) { case GenEngine.MSG: case RegEngine.MSG: final Bundle bundle = (Bundle) msg.obj; if (bundle.getLong("time") == 0) { cpu.setBoard(board); new Thread(cpu).start(); return true; } else if (activity.isFinishing()) { // activity is gone, so give up! return true; } currentMove(); final Move tmove = bundle.getParcelable("move"); final Move move = board.newMove(); if (board.validMove(tmove, move)) applyMove(move, true, true); break; case CpuTimeDialog.MSG: final PrefEdit pref = new PrefEdit(activity); pref.putInt(R.array.pf_cputime, (Integer) msg.obj); pref.commit(); cpu.setTime((Integer) msg.obj); break; case NetworkClient.GAME_DRAW: case NetworkClient.SUBMIT_MOVE: JSONObject json = (JSONObject) msg.obj; if (json.getString("result").equals("error")) { undoMove(); progress.remove(); Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } progress.setText("Checking Game Status"); net.game_status(settings.getString("gameid")); new Thread(net).start(); break; case ResignConfirm.MSG: progress.setText("Sending Resignation"); net.resign_game(settings.getString("gameid")); new Thread(net).start(); break; case NudgeConfirm.MSG: progress.setText("Sending Nudge"); net.nudge_game(settings.getString("gameid")); new Thread(net).start(); break; case IdleResignConfirm.MSG: progress.setText("Sending Idle Resign"); net.idle_resign(settings.getString("gameid")); new Thread(net).start(); break; case DrawDialog.MSG: case AcceptDrawDialog.MSG: final String value = (String) msg.obj; progress.setText("Sending Draw"); net.game_draw(settings.getString("gameid"), value); new Thread(net).start(); break; case PawnPromoteDialog.MSG: applyMove((RegMove) msg.obj, true, true); break; case NetworkClient.RESIGN_GAME: case NetworkClient.IDLE_RESIGN: json = (JSONObject) msg.obj; if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } progress.setText("Resignation Sent"); net.game_status(settings.getString("gameid")); new Thread(net).start(); break; case NetworkClient.NUDGE_GAME: json = (JSONObject) msg.obj; if (json.getString("result").equals("error")) Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); progress.remove(); break; case NetworkClient.GAME_STATUS: json = (JSONObject) msg.obj; if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } final int status = Enums.GameStatus(json.getString("status")); settings.putString("status", String.valueOf(status)); final GameDataDB db = new GameDataDB(activity); db.updateOnlineGame(json); db.close(); GenesisNotifier.clearNotification(activity, GenesisNotifier.YOURTURN_NOTE); applyRemoteMove(json.getString("history")); if (status != Enums.ACTIVE) { if (Integer.parseInt(settings.getString("eventtype")) == Enums.INVITE) { progress.remove(); ShowGameStats(json); return true; } progress.setText("Retrieving Score"); net.game_score(settings.getString("gameid")); new Thread(net).start(); } else { progress.setText("Status Synced"); progress.remove(); } break; case NetworkClient.GAME_SCORE: json = (JSONObject) msg.obj; if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } progress.setText("Score Loaded"); progress.remove(); ShowGameStats(json); break; case RematchConfirm.MSG: final Bundle data = (Bundle) msg.obj; progress.setText("Sending Newgame Request"); final String opponent = data.getString("opp_name"); final String color = Enums.ColorType(data.getInt("color")); final String gametype = Enums.GameType(data.getInt("gametype")); net.new_game(opponent, gametype, color); new Thread(net).start(); break; case NetworkClient.NEW_GAME: json = (JSONObject) msg.obj; if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(activity, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } progress.setText(json.getString("reason")); progress.remove(); break; } return true; } catch (final JSONException e) { throw new RuntimeException(e.getMessage(), e); } }